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
- GSM-BGS5-EEN by the SeaPraha company (see https://www.seapraha.en/produkt/gsm-bgs5-een). Allows to communicate via Ethernet.
- but also any other that supports the GSM ETSI 07.05 standard

Before using this driver in the PROMOTIC application it is highly recommended to watch "PROMOTIC video tutorial 4 - Communication drivers".

Basic properties of the driver:
- Usage of this driver requires purchase of the PmSMS licence. When developing the application in the freeware mode PmFree, or with development environment and while testing it in runtime, this component is always functional.
- The communication is done for Ethernet (PROMOTIC application is 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 the 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 receive SMS from the application"

Recommended values of the PmaComm object parameters:

Recommended values for the Serial link parameters:
Baud rate9600 Bd (depends on the GSM module settings)
Number data bits8
Number of stop bits2 (depends on the GSM module settings)
Number of repeats after unsuccessful transmission0
Timeout between receiving 2 characters100 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 transmission 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 / No.
This parameter is stronger than the similar Filter ECHO chars parameter in configurators Setting the parameters of the serial link. Therefore it is necessary to choose "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 by 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)!
Character setWhen initializing the driver, the command AT+CSCS is sent. This command switches the modem to a mode when the text messages are sent in selected character set.
No - The AT+CSCS command is not sent. All text messages will be sent as ASCII characters. In this case it is not possible to send characters in national code pages (e.g. characters ž,á,č ...).
UTF-8 - When initializing the AT+CSCS=UTF-8 command is sent. All text messages will be sent in Unicode UTF-8. In this case all national specific characters can be sent.

The communication description by means of the PmaCommMsg object

It can be defined message types in the message parameters of the PmaCommMsg object:

- 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. In this case it is necessary to increase the period for hooking up in the protocol parameters or to multiply the initialization message.
- The "Parameters" tab:
- Preferred message storage: Here can be set the memory module that is used for transmission of messages.. 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" tab:
- 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 variable on the "Data-received" tab.

- Sending SMS message: This message sends a SMS message to the specified phone number.
- The "Parameters" tab:
- Timeout to receive send confirmation [ms]:
Here it is possible to set how long the driver will wait (in milliseconds) for confirmation of receipt of the transmission.
The 0 value means that it will wait according to the value of the Timeout of one packet transfer [ms] parameter.
If the confirmation does not come before that time, then the transmission of the message is terminated with an error 24.
- There are following variables on the "Data-sent" tab:
- TLF (Phone number): The phone number to which the SMS message has to be delivered.
Example: "602505647" or "+48602505647".
Sometimes this number must be entered without quotes and sometimes with quotes.
- MSG (Content of message): Text of the SMS message that has to be sent. The text can be of 160 characters long at the most.
Example: "Failure of Boiler1".
- There is no variable on the "Data-received" tab.

- 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 message type (by the Run method) regulary, for example, each 10 seconds.
- There is no variable on the "Data-sent" tab.
- There are following variables on the "Data-received" tab:
- TIME (Time of receive): The delivery time of the message into the GSM module.
Example: "13.5.2023 15:40"
- FROM (Phone number): The phone number of the message originator.
Example: "+48602505648"
- MSG (Content of message): The text of the received SMS message.

- General message transmission: 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" tab:
- Type of data receiving: It is possible to set if the data come in 1 or 2 messages. They are in one message by default.
If the response 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" tab:
- 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" tab:
- DATA (Data for receive): The text of the response from the GSM module.
- 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 the "Serial link parameters" configuration window.
b) Response receipt timeout in the "Protocol parameters" configuration window.

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 Windows OS. But during a GPRS connection the serial port is controlled by Windows OS (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 the Windows OS).
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 Windows OS 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
// Error OpenPort !!!
// 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;
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.

Pm9.00.27: New "Timeout to receive send confirmation [ms]" configurator allows to define the timeout for the "Sending SMS message" confirmation.
Pm9.00.13: New "Character set" configurator allows the UTF-8 coding for the modem.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.