Skip to content

Commit e9fee35

Browse files
ccli8cfriedt
authored andcommitted
drivers: wifi: esp_at: fix AT+CIPSEND premature timeout
For TCP socket, this fixes AT+CIPSEND command with too short timeout. ESP modem replies SEND OK/SEND FAIL dependent on network traffic condition, so this timeout config changes as Kconfig option for being configurable by user. Signed-off-by: Chun-Chieh Li <[email protected]>
1 parent d7fb46a commit e9fee35

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/wifi/esp_at/Kconfig.esp_at

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ config WIFI_ESP_AT_RX_NET_PKT_ALLOC_TIMEOUT
9999
help
100100
Network interface RX net_pkt allocation timeout in milliseconds.
101101

102+
config WIFI_ESP_AT_TCP_SEND_TIMEOUT
103+
int "TCP socket send timeout"
104+
default 30000
105+
help
106+
For TCP socket, how long to wait in milliseconds for device
107+
to reply SEND OK/SEND FAIL after AT+CIPSEND has been sent.
108+
This can vary with network traffic condition.
109+
102110
choice
103111
prompt "ESP IP Address configuration"
104112
default WIFI_ESP_AT_IP_DHCP

drivers/wifi/esp_at/esp_offload.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ LOG_MODULE_REGISTER(wifi_esp_at_offload, CONFIG_WIFI_LOG_LEVEL);
2020

2121
#include "esp.h"
2222

23+
#define TCP_SEND_TIMEOUT \
24+
K_MSEC(CONFIG_WIFI_ESP_AT_TCP_SEND_TIMEOUT)
25+
2326
static int esp_listen(struct net_context *context, int backlog)
2427
{
2528
return -ENOTSUP;
@@ -330,7 +333,11 @@ static int _sock_send(struct esp_socket *sock, struct net_pkt *pkt)
330333
}
331334

332335
/* Wait for 'SEND OK' or 'SEND FAIL' */
333-
ret = k_sem_take(&dev->sem_response, ESP_CMD_TIMEOUT);
336+
if (esp_socket_ip_proto(sock) == IPPROTO_TCP) {
337+
ret = k_sem_take(&dev->sem_response, TCP_SEND_TIMEOUT);
338+
} else {
339+
ret = k_sem_take(&dev->sem_response, ESP_CMD_TIMEOUT);
340+
}
334341
if (ret < 0) {
335342
LOG_DBG("No send response");
336343
goto out;

0 commit comments

Comments
 (0)