Modem is used in the system to send sms notifications and receive sms commands.

To operate with a modem:

  1. Install the SIM card in the mobile phone and make sure that it is functional, check PIN-code;
  2. Insert the SIM card in modem;
  3. Turn on the power of the monitoring system;
  4. Configure the modem;
  5. Add SMS notifications and configure the logic or group notifications.

Configuring the modem

To configure modem, use the modem settings tab (Main Menu→System tree→GSM Modem):

Fields characterizing the properties of the modem element in a system:

Configurable parameters of the modem element in the system:

If the sim card has a pin, you must specify this pin in the corresponding field in the configuration form.

After 3 incorrect attempts, you must remove the sim card and use the PUK code to unlock it.

The default sms-center number is read from the sim card when the modem is initialized. If necessary, this number can be changed in the corresponding field of the configuration form.

The "OK" button is used to apply the settings in the current session.

To avoid resetting the settings when the monitoring system is reset to the default state, save the current settings to flash memory. In order to save the settings to the flash memory, you must press the button "  " (in the upper right corner of the web interface).

The Reset button is used to restart and reinitialize the modem. The message queue is not cleared with Reset button! Reset should be used in extreme cases: hang modem, sim-card after installation is not detected, registration in the home network ('registration denied') is forbidden.

SMS messages

To add a sms notification recipient, first open the window AddAdd Mailer SMS:

To test sms, click the Send sms button. In this case, the macros in the message text will be displayed in their original form (% ..). To apply the settings, click the Save button.

After filling in the notification parameters, you must specify the event (events) by which the sms message will be sent. To do this, open the Preferences → Logic schemes → Add window and specify the condition for sending the sms message in the logic. In one logic, it is possible to send SMS notifications to not more than 15 recipients for one or more events. If you need to send sms notifications to more than 15 recipients in the same logic, then create new logic with the same input condition.

SMS messages are sent to the queue, which allows you not to wait for the end of sending the previous message. The information about the sent messages is displayed in the monitoring system log. The capacity of the queue is 100 messages, if overflowed, the sent messages are automatically deleted.

If an error occurs while the message is being sent, the message with the status of sms send error is displayed in the log and the error number is indicated. The most likely error is 515 (Ps busy), the reasons of which may be:

If these items do not fit your situation, try to restart the monitoring system. Also check the sending of messages from your mobile phone, making sure that the numbers of the sms-centers are the same.

SMS commands

SMS commands are used for remote management by the monitoring system. Using these commands, you can read the status and measured values ​​of the sensors, and control the relay switches (sockets). The phone numbers from which the remote control will be made must be added to the list of allowed numbers in the modem parameters editing window (Main menu → System tree → GSM modem → Settings → List of allowed phone numbers).

To separate phone numbers, use a space. The number must start with "+". Up to 10 phone numbers is possible.

In response to each sms command, an SMS response message arrives, in case of an erroneous command, sms with an error description and an example of the command comes. In one sms message there can be only one command for one element.

Sensor, relays (sockets) status reading commands

Syntax. get [ID] or get [name], where ID is the "ID" number of the element, "name" is the name of the element. The get field is not case sensitive, you can use Get, GET. The name field is case sensitive and can not contain blank characters.

Description. The command requests the status of the sensor or relay (sockets) and sends a response sms to the phone from which the command came, describing the status of the sensor.

Illustration.  

Response. In this case the response message looks like this: Onboard Temperature[201001] state=normal value=23.5 or GSM Modem[404001] state=normal value=80.

Commands for setting the status of the relay (sockets)

Syntax. set [ID] [state] or set [name] [state], where ID - the "ID" number of the element, "name" is the name of the element, "state" is the state to which you want to switch.  The set and state fields are not case sensitive. The name field is case sensitive. The state field takes one of the following states: on - enable, off - disable.

Description. The command will switch the relay or socket in accordance with the state parameter and send the reply sms to the phone from which the command came, about the result of the command.

Illustration.  

Response. In this case the response message looks like this: The element was switched on or The element was switched off.

Relay (Socket) pulse setting commands

Syntax. set [ID]  pulse {duration} or set [name] pulse {duration}, where ID is the "ID" number of the element, "name" is the name of the element, duration is the delay time in seconds. The name field is case sensitive. The value range of the duration field is from 1 to 120. The duration field does not need to be specified, the previously set value is applied.

Description. The command switches the status of the relay (sockets) to the opposite one twice, with the time delay specified as the duration parameter in seconds.

Illustration.

Response. In this case the response message looks like this: The element was switched.

Logic control commands (logic)

Syntaxlogic [id] [state] {duration},  logic * [state], where ID – the "Logic number" of the logic (the symbol '*' for all logics), state - the state into which the logic goes ("off", "on"), duration - the time of logic shutdown in seconds. All fields are case insensitive.

Description. Commands disable or enable logic. The duration is indicated only when one logic is disabled. 

Illustration.

Response. In this case the response message looks like this: OK.

Hot swappable sim card (Hot Swap)

Without disconnecting the system power, you can remove and after a while back insert the same or another sim-card. When you remove the sim card in the system log, the message "GSM Modem error: SIM not inserted" is displayed. If there is no sim card every 15 minutes, the modem automatically restarts, and the SMS message queue is saved.


Sending SMS using third-party programs

To send SMS, you can use, for example, the cURL utility. Either other programs with similar functionality.

To send SMS, use the following command in the console:

gcc -O2 -o sendsms sendsms.c

Script for sending SMS


#!/bin/bash
# SMS sending script for version 2.4.x and higher
 
usage()
{
cat << EOF
usage: $0 options
 
OPTIONS:
   -?,-h   Show this message
   -H      Hostname or IP address
   -u      User name
   -p      Password
   -P      Phone for sending
   -m      Message for sending
EOF
}
 
HOSTIP=
USERNAME=
PASSWORD=
TOPHONE=
MESSAGE='Test'
 
while getopts “hH:u:p:P:m:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         H)
             HOSTIP=$OPTARG
             ;;
         u)
             USERNAME=$OPTARG
             ;;
         p)
             PASSWORD=$OPTARG
             ;;
         P)
             TOPHONE=$OPTARG
             ;;
         m)
             MESSAGE=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done
 
if [[ -z $HOSTIP ]] || [[ -z $USERNAME ]] || [[ -z $PASSWORD ]] || [[ -z $TOPHONE ]] || [[ -z $MESSAGE ]]
then
     usage
     exit 1
fi
 
# 1) password hash
HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'`
 
# 2) authorization
RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" "${HOSTIP}/engine.htm"`
 
# 3) session key
KEY=`echo -n  ${RESPONSE} | awk -F"\"" '{print $4}'`
 
# 4) send SMS
curl
 -d "querytype=send_sms_message&k=${KEY}" --data-urlencode
"to_phone=${TOPHONE}" --data-urlencode "message=${MESSAGE}"
${HOSTIP}/engine.htm > /dev/null 2>&1


In case of errors, leave comments below on the page or on our forum. Please indicate in the message the current version of the firmware of the monitoring system (System menu→About this system→Firmware version).