Skip to content

Commit e8a690f

Browse files
mike-scottnashif
authored andcommitted
drivers: modem: wncm14a2a: remove socket_reading logic
Remove overly complicated logic to skip incoming data if we were still waiting on a previous set of data to be read. This fixes a bug where an error during data receive could end up with the modem ignoring all incoming data. Signed-off-by: Michael Scott <[email protected]>
1 parent 1c5642a commit e8a690f

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

drivers/modem/wncm14a2a.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ struct wncm14a2a_socket {
153153
struct sockaddr dst;
154154

155155
int socket_id;
156-
bool socket_reading;
157156

158157
/** semaphore */
159158
struct k_sem sock_send_sem;
@@ -826,7 +825,7 @@ static void on_cmd_sockread(struct net_buf **buf, u16_t len)
826825
sock->recv_pkt = net_pkt_get_rx(sock->context, BUF_ALLOC_TIMEOUT);
827826
if (!sock->recv_pkt) {
828827
LOG_ERR("Failed net_pkt_get_reserve_rx!");
829-
goto cleanup;
828+
return;
830829
}
831830

832831
/* set pkt data */
@@ -839,7 +838,7 @@ static void on_cmd_sockread(struct net_buf **buf, u16_t len)
839838
LOG_ERR("Failed net_pkt_get_frag!");
840839
net_pkt_unref(sock->recv_pkt);
841840
sock->recv_pkt = NULL;
842-
goto cleanup;
841+
return;
843842
}
844843

845844
net_pkt_frag_add(sock->recv_pkt, frag);
@@ -866,7 +865,7 @@ static void on_cmd_sockread(struct net_buf **buf, u16_t len)
866865
LOG_ERR("Unable to add data! Aborting!");
867866
net_pkt_unref(sock->recv_pkt);
868867
sock->recv_pkt = NULL;
869-
goto cleanup;
868+
return;
870869
}
871870

872871
c = 0;
@@ -896,9 +895,6 @@ static void on_cmd_sockread(struct net_buf **buf, u16_t len)
896895
* case the app takes a long time.
897896
*/
898897
k_work_submit_to_queue(&wncm14a2a_workq, &sock->recv_cb_work);
899-
900-
cleanup:
901-
sock->socket_reading = false;
902898
}
903899

904900
/* Handler: @SOCKDATAIND: <socket_id>,<session_status>,<left_bytes> */
@@ -946,23 +942,14 @@ static void on_cmd_sockdataind(struct net_buf **buf, u16_t len)
946942
}
947943

948944
if (left_bytes > 0) {
949-
if (!sock->socket_reading) {
950-
LOG_DBG("socket_id:%d left_bytes:%d",
951-
socket_id, left_bytes);
952-
953-
/* TODO: add a timeout to unset this */
954-
sock->socket_reading = true;
955-
snprintk(sendbuf, sizeof(sendbuf), "AT@SOCKREAD=%d,%d",
956-
sock->socket_id, left_bytes);
957-
958-
/* We still have a lock from hitting this cmd trigger,
959-
* so don't hold one when we send the new command
960-
*/
961-
send_at_cmd(sock, sendbuf, K_NO_WAIT);
962-
} else {
963-
LOG_DBG("SKIPPING socket_id:%d left_bytes:%d",
964-
socket_id, left_bytes);
965-
}
945+
LOG_DBG("socket_id:%d left_bytes:%d", socket_id, left_bytes);
946+
snprintk(sendbuf, sizeof(sendbuf), "AT@SOCKREAD=%d,%d",
947+
sock->socket_id, left_bytes);
948+
949+
/* We still have a lock from hitting this cmd trigger,
950+
* so don't hold one when we send the new command
951+
*/
952+
send_at_cmd(sock, sendbuf, K_NO_WAIT);
966953
}
967954
}
968955

0 commit comments

Comments
 (0)