Skip to content

Commit

Permalink
lte/alt1250: Add internal function to get number of opened sockets
Browse files Browse the repository at this point in the history
Add internal function to get number of opened sockets for ckecking
condition to enter hibernation mode.
  • Loading branch information
SPRESENSE committed Jan 26, 2023
1 parent 7f3c5e8 commit dd9f975
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lte/alt1250/alt1250_daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct alt1250_s

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

#endif /* __LTE_ALT1250_ALT1250_DAEMON_H__ */
23 changes: 23 additions & 0 deletions lte/alt1250/alt1250_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,27 @@ int alt1250_set_api_enable(FAR struct alt1250_s *dev, bool enable)

return OK;
}

int alt1250_count_opened_sockets(FAR struct alt1250_s *dev)
{
int ret = 0;
int i = 0;
FAR struct usock_s *sock;

if (!dev)
{
return ERROR;
}

for (i = 0; i < ARRAY_SZ(dev->sockets); i++)
{
sock = &dev->sockets[i];
if (sock->state != SOCKET_STATE_CLOSED)
{
ret ++;
}
}

return ret;
}
#endif

0 comments on commit dd9f975

Please sign in to comment.