Page tree
Skip to end of metadata
Go to start of metadata

Modem is used to send SMS-notifications and to receive SMS-commands.

Configuring modem

Before modem can be used, you have to fill in the fields in the modem properties window.  Go to "System tree" menu and find modem, click on it. A modal window with properties will open.

  • Name – the name of modem, "GSM Modem" by default;

  • Group - groups are used in "Group tree" menu and are set manually by the user.

  • Current state – the state of modem;

    • not connected – modem is not connected;

    • low – modem is initiating or  disconnecting; 

    • normal – modem is ready to send SMS;

    • warning – occurence of a one-time error that does not affect the overall operation of the modem;

    • alarm – occurence of error that does not allow further operation of modem.

  • Current value - 0, ????

  • IMEI – unique number that identifies modem;

  • Signal level - the level of signal, values range from 0% to 100%.

  • Network registration - ???

  • Networkstatus – network status:

    • registered in Operator – registered in network  Operator;

    • registered – registered in network;

    • not registered – not registered in home network;

    • registration denied – registration in home network is denied.

  • Network status – network status:
    • not found – modem is not found; 

    • found, not ready – modem is found but is not ready for operation;

    • found, ready – modem is found and is ready for operation.  In addition, this field shows errors that occur during operation of a modem e.g.error sending SMS.

  • PIN code – PIN code of SIM card.  This field can be empty if PIN code is deactivated on SIM card; 

  • Phone of SMS center - the number of SMS center.   At connection the number is read from the SIM card.  After editing the changes are saved on SIM card;

  • List of allowed phone numbers - the list of numbers that are allowed to send SMS commands.  SMS commands from any other number will not be executed. The number must begin with a "+".

To save the settings press "Save".  In order to avoid repeating the procedure every time you connect monitoring system, the settings should be saved in the flash memory of the system.  Press "  " and then confirm.

SMS notifications

For more information on creating SMS see section Setting up GSM / USB modem .

To add recipient of SMS notification go to "System tree" or "Group tree" menu and press "  ", then choose "SMS".

  • Name – name of notification.  Can be random ( name, recipients position etc.) , "SMS" by default;

  • Phone number – the recipients phone number.  The number must begin with a  "+". 

  • Message – the text of the message, can be in any language.  The length of the message which contains latin characters is max 160, cyrillic characters - 70.  If the length of the message exceeds this limit the SMS is split into several parts.  In addition, this field allows you to edit macros (1%-7%) which insert the real values of the variables instead of the text. 

To send a test message press "Test". The macros in the message text will be displayed in its original form (% ..). To save the notification properties, click "Save". 

After filling in the properties of notification , you must specify the event, at occurence of which SMS notification will be sent. To do this, go to "Logic schemes" menu >> press add button "  " and specify the conditions for sending SMS notifications. 

For each new recipient you have to repeat the procedure of adding SMS notification.   

Before messages are sent they are queued up,  which means you do not have to wait until the previous message is sent. The information on all SMS sent is displayed in the log of monitoring system.

If an error occurs while sending a message, the log displays "SMS send error" and indicates the error number. The most common error is 515 (p.s. busy), which can occur when:

  • not enough credit on the SIM card; 

  • wrong SMS centre number;

  • low signal level ( less than 15%) in the home network;

  • wrong SMS format ( the number must begin with a "+") or the number is invalid.

If these points do not cover your case, try to reboot the system. In addition, try to send SMS from your mobile phone, make sure the SMS centre number is the same.

SMS commands

SMS-commands are used for remote control of monitoring systemUsing these commands, you can read the state and the measured values of sensors, control  relays or outletsPhone numbers from which the SMS commands will be sent, should be added to the list of allowed numbers in the modem properties ( Click on modem icon and edit "Allowed numbers").  In response to each SMS-command,  a response SMS will be sent.  In case of an error, an SMS will be sent with information about the error and an example of command. An SMS can contain only one command for only one element.

Command: reading sensor (relay, outlet) parameters

Function. get [id] or get [name], where id – number of the element, name – name of the element. Field "get" is not case sensitive, both can be used Get, GET.  Field "name" is case sensitive.

Description.  This command checks the state of the sensor or relay (outlet) and sends response SMS to the phone, from which the command was sent.

Examples.

  • “get 1034” - to obtain information about the sensor with number 1034;

  • ”Get Analog-1” - to obtain information about the state of the element with the name of Analog-1;

  • “GET Relay-2” - to obtain information about the state of the element with the name of Relay-2.  
    See section "Macros in the notification text" in Setting up GSM / USB modem for further information.

Command: setting state of relay/outlet

  Function. set [id] [state] or set [name] [state], where id – number of the element, name – name of the element, state – state to which relay/outlet switches. Field "set" and "state" are not case-sensitive. Field "name" is case-sensitive.  Field "state" can be in the following states:  on – switch on, off – switch off.

 Description. This command switches the relay ( outlet) in accordance with state parameter. In response it sends an sms notification to the phone number, from which the command was received,  with result of the command.

 Examples.

  • “set 1004 on” - switch on relay with number 1004;

  • ”Set Relay-1 on” - switch on relay with name Relay-1;

  • “SET Relay-2 Off” - switch off relay with name Relay-1;

  • “set 1005 OFF” - switch off relay with number 1005.

Command: setting impulse of relay/outlet

 Function. set [id] [name] pulse [duration], where id – number of the element, name – name of the element, duration – duration of delay in seconds. Field "name" is case sensitive.  The range of values for field "duration" is from 1 to 120.  

 Description. This command switches the relay ( outlet) two times with a temporary delay specified as a "duration" parameter in seconds.  

Examples.

  • “set 1004 pulse 15” - pulse is sent to the relay with number 1004 with delay time of 15 sec;

  • “SET Relay-1 PULSE 110” - pulse is sent to the delay with name Relay-1 with delay of 110 sec;

  • “set Relay-2 pulse 10” - pulse is sent to the relay with name Relay-2 with delay of 10 sec.

For errors related to a  modem, leave comments on this page.  Please indicate the firmware version of your monitoring system ( "System menu" → "About this system" → "Firmware version"). 

Sending SMS from PC

You can use an external program to send SMS directly from your PC, cURL for example.

To follow the example please use the following command in console:

gcc -O2 -o sendsms sendsms.c

Script example of sending SMS

 

SMS script
#!/bin/bash
# SMS script for version 2.4.x

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) hash
HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'`

# 2) autorisation
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

 

developer notes: linkchange