Skip to content

Commit

Permalink
lib: bin: lwm2m_carrier: update to latest version
Browse files Browse the repository at this point in the history
- Update to the latest library (v3.4.0)

Co-authored-by: Divya Pillai <[email protected]>
Co-authored-by: Stig Bjørlykke <[email protected]>
Co-authored-by: Lucas van der Ploeg <[email protected]>
Co-authored-by: Markus Rekdal <[email protected]>
Co-authored-by: Kacper Radoszewski <[email protected]>
Signed-off-by: Håvard Vermeer <[email protected]>
  • Loading branch information
6 people authored and jfischer-no committed Feb 28, 2024
1 parent b86721a commit 503b43b
Show file tree
Hide file tree
Showing 25 changed files with 763 additions and 431 deletions.
3 changes: 3 additions & 0 deletions applications/asset_tracker_v2/overlay-carrier.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Default partition for NVS is unused
CONFIG_PM_PARTITION_SIZE_NVS_STORAGE=0

# DFU target library
CONFIG_DFU_TARGET=y
6 changes: 4 additions & 2 deletions applications/asset_tracker_v2/src/modules/cloud_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,14 @@ static int setup(void)
return err;
}

#if defined(CONFIG_MCUBOOT_IMG_MANAGER)
#if (defined(CONFIG_MCUBOOT_IMG_MANAGER) && !defined(CONFIG_LWM2M_CARRIER))
/* After a successful initializaton, tell the bootloader that the
* current image is confirmed to be working.
* If the LwM2M Carrier library is enabled, allow the library to confirm
* the image.
*/
boot_write_img_confirmed();
#endif /* CONFIG_MCUBOOT_IMG_MANAGER */
#endif /* CONFIG_MCUBOOT_IMG_MANAGER && !CONFIG_LWM2M_CARRIER */

return 0;
}
Expand Down
27 changes: 26 additions & 1 deletion applications/serial_lte_modem/doc/CARRIER_AT_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Syntax

The ``<cmd>`` command is a string, and can be used as follows:

* ``AT#XCARRIER="app_data"[,<data>][,<obj_inst_id>,<res_inst_id>]``
* ``AT#XCARRIER="app_data_set"[,<data>][,<obj_inst_id>,<res_inst_id>]``

Put the value in ``<data>`` into the indicated path.
``<data>`` must be an opaque string in double quotes, unless ``slm_data_mode`` is enabled.
Expand Down Expand Up @@ -174,6 +174,12 @@ The ``<cmd>`` command is a string, and can be used as follows:

Request to reboot the device.

* ``AT#XCARRIER="send",<obj_id>,<obj_inst_id>,<res_id>[,<res_inst_id>]``

Perform a Send operation to send the currently stored data in the indicated resource or resource instance to the server.
This operation is currently only supported for readable opaque resources.
The URI path of the resource or resource instance is indicated as ``/<obj_id>/<obj_inst_id>/<res_id>/<res_inst_id>``.

* ``AT#XCARRIER="time"``

Read the time reported by the device, including the UTC time, the UTC offset and the timezone.
Expand Down Expand Up @@ -268,6 +274,11 @@ Examples
AT#XCARRIER="position","63.43","10.47","48",1708684683,"30.5"
OK

::

AT#XCARRIER="send",19,0,0,0
OK

Read command
------------

Expand Down Expand Up @@ -339,6 +350,13 @@ The ``<cmd>`` command is a string, and can be used as follows:
Two special values may also be used: ``-1`` to always use Confirmable notifications, or ``0`` to use the default interval of 86400 seconds.
For details, see the :kconfig:option:`CONFIG_LWM2M_CARRIER_COAP_CON_INTERVAL` Kconfig option.

* ``AT#XCARRIERCFG="download_timeout"[,<timeout>]``

Configure the time allowed for a single firmware image download before it is aborted.
This configuration is only supported for Push delivery method of firmware images.
``<timeout>`` must be an integer value specified in minutes.
For details, see the :kconfig:option:`CONFIG_LWM2M_CARRIER_FIRMWARE_DOWNLOAD_TIMEOUT` Kconfig option.

* ``AT#XCARRIERCFG="config_enable"[,<0|1>]``

