sendSMS()

The sendSMS() function sends an SMS message to a user-defined phone number. The message can be 128 characters long. The function also handles possible errors. Note that if you want to use the control function, the runtime script sms.ctl has to run in the console.

Synopsis

sendSMS ( string number, string message, int &error, string &sErrorText, string SMSDP="_SMS_1");

Parameters

Parameter Meaning
number The phone number of the recipient
message The message
&error

Error (reference parameter)

Value 0=OK

The possible error codes are listed below:

-1: v24 Error (error when connecting to the device)

-2 : Timeout: No response from SMS-driver!

-3 : Only one send request!

-4 : Cannot send empty SMS!

-5 : Wrong telephone number!

100 : Wrong PIN-Code

101 : Wrong SMSC

102 : PDU Mode not supported

103 : Deleting SMS not possible

104 : No quality information available

105 : Reading SMS not possible

106 : Sending SMS not possible

111 : Memory mapping not supported

200 : No SMS

&sErrorText Error text (reference parameter).
SMSDP = "_SMS_1" SMS data point. The default value is the _SMS_1 data point

Return value

None

Description

The sendSMS() function sends an SMS message to a user-defined phone number. The message can be 128 characters long.

Example

The example sends an SMS message and handles possible errors.

main()
{
  string number, message, sErrorText, SMSDP;
  int error;
  number ="436767890026";
  message ="This is a test, sending SMS messages";
  sendSMS(number, message, error, sErrorText, SMSDP =
  "_SMS_1");
  if (error == 0) // If the return value equals 0, the reading
  was
  // executed successfully.
  {
    DebugN("The SMS message: "+message+"; was sent successfully to
    the
    number: "+number);
  }
  else
  {
    DebugN(error, sErrorText);
  }
}

Assignment

Communication functions

Availability

CTRL