Skip to content

Commit 2a6ddd2

Browse files
mniestrojnashif
authored andcommitted
drivers: wifi: esp: fix AT+CWMODE_CUR compatibility with ESP AT 1.7
There was a regression when implementing automatic AT+CWMODE{,_CUR} handling based on driver needs. ESP AT 1.7 firmware does not support AT+CWMODE_CUR=0, which means that radio needs to be either in STA, AP or STA+AP mode (no NONE state available). Fix ESP AT 1.7 compatibility by keeping radio in STA mode whenever it is not used. Move also first AT+CWMODE_CUR invocation before AT+CWDHCP_CUR, so that the latter executes successfully with ESP AT 1.7. Fixes: 03ce610 ("drivers: wifi: esp: control CWMODE depending on current needs") Signed-off-by: Marcin Niestroj <[email protected]>
1 parent 99a4af6 commit 2a6ddd2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/wifi/esp/esp.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ static inline uint8_t esp_mode_from_flags(struct esp_data *data)
7878
mode |= ESP_MODE_AP;
7979
}
8080

81+
/*
82+
* ESP AT 1.7 does not allow to disable radio, so enter STA mode
83+
* instead.
84+
*/
85+
if (IS_ENABLED(CONFIG_WIFI_ESP_AT_VERSION_1_7) &&
86+
mode == ESP_MODE_NONE) {
87+
mode = ESP_MODE_STA;
88+
}
89+
8190
return mode;
8291
}
8392

@@ -806,6 +815,9 @@ static void esp_init_work(struct k_work *work)
806815
static const struct setup_cmd setup_cmds_target_baudrate[] = {
807816
SETUP_CMD_NOHANDLE("AT"),
808817
#endif
818+
#if defined(CONFIG_WIFI_ESP_AT_VERSION_1_7)
819+
SETUP_CMD_NOHANDLE(ESP_CMD_CWMODE(STA)),
820+
#endif
809821
#if defined(CONFIG_WIFI_ESP_IP_STATIC)
810822
/* enable Static IP Config */
811823
SETUP_CMD_NOHANDLE(ESP_CMD_DHCP_ENABLE(STATION, 0)),
@@ -823,8 +835,8 @@ static void esp_init_work(struct k_work *work)
823835
#if defined(CONFIG_WIFI_ESP_AT_VERSION_2_0)
824836
SETUP_CMD_NOHANDLE(ESP_CMD_CWMODE(STA)),
825837
SETUP_CMD_NOHANDLE("AT+CWAUTOCONN=0"),
826-
#endif
827838
SETUP_CMD_NOHANDLE(ESP_CMD_CWMODE(NONE)),
839+
#endif
828840
#if defined(CONFIG_WIFI_ESP_PASSIVE_MODE)
829841
SETUP_CMD_NOHANDLE("AT+CIPRECVMODE=1"),
830842
#endif

0 commit comments

Comments
 (0)