Sending and Receiving SMS Messages Via A SCALANCE M Router
Sending and Receiving SMS Messages Via A SCALANCE M Router
https://support.industry.siemens.com/cs/ww/en/view/54361177
Warranty and Liability
Note The Application Examples are not binding and do not claim to be complete regarding the
circuits shown, equipping and any eventuality. The Application Examples do not represent
customer-specific solutions. They are only intended to provide support for typical
applications. You are responsible for ensuring that the described products are used
correctly. These Application Examples do not relieve you of the responsibility to use safe
practices in application, installation, operation and maintenance. When using these
Application Examples, you recognize that we cannot be made liable for any
damage/claims beyond the liability clause described. We reserve the right to make
changes to these Application Examples at any time without prior notice. If there are any
deviations between the recommendations provided in this Application Example and other
Siemens publications – e.g. Catalogs – the contents of the other documents shall have
priority.
We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this application example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
deficiency or breach of fundamental contractual obligations (“wesentliche
Vertragspflichten”). The damages for a breach of a substantial contractual
obligation are, however, limited to the foreseeable damage, typical for the type of
Siemens AG 2016 All rights reserved
contract, except in the event of intent or gross negligence or injury to life, body or
health. The above provisions do not imply a change of the burden of proof to your
detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of Siemens AG.
Security Siemens provides products and solutions with industrial security functions that support the
informa- secure operation of plants, systems, machines and networks.
tion To protect plants, systems, machines and networks against cyber threats, it is necessary
to implement (and continuously maintain) a holistic, state-of-the-art industrial security
concept. Products and solutions from Siemens are only one part of such a concept.
The customer is responsible for preventing unauthorized access to the customer’s plants,
systems, machines and networks. Systems, machines and components should be
connected to the company network or the Internet only if and to the extent necessary and
if appropriate protective action (e.g., use of firewalls and network segmentation) was
taken.
In addition, Siemens’ recommendations regarding appropriate protective action should be
followed. For more information about industrial security, visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them even
more secure. Siemens strongly recommends to perform updates as they become
available and use only the latest product versions. Using versions that are out of date or
no longer supported can increase the risk of cyber threats.
To stay informed about product updates as they occur, subscribe to the Siemens
Industrial Security RSS feed at http://www.siemens.com/industrialsecurity.
Table of Contents
Warranty and Liability ................................................................................................. 2
1 Task ..................................................................................................................... 4
2 Solution............................................................................................................... 5
2.1 Overview............................................................................................... 5
2.2 Description of the core functionality ..................................................... 6
2.3 Overview and description of the user interface .................................... 8
2.4 Hardware and software components ................................................... 9
3 Principle of Operation ..................................................................................... 11
3.1 Complete overview of the “Escalation” program ................................ 11
3.1.1 Program overview .............................................................................. 13
3.1.2 Global data block: “EscalationParamDB” (DB1) ................................ 13
3.2 Functionality of the S7 station ............................................................ 15
3.2.1 Program details on the “EscalationSms” FB ...................................... 15
3.2.2 Call of the “EscalationSms” FB in OB1 .............................................. 18
3.2.3 “typeEscalation” PLC data type .......................................................... 19
3.3 Status and error displays.................................................................... 20
4 SCALANCE M874/M876 Configuration .......................................................... 21
4.1 Entering the SMS service center ........................................................ 21
4.2 Configuring the access details for the cellular network ...................... 22
Siemens AG 2016 All rights reserved
1 Task
Introduction
The application example shows how messages can be sent to mobile service
personnel using a simple SMS-based escalation system via the SCALANCE
M874/M876 router.
Escalation chain
Mobile service
Siemens AG 2016 All rights reserved
Automation station
Level
alarm
Requirements
This application example is intended to meet the following requirements:
The S7 station
sends a message to the first service employee,
waits for a configured time for the service employee’s acknowledgment SMS
message,
sends this message to the next employee if no acknowledgment has been
received within this time,
saves the information of who has acknowledged the alarm SMS message,
terminates the process with an error if no employee has acknowledged the
alarm SMS message.
The simulated process in the S7 station is to be operated and controlled with the
aid of visualization software.
2 Solution
2.1 Overview
Diagrammatic representation
The diagrammatic representation below shows the most important components of
the solution:
Figure 2-1
Configuration
Siemens AG 2016 All rights reserved
In this example, the SCALANCE M874-3 router is used to connect the S7-1200
CPU to the GSM network.
With the aid of the “LSmsSR” library, you can send messages to and receive
messages from a GSM-capable mobile device via SMS using the SCALANCE
M874-3 router (see \2\). The library blocks are called in the “EscalationSms” user
block that coordinates sending the message to the service personnel.
The application is visualized using WinCC Advanced.
Advantages
The solution presented here offers the following advantages:
The library blocks and the “EscalationSms” FB directly provide usable
application code.
The code of the “EscalationSms” FB
– already includes the above-described functions on a fully implemented
basis and
– can be easily customized for extensions.
Scope
This application does not include a description of
SIMATIC NET Industrial Remote Communication Remote Networks
SCALANCE M-800 devices
SIMATIC HMI operator panels
the LAD/FBD/STL/SCL programming languages.
Basic knowledge of these topics is required.
Start
1 Users
2
Service employee 1
.
Service employee 2
.
.
.
.
Next employee
.
Service employee 5
5
5
Siemens AG 2016 All rights reserved
1 min 3
No
Acknowledgment
Yes
6 4
Error Stop
1. Five service employees are parameterized for sending and receiving an alarm
SMS message.
2. The alarm SMS message is sent to the first parameterized service employee.
3. The station waits for 1 minute for the service employee’s acknowledgment.
4. If an acknowledgment has been received, the process is terminated.
5. If no acknowledgment has been received during this one minute, the alarm
SMS message is sent to the next service employee.
6. If none of the five parameterized service employees has acknowledged the
alarm SMS message, the process is terminated with an error.
Note For a more detailed description of these functions, please refer to Chapter 3 and
the following chapters.
Performance data
The following table shows the performance data of the user block FB
“EscalationSms”.
Table 2-1
Criterion Performance Note
data
Number of service employees 5 Can be customized in the
block.
Number of alarm SMS messages 5
Maximum alarm SMS message 160 characters
length
S7 CPUs per SCALANCE M router 1
Request time for sending an alarm 5 sec Average time from send
SMS message trigger command to end of
send operation.
Wait time for an acknowledgment 1 min Can be customized in the
block.
Siemens AG 2016 All rights reserved
5
1
6
2
7
8
9
Siemens AG 2016 All rights reserved
10
Table 2-2
No. Item Description
1. “Users” Input field
Number of service employees to whom the alarm
SMS message is sent.
2. “Array of Users” Input fields
Parameterized service employees to whom the
alarm SMS message is sent.
Each employee is assigned a phone number and
a connection name.
The employee to whom the alarm SMS message
is currently sent is displayed in “green.”
3. “Alarm SMS” Input field
Alarm SMS message that is sent to the service
employees.
4. “Send Alarm SMS” Button
Hardware components
Table 2-3
Component Article number No. Note
SCALANCE M874-3 6GK5874-3AA00-2AA2 1 Alternatively, you can use
any variants of the
SCALANCE M874 and M876
series.
SIMATIC S7-1200 6ES7217-1AG40-0XB0 1 Any S7-1200 CPU V4.0 or
CPU 1217C higher can be used.
DC/DC/DC
Software components
Table 2-4
Component No. Article number Note
STEP 7 Professional V13 SP1 1 6ES7822-1AA03-0YA5
WinCC Advanced V13 SP1 1 6AV2102-0AA03-0AA7
Table 2-5
Component Note
54361177_SMS_SCALANCE_M_PROJ_V10.zip This zip file contains:
The STEP 7 V13/WinCC
Advanced project for the S7-1200
CPU
54361177_SMS_SCALANCE_M_DOC_V10_en.pdf This document.
Siemens AG 2016 All rights reserved
3 Principle of Operation
Key points of this application example:
Configuration of the SCALANCE M847/M876 router using Web Based
Management for sending and receiving SMS messages (Chapter 4).
The communication mechanisms in the S7 CPU for sending and receiving
SMS messages via the SCALANCE M router.
S7 CPU User1
Port_number SMS Relay Outgoing “Text_1”
Siemens AG 2016 All rights reserved
Username
Password Port number
“Text_1”
Username
Users Password
User1 Conn1 TelNo1 User5
.
User5 Conn5 TelNo5 “Text_1”
Receive acknowledgment
Viewed from right to left, the following figure shows the receiving of an
acknowledgment from a service employee.
Figure 3-2
S7 CPU
IP address SMS Relay Incoming
Port number User1
“Text_1” Conn1
Conn5
Conn1
Note At a given time, only one S7 CPU can establish a connection to the SCALANCE M
router and send the SMS message.
The following figure shows the important elements of the program of the S7 station.
Figure 3-3
instDB_
Escalation LSmsSR_ Escalation
Main Sms
Sms SndSms
LSmsSR_ Escalation
RcvSms ParamDB
Table 3-1
Element Symbolic name Description
Siemens AG 2016 All rights reserved
Figure 3-4
Siemens AG 2016 All rights reserved
The “EscalationSms” function block starts the escalation process (see Chapter
2.2). Internally, it calls the blocks of the “LSmsSR” library for sending the message
to the service employees, “LSmsSR_SndSms”, and for receiving an
acknowledgment from them, “LSmsSR_RcvSms”.
Figure 3-5
reqSndSms
Start
Users
UserNo
alarmSms
i=1
User= User[i]
Siemens AG 2016 All rights reserved
1 min
LSmsSR_ Wait for acknowledgment
RcvSms
No
No
i=i+1
Save
employee
Yes i <= data
UserNo
No
Error= No Ack
Stop
The following figure and table show the call interface of the user block FB
“EscalationSms” (FB3).
Figure 3-6
Siemens AG 2016 All rights reserved
Table 3-2
Name Data type Description
reqSndSms Bool Starts the escalation process.
Input
Description,
Chapter 3.2.4).
escalationParam “typeEscalation” Parameters required for the
PLC data type escalation process (see Chapter
3.2.3).
alarmSms String Message sent to the service
employees.
The “EscalationSms” FB (FB3) is called cyclically in OB1. The input and output
parameters are stored in the global data block, “EscalationParamDB”, (see Chapter
3.1.2).
Figure 3-7
Siemens AG 2016 All rights reserved
Note If multiple “EscalationSms” FBs are called in OB1, you have to modify the
ConnectionIDs of the library blocks. These IDs must be unique for each call.
The “typeEscalation” PLC data type contains the parameters for the escalation
process.
To start up the application, this data type is used in the global data block,
“EscalationParamDB” (see Chapter 3.1.2), that is linked to the “escalationParam”
InOut parameter of the function block.
Figure 3-8
Table 3-3
Name Data type Description
Users Array[1..5, 1..3] of String[40] List of service employees to whom the
Siemens AG 2016 All rights reserved
Note:
Each employee is assigned a connection
name for assigning the acknowledgment.
UserNo Int Number of service employees to whom
the message (alarmSms) is sent.
The maximum value in this example is
“5”.
alarmSms Array[1..5] of String[160] List of any messages sent to the services
employees.
rcvAckUser Array[1..3] of String[40] List of employee data from whom an
acknowledgment was received.
User[1]: Employee name
User[2]: Employee phone number
User[3]: Employee connection name
escalationTime Time Wait time for acknowledgment.
In this example, this time is set to 1
minute.
Note:
When UserNo=5, enter the
data for 5 employees.
16#00008202 The escalation process is complete
without acknowledgment.
Note For information on the error messages that occur in the library blocks, please
refer to the Library Description, Chapter 3.3 \2\.
Siemens AG 2016 All rights reserved
Note The SMSC number is only required for sending SMS messages. If you only want
to receive SMS messages, this number is irrelevant.
Siemens AG 2016 All rights reserved
Figure 4-1
Note:
In the address bar of the web browser, enter the IP address or the URL of the
device.
2. Enter the user name “admin” and the associated password.
Click the “Login” button or confirm your entries with “Enter”.
Siemens AG 2016 All rights reserved
Note:
When you log in for the first time or after “Restore Factory Defaults and Restart”,
enter the default password, “admin”.
3. In the “SIM” tab of the WBM page of the SCALANCE M874/M876, enable the
mobile network interface, “Interfaces > Mobile > SIM”.
Note:
The PIN can be obtained from your mobile service provider.
No. Action
5. Open the “Operator” tab: “Interfaces > Mobile > Operator” and check the “Manual
APN” check box.
Note:
When the “Manual APN” check box is unchecked, the device automatically selects
the appropriate access parameters from the list of mobile network operators. By
factory default, the access details of four mobile network operators are set and
activated. The manually configured APN will be ignored.
Siemens AG 2016 All rights reserved
Note These access parameters can be obtained from your mobile network operator.
3. Enter the user name and password that must be included before the text is sent by
SMS.
Siemens AG 2016 All rights reserved
Note:
The user name and password must match the values entered in the “username”
and “password” “EscalationParamDB.SmsSndParam” parameters. The following
values have been entered in this example:
User: admin
Password: connection
4. Enter the port on which the SCALANCE M receives the SMS message.
Note:
This port number must match the port address entered in the “remotePort”
“EscalationParamDB.SmsSndParam” parameter (here: 26864).
Note At a given time, only one S7 CPU can establish a connection to the SCALANCE
M router and send the SMS message.
If multiple CPUs attempt to establish a connection to the SCALANCE M router at
a given time, the escalation block is terminated with error 16#000180A1 (The
specified connection or the port is already being used) (see Library Description,
Chapter 3.3 \2\).
No. Action
4. Enter
a. a unique name for the relay connection,
b. the recipient’s IP address (IP address of the S7 CPU),
c. the port number.
Note:
The connection name is entered in the command SMS message on the cellular
device:
RLY Connection Name smsText In this way, you define to which recipient
(CPU) the message will be relayed.
In this example, the connection name is additionally used to assign the
received acknowledgment.
The port number must match the port address entered in the “localPort”
“EscalationParamDB.smsRcvParam” parameter (here: 26860).
Siemens AG 2016 All rights reserved
5. Enter the user name to check the reception of the message. The user name is
entered in the frame.
No. Action
8. Repeat steps 3-7 for each service employee from whom an acknowledgment is
expected.
Note:
Each service employee is assigned a connection name for assigning the received
acknowledgment.
Siemens AG 2016 All rights reserved
Note For a more detailed description of how to configure the SCALANCE M874/M876
router using Web Based Management, please refer to the device manual (see
\3\).
NOTICE Before you switch on the power supply, complete and check the
installation!
Engineering station
Siemens AG 2016 All rights reserved
192.168.0.100
24 V
192.168.0.2 192.168.0.3
Industrial Ethernet
24 V
S7-1200
SCALANCE
M874/ M876
Table 5-1
No. Action
1. Insert your SIM card into the SCALANCE M router.
2. Attach the individual modules to a suitable rack.
3. Connect the CPU to the SCALANCE M router.
4. Connect the antenna to the SCALANCE M router.
5. Connect the engineering PG to the PROFINET interface of the S7 CPU.
No. Action
6. Connect the CPU 1217C and the SCALANCE M router to a 24 V DC power source.
7. Connect the DC power source to the power grid (220 / 230 V AC).
5.4 Startup
5.4.1 Setting the IP addresses
The following table shows the network settings to which you have to change the
engineering station.
Table 5-4
No. Action
1. Open the Internet Protocol (TCP/IP) Properties:
For a connection to be established between the device and the S7 CPU, both
devices must be in the same LAN.
Table 5-5
No. Action
1. Open the router’s WBM page.
Note:
In the address bar of the web browser, enter the IP address or the URL of the
device. By factory default, the SCALANCE M router can be reached at the following
IPv4 address:
IP address: 192.168.1.1
Subnet mask: 255.255.255.0
No. Action
2. Enter the user name “admin” and the associated password.
Click the “Login” button or confirm your entries with “Enter”.
Note:
When you log in for the first time or after “Restore Factory Defaults and Restart”,
enter the default password, “admin”.
3. In the “Layer 3 > Subnets > Configuration” tab, configure the subnet for the
interface.
Siemens AG 2016 All rights reserved
Requirements
A connection has been established between your engineering station and the
CPU (for example, via the PROFINET interface).
The CPU must be in a mode that allows downloading.
Before downloading the user program, a general reset of the CPU should be
performed to ensure that no “old” blocks are on the CPU.
Table 5-6
No. Action
1. Unzip the “54361177_SMS_SCALANCE_M_PROJ_V10.zip” project.
2. Open the STEP 7 V13 project, “SMS_SCALANCE_M.ap13”.
3. Select the “S7-1200” or “S7-1500” station.
Siemens AG 2016 All rights reserved
Main menu
Siemens AG 2016 All rights reserved
3. Open the “S7-1200” screen and enter the number of employees, “Users”, to whom
the SMS message is sent.
No. Action
4. Fill the list of employees with the required data:
Employee name
Phone number
Connection name
On the router’s WBM page, each employee was assigned a connection name.
Note:
The number of employees you have to enter in the list depends on the number of
employees, “Users”.
5. Enter the “Alarm101” SMS message.
Siemens AG 2016 All rights reserved
No. Action
7. The SMS message was sent to the first employee.
The station waits for an acknowledgment.
8. The SMS message was sent to the second employee, because no acknowledgment
was received within the time (1 min).
9. From your mobile device with the phone number of the second employee, send a
command SMS message in the following format:
RLY connection2 Alarm101
Siemens AG 2016 All rights reserved
Note:
The alarm SMS message (“Alarm101”) and the acknowledgment SMS message
(“Alarm101”) must match.
10. The station receives the
acknowledgment from the second
employee, saves the employee’s data
and terminates the process.
3. Open the “S7-1200” screen and enter the number of employees, “Users”, to whom
the SMS message is sent.
No. Action
4. Fill the list of employees with the required data:
Employee name
Phone number
Connection name
On the router’s WBM page, each employee was assigned a connection name.
Note:
The number of employees you have to enter in the list depends on the number of
employees, “Users”.
5. Enter the “Alarm101” SMS message.
Siemens AG 2016 All rights reserved
No. Action
7. The SMS message was sent to the first employee.
The station waits for an acknowledgment.
8. The SMS message was sent to the second employee, because no acknowledgment
was received within the time (1 min).
8 History
Table 8-1
Version Date Modifications
V1.0 06/2016 First version
Siemens AG 2016 All rights reserved