SMS subscriber

The current modem firmware allows only one SMS client. The SMS subscriber module acts as a unique and global client in the system that can dispatch SMS notifications to many subscribers, which makes it possible for more than one module to receive SMS messages.

The module provides functions to register and unregister SMS listeners, which are the modules that need to send or receive SMS messages. Each listener is identified by a unique handle and receives the SMS data and metadata through a callback function.

SMS listeners can be registered or unregistered at run time. The SMS data payload is given as raw data. It is up to the listener to parse and process it.

The SMS module uses AT commands to register as SMS client. SMS notifications are received using AT commands, but those are not visible for the users of this module. The module automatically acknowledges received SMS messages on behalf of each listener.

The module does not use a dedicated socket. It uses the shared AT socket that is provided by the AT command notifications module.

Configuration

Configure the following parameters when using this library:

Limitations

Only one SMS client can be registered in the system. If there already is an SMS client registered in the system (using AT commands, for example), the initialization of this module fails and an error is returned.

API documentation

Header file: include/modem/sms.h
Source file: lib/sms/sms.c
group sms

Public APIs of the SMS subscriber manager module.

Typedefs

typedef void (*sms_callback_t)(struct sms_data *const data, void *context)

SMS listener callback function.

Functions

int sms_init(void)

Initialize the SMS subscriber module.

Return

Zero on success, or a negative error code. The EBUSY error indicates that one SMS client has already been registered.

int sms_register_listener(sms_callback_t listener, void *context)

Register a new listener.

A listener is identified by a unique handle value. This handle should be used to unregister the listener. A listener can be registered multiple times with the same or a different context.

Return

Handle identifying the listener, or a negative value if an error occurred.

Parameters
  • listener: Callback function. Cannot be null.

  • context: User context. Can be null if not used.

Return Value
  • -EINVAL: Invalid parameter.

  • -ENOMEM: No memory to register new observers.

void sms_unregister_listener(int handle)

Unregister a listener.

Parameters
  • handle: Handle identifying the listener to unregister.

void sms_uninit(void)

Uninitialize the SMS subscriber module.

struct sms_data
#include <sms.h>

SMS PDU data.