This file contains data structures and prototypes definitions for high level SMS APIs.
SMS is a common way to communicate in the M2M world.
It's an easy, fast way to send a small amount of data (e.g., sensor values for gas telemetry). Usually, the radio module requests small power resources to send or receive a message. It's often a good way to wake-up a device that was disconnected from the network or that was operating in low power mode.
All the functions of this API are provided by the modemService.
Here's a code sample binding to modem services:
bindings: { clientExe.clientComponent.le_sms -> modemService.le_sms }
There are 3 kinds of supported messages: text messages, binary messages, and PDU messages.
You must create a Message object by calling le_sms_Create()
before using the message APIs. It automatically allocates needed resources for the Message object, which is referenced by le_sms_MsgRef_t
type.
When the Message object is no longer needed, call le_sms_Delete()
to free all allocated resources associated with the object.
To delete a Message object, call le_sms_Delete(). This frees all the resources allocated for the Message object. If several users own the Message object (e.g., several handler functions registered for SMS message reception), the Message object will be deleted only after the last user deletes the Message object.
To send a message, create an le_sms_MsgRef_t
object by calling the le_sms_Create()
function. Then, set all the needed parameters for the message:
After the Msg object is ready, call le_sms_Send()
.
le_sms_Send()
is a blocking function, it will return once the Modem has given back a positive or negative answer to the sending operation. The return of le_sms_Send()
API provides definitive status of the sending operation.
When a message sending has failed and returned LE_FAULT, call le_sms_GetErrorCode() to retrieve the 3GPP message error code or le_sms_Get3GPP2ErrorCode() to retrieve the 3GPP2 message error code. If LE_SMS_ERROR_3GPP_PLATFORM_SPECIFIC or LE_SMS_ERROR_3GPP2_PLATFORM_SPECIFIC values is returned, call le_sms_GetPlatformSpecificErrorCode() to retrieve the platform specific error code.
Please refer to Sample code for Mobile Originated SMS message page to get an example of SMS message sending.
To send an asynchronous message, le_sms_SendAsync() API can be called instead of le_sms_Send() and a specific timeout value can be used with le_sms_SetTimeout() API.
A text message can be sent with one simple function: le_sms_SendText(). You only have to pass the three following parameters:
A PDU message can be sent using the le_sms_SendPdu() functions. The parameters to give are:
When a message sending has failed, call le_sms_GetErrorCode() to retrieve the 3GPP message error code or le_sms_Get3GPP2ErrorCode() to retrieve the 3GPP2 message error code. If LE_SMS_ERROR_3GPP_PLATFORM_SPECIFIC or LE_SMS_ERROR_3GPP2_PLATFORM_SPECIFIC values is returned, call le_sms_GetPlatformSpecificErrorCode() to retrieve the platform specific error code.
Message object is never deleted regardless of the sending result. Caller has to delete it.
To receive SMS messages, register a handler function to obtain incoming messages. Use le_sms_AddRxMessageHandler()
to register that handler.
The handler must satisfy the following prototype: typedef
void (*le_sms_RxMessageHandlerFunc_t)(le_sms_MsgRef_t msg).
When a new incoming message is received, a Message object is automatically created and the handler is called. This Message object is Read-Only, any calls of a le_sms_SetXXX API will return a LE_NOT_PERMITTED error.
Use the following APIs to retrieve message information and data from the Message object:
If a succession of messages is received, a new Message object is created for each, and the handler is called for each new message.
Uninstall the handler function by calling le_sms_RemoveRxMessageHandler()
.
le_sms_RemoveRxMessageHandler()
API does not delete the Message Object. The caller has to delete it.Please refer to Sample code for Mobile Terminated SMS message page to get an example of SMS message reception handling.
Call le_sms_CreateRxMsgList()
to create a List object that lists the received messages present in the storage area, which is referenced by le_sms_MsgListRef_t
type.
If messages are not present, the le_sms_CreateRxMsgList() returns NULL.
Once the list is available, call le_sms_GetFirst()
to get the first message from the list, and then call le_sms_GetNext()
API to get the next message.
Call le_sms_DeleteList()
to free all allocated resources associated with the List object.
Call le_sms_GetStatus()
to read the status of a message (Received Read, Received Unread).
To finish, you can also modify the received status of a message with le_sms_MarkRead()
and le_sms_MarkUnread()
.
le_sms_DeleteFromStorage()
deletes the message from the storage area. Message is identified with le_sms_MsgRef_t
object. The API returns an error if the message is not found in the storage area.
The Cell Broadcast service permits a number of unacknowledged general messages to be broadcast to all receivers within a particular region. Cell Broadcast messages are broadcast to defined geographical areas known as cell broadcast areas. These areas may comprise of one or more cells, or may comprise the entire PLMN.
GSM or UMTS SMS cell broadcast service can be activated or deactivated with le_sms_ActivateCellBroadcast() and le_sms_DeactivateCellBroadcast() APIs.
CDMA cell broadcast service can be activated or deactivated with le_sms_ActivateCdmaCellBroadcast() and le_sms_DeactivateCdmaCellBroadcast() APIs.
Cell broadcast message receptions are notify by the SMS handler like a SMS message reception, but there are neither stored in SIM nor in the modem. So le_sms_DeleteFromStorage() can't be used but the message reference shall be delete with le_sms_Delete().
A sample code that implements a function for SMS Cell Broadcast reception can be found in smsCBTest.c file (please refer to Sample code for SMS Cell Broadcast reception page).
Serial Number
Cell Broadcast Serial Number parameter is a 16-bit integer which identifies a particular CBS message from the source and type indicated by the Message Identifier and is altered every time the CBS message with a given Message Identifier is changed.
The two bytes of the Serial Number field are divided into a 2-bit Geographical Scope (GS) indicator, a 10-bit Message Code and a 4-bit Update Number as shown below:
Serial Number fields meaning are defined in the 3GPP 23.041 (9.4.1.2.1 Serial Number).
Message Identifier
Message Identifier parameter identifies the source and type of the CBS message. For example, "Automotive Association" (= source), "Traffic Reports" (= type) could correspond to one value. A number of CBS messages may originate from the same source and/or be of the same type. These will be distinguished by the Serial Number.
Message identifier meaning ranges are defined in the 3GPP 23.041 (9.4.1.2.2 Message Identifier).
GSM or UMTS Cell broadcast Message identifiers range can be added or removed with le_sms_AddCellBroadcastIds() and le_sms_RemoveCellBroadcastIds() APIs. All Message identifiers can be removed with le_sms_ClearCellBroadcastIds() API.
CDMA Cell broadcast Service categories can be added or removed with le_sms_AddCdmaCellBroadcastServices() and le_sms_RemoveCdmaCellBroadcastServices() APIs. All Service categories can be removed with le_sms_ClearCdmaCellBroadcastServices() API.
Modem SMS Center Address can be set or get with le_sms_SetSmsCenterAddress() and le_sms_GetSmsCenterAddress() functions
A sample code that implements a function for Mobile Originated SMS message can be found in smsMO.c file (please refer to Sample code for Mobile Originated SMS message page).
A sample code that implements a function for Mobile Terminated SMS message can be found in smsMT.c file (please refer to Sample code for Mobile Terminated SMS message page).
These two samples can be easily compiled and run into the sms app, to install and use this app:
$ make ar7 $ bin/instapp build/ar7/bin/samples/sms.ar7 <ipaddress>
where ipaddress is the address of your target device.
Then on your target, just run:
$ app start sms
The sample replies to the sender by the message "Message from <phone number> received". Where "phone number" is the sender's phone number.
Sample code for that application can be seen in the following pages:
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.