SMS Messaging with SCALANCE M874/876
SMS Messaging with SCALANCE M874/876
Receiving SMS
Messages via a
SCALANCE M Router
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They are
non-binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2019 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with Industrial Security functions that support the secure
operation of plants, systems, machines and networks.
In order 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.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
Table of contents
Legal information ......................................................................................................... 2
1 Library Overview ................................................................................................ 4
1.1 General information .............................................................................. 5
1.2 Functions .............................................................................................. 6
1.3 Hardware and software requirements .................................................. 8
2 SCALANCE M874/M876 Configuration ............................................................ 9
2.1 Entering the SMS service center .......................................................... 9
2.2 Configuring the access details for the cellular network ...................... 10
2.3 Configuring SMS Relay (Outgoing) .................................................... 12
2.4 Configuring SMS Relay (Incoming) .................................................... 13
3 Function Blocks of the "LSmsSR" Library ................................................... 15
3.1 The "LSmsSR_SndSms" library block ............................................... 15
3.1.1 Call and parameter interface .............................................................. 15
3.1.2 Format of an SMS message to the SCALANCE M router ................. 16
3.1.3 Description of the "Send SMS message" function ............................. 18
3.1.4 UDT1 "LSmsSR_typeSmsSnd" .......................................................... 19
3.2 The "LSmsSR_RcvSms" library block ................................................ 21
3.2.1 Call and parameter interface .............................................................. 21
3.2.2 Format of an SMS message to the SCALANCE M router ................. 22
3.2.3 Description of the "Receive SMS message" function ........................ 24
© Siemens AG 2019 All rights reserved
1 Library Overview
This document describes the "LSmsSR" block library for sending and receiving an
SMS message to/ from SIMATIC S7-300/ S7-400 und IM151-8 PN CPUs using the
SCALANCE M874/M876 router.
The block library provides you with tested code with clearly defined interfaces.
They can be used as a basis for the task you want to implement.
Furthermore, this documentation shows possible fields of application and helps you
integrate the library into your STEP 7 project using step-by-step instructions
"LSmsSR“
Library
Cellular network
© Siemens AG 2019 All rights reserved
1.2 Functions
Overview
The "LSmsSR_SndSms" and "LSmsSR_RcvSms" function blocks of the "LSmsSR"
library are required for data exchange between S7-CPUs and the SCALANCE
M874/M876 router.
S7 CPU 1
Connection1
IP address of S7 CPU 1 RcvSms Message
Connection2
IP address of S7 CPU 2
S7 CPU 2
.
.
TCP/IP connection
ConnectionN
IP address of S7 CPU N
© Siemens AG 2019 All rights reserved
NOTE If a connection between the SCALANCE M router and the S7-CPU cannot be
established, all SMS messages received by the router will be deleted.
Hardware
Table 1-1
Component Article number Number Note
SCALANCE M874-3 6GK5874-3AA00-2AA2 1 Alternatively, you can use
any variants of the
SCALANCE M874 and M876
series.
SIMATIC S7-300 6ES7315-2EH14-0AB0 1 Any S7-300 PN-CPU can
CPU 315-2 PN/DP be used.
SIM card 1
Software
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\).
contract.
Figure 2-1
Note The SMSC number is only required for sending SMS messages. If you only want
to receive SMS messages, this number is irrelevant.
Note:
When you log in for the first time or after "Restore Factory Defaults and
Restart", enter
– the default name "admin"
– the default password "admin".
The password needs to be changed after the first logon or after a "Restore
Factory Defaults and Restart".
3. Click the "Login" button or confirm your entries with "Enter".
4. In the "SIM" tab of the WBM page of the SCALANCE M874/M876, enable the
mobile network interface, "Interfaces > Mobile > SIM".
Figure 2-3
Note:
The PIN can be obtained from your mobile service provider.
6. Open the "Operator” tab: "Interfaces > Mobile > Operator". In "APN" enter the
name of the mobile network operator. Check the "Manual APN" check box.
Figure 2-5
© Siemens AG 2019 All rights reserved
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.
NOTE These access parameters can be obtained from your mobile network operator.
4. Enter the user name and password that must be included before the text is
sent by SMS.
© Siemens AG 2019 All rights reserved
Note:
The user and password must match the values entered in the "username" and
"password" "LSmsSR_typeSmsSnd"- parameters.
5. Enter the port on which the SCALANCE M receives the SMS message.
Figure 2-7
Note:
This port number must match the port address entered in the "remotePort"
"LSmsSR_typeSmsSnd"- 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
(Chapter 3.3).
+4917123456789
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.
– The port number must match the port address entered in the "localPort"
"LSmsSR_typeRcvSnd"- parameter (here: 26864).
6. Enter the username to check the reception of the message. The username is
entered in the frame.
Figure 2-10
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\).
The following figure shows the call interface of the "LSmsSR_SndSms" library
block.
Figure 3-1
© Siemens AG 2019 All rights reserved
Table 3-1
Name Data type Description
sndSms Bool Starts the send process.
Input
with an error.
error Bool Provides feedback if an error occurs while
executing a routine.
Only valid for one cycle.
Default value: FALSE
status Dword When error = TRUE: Returns the status to
narrow down the cause of the error (see
Chapter 3.3).
Only valid for one cycle.
Username#Password#CommandCode#Seq-Num;Phone number;smsText:
1. Username
User name to check the send permission of an SMS message.
Maximum of 10 characters.
Note:
This user name must match the user name entered in WBM.
Figure 3-2
2. Password
Password associated with the user name.
Maximum of 10 characters.
Note:
This password must match the password entered in WBM.
Figure 3-3
3. CommandCode
Command for sending SMS messages from the local network. The default
value "105" must not be changed.
4. Seq-Num
The sequence number is used to assign multiple requests at the same time.
The function is currently not supported.
5. Phone number
© Siemens AG 2019 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\).
smsSnd Establish
active
connection
error
Connected
yes
Sms Generate
Param SMS msg
© Siemens AG 2019 All rights reserved
Send
SMS msg
error
Sent
yes
Terminate Error
active
connection
error
Connection
terminated
yes
End
1. ipAddress
IP address of the partner (SCALANCE M).
2. deviceId
Local_device_id (see \4\) of the S7-CPU.
3. remotePort
© Siemens AG 2019 All rights reserved
4. Usename
User name to check the send permission of an SMS message.
Note:
This user name must match the user name entered in WBM (SMS Relay
Outgoing).
Figure 3-7
5. Password
Password associated with the user name.
Note:
This password must match the password entered in WBM (SMS Relay
Outgoing).
Figure 3-8
© Siemens AG 2019 All rights reserved
6. telNo
SMS message recipient’s phone number.
7. smsText
SMS message text
The following figure and table show the call interface of the "LSmsSR_RcvSms"
library block.
Figure 3-9
Table 3-2
Name Data type Description
© Siemens AG 2019 All rights reserved
messages.
FALSE:
Deactivates the reception of SMS
messages.
smsParam "LSmsSR_typeSmsRcv" Parameters required for receiving an
PLC data type SMS message (see Chapter 3.2.4).
InOut
The router receives an SMS message from a cellular device in the following format:
The message is sent to the S7-CPU in a frame via the TCP/IP connection with this
connection name in the following format:
Username#Password#CommandCode#Seq-Num;Phone number;smsText:
1. Username
User name to check the reception of the message.
© Siemens AG 2019 All rights reserved
Maximum of 10 characters.
Figure 3-10
2. Password
Password associated with the user name.
Maximum of 10 characters.
Figure 3-11
3. CommandCode
4. Command for receiving SMS messages from the local network. The default
value "105" must not be changed.
5. Seq-Num
The sequence number is used to assign multiple requests at the same time.
The function is currently not supported.
6. Connection Name
SMS message recipient’s connection name with a maximum of 40 characters.
7. Phone number
SMS message sender’s phone number.
8. smsText
SMS message text with a maximum of 160 characters.
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\).
© Siemens AG 2019 All rights reserved
Applications can also receive SMS messages via the router’s Ethernet interface.
To do this, the router must establish a TCP/IP connection to the application on the
Ethernet interface. The router receives a command SMS message
(RLY Connection Name smsText) and sends the received message (see Chapter
3.2.2) to the application. For TCP/IP communication, the "LSmsSR_RcvSms"
library block internally uses the "TCON", "TRCV" function blocks.
Figure 3-12
activateRcvSms Configure
passive
=True connection
SCALANCE M874/M876
establishes the connection
when an SMS message is
received.
Establish
connection
© Siemens AG 2019 All rights reserved
yes
error
Connected
yes Error
error
SMS msg
received
Terminate
connection
SCALANCE M874/M876
terminates the connection
when the SMS message
has been entered in the
Sms Extract CPU.
Param SMS msg
End
3. rcvTelNo
SMS message sender’s phone number.
4. rcvMessage
SMS message text received.
"LSmsSR_SndSms" errors
Figure 3-15
Status Meaning Remedy / notes
16#0001xyzx "TCON" error message (active) For a description of the
communication errors, please refer
16#0011xyzx "TSEND" error message
to the STEP 7 Online Help.
16#0111xyzx "TDISCON" error message
16#00008101 Previous job not yet complete.
(You have started a new send
operation, although busy was
still active.)
© Siemens AG 2019 All rights reserved
"LSmsSR_RcvSms" errors
Table 3-3
Status Meaning Remedy / notes
16#0010xyzx "TCON" error message (passive) For a description of the
communication errors, please
16#0110xyzx "TRCV" error message
refer to the STEP 7 Online Help.
1. The library is available on the HTML page from which you downloaded this
document (\2\). Save the "54361177_SMS_SCALANCE_M _LIB_V56_V10.zip"
library to your hard drive.
2. Open the "SIMATIC Manager" and unzip the "54361177_SMS_SCALANCE_M
_LIB_V56_V10.zip" library ("File > Retrieve…").
3. From now on, the library is available under "Libraries".
Figure 4-1
© Siemens AG 2019 All rights reserved
9. In the "Program blocks" folder of your device, open the OB1 organization
block.
10. Use drag and drop to move the "LSmsSR_SndSms" or "LSmsSR_RcvSms"
function block to any network.
11. Enter the name of the instance data block. Generate the instance data block if
it does not exist.
Figure 4-6
Note:
Set within the properties of the Instance-DB the option "Non Retain ".
"Object Properties> General Part2> Non Retain"
12. Assign values to all necessary parameters. Use values from the global data
block DB1 "SmsParam".
© Siemens AG 2019 All rights reserved
Figure 4-7
13. Save the OB1 "organization block" and load the STEP 7 Project.
1. Open "SIMATIC Manager" and compare the current version number of each
element of the library with the latest version from the Industry Online Support
portal.
2. In the Project tree, right-click the blocks of the library. In the context menu,
select the "Object properties" option.
3. In the "Properties" window that is displayed, select the "General – Part 2"
menu.
Figure 4-8
© Siemens AG 2019 All rights reserved
4. If you want to update the library, integrate the latest library as described in
Chapter 4.2.
5. Delete all relevant elements in the "Blocks" folder.
6. Do not delete the function block call in OB1.
7. Add the new elements of the library as described in Chapter 4.2, Steps 1
through 3.
8. In the Project tree, right-click the blocks of the library
Update the elements of the project
"Blocks > Check Block Consistency".
Figure 4-9
5 Appendix
5.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2019 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc