Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

To operate with a modem:

...

Configuring the modem for send and receive SMS

To configure the modem, use the modem settings tab (Main Menu→SMS messages):

...

  • Status – the state of the cellular network;

  • Operator – the state of the cellular network;
  • Signal level – the signal level;
  • PIN code – pin-code of sim-card;

  • SMS center – SMS service center number, leave it blank to auto-detect;
  • List of allowed phone numbers – list of numbers from which SMS commands are allowed. To separate numbers, use a space. Incoming sms SMS messages from other numbers are not processed. Supports up to 10 phone numbers (100 for VT9xx systems).

  • Request current balance – the number on which the account balance is requested, to see the answer, click on the "OK" button and waiting for an answer;
  • Clear SMS list – clear list of SMS messages.

...

Warning

If an error occurs during the operation of the modem, or the SIM card is not installed, or the PIN code is not correct, the message writing in to into the log queue ("GSM modem: Error, check your SIM card and PIN code" or "GSM modem: modem error, restart smsd"). The message is displayed only 5 times in order not to overflow the log.

SMS messages

To add a sms an SMS notification recipient, first, open the System Tree menu, further open window SMS:

  • Name – name of the notification. Can be arbitrary (name, the position of the recipient, ...);

  • Phone number –  – the telephone number to which the notification has to be sent.  

  • Message text – text message , can be in any language. Also in this field, you can use various macros (%1 - %8), which insert the current values of variables into the text.

To apply the settings, click the "Save" button. To test smsSMS, click the "Test" button.

Warning

When You press "Test", the system send sends a message to test if the SMS is sent correctly. Test SMS may contain incorrect information about sensors (macros %1 and %2) for testing purpose purposes only.

After filling in the notification parameters, you must specify the event (events) by which the sms SMS message will be sent. To do this, open the Preferences → Logic schemes → Add window and specify the condition for sending the sms 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 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 until 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 SMS send error is displayed in the log, the reasons of which may be:

  • the negative balance on the sim card account.

  • low signal level;
  • wrong format or nonexistent recipient phone number.

If these items do not fit your situation, try to restart the monitoring system. Also, check the sending of messages from your mobile phone.

...

SMS commands are used for remote management by the monitoring system. Using these commands, you can read the system status, the status, and the measured value of individual sensors and a group of sensors, as well as control the relay switches (outletsoutlets). 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 → SMS messages → List of allowed phone numbers).

Info
titleAttention!
To separate phone numbers, use a space. The number must start with "+". Up to 10 phone numbers is are possible (100 for VT9xx systems).

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

...

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 must be enclosed in quotesAlso, the name of the requested sensor must be unique, otherwise, the answer may be incorrect.

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

...

get system - get information about the system. Responce contains the The response contains the system device type, firmware version, system state, IP address, etc. Responce Responses look like this:

Code Block
languagexml
titleget system
System: VT335
Firmware: 2.7.4 b570
State: normal
Hostname: monitoring_unit_1
IP: 192.168.0.193

...

get [group name or ID] - get information about the group of sensors. Responce Response contains a description of the group and a brief description of all the modules and sensors in the group. Responce Responses look like this:

Code Block
languagexml
titleget group
Group: test group [3001]
State: normal
Description: here if available

Analog-4[102001] normal 0
Onboard Temperature[201001] normal 30.20 C
Onboard Voltage DC[203001] normal 12.21 V

...

get [sensor name or ID] - get information about the sensor. Responce Responses look like this:

Code Block
languagexml
titleget element
Element: Temperature-1 [201003]
State: normal
Value: 27.5 C

...

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 under the state parameter and send the reply sms SMS to the phone from which the command came, about the result of the command.

...

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.

...

  • logic 1 off 10 - disabling logic with the number 1 for 10 seconds;
  • logic 1 on - the inclusion of logic with the number 1;
  • logic * off - disabling all logics logic for 24 hours;
  • logic * on - including all logicslogic.

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

...

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"`
# or for HTTPS case
#RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" -k "https://${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
# or for HTTPS case
#curl -d "querytype=send_sms_message&k=${KEY}" --data-urlencode "to_phone=${TOPHONE}" --data-urlencode "message=${MESSAGE}" -k https://${HOSTIP}/engine.htm > /dev/null 2>&1


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

...