ADVANCED: gsmSendPDU (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This function sends an SMS message through the GSM network. It will return the 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.

Unlike the gsmSendSMS function, which can only send simple text messages, the gsmSendPDU can send binary messages.

 
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 : PTR

The address of the message to send.

 

length : INT

Length of message to send in bytes (maximum of 140 bytes).

 

dcs : SINT

Data Coding Scheme to use, typically 16#F5. Please consult the appropriate documentation for this field.

 

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 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 gsmSendPDU : INT;
VAR_INPUT
  phonenumber : STRING;
  message     : PTR;
  length     : INT;
  dcs         : SINT := -11; // Equals 16#F5
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  PDUBuffer : ARRAY[0..31] OF SINT;
END_VAR;
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
 
BEGIN
  ...
  // Note: we are NOT checking the return code from the gsmSendPDU function in this example
  gsmSendPDU(phonenumber := "+44 12 34 56 789", message := ADDR(PDUBuffer), length:=10, dcs:=SINT(16#F5));
  ...
END;
 
END_PROGRAM;