gsmSendSMS (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This function sends an SMS message by using the GSM module. It will return status of the send command (see below).

The number can contain "-" and " " (dash and space) as part of the number to send the message to.

 

Please note that you should always check the return value from this function. There are a number of reasons why this function could fail such as too much traffic on the GSM network etc., so always check the return value, and based on that it is possible to make a strategy for resending a message.

 

This function can also send GSM network SMS messages during an active mobile network session. The mobile network session will simply be suspended during the transmission of the SMS message and automatically be resumed after the operation has ended.

 

Input:

phonenumber : STRING (max length is 20, excluding " " and "-")

Number to send the SMS message to (if "9999" is used, the message will be sent to a connected PC - either through a cable connection or via an active data connection).

 

If the number is prefixed with an "@", the message is sent through the RTCU Communication Hub to the specified node number after the "@" character

(only supported on network-enabled devices).

 

In case the device is not connected to the GSM network, the return value will be 1.

 

message : STRING

The actual message to send (maximum of 160 characters).

 

Returns: INT

 

For GSM SMS messages:

0

If successful.

1

If general error.

2

If CMS/CME error (error on GSM net).

3

If not connected to a base station.

4

If GSM module is not powered on (see gsmPower()).

5

If GSM module is busy with a data call.

 

For RTCU Communication Hub VSMS messages:

0

If successful.

1

If the receiver is not connected to the GW.

2

If timeout delivering message to the receiver.

3

If not connected to a GW.

5

If the message was rejected by the receiver.

 

Declaration:

FUNCTION gsmSendSMS : INT;
VAR_INPUT
  phonenumber : STRING;
  message     : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
 
BEGIN
  ...
  // Note: we are NOT checking the return code from the gsmSendSMS function in this example
  gsmSendSMS(phonenumber := "+44 12 34 56 789", message := "This is a test message sent using SMS");
  ...
END;
 
END_PROGRAM;