Lines Matching +full:conf +full:- +full:rx
4 * SPDX-License-Identifier: Apache-2.0
94 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_send()
96 esp_interface_t ifx = data->state == ESP32_AP_CONNECTED ? ESP_IF_WIFI_AP : ESP_IF_WIFI_STA; in esp32_wifi_send()
99 if (net_pkt_read(pkt, data->frame_buf, pkt_len) < 0) { in esp32_wifi_send()
104 if (esp_wifi_internal_tx(ifx, (void *)data->frame_buf, pkt_len) != ESP_OK) { in esp32_wifi_send()
109 data->stats.bytes.sent += pkt_len; in esp32_wifi_send()
110 data->stats.pkts.tx++; in esp32_wifi_send()
120 data->stats.errors.tx++; in esp32_wifi_send()
122 return -EIO; in esp32_wifi_send()
132 return -EIO; in eth_esp32_rx()
139 return -EIO; in eth_esp32_rx()
154 esp32_data.stats.pkts.rx++; in eth_esp32_rx()
165 esp32_data.stats.errors.rx++; in eth_esp32_rx()
168 return -EIO; in eth_esp32_rx()
179 return -EIO; in wifi_esp32_ap_iface_rx()
186 return -EIO; in wifi_esp32_ap_iface_rx()
201 esp32_ap_sta_data.stats.pkts.rx++; in wifi_esp32_ap_iface_rx()
212 esp32_ap_sta_data.stats.errors.rx++; in wifi_esp32_ap_iface_rx()
214 return -EIO; in wifi_esp32_ap_iface_rx()
226 LOG_INF("No Wi-Fi AP found"); in scan_done_handler()
316 wifi_mgmt_raise_disconnect_result_event(esp32_wifi_iface, -1); in esp_wifi_handle_sta_disconnect_event()
319 LOG_DBG("Disconnect reason: %d", event->reason); in esp_wifi_handle_sta_disconnect_event()
320 switch (event->reason) { in esp_wifi_handle_sta_disconnect_event()
336 (event->reason != WIFI_REASON_ASSOC_LEAVE)) { in esp_wifi_handle_sta_disconnect_event()
355 LOG_DBG("Station " MACSTR " join, AID=%d", MAC2STR(event->mac), event->aid); in esp_wifi_handle_ap_connect_event()
363 memcpy(sta_info.mac, event->mac, WIFI_MAC_ADDR_LEN); in esp_wifi_handle_ap_connect_event()
372 if (memcmp(event->mac, sta->mac, 6) == 0) { in esp_wifi_handle_ap_connect_event()
373 if (sta->phy_11n) { in esp_wifi_handle_ap_connect_event()
375 } else if (sta->phy_11g) { in esp_wifi_handle_ap_connect_event()
377 } else if (sta->phy_11b) { in esp_wifi_handle_ap_connect_event()
402 LOG_DBG("station " MACSTR " leave, AID=%d", MAC2STR(event->mac), event->aid); in esp_wifi_handle_ap_disconnect_event()
408 memcpy(sta_info.mac, event->mac, WIFI_MAC_ADDR_LEN); in esp_wifi_handle_ap_disconnect_event()
411 if (!(--esp32_data.ap_connection_cnt)) { in esp_wifi_handle_ap_disconnect_event()
427 LOG_DBG("Wi-Fi event: %d", event_id); in esp_wifi_event_handler()
447 ap_data->state = ESP32_AP_STARTED; in esp_wifi_event_handler()
452 ap_data->state = ESP32_AP_STOPPED; in esp_wifi_event_handler()
457 ap_data->state = ESP32_AP_CONNECTED; in esp_wifi_event_handler()
461 ap_data->state = ESP32_AP_DISCONNECTED; in esp_wifi_event_handler()
475 return -EAGAIN; in esp32_wifi_disconnect()
484 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_connect()
489 if (data->state == ESP32_STA_CONNECTING || data->state == ESP32_STA_CONNECTED) { in esp32_wifi_connect()
490 wifi_mgmt_raise_connect_result_event(iface, -1); in esp32_wifi_connect()
491 return -EALREADY; in esp32_wifi_connect()
496 LOG_ERR("Failed to get Wi-Fi mode (%d)", ret); in esp32_wifi_connect()
497 return -EAGAIN; in esp32_wifi_connect()
508 LOG_ERR("Failed to set Wi-Fi mode (%d)", ret); in esp32_wifi_connect()
509 return -EAGAIN; in esp32_wifi_connect()
513 LOG_ERR("Failed to start Wi-Fi driver (%d)", ret); in esp32_wifi_connect()
514 return -EAGAIN; in esp32_wifi_connect()
517 if (data->state != ESP32_STA_STARTED) { in esp32_wifi_connect()
518 LOG_ERR("Wi-Fi not in station mode"); in esp32_wifi_connect()
519 wifi_mgmt_raise_connect_result_event(iface, -1); in esp32_wifi_connect()
520 return -EIO; in esp32_wifi_connect()
523 data->state = ESP32_STA_CONNECTING; in esp32_wifi_connect()
525 memcpy(data->status.ssid, params->ssid, params->ssid_length); in esp32_wifi_connect()
526 data->status.ssid[params->ssid_length] = '\0'; in esp32_wifi_connect()
532 memcpy(wifi_config.sta.ssid, params->ssid, params->ssid_length); in esp32_wifi_connect()
533 wifi_config.sta.ssid[params->ssid_length] = '\0'; in esp32_wifi_connect()
534 switch (params->security) { in esp32_wifi_connect()
537 data->status.security = WIFI_AUTH_OPEN; in esp32_wifi_connect()
541 memcpy(wifi_config.sta.password, params->psk, params->psk_length); in esp32_wifi_connect()
542 wifi_config.sta.password[params->psk_length] = '\0'; in esp32_wifi_connect()
545 data->status.security = WIFI_AUTH_WPA2_PSK; in esp32_wifi_connect()
549 if (params->sae_password) { in esp32_wifi_connect()
550 memcpy(wifi_config.sta.password, params->sae_password, in esp32_wifi_connect()
551 params->sae_password_length); in esp32_wifi_connect()
552 wifi_config.sta.password[params->sae_password_length] = '\0'; in esp32_wifi_connect()
554 memcpy(wifi_config.sta.password, params->psk, params->psk_length); in esp32_wifi_connect()
555 wifi_config.sta.password[params->psk_length] = '\0'; in esp32_wifi_connect()
557 data->status.security = WIFI_AUTH_WPA3_PSK; in esp32_wifi_connect()
564 return -EINVAL; in esp32_wifi_connect()
568 return -EIO; in esp32_wifi_connect()
571 if (params->channel == WIFI_CHANNEL_ANY) { in esp32_wifi_connect()
573 data->status.channel = 0U; in esp32_wifi_connect()
575 wifi_config.sta.channel = params->channel; in esp32_wifi_connect()
576 data->status.channel = params->channel; in esp32_wifi_connect()
581 LOG_ERR("Failed to set Wi-Fi configuration (%d)", ret); in esp32_wifi_connect()
582 return -EINVAL; in esp32_wifi_connect()
587 LOG_ERR("Failed to connect to Wi-Fi access point (%d)", ret); in esp32_wifi_connect()
588 return -EAGAIN; in esp32_wifi_connect()
597 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_scan()
600 if (data->scan_cb != NULL) { in esp32_wifi_scan()
602 return -EINPROGRESS; in esp32_wifi_scan()
605 data->scan_cb = cb; in esp32_wifi_scan()
611 scan_config.scan_type = params->scan_type; in esp32_wifi_scan()
628 LOG_ERR("Failed to set Wi-Fi mode (%d)", ret); in esp32_wifi_scan()
629 return -EINVAL; in esp32_wifi_scan()
634 LOG_ERR("Failed to start Wi-Fi driver (%d)", ret); in esp32_wifi_scan()
635 return -EAGAIN; in esp32_wifi_scan()
640 LOG_ERR("Failed to start Wi-Fi scanning"); in esp32_wifi_scan()
641 return -EAGAIN; in esp32_wifi_scan()
650 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_ap_enable()
653 /* Build Wi-Fi configuration for AP mode */ in esp32_wifi_ap_enable()
657 .channel = params->channel == WIFI_CHANNEL_ANY ? in esp32_wifi_ap_enable()
658 0 : params->channel, in esp32_wifi_ap_enable()
662 memcpy(data->status.ssid, params->ssid, params->ssid_length); in esp32_wifi_ap_enable()
663 data->status.ssid[params->ssid_length] = '\0'; in esp32_wifi_ap_enable()
665 strncpy((char *) wifi_config.ap.ssid, params->ssid, params->ssid_length); in esp32_wifi_ap_enable()
666 wifi_config.ap.ssid_len = params->ssid_length; in esp32_wifi_ap_enable()
668 switch (params->security) { in esp32_wifi_ap_enable()
672 data->status.security = WIFI_AUTH_OPEN; in esp32_wifi_ap_enable()
676 strncpy((char *) wifi_config.ap.password, params->psk, params->psk_length); in esp32_wifi_ap_enable()
678 data->status.security = WIFI_AUTH_WPA2_PSK; in esp32_wifi_ap_enable()
683 return -EINVAL; in esp32_wifi_ap_enable()
686 /* Start Wi-Fi in AP mode with configuration built above */ in esp32_wifi_ap_enable()
697 LOG_ERR("Failed to set Wi-Fi mode (%d)", err); in esp32_wifi_ap_enable()
698 return -EINVAL; in esp32_wifi_ap_enable()
703 LOG_ERR("Failed to set Wi-Fi configuration (%d)", err); in esp32_wifi_ap_enable()
704 return -EINVAL; in esp32_wifi_ap_enable()
709 LOG_ERR("Failed to enable Wi-Fi AP mode"); in esp32_wifi_ap_enable()
710 return -EAGAIN; in esp32_wifi_ap_enable()
729 LOG_ERR("Failed to disable Wi-Fi AP mode: (%d)", err); in esp32_wifi_ap_disable()
730 return -EAGAIN; in esp32_wifi_ap_disable()
738 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_status()
740 wifi_config_t conf; in esp32_wifi_status() local
743 switch (data->state) { in esp32_wifi_status()
746 status->state = WIFI_STATE_INACTIVE; in esp32_wifi_status()
750 status->state = WIFI_STATE_DISCONNECTED; in esp32_wifi_status()
753 status->state = WIFI_STATE_SCANNING; in esp32_wifi_status()
757 status->state = WIFI_STATE_COMPLETED; in esp32_wifi_status()
763 strncpy(status->ssid, data->status.ssid, WIFI_SSID_MAX_LEN); in esp32_wifi_status()
764 status->ssid_len = strnlen(data->status.ssid, WIFI_SSID_MAX_LEN); in esp32_wifi_status()
765 status->ssid[status->ssid_len] = '\0'; in esp32_wifi_status()
766 status->band = WIFI_FREQ_BAND_2_4_GHZ; in esp32_wifi_status()
767 status->link_mode = WIFI_LINK_MODE_UNKNOWN; in esp32_wifi_status()
768 status->mfp = WIFI_MFP_DISABLE; in esp32_wifi_status()
775 esp_wifi_get_config(ESP_IF_WIFI_STA, &conf); in esp32_wifi_status()
778 status->iface_mode = WIFI_MODE_INFRA; in esp32_wifi_status()
779 status->channel = ap_info.primary; in esp32_wifi_status()
780 status->rssi = ap_info.rssi; in esp32_wifi_status()
781 memcpy(status->bssid, ap_info.bssid, WIFI_MAC_ADDR_LEN); in esp32_wifi_status()
786 status->link_mode = WIFI_1; in esp32_wifi_status()
788 status->link_mode = WIFI_3; in esp32_wifi_status()
791 status->link_mode = WIFI_4; in esp32_wifi_status()
793 status->link_mode = WIFI_6; in esp32_wifi_status()
797 status->beacon_interval = conf.sta.listen_interval; in esp32_wifi_status()
799 esp_wifi_get_config(ESP_IF_WIFI_AP, &conf); in esp32_wifi_status()
800 status->iface_mode = WIFI_MODE_AP; in esp32_wifi_status()
801 status->link_mode = WIFI_LINK_MODE_UNKNOWN; in esp32_wifi_status()
802 status->channel = conf.ap.channel; in esp32_wifi_status()
803 status->beacon_interval = conf.ap.beacon_interval; in esp32_wifi_status()
806 status->iface_mode = WIFI_MODE_UNKNOWN; in esp32_wifi_status()
807 status->link_mode = WIFI_LINK_MODE_UNKNOWN; in esp32_wifi_status()
808 status->channel = 0; in esp32_wifi_status()
812 switch (data->status.security) { in esp32_wifi_status()
814 status->security = WIFI_SECURITY_TYPE_NONE; in esp32_wifi_status()
817 status->security = WIFI_SECURITY_TYPE_PSK; in esp32_wifi_status()
820 status->security = WIFI_SECURITY_TYPE_SAE; in esp32_wifi_status()
823 status->security = WIFI_SECURITY_TYPE_UNKNOWN; in esp32_wifi_status()
832 struct esp32_wifi_runtime *dev_data = dev->data; in esp32_wifi_init()
835 eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI; in esp32_wifi_init()
842 dev_data->state = ESP32_AP_STOPPED; in esp32_wifi_init()
844 esp_read_mac(dev_data->mac_addr, ESP_MAC_WIFI_SOFTAP); in esp32_wifi_init()
848 dev_data->state = ESP32_STA_STOPPED; in esp32_wifi_init()
850 /* Start interface when we are actually connected with Wi-Fi network */ in esp32_wifi_init()
851 esp_read_mac(dev_data->mac_addr, ESP_MAC_WIFI_STA); in esp32_wifi_init()
858 dev_data->state = ESP32_STA_STOPPED; in esp32_wifi_init()
860 /* Start interface when we are actually connected with Wi-Fi network */ in esp32_wifi_init()
861 esp_read_mac(dev_data->mac_addr, ESP_MAC_WIFI_STA); in esp32_wifi_init()
867 net_if_set_link_addr(iface, dev_data->mac_addr, 6, NET_LINK_ETHERNET); in esp32_wifi_init()
876 struct esp32_wifi_runtime *data = dev->data; in esp32_wifi_stats()
878 stats->bytes.received = data->stats.bytes.received; in esp32_wifi_stats()
879 stats->bytes.sent = data->stats.bytes.sent; in esp32_wifi_stats()
880 stats->pkts.rx = data->stats.pkts.rx; in esp32_wifi_stats()
881 stats->pkts.tx = data->stats.pkts.tx; in esp32_wifi_stats()
882 stats->errors.rx = data->stats.errors.rx; in esp32_wifi_stats()
883 stats->errors.tx = data->stats.errors.tx; in esp32_wifi_stats()
884 stats->broadcast.rx = data->stats.broadcast.rx; in esp32_wifi_stats()
885 stats->broadcast.tx = data->stats.broadcast.tx; in esp32_wifi_stats()
886 stats->multicast.rx = data->stats.multicast.rx; in esp32_wifi_stats()
887 stats->multicast.tx = data->stats.multicast.tx; in esp32_wifi_stats()
888 stats->sta_mgmt.beacons_rx = data->stats.sta_mgmt.beacons_rx; in esp32_wifi_stats()
889 stats->sta_mgmt.beacons_miss = data->stats.sta_mgmt.beacons_miss; in esp32_wifi_stats()
905 LOG_ERR("Not enough memory to initialize Wi-Fi."); in esp32_wifi_dev_init()
907 return -ENOMEM; in esp32_wifi_dev_init()
909 LOG_ERR("Unable to initialize the Wi-Fi: %d", ret); in esp32_wifi_dev_init()
910 return -EIO; in esp32_wifi_dev_init()