HOW-TO: Use a Teltonika 4G Modem as an SMS Dialler

There has been some complaints about the SMS capability of the SMS Notifications module that I have seen recently.
Most of these centre around how the Sierra Wireless SMS modems have no feedback on whether an SMS has been sent or if the modem is even connected.
I personally have a couple of issues with the module:

  • The Sierra dialler uses UDP, so there is no confirmation a packet ever made it to the unit.
  • The dialler cannot have a gateway address configured on it, so it MUST be on the same subnet as the Ignition instance connected to it.
  • The Sierra dialler is very clunky to set up and it seems to be not very user friendly.
  • The Sierra series of diallers is not very common and getting these units off the shelf is not easy.
  • There is no way of reattempting to send an SMS if the system has not received the request.
  • There is no way to see what state the dialler is in, signal strength or other options.
  • There is no redundancy for these units available.

To work on a solution to these issues, I have had a look around at the offerings that are readily available to me.
Teltonika make a lot of affordable and highly featured units with lots of options on power etc.

I happen to have a Teltonika RUT956 on my desk here, so I have done some work on this unit:

  • This unit is dual SIM, so immediately it is attractive to me as a redundancy option for redundant telecom providers.

  • This unit is properly configurable on the IP front, so you can set this modem up as a simple device on any subnet and also disable mobile data, so you close off the cybersecurity risks on another front.

  • This unit has OPC-UA capability:
    Log into the Teltonika and click on Advanced Mode. Navigate to System -> Package Manager -> Upload. Click on the "this repository" link and download the opc_ua_server.tar.gz file.
    Return to the System -> Package Manager -> Upload page and browse to the downloaded file, click upload, and this will install the OPC-UA service. Navigate to Services -> OPC UA Server and enter "4840" in the port number section, click Enabled so that it shows "on" and then click Save & Apply
    In Ignition Gateway, add a new OPC-UA connection, the connection URL will be opc.tcp://<Teltonika IP>:4840 where is your Teltonika devices IP.
    Click next to finish setting up the device and also check the box "Read Only" when you are presented with the option. Click Save when done.
    At this point you will now be able to browse in your designer to the new OPC-UA server and get these tags onto your project, should you want any of them:

  • This unit also has REST capability for sending SMS messages:
    In the Teltonika web config, navigate to Services -> Mobile Utilities -> SMS Gateway Click on Enable, and set a username and password here. Click Save & Apply. In Ignition, Create a new Alarm Pipeline, and add a Script element to it. Paste this code into the Script:

def handleAlarm(event):
	logger = system.util.getLogger("SMSLogger")
	teltonikaUsername = "user1"
	teltonikaPassword = "Sms12345"
	teltonikaAddress = "192.168.1.1"
	
	smsNumber = "%2B1234567892"
	smsText = "Test SMS"
	
	#set up sms payload
	requestData = "username="  + teltonikaUsername + "&password=" + teltonikaPassword + "&number=" + smsNumber + "&text=" + smsText		
	handler = system.net.httpClient()
	response = handler.post("http://"+teltonikaAddress+"/cgi-bin/sms_send",
	headers = {"Content-Type": "application/x-www-form-urlencoded"},data = requestData)
	if "OK" in response.text :
		event.cancelNotification()
	else :
		logger.info("SMS Failed to send: " + response.text)

Add your details to the username, password and address variables, and save the pipeline.
At this point, if you assign a tag alarm to this pipeline, it will send a text to "001234567892" saying "Test SMS", then it will stop the pipeline. If the sending fails, it will log the response, and the event will be passed to the next item in the pipeline, enabling you to handle failed alarm notifications.

I am sure that you can all see the benefits here of the Teltonika modems in this application, and you can make a lot of mods to what my proof of concept code here does.

5 Likes

Well done!

1 Like

Maybe watch this space, I just wrote my first Ignition Module on the weekend.
I am keen to make this a drag and drop alarm pipeline element with all the features inbuilt into the alarm pipeline like the other notification elements.

1 Like

The right thing for this to be is an Alarm Notification Profile, not a custom pipeline block.

See ignition-sdk-examples/slack-alarm-notification at master · inductiveautomation/ignition-sdk-examples · GitHub

1 Like

That was exactly the sdk example I was going to use. I hadn't quite got that far.

Doing a bit of research into this, there doesn't seem to be a way of having a return boolean for success or failure that can split the "out" into "success" or "failure". The Notification Profile seems completely single direction, with any returned status or value only going to the event log. Is this correct?

Yes, I have lamented this flaw in the notification profiles before :frowning:

1 Like