Chapter 2. API Reference
• [in] select_parent: Only valid when self-organized networking is enabled.
– if select_parent is set to true, the root will give up its mesh root status and search for a new
parent like other non-root devices.
bool esp_mesh_get_self_organized(void)
Return whether enable self-organized networking or not.
Return true/false
esp_err_t
esp_mesh_waive_root(const
Cause the root device to give up (waive) its mesh root status.
• A device is elected root primarily based on RSSI from the external router.
• If external router conditions change, users can call this API to perform a root switch.
• In this API, users could specify a desired root address to replace itself or specify an attempts value to
ask current root to initiate a new round of voting. During the voting, a better root candidate would be
expected to find to replace the current one.
• If no desired root candidate, the vote will try a specified number of attempts (at least 15). If no better
root candidate is found, keep the current one. If a better candidate is found, the new better one will send
a root switch request to the current root, current root will respond with a root switch acknowledgment.
• After that, the new candidate will connect to the router to be a new root, the previous root will disconnect
with the router and choose another parent instead.
Root switch is completed with minimal disruption to the whole mesh network.
Attention This API is only called by the root.
Return
• ESP_OK
• ESP_ERR_MESH_QUEUE_FULL
• ESP_ERR_MESH_DISCARD
• ESP_FAIL
Parameters
• [in] vote: vote configuration
– If this parameter is set NULL, the vote will perform the default 15 times.
– Field percentage threshold is 0.9 by default.
– Field is_rc_specified shall be false.
– Field attempts shall be at least 15 times.
• [in] reason: only accept MESH_VOTE_REASON_ROOT_INITIATED for now
esp_err_t
esp_mesh_set_vote_percentage(float percentage)
Set vote percentage threshold for approval of being a root (default:0.9)
• During the networking, only obtaining vote percentage reaches this threshold, the device could be a root.
Attention This API shall be called before mesh is started.
Return
• ESP_OK
• ESP_FAIL
Parameters
• [in] percentage: vote percentage threshold
float esp_mesh_get_vote_percentage(void)
Get vote percentage threshold for approval of being a root.
Return percentage threshold
esp_err_t
esp_mesh_set_ap_assoc_expire(int seconds)
Set mesh softAP associate expired time (default:10 seconds)
• If mesh softAP hasn't received any data from an associated child within this time, mesh softAP will
take this child inactive and disassociate it.
• If mesh softAP is encrypted, this value should be set a greater value, such as 30 seconds.
Return
• ESP_OK
Espressif Systems
mesh_vote_t
*vote, int reason)
147
Submit Document Feedback
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?