[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 

DisplayStringREAD/WRITESending a random SMS notification in the encoding UTF-8.
.1.3.6.1.4.1.25728.3800.1.10.0

npGsmSendSmsWin1251 

DisplayStringREAD/WRITESending a random SMS notification in the encoding Windows-1251.

A format of a random SMS notification:

[phone_number,phone_number,...] Message

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:

In a command line, go to the installation directory of the snmpset.exe utility

3. Run the utility snmpset.exe with the next parameters of a command line:

snmpset.exe -v 1 -c COMMUNITY IP OID TYPE VALUE

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Условное обозначение типов приведено на рисунке:

A type of a recorded value of an SNMP variable identifier

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:

C:\Program Files (x86)\net-snmp\usr\bin>snmpset.exe -v 1 -c SWITCH 192.168.0.100 .1.3.6.1.4.1.25728.3800.1.9.0 s "[+79130000000] Hello! Test SMS!"

4. After a successful execution of a command, the next response must be received:

SNMPv2-SMI::enterprises.25728.3800.1.9.0 = STRING: "[+79130000000] Hello! Test SMS!"

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:

var r = new XMLHttpRequest();
r.open('POST', 'http://192.168.0.100/sendsms.cgi?utf8', true, 'visor', 'ping'); // visor:ping – are username and password
r.withCredentials = true;
r.send('[+79130000000] Huston, we have a problem!');

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:

sendsms_result('ok');

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:

$url = "http://192.168.0.100/sendsms.cgi?utf8"
$username = "visor"
$password = "ping"

$reqBody = "[+79136895423] Huston, we have a problem!"

$req = [System.Net.WebRequest]::Create($url)
$req.Method = "POST";

$req.Credentials = new-object System.Net.NetworkCredential($username, $password)

$Body = [System.Text.Encoding]::UTF8.GetBytes($reqBody);

$stream = $req.GetRequestStream();
$stream.Write($Body, 0, $Body.Length);

$stream.Flush();
$stream.Close();

$resp = $req.GetResponse().GetResponseStream()
$resp.Close() 

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.