Promotic
WikipediaLinkedInYoutubeTwitterFacebook

PmSMS - Driver for communication with GSM modules by SMS messages

Communication driver for SMS messages allows sending and receiving SMS (Short Message Service) messages by GSM module.

The GSM modem must support AT commands in text mode (standard GSM ETSI 07.05). This standard is supported by majority of available GSM modems.

 
The driver has been tested for example with the following GSM modules:
- TC35, TC35i, MC35, MC35i, MC39i by the SIEMENS company
- GS-01 by the WESTERMO company
- Wavecom (e.g. WMOD2) by the WISMO company
 
Before using this driver in the PROMOTIC application it is highly recommended to read the chapter: Communication using the PROMOTIC drivers.
 
Basic properties of the driver:
- Usage of this driver requires purchase of the PmSMS license. With the freeware version PmFree, or when developing the application (with development environment for tersting purposes), this component is always functional.
- The communication is done for Ethernet-client or for serial link (COM1, COM2 ...). Sending the same data via Ethernet as for serial link is currently implemented.

Even if the device does not have the Ethernet interface it is possible to connect it by "serial link-Ethernet" converter and let it communicate with the PROMOTIC application via Ethernet.

- The driver is incorporated into the PROMOTIC system by means of the PmaComm object.

The driver supports to usage of the PmaCommMsg object. The PmaCommGroup object cannot be used.

For easy integration of this driver into the application it is handy to use: Preconfiguration "PmSMS - send and recive SMS from appliation"

 

Recommended parameters values:

Recommended values for the Serial link parameters:
Baud rate9600 Bd (depends on the GSM module settings)
Number of data bits8
ParityNO
Number of stop bits2 (depends on the GSM module settings)
Number of repeats after unsuccessful transmission0
Timeout between receiving 2 chars100 ms
Delay between receive-send200 ms
RTS flow controllog.1
DTR flow controllog.1
Recommended values for the Ethernet-client parameters:
Sending the same data via Ethernet as for serial link is currently implemented. In this case, the Ethernet parameters can be set accorting to the Eternet/serial link converter.
Description and recommended values for the Protocol parameters:
Response receipt timeout2000 ms. Only for serial link. The time (in milliseconds) the driver is waiting for the response on sending the message. If no response comes during this time, then the transfer of the message is terminated (the onEndOfTransfer event is triggered with error 24 or 66).
Delay of connection establishing at initialization2000 - 5000 ms
Perform initialization modem settingspecifies the command that is sent to the modem while initializing
Yes - Command "AT&F" (manufacturer modem setting)
No - Nothing is sent
Sent message will be in received message (i.e. ECHO present)Yes This parameter is stronger than the similar parameter "Filter ECHO chars" in configurators Setting the parameters of the serial link. Therefore it is necessary to set "Filter ECHO chars"=No.
Message formatThere are several types of GSM modems that are not fully compatible together. That's why it is possible to determine the type of the message format:
Text mode by GSM 07.05 - We recommend this mode. Data are transferred in the text mode. This mode is compatible for example with GSM modules: Siemens M20,TC35,TC35i,MC35,MC35i,MC39i, Westermo-GS01, Wavecom-WMOD2, etc.
PDU mode for old GSM module M1 - Data are transferred in so-called PDU data that are compatible with the GSM module M1 from the Siemens company.
PDU mode for old GSM module A1 - Data are transferred in the TPDU data (by GSM 03.40) that are compatible with the A1 module (but probable even with the M20 and Westermo-GS01 modules). Here is implemented only sending SMS messages (not receiving)!

The communication description by the PmaCommMsg objects

