From 10e4c3d1597656e8c8e7537fec32407ca82eb634 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:41:52 +0900 Subject: [PATCH 1/6] lte/alt1250: Add static to a private variable Add static scope to a private variable reset_arg. --- lte/alt1250/alt1250_reset_seq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lte/alt1250/alt1250_reset_seq.c b/lte/alt1250/alt1250_reset_seq.c index dc17fa80a..5f1e600a8 100644 --- a/lte/alt1250/alt1250_reset_seq.c +++ b/lte/alt1250/alt1250_reset_seq.c @@ -55,7 +55,7 @@ struct reset_arg_s * Private Data ****************************************************************************/ -struct reset_arg_s reset_arg; +static struct reset_arg_s reset_arg; static postproc_hdlr_t ponreset_seq[] = { From 31d9d25db64fa84c804a6e72e7e72bb2aaba0673 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 21 Jul 2022 00:56:17 -0700 Subject: [PATCH 2/6] lte/lapi: Fix wrong error handling lte_enablem2m_objects() required no error returns even when mandatory objects are not set to enable. --- lte/lapi/src/lapi_lwm2m.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lte/lapi/src/lapi_lwm2m.c b/lte/lapi/src/lapi_lwm2m.c index b739c478c..d91047b08 100644 --- a/lte/lapi/src/lapi_lwm2m.c +++ b/lte/lapi/src/lapi_lwm2m.c @@ -304,20 +304,13 @@ int lte_enablem2m_objects(uint16_t *objids, int objnum) objids, (void *)objnum }; - if (!objids || objnum < 2) + if (!objids || objnum <= 0) { return -EINVAL; } insert_sort(objids, objnum); - if (objids[0] != 0 || objids[1] != 1) - { - /* Object 0 and 1 are mandatory. */ - - return -EINVAL; - } - return lapi_req(LTE_CMDID_LWM2M_SETACTIVEOBJ, &inarg, 2, NULL, 0, NULL); } From e9186cb01977be3e2b89941b42e73ab0fbca5ca5 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:08:30 +0900 Subject: [PATCH 3/6] lte/alt1250: Fix uninitialized variable Fix uninitialized variable. Detected by Codesonar 1229904 --- lte/alt1250/alt1250_select.c | 5 +++-- lte/alt1250/usock_handlers/alt1250_sms.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lte/alt1250/alt1250_select.c b/lte/alt1250/alt1250_select.c index 11b7815b6..26a05e071 100644 --- a/lte/alt1250/alt1250_select.c +++ b/lte/alt1250/alt1250_select.c @@ -88,8 +88,10 @@ static int send_select_command(FAR struct alt1250_s *dev, { FAR void *in[7]; uint16_t used_setbit = 0; - struct alt_container_s container; int32_t usock_result; + struct alt_container_s container = { + 0 + }; if (readset) { @@ -113,7 +115,6 @@ static int send_select_command(FAR struct alt1250_s *dev, in[5] = writeset; in[6] = exceptset; - clear_container(&container); set_container_ids(&container, 0, LTE_CMDID_SELECT); set_container_argument(&container, in, ARRAY_SZ(in)); diff --git a/lte/alt1250/usock_handlers/alt1250_sms.c b/lte/alt1250/usock_handlers/alt1250_sms.c index 33a81179c..1363c1b20 100644 --- a/lte/alt1250/usock_handlers/alt1250_sms.c +++ b/lte/alt1250/usock_handlers/alt1250_sms.c @@ -280,9 +280,10 @@ static int send_smsdelete_command(FAR struct alt1250_s *dev, static int send_smsreportrecv_command(FAR struct alt1250_s *dev, FAR int32_t *usock_result) { - struct alt_container_s container; + struct alt_container_s container = { + 0 + }; - clear_container(&container); set_container_ids(&container, 0, LTE_CMDID_SMS_REPORT_RECV); return altdevice_send_command(dev->altfd, &container, usock_result); From 6708b8d2ca03647c68f594f95c048255036008e2 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:19:17 +0900 Subject: [PATCH 4/6] include/lte: Add comment to ltefwupdate_execute() Add comment to ltefwupdate_execute() that wakelock is required --- include/lte/lte_fwupdate.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/lte/lte_fwupdate.h b/include/lte/lte_fwupdate.h index 5c1b61a2f..af069ef59 100644 --- a/include/lte/lte_fwupdate.h +++ b/include/lte/lte_fwupdate.h @@ -112,6 +112,10 @@ int ltefwupdate_injected_datasize(void); * attention When this function is executed, the modem is automatically * rebooted multiple times. The progress of the update can be checked by * the callback set by lte_set_report_restart(). + * Before executing this function, the modem must be woken up using + * lte_acquire_wakelock() to safely update the modem. Then + * lte_release_wakelock() is executed when the callback set by + * lte_set_report_restart() is called. * * On success, 0 is returned. On failure, * negative value is returned as below values. From ab98c2ab3e0d0cf8729a87a72a7dc00bc06e4fde Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:23:09 +0900 Subject: [PATCH 5/6] include/lte: Fix nxstyle --- include/lte/lte_fwupdate.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/lte/lte_fwupdate.h b/include/lte/lte_fwupdate.h index af069ef59..0d1e29dd1 100644 --- a/include/lte/lte_fwupdate.h +++ b/include/lte/lte_fwupdate.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/include/lte/lte_fw_api.h + * apps/include/lte/lte_fwupdate.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -59,15 +59,15 @@ extern "C" ****************************************************************************/ /* Initialze injection delta image to LTE modem. - * + * * Initialize LTE modem delta image injection with some data of top of delta * image. * * [in] initial_data: Pointer to top data of update image. * [in] len: Size of initial_data. * - * Return value : Positive value is the injected length. Negative falue is any - * error. In error case, the value can be below values. + * Return value : Positive value is the injected length. Negative value is + * any error. In error case, the value can be below values. * * - LTEFW_RESULT_NOT_ENOUGH_INJECTSTORAGE * - LTEFW_RESULT_DELTAIMAGE_HDR_CRC_ERROR @@ -80,15 +80,15 @@ extern "C" int ltefwupdate_initialize(const char *initial_data, int len); /* Inject rest delta image to LTE modem. - * + * * Inject the rest of the delta image following the data injected * by the ltefwupdate_initialize() and ltefwupdate_injectrest() functions. * * [in] rest_data: Pointer to top data of update image. * [in] len: Size of initial_data. * - * Return value : Positive value is the injected length. Negative falue is any - * error. In error case, the value can be below values. + * Return value : Positive value is the injected length. Negative value is + * any error. In error case, the value can be below values. * * - LTEFW_RESULT_NOT_ENOUGH_INJECTSTORAGE * - LTEFW_RESULT_DELTAIMAGE_HDR_CRC_ERROR @@ -119,7 +119,7 @@ int ltefwupdate_injected_datasize(void); * * On success, 0 is returned. On failure, * negative value is returned as below values. - * + * * - LTEFW_RESULT_PRECHK_SET_DELTAIMAGE_FAILED * - LTEFW_RESULT_PRECHK_DELTAIMAGE_MISSING * - LTEFW_RESULT_PRECHK_OOM From 66e1af013c2eccb7042cbb00d2ed8636946f812e Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Sun, 31 Jul 2022 21:56:35 +0000 Subject: [PATCH 6/6] wireless/gs2200m: Release all blocking socket When dis-associtaion happens, the socket is destroyed. And all blocking sockets are released for that error handling can be performed. (cherry picked from commit cfa5af51cd25f9122eafc640299db2759bba7541) --- wireless/gs2200m/gs2200m_main.c | 54 +++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c index bd7a98a49..3364d1e5f 100644 --- a/wireless/gs2200m/gs2200m_main.c +++ b/wireless/gs2200m/gs2200m_main.c @@ -436,6 +436,24 @@ static int usock_send_event(int fd, FAR struct gs2200m_s *priv, return _write_to_usock(fd, &event, sizeof(event)); } +/**************************************************************************** + * Name: usock_sendevent_toall + ****************************************************************************/ + +static void usock_sendevent_toall(FAR struct gs2200m_s *priv, int fd) +{ + int i; + + for (i = 0; i < SOCKET_COUNT; i++) + { + if (priv->sockets[i].state != CLOSED) + { + usock_send_event(fd, priv, &priv->sockets[i], + USRSOCK_EVENT_RECVFROM_AVAIL); + } + } +} + /**************************************************************************** * Name: socket_request ****************************************************************************/ @@ -1669,21 +1687,37 @@ static int gs2200m_loop(FAR struct gs2200m_s *priv) ret = read(fd[1], &cid, sizeof(cid)); ASSERT(ret == sizeof(cid)); - /* find usock by the cid */ + /* Check if all socket destroy or not */ - usock = gs2200m_find_socket_by_cid(priv, cid); - - if (NULL == usock) + if (cid == DISASSOCIATION_CID) { - gs2200m_printf("=== %s: cid=%c not found (ignored) \n", - __func__, cid); + gs2200m_printf("=== %s: Disassocitaion event\n", + __func__); + + /* To release sockets blocking in user-sock, + * send event to all opened sockets. + */ + + usock_sendevent_toall(priv, fd[0]); } else { - /* send event to call xxxx_request() */ - - usock_send_event(fd[0], priv, usock, - USRSOCK_EVENT_RECVFROM_AVAIL); + /* find usock by the cid */ + + usock = gs2200m_find_socket_by_cid(priv, cid); + + if (NULL == usock) + { + gs2200m_printf("=== %s: cid=%c not found (ignored)\n", + __func__, cid); + } + else + { + /* send event to call xxxx_request() */ + + usock_send_event(fd[0], priv, usock, + USRSOCK_EVENT_RECVFROM_AVAIL); + } } } }