readSMS()

The readSMS() function reads a SMS message with the phone number of the sender and the time when the message has been sent. Possible errors will be read as well. If you want to use the control function, the runtime script sms.ctl has to run in the console.

Synopsis

readSMS( string &number, string &message, time &t, int &error, string &sErrorText, string SMSDP = "_SMS_1");

Parameters

Parameter Meaning
&number The phone number of the sender (reference parameter)
&message The message (reference parameter)
&t The time the received SMS message was sent (reference parameter)
&error

Error (reference parameter)

See sendSMS() for possible error codes.

&sErrorText

Error Text (reference parameter)

See the chapter sendSMS() for possible error texts.

SMSDP = "_SMS_1" SMS data point. The default value is _SMS_1.

Return value

None

Description

The readSMS() function reads an SMS message with the phone number of the sender and the time when the message was sent. The values (number of the sender, the message, time and possible errors) are read as reference parameters.

The function readSMS() can read multipart SMS with more than 160 characters.

Example

The example reads an SMS message (with the time, the message was sent):

main()
{
  string number, message, sErrorText, SMSDP;
  time t;
  int error;
  readSMS(number, message, t, error, sErrorText, SMSDP =
  "_SMS_1");
  if (error == 0) // If the return value equals 0, the reading
  was
  // executed successfully.
  {
    DebugN(number, message, t);
  }
  else
  {
    DebugN(sErrorText);
  }
}

Assignment

Communication functions

Availability

CTRL