mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
cpu/esp: NETOPT_CHANNEL for esp_wifi and esp_now
This commit is contained in:
parent
b441765908
commit
331313db4f
@ -1260,6 +1260,9 @@ the verification of the AP certificate is not yet supported.
|
||||
[ESP-NOW network interface](#esp32_esp_now_network_interface) (module `esp_now`)
|
||||
can be used simultaneously, for example, to realize a border router for
|
||||
a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP as value for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
\anchor esp32_esp_now_network_interface
|
||||
## <a name="esp32_esp_now_network_interface"> ESP-NOW Network Interface </a> [[TOC](#esp32_toc)]
|
||||
@ -1294,6 +1297,9 @@ ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication betw
|
||||
[Wifi network interface](#esp32_wifi_network_interface) (module `esp_wifi` or `esp_wifi_enterprise`)
|
||||
can be used simultaneously, for example, to realize a border router for
|
||||
a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
## <a name="esp32_other_network_devices"> Other Network Devices </a> [[TOC](#esp32_toc)]
|
||||
|
||||
|
||||
@ -710,6 +710,9 @@ make -C examples/gnrc_networking BOARD=...
|
||||
[ESP-NOW network interface](#esp8266_esp_now_network_interface)
|
||||
(module `esp_now`) can be used simultaneously, for example, to realize a
|
||||
border router for a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
\anchor esp8266_esp_now_network_interface
|
||||
## <a name="esp8266_esp_now_network_interface"> ESP-NOW Network Interface </a> [[TOC](#esp8266_toc)]
|
||||
@ -756,6 +759,9 @@ Parameter | Default | Description
|
||||
[Wifi network interface](#esp8266_wifi_network_interface) (module `esp_wifi`)
|
||||
can be used simultaneously, for example, to realize a border router for
|
||||
a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
# <a name="esp8266_preconfigured_devices"> Preconfigured Devices </a> [[TOC](#esp8266_toc)]
|
||||
|
||||
|
||||
@ -45,5 +45,8 @@ ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication betw
|
||||
Wifi network interface (module `esp_wifi`)
|
||||
can be used simultaneously, for example, to realize a border router for
|
||||
a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
*/
|
||||
|
||||
@ -636,6 +636,12 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
|
||||
res = sizeof(dev->addr);
|
||||
break;
|
||||
|
||||
case NETOPT_CHANNEL:
|
||||
CHECK_PARAM_RET(max_len >= sizeof(uint16_t), -EOVERFLOW);
|
||||
*((uint16_t *)val) = ESP_NOW_CHANNEL;
|
||||
res = sizeof(uint16_t);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG("%s: %s not supported\n", __func__, netopt2str(opt));
|
||||
break;
|
||||
|
||||
@ -114,4 +114,8 @@ the verification of the AP certificate is not yet supported.
|
||||
ESP-NOW network interface (module `esp_now`)
|
||||
can be used simultaneously, for example, to realize a border router for
|
||||
a mesh network which uses ESP-NOW.
|
||||
In this case the ESP-NOW interface must use the same channel as the AP of the
|
||||
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
|
||||
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
|
||||
|
||||
*/
|
||||
|
||||
@ -402,8 +402,12 @@ static const char *_esp_wifi_disc_reasons [] = {
|
||||
"HANDSHAKE_TIMEOUT" /* 204 */
|
||||
};
|
||||
|
||||
/* indicator whether the WiFi interface is started */
|
||||
static unsigned _esp_wifi_started = 0;
|
||||
|
||||
/* current channel used by the WiFi interface */
|
||||
static unsigned _esp_wifi_channel = 0;
|
||||
|
||||
/*
|
||||
* Event handler for esp system events.
|
||||
*/
|
||||
@ -440,6 +444,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
ESP_WIFI_LOG_INFO("WiFi connected to ssid %s, channel %d",
|
||||
event->event_info.connected.ssid,
|
||||
event->event_info.connected.channel);
|
||||
_esp_wifi_channel = event->event_info.connected.channel;
|
||||
|
||||
/* register RX callback function */
|
||||
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, _esp_wifi_rx_cb);
|
||||
@ -623,6 +628,10 @@ static int _esp_wifi_get(netdev_t *netdev, netopt_t opt, void *val, size_t max_l
|
||||
switch (opt) {
|
||||
case NETOPT_IS_WIRED:
|
||||
return -ENOTSUP;
|
||||
case NETOPT_CHANNEL:
|
||||
CHECK_PARAM_RET(max_len >= sizeof(uint16_t), -EOVERFLOW);
|
||||
*((uint16_t *)val) = _esp_wifi_channel;
|
||||
return sizeof(uint16_t);
|
||||
case NETOPT_ADDRESS:
|
||||
assert(max_len >= ETHERNET_ADDR_LEN);
|
||||
esp_wifi_get_mac(ESP_MAC_WIFI_STA,(uint8_t *)val);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user