Skip to content

Commit

Permalink
examples/lte_lwm2mstub: Add handling when version mismatches occur
Browse files Browse the repository at this point in the history
If the application detects a version mismatch, it should
display the version mismatch log and the firmware version
of the modem and exit.
  • Loading branch information
SPRESENSE committed Feb 22, 2023
1 parent cf4c6e5 commit b08e275
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/lte_lwm2mstub/app_lte_util.c
Expand Up @@ -62,6 +62,7 @@ static void lte_restart_cb(uint32_t reason)
{
case LTE_RESTART_USER_INITIATED:
case LTE_RESTART_MODEM_INITIATED:
case LTE_RESTART_VERSION_ERROR:
msg.msgid = MESSAGE_ID_LTE_RESTARTED;
msg.arg.code = reason;
send_message(MESSAGE_QUEUE_NAME, &msg);
Expand All @@ -78,14 +79,29 @@ static void lte_restart_cb(uint32_t reason)

static int wait_for_lterestart(void)
{
int ret;
struct app_message_s msg;
lte_version_t version = {0};
if (receive_message(MESSAGE_QUEUE_NAME, &msg) == OK)
{
if (msg.msgid == MESSAGE_ID_LTE_RESTARTED &&
msg.arg.code == LTE_RESTART_USER_INITIATED)
{
return OK;
}
else if (msg.msgid == MESSAGE_ID_LTE_RESTARTED &&
msg.arg.code == LTE_RESTART_VERSION_ERROR)
{
printf("Please enable the disabled protocol version"
" and flash the application.\n");

ret = lte_get_version_sync(&version);
if (ret == 0)
{
printf("Modem IC Type : %s\n", version.bb_product);
printf(" FW Ver. : %s\n", version.np_package);
}
}
}

return ERROR;
Expand Down

0 comments on commit b08e275

Please sign in to comment.