Modem information

The modem information library can be used by an LTE application to obtain specific data from a modem. It issues AT commands to retrieve the following data:

  • Signal strength indication (RSRP)
  • Current LTE band
  • Current mode
  • Current operator
  • The cell ID of the device
  • The IP address of the device
  • UICC state
  • The battery voltage, measured by the modem
  • The temperature level, measured by the modem
  • The modem firmware version

The modem information library uses the AT command parser.

Call modem_info_init() to initialize the library. To obtain a data value, call modem_info_string_get() (to retrieve the value as a string) or modem_info_short_get() (to retrieve the value as a short). You can also retrieve all available data as a single JSON string by calling modem_info_json_string_get().

Note, however, that signal strength data (RSRP) is only available by registering a subscription. To do so, call modem_info_rsrp_register().

API documentation

group modem_info

Defines

MODEM_INFO_MAX_RESPONSE_SIZE

Largest expected parameter response size.

MODEM_INFO_JSON_STRING_SIZE

Size of the JSON string.

MODEM_INFO_RSRP_OFFSET_VAL

RSRP offset value.

Typedefs

typedef void (*rsrp_cb_t)(char rsrp_value)

RSRP event handler function protoype.

Enums

enum modem_info

LTE link information data.

Values:

MODEM_INFO_RSRP

Signal strength.

MODEM_INFO_BAND

Current LTE band.

MODEM_INFO_MODE

Current mode.

MODEM_INFO_OPERATOR

Current operator name.

MODEM_INFO_CELLID

Cell ID of the device.

MODEM_INFO_IP_ADDRESS

IP address of the device.

MODEM_INFO_UICC

UICC state.

MODEM_INFO_BATTERY

Battery voltage.

MODEM_INFO_TEMP

Temperature level.

MODEM_INFO_FW_VERSION

Modem firmware version.

MODEM_INFO_ICCID

SIM ICCID

MODEM_INFO_COUNT

Number of legal elements in the enum.

Functions

int modem_info_init(void)

Initialize the link information driver.

Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

int modem_info_rsrp_register(rsrp_cb_t cb)

Initialize the subscription of RSRP values.

Parameters
  • cb: Callback function.
Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

int modem_info_string_get(enum modem_info info, char *buf)

Request the current modem status of any predefined information value as a string.

If the data parameter returned by the modem is originally a short, it is still returned as a string.

Return
Length of received data if the operation was successful. Otherwise, a (negative) error code is returned.
Parameters
  • info: The requested information type.
  • buf: The string where to store the information.

int modem_info_short_get(enum modem_info info, u16_t *buf)

Request the current modem status of any predefined information value as a short.

If the data parameter returned by the modem is originally a string, this function fails.

Return
Length of received data if the operation was successful. Otherwise, a (negative) error code is returned.
Parameters
  • info: The requested information type.
  • buf: The short where to store the information.

int modem_info_name_get(enum modem_info info, char *name)

Function for requesting the name of a modem information data type.

Return
Length of received data if the operation was successful. Otherwise, a (negative) error code is returned.
Parameters
  • info: The requested information type.
  • buf: The string where to store the name.

enum at_param_type modem_info_type_get(enum modem_info info)

Function for requesting the data type of the current modem information type.

Return
The data type of the requested modem information data.
Parameters
  • info: The requested information type.

int modem_info_json_string_get(char *buf)

Function for requesting the current device status.

The data is added to the string buffer with JSON formatting.

Return
Length of the string buffer data if the operation was successful. Otherwise, a (negative) error code is returned.
Parameters
  • buf: The string where to store the data.