To send or receive SMS Messages, you must first Configure a ModemConfigure a Modem.
Click Modems in the Solution Explorer.
Click Add Modem.
Click the fields to edit Modem parameters Modem Name, Type, and Signal Quality Refresh rate fields.
Assign a Communication Channel.
The parameter Port defines the communication channel between controller and modem. You can select a channel that is physically located on a communication module, or the Panel USB Port.
To enable the modem to accept incoming SMS messages and add them to the SMS Received Queue, you must check the Receive SMS option.
To filter the phone numbers from which incoming message may be received, click Authorized Numbers and add permissible phone numbers to the list.
Checking SMS Received adds the message to the queue. However, the only way for the controller to receive the message is via the Receive SMS ladder function |
When you add the modem, the program creates a struct that you can use in your program.
Name |
Data Type |
Definition |
|
Success |
Bit |
ON=Modem Initialized Successfully |
|
Fail |
Bit |
ON=Modem Initialization Failed |
|
Status |
UINT32 |
Code Message 0 = No Errors 1 = Function Started 2 = Function in Progress -1 = General initialization error -2 = Pin code Error -3 = Baud Rate Error -4 = Signal Quality Error -5 = Router name error -6 = Save router parameter error -7 = Modem GPRS error -9 = Router General Error -10 = Router signal quality error -11 = Router session ID error -12 = Router network type error -13 = Router GPS error -14 = Router mobile traffic error -17 = Router Model Name error -99 = Modem/Router not connected -100 = Modem/Router powered off |
|
Signal Quality |
UINT8 |
Written here by the controller |
|
Modem Name |
ASCII |
Entered by user when defining the modem. |
|
PIN Code |
ASCII |
Entered by user when defining the modem. |
|
GPRS APN |
ASCII |
Entered by user when defining the modem. |
|
GPRS User |
ASCII |
Entered by user when defining the modem. |
|
GPRS Password |
ASCII |
Entered by user when defining the modem. |
|
GPRS IP |
ASCII |
Entered by user when defining the modem. |
|
SMS Received Queue |
UINT8
|
This is the number of SMS messages that are in the modem queue, that have not been transferrer to the controller. |
First, you must create the messages, and then send them in your program.
SMS message can contain both fixed text and variables.
Note |
The length of the SMS message is limited by whether you have enabled non-English SMS characters in the Send SMS Ladder Element
|
Select SMS Messages in the Solution Explorer.
Click the Add New SMS button.
Click the SMS message to open it up and define it.
From the Toolbox, select elements to add to the message, and configure these elements via the Properties Window.
Add phone numbers by clicking the Message header icon to open the properties window, and then click Phone Numbers Collection.
Click Add New Phone Number, and link a String-ASCII data tag.
SMS Message Struct
When you create an SMS message, UniLogic automatically creates a supporting struct.
Name |
Data Type |
Definition |
|
Send:Success |
Bit |
ON=Sent Successfully |
|
Send: Fail |
Bit |
ON=Send Failed |
|
Status
|
UINT32
|
Error |
SMS Send Status Message |
0 |
No errors |
||
1 |
Function start |
||
2 |
Function in Progress |
||
-1 |
Modem only: General COM error. Please check the physical connections. |
||
-2 |
Modem only: Sent message error |
||
-3 |
Modem only: Telephone number format error Note that the number cannot contain spaces. |
||
-4
|
Modem only: Parse Message error. This may result because: - The elements in the message may contain a 'null' character - Message length exceed the maximum limit,150 for English-only, 70 for non-English characters. |
||
-5 |
SMS Last Error |
||
-6 |
Router only: Incorrect Username or Password to Router's SMS module |
||
-7 |
Router only: General Error. Resend message; if error persists, check the Router authorizations. |
Place a COM>: SMS &
email> Initialize Modem function in the Ladder.
In order to ensure that the modem will be initialized at power-up,
place it after a direct contact.
Place a Send SMS ladder element after your desired logic send conditions.
In the Send SMS element:
Click parameter A to open the list of SMS messages and select one
Click parameter B and select the modem that will send the SMS.
If you are using a non-English characters in your SMS message, change parameter C to #1, otherwise leave it as default.
In your Modem Configuration:
In your Ladder:
Check that there are messages in the SMS Received Queue
Provide a method for storing the message in a buffer, and then parsing the message. You can do this, for example, by defining a message in the Message Composer that matches the SMS structure, or via C function
Place a COM>: SMS & email> Initialize Modem function in the Ladder.
In order to ensure that the modem will be initialized at power-up, place it after a direct contact.
Check that there are messages in the SMS Received Queue.
Place a Receive SMS ladder element after your desired logic send conditions.
You can parse your received message via the Third-party Protocol function, Parse.
If you are connected to the Internet, click to view the video Sending SMS Messages