From 26fa8260b1f24061b41bf716256c459ed688eef1 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Thu, 17 Mar 2022 14:37:10 +0800 Subject: [PATCH] Doc:update wifi api docs * Add documents related to espnow config rate * Optimization set dns server api description --- components/esp_netif/include/esp_netif.h | 5 +-- components/esp_wifi/include/esp_now.h | 32 ++++++++++++-------- components/esp_wifi/include/esp_wifi.h | 14 --------- docs/en/api-reference/network/esp_now.rst | 5 +++ docs/zh_CN/api-reference/network/esp_now.rst | 5 +++ tools/ci/check_copyright_ignore.txt | 1 - 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/components/esp_netif/include/esp_netif.h b/components/esp_netif/include/esp_netif.h index 5cefaea813..d0d076626e 100644 --- a/components/esp_netif/include/esp_netif.h +++ b/components/esp_netif/include/esp_netif.h @@ -614,9 +614,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 diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index de41a87936..d7ffe2bf93 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -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 * diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index e5a307f4dd..c4fc1bfbf6 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1208,20 +1208,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. * diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index 7b6b8135f3..2edda4de18 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -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()``. + Application Examples -------------------- diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index 27d39866e6..34a001215a 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -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()`` 之后调用。 + 应用示例 ---------- diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 88a48f2230..8f4aba3d94 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -711,7 +711,6 @@ components/esp_timer/test/test_esp_timer_light_sleep.c components/esp_timer/test/test_ets_timer.c components/esp_wifi/include/esp_coexist_adapter.h components/esp_wifi/include/esp_mesh_internal.h -components/esp_wifi/include/esp_now.h components/esp_wifi/include/esp_private/esp_wifi_private.h components/esp_wifi/include/esp_private/esp_wifi_types_private.h components/esp_wifi/include/esp_private/wifi_types.h