From 71e7cd3f992e5cd946f9ea8a583fbb5cddcf7a40 Mon Sep 17 00:00:00 2001 From: Tobias Svehagen Date: Mon, 6 Jul 2020 14:59:17 +0200 Subject: [PATCH] drivers: wifi: esp: Fix issue with incorrect tx timeout It can happen that the command '>' is received between modem_cmd_send_nolock and modem_cmd_handler_update_cmds. Since the command handler for '>' is not set, sem_tx_ready will not be given and _sock_send will timeout. Make sure the command handlers are set before the send by also passing them to modem_cmd_send_nolock. Signed-off-by: Tobias Svehagen --- drivers/wifi/esp/esp_offload.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/wifi/esp/esp_offload.c b/drivers/wifi/esp/esp_offload.c index b68f16ee2c4..5a9a8eb82d0 100644 --- a/drivers/wifi/esp/esp_offload.c +++ b/drivers/wifi/esp/esp_offload.c @@ -237,8 +237,8 @@ static int _sock_send(struct esp_data *dev, struct esp_socket *sock) k_sem_reset(&dev->sem_tx_ready); ret = modem_cmd_send_nolock(&dev->mctx.iface, &dev->mctx.cmd_handler, - NULL, 0, cmd_buf, &dev->sem_response, - ESP_CMD_TIMEOUT); + cmds, ARRAY_SIZE(cmds), cmd_buf, + &dev->sem_response, ESP_CMD_TIMEOUT); if (ret < 0) { LOG_DBG("Failed to send command"); goto out; @@ -339,6 +339,10 @@ static int esp_sendto(struct net_pkt *pkt, LOG_DBG("link %d, timeout %d", sock->link_id, timeout); + if (!esp_flag_is_set(dev, EDF_STA_CONNECTED)) { + return -ENETUNREACH; + } + if (sock->tx_pkt) { return -EBUSY; }