Skip to content

Commit 1848dd5

Browse files
authored
lte/alt1250: Add error handling to ltefwupdate_execute()
2 parents 15dfe87 + eabeeb8 commit 1848dd5

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

include/lte/lte_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,16 @@ int lte_acquire_wakelock(void);
15131513

15141514
int lte_release_wakelock(void);
15151515

1516+
/* Get the number of wakelock counts acquired.
1517+
* Please call this API after calling lte_initialize().
1518+
* Otherwise this API will result in an error.
1519+
*
1520+
* On success, return the count of the current modem wakelock. On failure,
1521+
* negative value is returned according to <errno.h>.
1522+
*/
1523+
1524+
int lte_get_wakelock_count(void);
1525+
15161526
/* Send AT command to the modem.
15171527
*
15181528
* [in] cmd: The AT command data.

include/lte/lte_fwupdate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int ltefwupdate_injected_datasize(void);
126126
* - LTEFW_RESULT_PRECHK_SIZE_ERROR
127127
* - LTEFW_RESULT_PRECHK_PKG_ERROR
128128
* - LTEFW_RESULT_PRECHK_CRC_ERROR
129+
* - -EPERM
129130
*
130131
*/
131132

lte/alt1250/usock_handlers/alt1250_ioctl_power.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ int usockreq_ioctl_power(FAR struct alt1250_s *dev,
6363
case LTE_CMDID_POWERON:
6464
case LTE_CMDID_TAKEWLOCK:
6565
case LTE_CMDID_GIVEWLOCK:
66+
case LTE_CMDID_COUNTWLOCK:
6667
*usock_result = altdevice_powercontrol(dev->altfd, ltecmd->cmdid);
6768
if (MODEM_STATE_IS_POFF(dev) && ltecmd->cmdid == LTE_CMDID_POWERON)
6869
{

lte/lapi/src/lapi_firmware.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "lte/lte_fwupdate.h"
3636

3737
#include "lapi_util.h"
38+
#include "lapi_dbg.h"
3839

3940
/****************************************************************************
4041
* Private Functions
@@ -106,6 +107,24 @@ int ltefwupdate_injected_datasize(void)
106107

107108
int ltefwupdate_execute(void)
108109
{
110+
int ret;
111+
112+
/* If wakelock is not acquired, firmware update
113+
* cannot be performed.
114+
*/
115+
116+
ret = lte_get_wakelock_count();
117+
if (ret <= 0)
118+
{
119+
if (ret == 0)
120+
{
121+
lapi_printf("wakelock is not acquired\n");
122+
ret = -EPERM;
123+
}
124+
125+
return ret;
126+
}
127+
109128
return fw_generic_request(LTE_CMDID_EXEUPDATE);
110129
}
111130

lte/lapi/src/lapi_power.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ int lte_release_wakelock(void)
273273
return lapi_req(LTE_CMDID_GIVEWLOCK, NULL, 0, NULL, 0, NULL);
274274
}
275275

276+
/****************************************************************************
277+
* Name: lte_get_wakelock_count
278+
****************************************************************************/
279+
280+
int lte_get_wakelock_count(void)
281+
{
282+
return lapi_req(LTE_CMDID_COUNTWLOCK, NULL, 0, NULL, 0, NULL);
283+
}
284+
276285
/****************************************************************************
277286
* Name: lte_set_context_save_cb
278287
****************************************************************************/

0 commit comments

Comments
 (0)