It can be defined 4 message types in the message parameters of the PmaCommMsg object.
1) SMS initialization: This message must be sent before any other types. The initialization of the GSM module will be performed. Because of the slowness of hooking up (caused by the module registration in the GSM network), it is possible that the initialization fails at the first attempt. Then it is necessary to increase the period for hooking up in the protocol parameters or to multiply the initialization message.
- The "Parameters" page:
- Preferred message storage: Here it is possible to select the memory module that is used for the data transfer. There are the following possibilities:
- By settings in GSM module (default)
- Storage in SIM card
- Storage in GSM module
- Storage in SIM card and GSM module
- There are following variables on the "Data-sent" page:
- PIN (Personal Identification Number): PIN number of the SIM (Subscriber Identity Module) card inserted into the GSM module. Example: "1589"
- SCA (Service center address): Phone number of the SMSC (Short Message Service Center).
- There is no varible on the "Data-received" page.
2) Sending SMS message: This message sends a SMS message to the specified telephone number.
- There are following variables on the "Data-sent" page:
- TLF (Phone number): The phone number to which the SMS message has to be delivered. Example: "602505647" or "+420602505647"
- MSG (Content of message): Text of the SMS message that has to be sent. The text can be of 160 chars long at the most. Example: "Failure of Boiler1"
- There is no varible on the "Data-received" page.
3) Receiving SMS message: This message finds out if at least one SMS message has been delivered to the GSM module. If yes, then it stores the content of the first SMS message into the data for receive; this SMS message is deleted in the GSM module and the transmission is terminated. If no received message finds itself in the GSM module, then transmission is terminated (i.e. the onEndOfTransfer event is triggered) with the error 62 (negative acknowledgement). Thus running a message of this type receives one single message at the most. For the continuous receiving SMS messages it is necessary to run the PmaCommMsg object with this type (by the Run method) regulary, for example, each 10 seconds.
- There is no varible on the "Data-sent" page.
- There are following variables on the "Data-received" page:
- TIME (Time of receive): The delivery time of the message into the GSM module. Example: "13.5.2018 15:40"
- FROM (Phone number): The phone number of the message originator. Example: "+420602505648"
- MSG (Content of message): The text of the received SMS message.
4) General message transfer: This optional message serves to the direct control of the GSM module, for example by means of AT commands. A list of these AT commands is out of this documentation scope.
- The "Parameters" page:
- Type of data receiving: It is possible to set if the data come in 1 or 2 messages. They are in 1 message by default. If the answer comes at first, for example, from the GSM module and then from the SMS center, then set it to 2 messages.
- There are following variables on the "Data-sent" page:
- DATA (Data for send): The text of the message (command) that has to be sent into the GSM module.
- There are following variables on the "Data-received" page:
- DATA (Data for receive): The text of the response from the GSM module.
Notes:
- SMS messages shouldn't contain diacritical marks.
- The GSM module can have problems receiving messages coming in quickly. In some situations it can even disconnect the communication and then it has to be reset manually. If such situations occur, then it is necessary to increase:
a) Delay between receive-send in configuration window Serial link parameters.
b) Response receipt timeout in configuration window Protocol parameters.
 
GSM modem, GPRS network and sending SMS:

If a GSM/GPRS modem has to be connected to the GPRS network, then the modem has to be installed in OS Windows. But during a GPRS connection the serial port is controlled by OS Windows (over the installed modem) and the driver cannot access this port - and so it is not possible to send SMS messages. The solution is dynamically disconnect the GPRS network, connect the driver, sent/receive a SMS and then disconnect the driver and connect the GPRS network. The GPRS network can be controlled by the utility rasphone.exe (is a part of OS Windows).

Example:

At the beginning the "PmaComm > Setting the parameters of the serial link > Serial port" configurator is set to "Not set". The GPRS network is connected (the name of the modem in OS Windows is, for example, "GSMname") and so, for example, the "COM1" cannot be used. Now a SMS message needs to be sent:

JavaScriptVBScriptSelect and copy to clipboard

var b1, b2;
b1 = Pm.CreateProcessSync("rasphone -h GSMname", ".");  //disconnection from GRPS network
if (b1)
{
b2 = pMe.Pm("/PmaCommSMS").OpenPort("COM1");
if (b2)
pMe.Pm("/PmaCommSMS/Msg1").Run();  //sending SMS message
else
//Error OpenPort !!!
}
else
//Error Disconnect Rasphone !!!
If no error occurs, then these commands stimulate sending a SMS message. After sending the SMS message, the PmaCommMsg.onEndOfTransfer event is triggered, in which it is possible to close the port and to connect the network again:
JavaScriptVBScriptSelect and copy to clipboard

var b1;
pMe.Pm("/PmaCommSMS").ClosePort();
b1 = Pm.CreateProcessSync("rasphone -d GSMname", ".");  //connection to GPRS network
if (! b1)
//Error Connect Rasphone
Commands for disconnection and connection of the network are synchronous and they can last longer time (a few seconds). So it is advisable to call the presented algorithms in another thread - see How to start selected scripts in another thread.

History:
Pm7.02.00:
- Enhancement for Ethernet-client.
- New parameter "Perform initialization modem setting" was added among protocol parameters that defines whether to send modem command "AT&F".
PROMOTIC 9.0.7 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice