Some strategies for utilizing messaging technologies

Fully utilizing messaging technologies

I am a avid fan of messaging; especially text messaging (SMS) but any form of instant messaging will do also.

Modern work includes modest amount of meetings and other happenings where phone calls are out of the question; messaging is there to alarm you of any important issues that may arise. In my case SMS is the fastest way to get my attention and it is not drowning in spam like email is. Therefore I feel that it is the best media to use for notifications and quick status updates.

Now there is more to messaging than just your daily basic communications - especially if you are into monitoring, automation and IT.

Some practical scenarios

  • monitoring information messaging; my personal favorite would be Nagios / Icinga notifications like critical issues
  • home automation/monitoring information messaging; rapidly changing temperature or moisture alarms or even magnetic switch sensory alarms
  • bi-directional environment management like electrical switches (Telldus) for lights etc, magic packets to control server environments or even advance programmed actions
  • create a web user interface for messaging - true keyboard overrules the virtual keyboard always
  • alarm system information and arming via reverse messages

So here are some options for messaging (options that work on all mobile platforms)

  • create your own SMS gateway
    • pros:
      • bi-directional
      • multiple formats (plain SMS / 'flash' SMS / MMS / vCard / vCalendar / ringtone (those oldish style) /etc) available
      • does not rely on internet but operator network
    • cons
      • may cost to setup and somewhat expensive to use depending on the operator offering
    • misc
      • You could even go as far as having two UPS backupped Raspberry Pi's with cheap modems using SIM cards from two operators - a true HA setup :-)
  • use SMS gateway provided by some operator
    • pros:
      • easy to setup
    • cons
      • usually message credits need to be purchased in advance
      • relies on internet access (power failure issues)
  • go with some messaging app with quality API like WhatsApp or Yahoo messanger
    • pros:
      • relatively easy to setup
      • Free or minimal charging without amount restrictions
    • cons
      • relies on internet access (power failure issues)
See below for more details on each scheme with emphasis on the own SMS gateway option.

Create your very own SMS gateway

Few ideas how to pull this of:
  1. get a high end Ethernet enabled modem like Moxa Nport series that work with AT commands
  2. utilize a old mobile phone with appropriate serial cable
  3. my personal favorite: use an existing USB modem stick. If you are missing one, just ask your work IT department for one as they usually have excess ones 

Below are some guidelines for options 2. & 3.

You have a multitude of free software to choose from for this purposes like Gnokii and Gammu - I would go ahead with Gammu. Gammu can support almost any USB modem you can come up with.

The installation

In Debian like systems (Debian, Ubuntu, Mint, etc)
$ sudo apt-get install gammu gammu-smsd
In RedHat like systems (RHEL, Fedora, SuSe) (the Fedora Gammu package includes the gammu-smsd functionality so one package is sufficient)
$ sudo yum install gammu


To verify that the modem has been detected by the operating system
$ lsusb 
Bus 001 Device 006: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem

Which port?
$ tailf /var/log/messages 
Jul 29 00:45:39 localhost modem-manager[601]: <info>  (Huawei): GSM modem /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2 claimed port ttyUSB0
Notice the port ttyUSB0 in the end of the line which equals to port /dev/ttyUSB0
Configure the Gammu config file by initiating gammu-config with command
$ gammu-config
Update the Port section with the appropriate port. Otherwise everything is usually fine (connection at19200, etc).
The configuration can be checked with command gammu identify.
$ sudo gammu identify 
Device               : /dev/ttyUSB0
Manufacturer         : Huawei
Model                : E160X (E160X)
Firmware             : 11.608.06.00.00
IMEI                 : 35376203xxxxxxx
SIM IMSI             : 24421200xxxxxx


Unlock the SIM (with outputs before and after issuing PIN)
$ sudo gammu --getsecuritystatus
Waiting for PIN. 
$ sudo gammu --entersecuritycode PIN 1234
$ sudo gammu --getsecuritystatus
Nothing to enter.
Sending basic SMS message
$ sudo gammu sendsms TEXT phonenumberhere -text "All your base are belong to us" 
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=69
Previous can be sent also with syntax echo "sms test" | sudo gammu --sendsms TEXT phonenumber
Sending flash SMS message (presents as pop-up message and not saved locally by default)
$ sudo gammu sendsms TEXT phonenumber -flash -text "All your base are belong to us" 
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=70

Additional things to notice

  • there is a GUI for Gammu called Wammu (xgnokii can be found for Gnokii)
  • Gammu (as well as Gnokii) have a built in daemon (smsd) with multiple database connectors making it an ideal real life SMS gateway with tracking / audit / history data
  • there are also many nice third party applications for Gammu - see list here 
  • want to use gammu SMS gateway on Nagios/forks? Please see this excellent article on matter here:

Use SMS gateway provided by mobile operator

There is nowadays many SMS (+MMS) gateway operators to choose from; my favorite is reasonable priced Clickatell with nice APIs and ready made scripts for many languages. This is most likely the fastest way to get SMS sending up'n'running... But there are few pitfalls with the 'cloud' SMS gateways:
  • there is the question of latency and other delivery issues that sometimes happen with these online SMS messaging operators
  • this kind of SMS messaging is relying on working internet connection; consider situation like having a burglar alarm system with hypothesis that the lines may be down
At least within Europe/Finland Clickatell usually works without latency or any major problems.

Utilizing messaging app with API

There are many messaging apps/platforms to choose from like Google Hangouts, Yahoo Messanger and the super easy WhatsApp messaging. WhatsApp has a really easy and well documented API for the developers.
This article tells in details how to utilize simple PHP script to send messages via WhatsApp messenger:

That's all folks