Skip to content

Commit

Permalink
lte/alt1250: Add internal function to stop API request from Application
Browse files Browse the repository at this point in the history
Add internal function to stop any LTE/Socket request from
application.
Before enterting hibernation mode, system need to stop API request.
  • Loading branch information
SPRESENSE committed Jan 26, 2023
1 parent 77f450c commit 7f3c5e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lte/alt1250/alt1250_daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ struct alt1250_s
struct sms_info_s sms_info;
bool is_support_lwm2m;
int64_t lwm2m_apply_xid;
bool api_enable;
};

/****************************************************************************
* Public Functions
****************************************************************************/

#ifdef CONFIG_LTE_ALT1250_ENABLE_HIBERNATION_MODE
int alt1250_set_api_enable(FAR struct alt1250_s *dev, bool enable);
#endif

#endif /* __LTE_ALT1250_ALT1250_DAEMON_H__ */
15 changes: 15 additions & 0 deletions lte/alt1250/alt1250_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ int main(int argc, FAR char *argv[])
g_daemon->usock_enable = TRUE;
g_daemon->is_support_lwm2m = false;
g_daemon->lwm2m_apply_xid = -1;
g_daemon->api_enable = true;
MODEM_STATE_POFF(g_daemon);

reset_fwupdate_info(g_daemon);
Expand All @@ -269,3 +270,17 @@ int main(int argc, FAR char *argv[])

return ret;
}

#ifdef CONFIG_LTE_ALT1250_ENABLE_HIBERNATION_MODE
int alt1250_set_api_enable(FAR struct alt1250_s *dev, bool enable)
{
if (!dev)
{
return ERROR;
}

dev->api_enable = enable;

return OK;
}
#endif
7 changes: 7 additions & 0 deletions lte/alt1250/usock_handlers/alt1250_sockethdlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ int usockreq_socket(FAR struct alt1250_s *dev,
return REP_SEND_ACK_WOFREE;
}

if (!dev->api_enable)
{
dbg_alt1250("Don't allow to call any API now.\n");
*usock_result = -EBUSY;
return REP_SEND_ACK_WOFREE;
}

usock = usocket_alloc(dev);
if (usock == NULL)
{
Expand Down

0 comments on commit 7f3c5e8

Please sign in to comment.