Page 1 of 1

Create plugin/script to send notifications via SMS gateway

Posted: Sunday 06 August 2017 22:47
by Lomax
I've got a Sierra Wireless 3G/4G modem/router that allows me to send SMS messages by simply throwing it a UDP message. From the ALEOS Software Configuration User Guide:
Example: You want to send the following message: “Test message” to phone
number (510) 555-4200. To use this feature, convert the message to
hex:54657374206d657373616765. Then format the message as follows:
<<<15105554200,ASCII,12,54657374206d657373616765>>>
where:
· “<<<” is the start delimiter
· “15105554200” is the phone number
· “,” is the delimiter between fields
· “ASCII” is the data type
· “12” is the number of characters in the original message (before it is
converted to ASCII hex format)
· “54657374206d657373616765” is the message itself
· “>>>” is the end delimiter

Send the UDP packet to the configured ALEOS port.
After your message is sent, you receive an ACK message in the format ACK
Field acknowledgment Code ACK Field. For example, if your message was
successfully queued to be sent, you receive the message: ACK0ACK.
This looks pretty straightforward, but I'm confused whether I should implement this as a Python "plugin" or a LUA "script"? Plugins seem to be more intended for "devices" such as switches, while I'm after something that will let me use it in Blockly/LUA/Python "events", similarly to how the built-in Clickatel SMS notifier works. Any pointers appreciated!

Re: Create plugin/script to send notifications via SMS gateway

Posted: Sunday 13 August 2017 13:37
by Lomax
The answer, of course, is to use MQTT through a Node-Red flow, which makes it dead easy not only to push the UDP data, but also to set up the ASCII encoding function. https://www.domoticz.com/wiki/MQTT

Edit: Specifically, my "Encode SMS" function in Node-Red looks like this:

Code: Select all

var beg = "<<<";
var end = ">>>";
var rcp = msg.payload.phone;
var enc = "ASCII";
var buf = new Buffer(msg.payload.text);
var len = buf.length;
var hex = buf.toString("hex");
var arr = [rcp,enc,len,hex];
msg.payload = beg + arr.join(",") + end;
return msg;
It expects a JSON payload in the format {"text":"the SMS message","phone":"441234567890"} Gave me geekbumps the first time I tried it and it just worked.

Edit: Hahhahahhaaa, this is nuts; I'm chatting to my MQTT broker via SMS :D

Image