Set flag to apply the stored settings to the general Kconfig options (see the :ref:`general_options_lwm2m` section of the library's documentation).
Expand Down Expand Up @@ -407,6 +425,13 @@ The ``<cmd>`` command is a string, and can be used as follows:

For details, see the :kconfig:option:`CONFIG_LWM2M_CARRIER_PDN_TYPE` Kconfig option.

* ``AT#XCARRIERCFG="queue_mode"[,<0|1>]``

Configure whether the LwM2M carrier library is to inform the server that it may be disconnected for an extended period of time.
This configuration corresponds to the Queue Mode Operation as defined in the OMA LwM2M specification.
This command accepts two possible input parameters: ``0`` to disable or ``1`` to enable.
For details, see the :kconfig:option:`CONFIG_LWM2M_CARRIER_QUEUE_MODE` Kconfig option.

* ``AT#XCARRIERCFG="binding"[,<binding>]``

Configure the binding over which the LwM2M carrier library is to connect to the device management network.
Expand Down
2 changes: 1 addition & 1 deletion applications/serial_lte_modem/doc/slm_data_mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Other examples:
* ``AT#XFTP="mput",<file>``
* ``AT#XMQTTPUB=<topic>,"",<qos>,<retain>``
* ``AT#XNRFCLOUD=2``
* ``AT#XCARRIER="app_data"``
* ``AT#XCARRIER="app_data_set"``

The SLM application sends an *OK* response when it successfully enters data mode.

Expand Down
3 changes: 3 additions & 0 deletions applications/serial_lte_modem/overlay-carrier.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ CONFIG_SLM_CUSTOMER_VERSION="lwm2m_carrier"

# Enable LwM2M carrier settings support
CONFIG_LWM2M_CARRIER_SETTINGS=y

# DFU target library
CONFIG_DFU_TARGET=y
7 changes: 3 additions & 4 deletions applications/serial_lte_modem/src/lwm2m_carrier/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ config SLM_CARRIER
if SLM_CARRIER

config SLM_CARRIER_APP_DATA_BUFFER_LEN
int "Size of the buffer for sending application data"
int "Size of the buffer for setting application data"
default 512
help
Specifies maximum application data size to be sent to the server
through the App Data Container, the Binary App Data Container or
the Event Log objects.
Specifies maximum application data size to be set in the App Data Container,
the Binary App Data Container or the Event Log objects.

endif # SLM_CARRIER
49 changes: 40 additions & 9 deletions applications/serial_lte_modem/src/lwm2m_carrier/slm_at_carrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(slm_carrier, CONFIG_SLM_LOG_LEVEL);
/**@brief LwM2M Carrier operations. */
enum slm_carrier_operation {
/* Carrier AppData Operation */
CARRIER_OP_APPDATA_SEND,
CARRIER_OP_APPDATA_SET,
/* Carrier Device Operation */
CARRIER_OP_DEVICE_BATTERY_LEVEL,
CARRIER_OP_DEVICE_BATTERY_STATUS,
Expand All @@ -45,6 +45,8 @@ enum slm_carrier_operation {
CARRIER_OP_REQUEST_REBOOT,
CARRIER_OP_REQUEST_LINK_DOWN,
CARRIER_OP_REQUEST_LINK_UP,
/* Carrier Send Operation */
CARRIER_OP_SEND,
/* Count */
CARRIER_OP_MAX
};
Expand All @@ -59,7 +61,7 @@ struct carrier_op_list {
static int m_mem_free;

/** forward declaration of cmd handlers **/
static int do_carrier_appdata_send(void);
static int do_carrier_appdata_set(void);
static int do_carrier_device_battery_level(void);
static int do_carrier_device_battery_status(void);
static int do_carrier_device_current(void);
Expand All @@ -79,10 +81,11 @@ static int do_carrier_portfolio(void);
static int do_carrier_request_reboot(void);
static int do_carrier_request_link_down(void);
static int do_carrier_request_link_up(void);
static int do_carrier_send(void);

/**@brief SLM Carrier AT Command list type. */
static struct carrier_op_list op_list[CARRIER_OP_MAX] = {
{CARRIER_OP_APPDATA_SEND, "app_data", do_carrier_appdata_send},
{CARRIER_OP_APPDATA_SET, "app_data_set", do_carrier_appdata_set},
{CARRIER_OP_DEVICE_BATTERY_LEVEL, "battery_level", do_carrier_device_battery_level},
{CARRIER_OP_DEVICE_BATTERY_STATUS, "battery_status", do_carrier_device_battery_status},
{CARRIER_OP_DEVICE_CURRENT, "current", do_carrier_device_current},
Expand All @@ -102,6 +105,7 @@ static struct carrier_op_list op_list[CARRIER_OP_MAX] = {
{CARRIER_OP_REQUEST_REBOOT, "reboot", do_carrier_request_reboot},
{CARRIER_OP_REQUEST_LINK_DOWN, "link_down", do_carrier_request_link_down},
{CARRIER_OP_REQUEST_LINK_UP, "link_up", do_carrier_request_link_up},
{CARRIER_OP_SEND, "send", do_carrier_send},
};

#define SLM_CARRIER_OP_STR_MAX (sizeof("battery_status") + 1)
Expand Down Expand Up @@ -276,7 +280,7 @@ int lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *event)
return err;
}

/* Carrier App Data Send data mode handler */
/* Carrier App Data Set data mode handler */
static int carrier_datamode_callback(uint8_t op, const uint8_t *data, int len, uint8_t flags)
{
int ret = 0;
Expand All @@ -290,7 +294,7 @@ static int carrier_datamode_callback(uint8_t op, const uint8_t *data, int len, u
uint16_t path[3] = { LWM2M_CARRIER_OBJECT_APP_DATA_CONTAINER, 0, 0 };
uint8_t path_len = 3;

ret = lwm2m_carrier_app_data_send(path, path_len, data, len);
ret = lwm2m_carrier_app_data_set(path, path_len, data, len);
LOG_INF("datamode send: %d", ret);
if (ret < 0) {
(void)exit_datamode_handler(ret);
Expand All @@ -302,8 +306,8 @@ static int carrier_datamode_callback(uint8_t op, const uint8_t *data, int len, u
return ret;
}

/* AT#XCARRIER="app_data"[,<data>][,<obj_inst_id>,<res_inst_id>] */
static int do_carrier_appdata_send(void)
/* AT#XCARRIER="app_data_set"[,<data>][,<obj_inst_id>,<res_inst_id>] */
static int do_carrier_appdata_set(void)
{
int ret = 0;

Expand All @@ -327,7 +331,7 @@ static int do_carrier_appdata_send(void)
return ret;
}

ret = lwm2m_carrier_app_data_send(path, path_len, data, size);
ret = lwm2m_carrier_app_data_set(path, path_len, data, size);
} else if (param_count == 4 || param_count == 5) {
uint8_t *data = NULL;
char buffer[CONFIG_SLM_CARRIER_APP_DATA_BUFFER_LEN] = {0};
Expand Down Expand Up @@ -362,7 +366,7 @@ static int do_carrier_appdata_send(void)
data = buffer;
}

ret = lwm2m_carrier_app_data_send(path, path_len, data, size);
ret = lwm2m_carrier_app_data_set(path, path_len, data, size);
}

return ret;
Expand Down Expand Up @@ -853,6 +857,33 @@ static int do_carrier_request_link_up(void)
return lwm2m_carrier_request(LWM2M_CARRIER_REQUEST_LINK_UP);
}

/* AT#XCARRIER="send",<obj_id>,<obj_inst_id>,<res_id>[,<res_inst_id>] */
static int do_carrier_send(void)
{
int ret = 0;

uint32_t param_count = at_params_valid_count_get(&slm_at_param_list);

if (param_count != 5 && param_count != 6) {
LOG_DBG("AT#XCARRIER=\"send\" failed: invalid number of arguments");
return -EINVAL;
}

uint16_t path[4];
uint8_t path_len = 0;

for (int i = 2; i < param_count; i++) {
ret = at_params_unsigned_short_get(&slm_at_param_list, i, &path[i - 2]);
if (ret) {
return ret;
}

++path_len;
}

return lwm2m_carrier_data_send(path, path_len);
}

/**
* @brief API to handle AT#XCARRIER command.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ enum slm_carrier_cfg_operation {
CARRIER_CFG_OP_CONFIG_BOOTSTRAP_FROM_SMARTCARD,
CARRIER_CFG_OP_CONFIG_CARRIERS,
CARRIER_CFG_OP_CONFIG_COAP_CON_INTERVAL,
CARRIER_CFG_OP_CONFIG_FIRMWARE_DOWNLOAD_TIMEOUT,
CARRIER_CFG_OP_CONFIG_LGU_DEVICE_SERIAL_NO_TYPE,
CARRIER_CFG_OP_CONFIG_LGU_SERVICE_CODE,
CARRIER_CFG_OP_CONFIG_PDN_TYPE,
CARRIER_CFG_OP_CONFIG_QUEUE_MODE,
CARRIER_CFG_OP_CONFIG_SESSION_IDLE_TIMEOUT,
/* Device Custom Configuration */
CARRIER_CFG_OP_DEVICE_ENABLE,
Expand All @@ -52,6 +54,7 @@ static int do_cfg_auto_startup(void);
static int do_cfg_bootstrap_from_smartcard(void);
static int do_cfg_carriers(void);
static int do_cfg_coap_con_interval(void);
static int do_cfg_firmware_download_timeout(void);
static int do_cfg_config_enable(void);
static int do_cfg_device_enable(void);
static int do_cfg_device_type(void);
Expand All @@ -63,6 +66,7 @@ static int do_cfg_software_version(void);
static int do_cfg_device_serial_no_type(void);
static int do_cfg_service_code(void);
static int do_cfg_pdn_type(void);
static int do_cfg_queue_mode(void);
static int do_cfg_binding(void);
static int do_cfg_server_enable(void);
static int do_cfg_is_bootstrap(void);
Expand All @@ -84,11 +88,14 @@ static struct carrier_cfg_op_list cfg_op_list[CARRIER_CFG_OP_MAX] = {
do_cfg_bootstrap_from_smartcard},
{CARRIER_CFG_OP_CONFIG_CARRIERS, "carriers", do_cfg_carriers},
{CARRIER_CFG_OP_CONFIG_COAP_CON_INTERVAL, "coap_con_interval", do_cfg_coap_con_interval},
{CARRIER_CFG_OP_CONFIG_FIRMWARE_DOWNLOAD_TIMEOUT, "download_timeout",
do_cfg_firmware_download_timeout},
{CARRIER_CFG_OP_CONFIG_ENABLE, "config_enable", do_cfg_config_enable},
{CARRIER_CFG_OP_CONFIG_LGU_DEVICE_SERIAL_NO_TYPE, "device_serial_no_type",
do_cfg_device_serial_no_type},
{CARRIER_CFG_OP_CONFIG_LGU_SERVICE_CODE, "service_code", do_cfg_service_code},
{CARRIER_CFG_OP_CONFIG_PDN_TYPE, "pdn_type", do_cfg_pdn_type},
{CARRIER_CFG_OP_CONFIG_QUEUE_MODE, "queue_mode", do_cfg_queue_mode},
{CARRIER_CFG_OP_CONFIG_SESSION_IDLE_TIMEOUT, "session_idle_timeout",
do_cfg_session_idle_timeout},
{CARRIER_CFG_OP_DEVICE_ENABLE, "device_enable", do_cfg_device_enable},
Expand Down Expand Up @@ -221,7 +228,7 @@ static int do_cfg_bootstrap_from_smartcard(void)
const static uint32_t carriers_enabled_map[] = {
LWM2M_CARRIER_GENERIC,
LWM2M_CARRIER_VERIZON,
LWM2M_CARRIER_ATT,
LWM2M_CARRIER_BELL_CA,
LWM2M_CARRIER_LG_UPLUS,
LWM2M_CARRIER_T_MOBILE,
LWM2M_CARRIER_SOFTBANK
Expand Down Expand Up @@ -316,6 +323,31 @@ static int do_cfg_coap_con_interval(void)
return lwm2m_settings_coap_con_interval_set(coap_con_interval);
}

/* AT#XCARRIERCFG="download_timeout"[,<timeout>] */
static int do_cfg_firmware_download_timeout(void)
{
uint32_t count;

count = at_params_valid_count_get(&slm_at_param_list);
if (count == 2) {
rsp_send("\r\n#XCARRIERCFG: %hu\r\n",
lwm2m_settings_firmware_download_timeout_get());
return 0;
} else if (count != 3) {
return -EINVAL;
}

int ret;
uint16_t firmware_download_timeout;

ret = at_params_unsigned_short_get(&slm_at_param_list, 2, &firmware_download_timeout);
if (ret) {
return ret;
}

return lwm2m_settings_firmware_download_timeout_set(firmware_download_timeout);
}

/* AT#XCARRIERCFG="config_enable"[,<0|1>] */
static int do_cfg_config_enable(void)
{
Expand Down Expand Up @@ -631,6 +663,35 @@ static int do_cfg_pdn_type(void)
return lwm2m_settings_pdn_type_set(pdn_type);
}

/* AT#XCARRIERCFG="queue_mode"[,<0|1>] */
static int do_cfg_queue_mode(void)
{
uint32_t count;

count = at_params_valid_count_get(&slm_at_param_list);
if (count == 2) {
rsp_send("\r\n#XCARRIERCFG: %d\r\n", lwm2m_settings_queue_mode_get());
return 0;
} else if (count != 3) {
return -EINVAL;
}

int ret;
uint16_t queue_mode;

ret = at_params_unsigned_short_get(&slm_at_param_list, 2, &queue_mode);
if (ret) {
return ret;
}

if (queue_mode > 1) {
LOG_ERR("AT#XCARRIERCFG=\"queue_mode\" failed: must be 0 or 1");
return -EINVAL;
}

return lwm2m_settings_queue_mode_set(queue_mode);
}

/* AT#XCARRIERCFG="binding"[,<binding>] */
static int do_cfg_binding(void)
{
Expand Down
Loading

0 comments on commit 503b43b

Please sign in to comment.