Skip to content

Commit 183b74c

Browse files
sylvioalvesfabiobaltieri
authored andcommitted
driver: wifi: esp32: fix send event when not connected
Make sure send event returns error when device is not connected into STA or have AP mode in place. Signed-off-by: Sylvio Alves <[email protected]>
1 parent f22de97 commit 183b74c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/wifi/esp32/src/esp_wifi_drv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ static int esp32_wifi_send(const struct device *dev, struct net_pkt *pkt)
9595
const int pkt_len = net_pkt_get_len(pkt);
9696
esp_interface_t ifx = data->state == ESP32_AP_CONNECTED ? ESP_IF_WIFI_AP : ESP_IF_WIFI_STA;
9797

98+
if (esp32_data.state != ESP32_STA_CONNECTED && esp32_data.state != ESP32_AP_CONNECTED) {
99+
return -EIO;
100+
}
101+
98102
/* Read the packet payload */
99103
if (net_pkt_read(pkt, data->frame_buf, pkt_len) < 0) {
100104
goto out;

0 commit comments

Comments
 (0)