Skip to content

Commit

Permalink
net/usrsock: Add events to usrsock
Browse files Browse the repository at this point in the history
Add USRSOCK_EVENT_CONNECTED and USRSOCK_EVENT_LISTENING events.
In the case where the Host side turns off power while the
communication device side has opened the socket,
it is necessary to recover the socket that has already been
opened after the Host side turns on power.
These events are necessary for this process, so add these events.
  • Loading branch information
SPRESENSE committed Aug 20, 2024
1 parent 5038472 commit c322788
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nuttx/net/usrsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#define USRSOCK_EVENT_SENDTO_READY (1 << 2)
#define USRSOCK_EVENT_RECVFROM_AVAIL (1 << 3)
#define USRSOCK_EVENT_REMOTE_CLOSED (1 << 4)
#define USRSOCK_EVENT_CONNECTED (1 << 5)
#define USRSOCK_EVENT_LISTENING (1 << 6)

/* Response message flags */

Expand Down
10 changes: 10 additions & 0 deletions net/usrsock/usrsock_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ int usrsock_event(FAR struct usrsock_conn_s *conn)
{
conn->flags |= USRSOCK_EVENT_RECVFROM_AVAIL;
}

if (events & USRSOCK_EVENT_CONNECTED)
{
conn->connected = true;
}

if (events & USRSOCK_EVENT_LISTENING)
{
conn->sconn.s_flags |= _SF_LISTENING;
}
}

if (events & USRSOCK_EVENT_REMOTE_CLOSED)
Expand Down

0 comments on commit c322788

Please sign in to comment.