Skip to content

Commit

Permalink
lte/alt1250: Fix bug that caused connect() to get stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE authored May 17, 2022
2 parents 7e96a64 + 19b43ad commit 6f97d73
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
12 changes: 3 additions & 9 deletions lte/alt1250/alt1250_daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@
* Pre-processor Definitions
****************************************************************************/

#if defined(CONFIG_NET_USRSOCK_CONNS)
# if (CONFIG_NET_USRSOCK_CONNS > ALTCOM_NSOCKET)
# define SOCKET_COUNT ALTCOM_NSOCKET
# else
# define SOCKET_COUNT CONFIG_NET_USRSOCK_CONNS
# endif
#else
# define SOCKET_COUNT ALTCOM_NSOCKET
#endif
/* The maximum number of sockets that the ALT1250 modem can open. */

#define SOCKET_COUNT 5

#define _TX_BUFF_SIZE (1500)
#define _RX_BUFF_SIZE (1500)
Expand Down
59 changes: 58 additions & 1 deletion lte/alt1250/usock_handlers/alt1250_accepthdlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,62 @@
* Private Functions
****************************************************************************/

/****************************************************************************
* name: postproc_accepterr
****************************************************************************/

static int postproc_accepterr(FAR struct alt1250_s *dev,
FAR struct alt_container_s *reply,
FAR struct usock_s *usock,
FAR int32_t *usock_result,
FAR uint8_t *usock_xid,
FAR struct usock_ackinfo_s *ackinfo,
unsigned long arg)
{
int ret = REP_SEND_ACK;

dbg_alt1250("%s start\n", __func__);

/* resp[0]: ret code
* resp[1]: error code
*/

*usock_xid = USOCKET_XID(usock);
*usock_result = -EBUSY;

return ret;
}

/****************************************************************************
* name: send_close_command
****************************************************************************/

static int send_close_command(FAR struct alt1250_s *dev,
FAR struct alt_container_s *container,
FAR struct usock_s *usock,
int altsock,
FAR int32_t *usock_result)
{
int idx = 0;
FAR void *inparam[1];

/* This member is referenced only when sending a command and
* not when receiving a response, so local variable is used.
*/

inparam[0] = &altsock;

USOCKET_SET_RESPONSE(usock, idx++, USOCKET_REP_RESULT(usock));
USOCKET_SET_RESPONSE(usock, idx++, USOCKET_REP_ERRCODE(usock));

set_container_ids(container, USOCKET_USOCKID(usock), LTE_CMDID_CLOSE);
set_container_argument(container, inparam, ARRAY_SZ(inparam));
set_container_response(container, USOCKET_REP_RESPONSE(usock), idx);
set_container_postproc(container, postproc_accepterr, 0);

return altdevice_send_command(dev->altfd, container, usock_result);
}

/****************************************************************************
* name: postproc_accept
****************************************************************************/
Expand Down Expand Up @@ -70,7 +126,8 @@ static int postproc_accept(FAR struct alt1250_s *dev,
accept_sock = usocket_alloc(dev);
if (!accept_sock)
{
*usock_result = -EBUSY;
ret = send_close_command(dev, reply, usock, altsock_res,
usock_result);
*usock_xid = USOCKET_XID(usock);
}
else
Expand Down

0 comments on commit 6f97d73

Please sign in to comment.