[ENG] 11.11. [DKSF 70/71.6 IU] How to Send Random SMS?
Information in the section applies to the device UniPing server solution v3/SMS with a built-in GSM modem.
In the firmware of a UniPing server solution v3/SMS device in the version DKSF 70.6.X, there is an implemented feature of sending random SMS notifications via an SNMP protocol and third-party web applications (HTTP API).
Sending SMS Notifications via an SNMP Protocol
To send random SMS notifications in Cyrillic via an SNMP protocol, there is a need to use the encoding UTF-8 (Converting files to UTF-8) or Windows-1251 in a text of an SMS notification.
To send SMS using an SNMP protocol, there is a need to use the variable «npGsmSendSmsUtf8» or «npGsmSendSmsWin1251», in which a destination phone number is written as well as a text of an SMS notification. To do this, see the MIB file that can be downloaded from the page of a description of a device in the section «Documentation and FIles».
OID | Name | Type | Access | Description |
---|---|---|---|---|
.1.3.6.1.4.1.25728.3800.1.9.0 | npGsmSendSmsUtf8 | DisplayString | READ/WRITE | Sending a random SMS notification in the encoding UTF-8. |
.1.3.6.1.4.1.25728.3800.1.10.0 | npGsmSendSmsWin1251 | DisplayString | READ/WRITE | Sending a random SMS notification in the encoding Windows-1251. |
A format of a random SMS notification:
where:
phone_number – is a destination number in square brackets.
Message – is a text of a notification (it is divided by a space from a destination number).
It is possible to send SMS to several destination addresses by indicating them in square brackets divided by a comma without spaces. If destination numbers are not chosen, SMS will be sent to the numbers specified in the settings on the page «SMS» of a device web interface.
Example of a command consequence or sending a random SMS through the SNMP using the NET-SNMP package
1. To send a random SMS it is possible to use a specific package NET-SNMP.
2. After installing the package NET-SNMP, run the utility snmpset.exe in a command line. To run a command line, use a combination of keys «Windows+L». After the window «Execute» opens, enter a command «cmd» and click the button «Enter». Then, in a command line, go to the installation directory of the utility snmpset.exe:
3. Run the utility snmpset.exe with the next parameters of a command line:
where:
COMMUNITY – is a specific password, which is specified on the page «SETUP» of a device web interface. In NetPing devices, community=SWITCH on default;
IP – is an IP address of a NetPing device, through which a random SMS notification will be sent;
OID – is an SNMP identifier of the variable «npGsmSendSmsUtf8» or «npGsmSendSmsWin1251», which is used for sending a random SMS notification;
TYPE – is a type of the recorded value of an SNMP identifier of a variable. Symbols of types are represented on the pictureУсловное обозначение типов приведено на рисунке:
VALUE – is a recorded value, i.e. a text of an SMS notification
According to the description provided above, a command for sending a random SMS using the utility snmpset.exe is as follows:
4. After a successful execution of a command, the next response must be received:
Sending SMS Notifications through Third-Party Web Applications (HTTP API)
A maximum length of random SMS notifications must not exceed 255 characters.
Example of sending a random SMS using the JavaScript code
To send SMS through third-party web applications, it is possible to use the next JavaScript code:
where:
192.168.0.100 – is a default IP address of a device.
visor – is a default username for connecting to device web interface.
ping – is a default password for connecting to a device web interface.
It is possible to send SMS to several destination numbers, by having specified them in square brackets divided by a comma without spaces. If destination numbers are not chosen, an SMS will be sent to the numbers, specified in the settings on the page «SMS» of a device web interface.
If a data format is correct, the next JavaScript code is returned as a result:
A result of sending a notification does not influence the returned CGI (Common Gateway Interface) response. CGI only initiates sending of a notification.
Example of sending a random SMS using the PowerShell script
To send SMS through the third party web applications, it is possible to use the next PowerShell script:
where:
$url – is a variable, in which an IP address of a NetPing device is specified as well as a script for sending random SMS notifications.
$username – is a variable, in which a username is specified for authorization in a NetPing device.
$password – is a variable, in which a password is specified for authorization in a NetPing device.
$reqBody – is a variable, in which a destination number is specified in square brackets as well as a text of an SMS notification (it is divided by a space from a destination number). It is possible to send SMS to several destinations, by having specified them in square brackets divided by a comma, without spaces.