mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
Merge branch 'bufix/Backport_some_wifi_lwip_bugs_for_4.3_0719' into 'release/v4.3'
Backport some wifi&lwip bugs for 4.3 0719 See merge request espressif/esp-idf!19110
This commit is contained in:
@ -571,9 +571,10 @@ esp_err_t esp_netif_dhcps_stop(esp_netif_t *esp_netif);
|
||||
*
|
||||
* If DHCP server is enabled, the Main DNS Server setting is used by the DHCP server to provide a DNS Server option
|
||||
* to DHCP clients (Wi-Fi stations).
|
||||
* - The default Main DNS server is typically the IP of the Wi-Fi AP interface itself.
|
||||
* - The default Main DNS server is typically the IP of the DHCP server itself.
|
||||
* - This function can override it by setting server type ESP_NETIF_DNS_MAIN.
|
||||
* - Other DNS Server types are not supported for the Wi-Fi AP interface.
|
||||
* - Other DNS Server types are not supported for the DHCP server.
|
||||
* - To propagate the DNS info to client, please stop the DHCP server before using this API.
|
||||
*
|
||||
* @param[in] esp_netif Handle to esp-netif instance
|
||||
* @param[in] type Type of DNS Server to set: ESP_NETIF_DNS_MAIN, ESP_NETIF_DNS_BACKUP, ESP_NETIF_DNS_FALLBACK
|
||||
|
@ -10,7 +10,7 @@ ppMapTxQueue = 0x400016d8;
|
||||
rcGetSched = 0x40001764;
|
||||
wDevCheckBlockError = 0x400017b4;
|
||||
ppProcTxDone = 0x40001804;
|
||||
sta_input = rom_sta_input;
|
||||
/*sta_input = rom_sta_input;*/
|
||||
|
||||
/***************************************
|
||||
Group rom_phy
|
||||
|
@ -1550,7 +1550,7 @@ pm_on_data_rx = 0x40001680;
|
||||
pm_on_tbtt = 0x40001684;
|
||||
pm_parse_beacon = 0x40001688;
|
||||
pm_process_tim = 0x4000168c;
|
||||
pm_rx_beacon_process = 0x40001690;
|
||||
/*pm_rx_beacon_process = 0x40001690;*/
|
||||
pm_rx_data_process = 0x40001694;
|
||||
/*pm_sleep = 0x40001698;*/
|
||||
pm_sleep_for = 0x4000169c;
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_NOW_H__
|
||||
#define __ESP_NOW_H__
|
||||
@ -237,6 +229,20 @@ esp_err_t esp_now_del_peer(const uint8_t *peer_addr);
|
||||
*/
|
||||
esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Config ESPNOW rate of specified interface
|
||||
*
|
||||
* @attention 1. This API should be called after esp_wifi_start().
|
||||
*
|
||||
* @param ifx Interface to be configured.
|
||||
* @param rate Phy rate to be configured.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: failed
|
||||
*/
|
||||
esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate);
|
||||
|
||||
/**
|
||||
* @brief Get a peer whose MAC address matches peer_addr from peer list
|
||||
*
|
||||
|
@ -251,6 +251,7 @@ esp_err_t esp_wifi_internal_set_sta_ip(void);
|
||||
*
|
||||
* @attention 1. If fixed rate is enabled, both management and data frame are transmitted with fixed rate
|
||||
* @attention 2. Make sure that the receiver is able to receive the frame with the fixed rate if you want the frame to be received
|
||||
* @attention 3. Not support to set fix rate for espnow and 80211_tx
|
||||
*
|
||||
* @param ifx : wifi interface
|
||||
* @param en : false - disable, true - enable
|
||||
|
@ -1218,20 +1218,6 @@ esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm);
|
||||
*/
|
||||
esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable);
|
||||
|
||||
/**
|
||||
* @brief Config ESPNOW rate of specified interface
|
||||
*
|
||||
* @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start().
|
||||
*
|
||||
* @param ifx Interface to be configured.
|
||||
* @param rate Phy rate to be configured.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: failed
|
||||
*/
|
||||
esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate);
|
||||
|
||||
/**
|
||||
* @brief Set interval for station to wake up periodically at disconnected.
|
||||
*
|
||||
|
@ -345,7 +345,7 @@ typedef struct {
|
||||
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */
|
||||
unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
unsigned :8; /**< reserved */
|
||||
#endif
|
||||
@ -358,14 +358,14 @@ typedef struct {
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
unsigned :32; /**< reserved */
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
|
||||
unsigned :24; /**< reserved */
|
||||
unsigned :32; /**< reserved */
|
||||
#endif
|
||||
unsigned :31; /**< reserved */
|
||||
unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/
|
||||
unsigned :24; /**< reserved */
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
unsigned :32; /**< reserved */
|
||||
|
Submodule components/esp_wifi/lib updated: ef6c4a7cb1...c9f08e68e3
@ -877,6 +877,13 @@ menu "LWIP"
|
||||
bool "Enable LWIP Debug"
|
||||
default n
|
||||
|
||||
config LWIP_DEBUG_ESP_LOG
|
||||
bool "Route LWIP debugs through ESP_LOG interface"
|
||||
depends on LWIP_DEBUG
|
||||
default n
|
||||
help
|
||||
Enabling this option routes all enabled LWIP debugs through ESP_LOGD.
|
||||
|
||||
config LWIP_NETIF_DEBUG
|
||||
bool "Enable netif debug messages"
|
||||
depends on LWIP_DEBUG
|
||||
|
@ -25,6 +25,7 @@ typedef struct _ping_option {
|
||||
size_t ping_data_len;
|
||||
uint16_t ping_id;
|
||||
u8_t ping_tos;
|
||||
u8_t ping_ttl;
|
||||
esp_ping_found_fn ping_res_fn;
|
||||
esp_ping_found ping_res;
|
||||
void *ping_reserve;
|
||||
|
@ -67,6 +67,7 @@ typedef struct {
|
||||
uint32_t elapsed_time_ms;
|
||||
uint32_t total_time_ms;
|
||||
uint8_t ttl;
|
||||
uint8_t tos;
|
||||
uint32_t flags;
|
||||
void (*on_ping_success)(esp_ping_handle_t hdl, void *args);
|
||||
void (*on_ping_timeout)(esp_ping_handle_t hdl, void *args);
|
||||
@ -131,6 +132,7 @@ static int esp_ping_receive(esp_ping_t *ep)
|
||||
if ((iecho->id == ep->packet_hdr->id) && (iecho->seqno == ep->packet_hdr->seqno)) {
|
||||
ep->received++;
|
||||
ep->ttl = iphdr->_ttl;
|
||||
ep->tos = iphdr->_tos;
|
||||
ep->recv_len = lwip_ntohs(IPH_LEN(iphdr)) - data_head; // The data portion of ICMP
|
||||
return len;
|
||||
}
|
||||
@ -289,6 +291,9 @@ esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_c
|
||||
/* set tos */
|
||||
setsockopt(ep->sock, IPPROTO_IP, IP_TOS, &config->tos, sizeof(config->tos));
|
||||
|
||||
/* set ttl */
|
||||
setsockopt(ep->sock, IPPROTO_IP, IP_TTL, &config->ttl, sizeof(config->ttl));
|
||||
|
||||
/* set socket address */
|
||||
if (IP_IS_V4(&config->target_addr)) {
|
||||
struct sockaddr_in *to4 = (struct sockaddr_in *)&ep->target_addr;
|
||||
@ -371,6 +376,10 @@ esp_err_t esp_ping_get_profile(esp_ping_handle_t hdl, esp_ping_profile_t profile
|
||||
from = &ep->packet_hdr->seqno;
|
||||
copy_size = sizeof(ep->packet_hdr->seqno);
|
||||
break;
|
||||
case ESP_PING_PROF_TOS:
|
||||
from = &ep->tos;
|
||||
copy_size = sizeof(ep->tos);
|
||||
break;
|
||||
case ESP_PING_PROF_TTL:
|
||||
from = &ep->ttl;
|
||||
copy_size = sizeof(ep->ttl);
|
||||
|
@ -67,7 +67,8 @@ typedef struct {
|
||||
uint32_t interval_ms; /*!< Milliseconds between each ping procedure */
|
||||
uint32_t timeout_ms; /*!< Timeout value (in milliseconds) of each ping procedure */
|
||||
uint32_t data_size; /*!< Size of the data next to ICMP packet header */
|
||||
uint8_t tos; /*!< Type of Service, a field specified in the IP header */
|
||||
int tos; /*!< Type of Service, a field specified in the IP header */
|
||||
int ttl; /*!< Time to Live,a field specified in the IP header */
|
||||
ip_addr_t target_addr; /*!< Target IP address, either IPv4 or IPv6 */
|
||||
uint32_t task_stack_size; /*!< Stack size of internal ping task */
|
||||
uint32_t task_prio; /*!< Priority of internal ping task */
|
||||
@ -85,6 +86,7 @@ typedef struct {
|
||||
.timeout_ms = 1000, \
|
||||
.data_size = 64, \
|
||||
.tos = 0, \
|
||||
.ttl = IP_DEFAULT_TTL, \
|
||||
.target_addr = *(IP_ANY_TYPE), \
|
||||
.task_stack_size = 2048, \
|
||||
.task_prio = 2, \
|
||||
@ -99,6 +101,7 @@ typedef struct {
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PING_PROF_SEQNO, /*!< Sequence number of a ping procedure */
|
||||
ESP_PING_PROF_TOS, /*!< Type of service of a ping procedure */
|
||||
ESP_PING_PROF_TTL, /*!< Time to live of a ping procedure */
|
||||
ESP_PING_PROF_REQUEST, /*!< Number of request packets sent out */
|
||||
ESP_PING_PROF_REPLY, /*!< Number of reply packets received */
|
||||
|
@ -74,7 +74,15 @@ typedef int sys_prot_t;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef CONFIG_LWIP_DEBUG_ESP_LOG
|
||||
// lwip debugs routed to ESP_LOGD
|
||||
#include "esp_log.h"
|
||||
#define LWIP_ESP_LOG_FUNC(format, ...) ESP_LOG_LEVEL(ESP_LOG_DEBUG, "lwip", format, ##__VA_ARGS__)
|
||||
#define LWIP_PLATFORM_DIAG(x) LWIP_ESP_LOG_FUNC x
|
||||
#else
|
||||
// lwip debugs routed to printf
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
|
@ -306,6 +306,16 @@ The default lwIP implementation is to have these timers enabled all the time, ev
|
||||
|
||||
To return to the default lwIP behaviour (always-on timers), disable :ref:`CONFIG_LWIP_TIMERS_ONDEMAND`.
|
||||
|
||||
Lwip timers API
|
||||
+++++++++++++++
|
||||
|
||||
When users are not using WiFi, these APIs provide users with the ability to turn off LwIP timer to reduce power consumption.
|
||||
|
||||
The following API functions are supported. For full details see :component_file:`lwip/lwip/src/include/lwip/timeouts.h`.
|
||||
|
||||
- ``sys_timeouts_init()``
|
||||
- ``sys_timeouts_deinit()``
|
||||
|
||||
Abort TCP connections when IP changes
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
@ -205,11 +205,11 @@ IP_EVENT_GOT_IP6
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
This event arises when the IPV6 SLAAC support auto-configures an address for the {IDF_TARGET_NAME}, or when this address changes. The event means that everything is ready and the application can begin its tasks (e.g., creating sockets).
|
||||
|
||||
IP_STA_LOST_IP
|
||||
IP_EVENT_STA_LOST_IP
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
This event arises when the IPV4 address become invalid.
|
||||
|
||||
IP_STA_LOST_IP doesn't arise immediately after the Wi-Fi disconnects, instead it starts an IPV4 address lost timer, if the IPV4 address is got before ip lost timer expires, IP_EVENT_STA_LOST_IP doesn't happen. Otherwise, the event arises when IPV4 address lost timer expires.
|
||||
IP_EVENT_STA_LOST_IP doesn't arise immediately after the Wi-Fi disconnects, instead it starts an IPV4 address lost timer, if the IPV4 address is got before ip lost timer expires, IP_EVENT_STA_LOST_IP doesn't happen. Otherwise, the event arises when IPV4 address lost timer expires.
|
||||
|
||||
Generally the application don't need to care about this event, it is just a debug event to let the application know that the IPV4 address is lost.
|
||||
|
||||
|
@ -81,6 +81,11 @@ Receiving ESP-NOW Data
|
||||
Call ``esp_now_register_recv_cb`` to register receiving callback function. Call the receiving callback function when receiving ESP-NOW. The receiving callback function also runs from the Wi-Fi task. So, do not do lengthy operations in the callback function.
|
||||
Instead, post the necessary data to a queue and handle it from a lower priority task.
|
||||
|
||||
Config ESP-NOW Rate
|
||||
-------------------
|
||||
|
||||
Call ``esp_wifi_config_espnow_rate`` to config ESPNOW rate of specified interface. Make sure that the interface is enabled before config rate. This API should be called after ``esp_wifi_start()``.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
|
@ -205,7 +205,7 @@ IP_EVENT_GOT_IP6
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
当 IPV6 SLAAC 支持自动为 {IDF_TARGET_NAME} 配置一个地址,或 {IDF_TARGET_NAME} 地址发生改变时,将引发此事件。此事件意味着应用程序一切就绪,可以开始任务(如:创建套接字)。
|
||||
|
||||
IP_STA_LOST_IP
|
||||
IP_EVENT_STA_LOST_IP
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
当 IPV4 地址失效时,将引发此事件。
|
||||
|
||||
@ -1294,7 +1294,7 @@ Wi-Fi 供应商 IE 配置
|
||||
Wi-Fi Easy Connect™ (DPP)
|
||||
--------------------------
|
||||
|
||||
Wi-Fi Easy Connect\ :sup:`TM`(也称为设备配置协议)是一个安全且标准化的配置协议,用于配置 Wi-Fi 设备。更多信息请参考 :doc:`esp_dpp <../api-reference/network/esp_dpp>`。
|
||||
Wi-Fi Easy Connect\ :sup:`TM` (也称为设备配置协议)是一个安全且标准化的配置协议,用于配置 Wi-Fi 设备。更多信息请参考 :doc:`esp_dpp <../api-reference/network/esp_dpp>`。
|
||||
|
||||
WPA2-Enterprise
|
||||
+++++++++++++++++++++++++++++++++
|
||||
|
@ -81,6 +81,11 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参
|
||||
调用 ``esp_now_register_recv_cb`` 注册接收回调函数。当接收 ESP-NOW 数据时,需要调用接收回调函数。接收回调函数也在 Wi-Fi 任务任务中运行。因此,不要在回调函数中执行冗长的操作。
|
||||
相反,将必要的数据发布到队列,并交给优先级较低的任务处理。
|
||||
|
||||
配置 ESP-NOW 速率
|
||||
----------------------
|
||||
|
||||
调用 ``esp_wifi_config_espnow_rate`` 配置指定接口的 ESPNOW 速率。确保在配置速率之前使能接口。这个 API 应该在 ``esp_wifi_start()`` 之后调用。
|
||||
|
||||
API 参考
|
||||
-------------
|
||||
|
||||
|
@ -73,6 +73,7 @@ static struct {
|
||||
struct arg_int *data_size;
|
||||
struct arg_int *count;
|
||||
struct arg_int *tos;
|
||||
struct arg_int *ttl;
|
||||
struct arg_str *host;
|
||||
struct arg_end *end;
|
||||
} ping_args;
|
||||
@ -107,6 +108,10 @@ static int do_ping_cmd(int argc, char **argv)
|
||||
config.tos = (uint32_t)(ping_args.tos->ival[0]);
|
||||
}
|
||||
|
||||
if (ping_args.ttl->count > 0) {
|
||||
config.ttl = (uint32_t)(ping_args.ttl->ival[0]);
|
||||
}
|
||||
|
||||
// parse IP address
|
||||
struct sockaddr_in6 sock_addr6;
|
||||
ip_addr_t target_addr;
|
||||
@ -156,6 +161,7 @@ static void register_ping(void)
|
||||
ping_args.data_size = arg_int0("s", "size", "<n>", "Specify the number of data bytes to be sent");
|
||||
ping_args.count = arg_int0("c", "count", "<n>", "Stop after sending count packets");
|
||||
ping_args.tos = arg_int0("Q", "tos", "<n>", "Set Type of Service related bits in IP datagrams");
|
||||
ping_args.ttl = arg_int0("T", "ttl", "<n>", "Set Time to Live related bits in IP datagrams");
|
||||
ping_args.host = arg_str1(NULL, NULL, "<host>", "Host address");
|
||||
ping_args.end = arg_end(1);
|
||||
const esp_console_cmd_t ping_cmd = {
|
||||
|
@ -12,6 +12,7 @@ In order to create UDP client that communicates with UDP server example, choose
|
||||
There are many host-side tools which can be used to interact with the UDP/TCP server/client.
|
||||
One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets.
|
||||
Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands.
|
||||
If want to use this RECVINFO function, please enable LWIP_NETBUF_RECVINFO in menuconfig,this function can only resolve the destination address of IPV4.
|
||||
|
||||
In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples.
|
||||
|
||||
|
@ -57,6 +57,11 @@ static void udp_server_task(void *pvParameters)
|
||||
}
|
||||
ESP_LOGI(TAG, "Socket created");
|
||||
|
||||
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||
int enable = 1;
|
||||
lwip_setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &enable, sizeof(enable));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLE_IPV4) && defined(CONFIG_EXAMPLE_IPV6)
|
||||
if (addr_family == AF_INET6) {
|
||||
// Note that by default IPV6 binds to both protocols, it is must be disabled
|
||||
@ -73,13 +78,33 @@ static void udp_server_task(void *pvParameters)
|
||||
}
|
||||
ESP_LOGI(TAG, "Socket bound, port %d", PORT);
|
||||
|
||||
struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6
|
||||
socklen_t socklen = sizeof(source_addr);
|
||||
|
||||
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||
struct iovec iov;
|
||||
struct msghdr msg;
|
||||
struct cmsghdr *cmsgtmp;
|
||||
u8_t cmsg_buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
||||
|
||||
iov.iov_base = rx_buffer;
|
||||
iov.iov_len = sizeof(rx_buffer);
|
||||
msg.msg_control = cmsg_buf;
|
||||
msg.msg_controllen = sizeof(cmsg_buf);
|
||||
msg.msg_flags = 0;
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_name = (struct sockaddr *)&source_addr;
|
||||
msg.msg_namelen = socklen;
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
|
||||
ESP_LOGI(TAG, "Waiting for data");
|
||||
struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6
|
||||
socklen_t socklen = sizeof(source_addr);
|
||||
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||
int len = recvmsg(sock, &msg, 0);
|
||||
#else
|
||||
int len = recvfrom(sock, rx_buffer, sizeof(rx_buffer) - 1, 0, (struct sockaddr *)&source_addr, &socklen);
|
||||
|
||||
#endif
|
||||
// Error occurred during receiving
|
||||
if (len < 0) {
|
||||
ESP_LOGE(TAG, "recvfrom failed: errno %d", errno);
|
||||
@ -90,6 +115,15 @@ static void udp_server_task(void *pvParameters)
|
||||
// Get the sender's ip address as string
|
||||
if (source_addr.ss_family == PF_INET) {
|
||||
inet_ntoa_r(((struct sockaddr_in *)&source_addr)->sin_addr, addr_str, sizeof(addr_str) - 1);
|
||||
#if defined(CONFIG_LWIP_NETBUF_RECVINFO) && !defined(CONFIG_EXAMPLE_IPV6)
|
||||
for ( cmsgtmp = CMSG_FIRSTHDR(&msg); cmsgtmp != NULL; cmsgtmp = CMSG_NXTHDR(&msg, cmsgtmp) ) {
|
||||
if ( cmsgtmp->cmsg_level == IPPROTO_IP && cmsgtmp->cmsg_type == IP_PKTINFO ) {
|
||||
struct in_pktinfo *pktinfo;
|
||||
pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsgtmp);
|
||||
ESP_LOGI(TAG, "dest ip: %s\n", inet_ntoa(pktinfo->ipi_addr));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (source_addr.ss_family == PF_INET6) {
|
||||
inet6_ntoa_r(((struct sockaddr_in6 *)&source_addr)->sin6_addr, addr_str, sizeof(addr_str) - 1);
|
||||
}
|
||||
|
@ -17,4 +17,29 @@ menu "Example Configuration"
|
||||
default 5
|
||||
help
|
||||
Set the Maximum retry to avoid station reconnecting to the AP unlimited when the AP is really inexistent.
|
||||
|
||||
choice ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD
|
||||
prompt "WiFi Scan auth mode threshold"
|
||||
default ESP_WIFI_AUTH_OPEN
|
||||
help
|
||||
The weakest authmode to accept in the scan mode.
|
||||
|
||||
config ESP_WIFI_AUTH_OPEN
|
||||
bool "OPEN"
|
||||
config ESP_WIFI_AUTH_WEP
|
||||
bool "WEP"
|
||||
config ESP_WIFI_AUTH_WPA_PSK
|
||||
bool "WPA PSK"
|
||||
config ESP_WIFI_AUTH_WPA2_PSK
|
||||
bool "WPA2 PSK"
|
||||
config ESP_WIFI_AUTH_WPA_WPA2_PSK
|
||||
bool "WPA/WPA2 PSK"
|
||||
config ESP_WIFI_AUTH_WPA3_PSK
|
||||
bool "WPA3 PSK"
|
||||
config ESP_WIFI_AUTH_WPA2_WPA3_PSK
|
||||
bool "WPA2/WPA3 PSK"
|
||||
config ESP_WIFI_AUTH_WAPI_PSK
|
||||
bool "WAPI PSK"
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
@ -28,6 +28,24 @@
|
||||
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
|
||||
#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY
|
||||
|
||||
#if CONFIG_ESP_WIFI_AUTH_OPEN
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WEP
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WPA_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WPA2_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WPA3_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
|
||||
#elif CONFIG_ESP_WIFI_AUTH_WAPI_PSK
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
|
||||
#endif
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected*/
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
|
||||
@ -41,6 +59,7 @@ static const char *TAG = "wifi station";
|
||||
|
||||
static int s_retry_num = 0;
|
||||
|
||||
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
{
|
||||
@ -95,7 +114,7 @@ void wifi_init_sta(void)
|
||||
/* Setting a password implies station will connect to all security modes including WEP/WPA.
|
||||
* However these modes are deprecated and not advisable to be used. Incase your Access point
|
||||
* doesn't support WPA2, these mode can be enabled by commenting below line */
|
||||
.threshold.authmode = WIFI_AUTH_WPA2_PSK,
|
||||
.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
@ -123,11 +142,6 @@ void wifi_init_sta(void)
|
||||
} else {
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
|
||||
/* The event will not be processed after unregister */
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
|
||||
vEventGroupDelete(s_wifi_event_group);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
|
Reference in New Issue
Block a user