Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 28 Next »

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:

  • ID – modem element ID in the system;

  • IMEI – unique number of the modem;


  • State – the state of the modem;

    • normal – the modem is found, registered in the network;

    • alarm – sim card error, modem initialization error, no network.

  • Status – the status of the cellular network:

    • registered – registered in the network;

    • registered roaming – registered in the roaming network; 
    • not registered, searching - searching the network;
    • not registered, not searching – network not found;

    • registration denied – registration is prohibited;

    • found, not ready – modem is not ready to send sms messages;

    • found, ready – modem is ready to send sms messages; 

    • error text, for example: SIM not inserted..
  • Signal level – the signal level, the range of values ​​is from 0% to 100%.

Configurable parameters of the modem element in the system:

  • Name – the name of the modem element in the system;

  • Verbosity level – determines the level of messages by their importance, which are output to the log from Critical (only the most important messages) to Debug (all messages);
  • PIN code – pin-code of sim-card;

  • Phone of SMS centre – sms-center number;

  • List of allowed phone numbers – list of numbers from which sms commands are allowed. To separate numbers, use a space. Incoming sms messages from other numbers are not processed. The number must start with "+".

  • Phone number for balance – the number on which the account balance is requested on the account, the request itself is made using the Request current balance button, to see the answer, close the window and open it again.

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

Attention!

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.

Attention!

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:

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

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

  • Message – text message, can be in any language. The length of one message containing only Latin characters is 160, with national symbols 70. If the length of one message exceeds the limit, the message is divided into several parts. Also in this field you can use various macros (% 1-% 7), which insert the current values of variables into the text.

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.

When You press "test message", the system send a test message to test if the SMS is sent correctly. A test SMS does not contain macrosses, it is empty.

In order to test macroses of the notification You need to create a test logic or use an existing logic. E.g. a logic scheme may look like: if sensor goes to alarm state, then send SMS. After You save the logic and bring the sensor into an alarm state, You should receive SMS with macroses.


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:

  • negative balance on the sim card account.

  • low signal level;
  • wrong number of sms-center, specify the number from the mobile operator;

  • 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, 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).

Attention!

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.  

  • “get 201001” - get information about the sensor with the number 201001;
  • ”get Analog-1” - get information about the sensor with the name Analog-1;
  • "get 404001" - get information about the GSM Modem, in this case, the response message will only come if the modem is in the normal state, the response message show the signal level in the "value" field.

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.  

  • “set 302001 on” - turn on relay number 302001;

  • ”set Outlet-1 on” - turn on relay Outlet-1;

  • “set 302002 off” - turn off relay number 302002;
  • “set Outlet-2 off” - turn off relay Outlet-2.

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.

  • “set 302003 pulse 15” - the impulse to the relay number 302003 with a delay of 15 seconds;

  • “set Relay-1 pulse 110” - the impulse to the relay named Relay-1 with a delay of 110 seconds; 

  • "set Outlet-2 pulse" - sending a pulse to an outlet with the name Outlet-2 with a previously set delay. 

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.

  • "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 logs for 24 hours;
  • "logic * on" - including all logics.

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).

LTE mode

Если встроенный модем поддерживает LTE режим передачи данных, то в окне настройки модема появится вкладка "LTE mode". По умолчанию режим отключен. Чтобы его включить, нужно установить флаг "Enable LTE", указать номер телефона для соединения с провайдером "Phone for connection", указать точку доступа "Access point (APN)". Если дополнительно требуется аутентификация пользователя, то нужно установить соответствующий флаг и указать имя и пароль пользователя.

После нажатия кнопки "OK" или "Apply", настройки режима LTE будут сохранены и через несколько секунд модем перейдет к установке соединения с провайдером. О ходе соединения можно судить по полю "Status" в окне настройки модема.

После установки LTE соединения через модем, отправка SMS, проверка баланса и уровня сигнала станут невозможны, т.к. модем находится в режиме передачи данных.

При отключении режима LTE, после нажатия кнопки "OK" или "Apply" произойдет перезагрузка устройства. Будте внимательны, сохраните сделанные в системе изменения перед этим.


  • No labels