From f9fe524c327ea6b1cebe6759932ad76fdeeff02c Mon Sep 17 00:00:00 2001 From: shenjun Date: Fri, 12 Mar 2021 16:39:24 +0800 Subject: [PATCH] mesh/ps: network duty signaling --- components/esp_wifi/include/esp_mesh.h | 24 +++++++++++++------ components/esp_wifi/lib | 2 +- .../main/Kconfig.projbuild | 4 ++-- .../internal_communication/main/mesh_main.c | 4 ++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/components/esp_wifi/include/esp_mesh.h b/components/esp_wifi/include/esp_mesh.h index 4e098ec075..242e3ad8fb 100644 --- a/components/esp_wifi/include/esp_mesh.h +++ b/components/esp_wifi/include/esp_mesh.h @@ -212,6 +212,7 @@ typedef enum { router with the same SSID, this event will be posted and the new router information is attached. */ MESH_EVENT_PS_PARENT_DUTY, /**< parent duty */ MESH_EVENT_PS_CHILD_DUTY, /**< child duty */ + MESH_EVENT_PS_DEVICE_DUTY, /**< device duty */ MESH_EVENT_MAX, } mesh_event_id_t; @@ -237,8 +238,8 @@ typedef enum { MESH_PROTO_HTTP, /**< HTTP protocol */ MESH_PROTO_JSON, /**< JSON format */ MESH_PROTO_MQTT, /**< MQTT protocol */ - MESH_PROTO_AP, /**< IP network mesh communication of node's AP inteface */ - MESH_PROTO_STA, /**< IP network mesh communication of node's STA inteface */ + MESH_PROTO_AP, /**< IP network mesh communication of node's AP interface */ + MESH_PROTO_STA, /**< IP network mesh communication of node's STA interface */ } mesh_proto_t; /** @@ -1565,7 +1566,7 @@ bool esp_mesh_is_device_active(void); /** * @brief Set the device duty cycle and type - * - The range of dev_duty values is 1 to 100. The default value is 12. + * - The range of dev_duty values is 1 to 100. The default value is 10. * - dev_duty = 100, the PS will be stopped. * - dev_duty is better to not less than 5. * - dev_duty_type could be MESH_PS_DEVICE_DUTY_REQUEST or MESH_PS_DEVICE_DUTY_DEMAND. @@ -1596,7 +1597,7 @@ esp_err_t esp_mesh_get_active_duty_cycle(int* dev_duty, int* dev_duty_type); /** * @brief Set the network duty cycle, duration and rule - * - The range of nwk_duty values is 1 to 100. The default value is 12. + * - The range of nwk_duty values is 1 to 100. The default value is 10. * - nwk_duty is the network duty cycle the entire network or the up-link path will use. A device that successfully * sets the nwk_duty is known as a NWK-DUTY-MASTER. * - duration_mins specifies how long the specified nwk_duty will be used. Once duration_mins expires, the root will take @@ -1604,7 +1605,6 @@ esp_err_t esp_mesh_get_active_duty_cycle(int* dev_duty, int* dev_duty_type); * NWK-DUTY-MASTER again. * - duration_mins = (-1) represents nwk_duty will be used until a new NWK-DUTY-MASTER with a different nwk_duty appears. * - Only the root can set duration_mins to (-1). - * - applied_rule could be MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE or MESH_PS_NETWORK_DUTY_APPLIED_UPLINK. * - If applied_rule is set to MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE, the nwk_duty will be used by the entire network. * - If applied_rule is set to MESH_PS_NETWORK_DUTY_APPLIED_UPLINK, the nwk_duty will only be used by the up-link path nodes. * - The root does not accept MESH_PS_NETWORK_DUTY_APPLIED_UPLINK. @@ -1620,7 +1620,7 @@ esp_err_t esp_mesh_get_active_duty_cycle(int* dev_duty, int* dev_duty_type); * * @param[in] nwk_duty network duty cycle * @param[in] duration_mins duration (unit: minutes) - * @param[in] applied_rule MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE or MESH_PS_NETWORK_DUTY_APPLIED_UPLINK + * @param[in] applied_rule only support MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE * * @return * - ESP_OK @@ -1634,7 +1634,7 @@ esp_err_t esp_mesh_set_network_duty_cycle(int nwk_duty, int duration_mins, int a * @param[out] nwk_duty current network duty cycle * @param[out] duration_mins the duration of current nwk_duty * @param[out] dev_duty_type if it includes MESH_PS_DEVICE_DUTY_MASTER, this device is the current NWK-DUTY-MASTER. - * @param[out] applied_rule MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE or MESH_PS_NETWORK_DUTY_APPLIED_UPLINK + * @param[out] applied_rule MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE * * @return * - ESP_OK @@ -1656,6 +1656,16 @@ esp_err_t esp_mesh_get_network_duty_cycle(int* nwk_duty, int* duration_mins, int */ int esp_mesh_get_running_active_duty_cycle(void); +/** + * @brief Duty signaling + * + * @param[in] fwd_times the times of forwarding duty signaling packets + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_ps_duty_signaling(int fwd_times); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 8f951ea341..8aa2b95369 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 8f951ea341721767731e18a260847f6306fc68b7 +Subproject commit 8aa2b953691b35a64775efe48ebc4c22dfc96cd0 diff --git a/examples/mesh/internal_communication/main/Kconfig.projbuild b/examples/mesh/internal_communication/main/Kconfig.projbuild index 6dfb1dad43..c8aa139a17 100644 --- a/examples/mesh/internal_communication/main/Kconfig.projbuild +++ b/examples/mesh/internal_communication/main/Kconfig.projbuild @@ -50,7 +50,7 @@ menu "Example Configuration" int "Mesh PS device duty cycle" depends on MESH_ENABLE_PS range 1 100 - default 12 + default 10 help Mesh PS device duty cycle. @@ -58,7 +58,7 @@ menu "Example Configuration" int "Mesh PS network duty cycle" depends on MESH_ENABLE_PS range 1 100 - default 12 + default 10 help Mesh PS network duty cycle. diff --git a/examples/mesh/internal_communication/main/mesh_main.c b/examples/mesh/internal_communication/main/mesh_main.c index 6275acde3b..595ab3712b 100644 --- a/examples/mesh/internal_communication/main/mesh_main.c +++ b/examples/mesh/internal_communication/main/mesh_main.c @@ -438,9 +438,9 @@ void app_main(void) /* mesh start */ ESP_ERROR_CHECK(esp_mesh_start()); #ifdef CONFIG_MESH_ENABLE_PS - /* set the device active duty cycle. (default:12, MESH_PS_DEVICE_DUTY_REQUEST) */ + /* set the device active duty cycle. (default:10, MESH_PS_DEVICE_DUTY_REQUEST) */ ESP_ERROR_CHECK(esp_mesh_set_active_duty_cycle(CONFIG_MESH_PS_DEV_DUTY, CONFIG_MESH_PS_DEV_DUTY_TYPE)); - /* set the network active duty cycle. (default:12, -1, MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE) */ + /* set the network active duty cycle. (default:10, -1, MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE) */ ESP_ERROR_CHECK(esp_mesh_set_network_duty_cycle(CONFIG_MESH_PS_NWK_DUTY, CONFIG_MESH_PS_NWK_DUTY_DURATION, CONFIG_MESH_PS_NWK_DUTY_RULE)); #endif ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d, %s<%d>%s, ps:%d\n", esp_get_minimum_free_heap_size(),