mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'mesh/update_libs' into 'master'
mesh: update libs See merge request idf/esp-idf!2416
This commit is contained in:
commit
4d6e600f23
@ -359,6 +359,9 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_DISCARD
|
||||
ERR_TBL_IT(ESP_ERR_MESH_DISCARD), /* 16405 0x4015 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_VOTING
|
||||
ERR_TBL_IT(ESP_ERR_MESH_VOTING), /* 16406 0x4016 */
|
||||
# endif
|
||||
// components/tcpip_adapter/include/tcpip_adapter.h
|
||||
# ifdef ESP_ERR_TCPIP_ADAPTER_BASE
|
||||
|
@ -123,6 +123,7 @@ extern "C" {
|
||||
#define ESP_ERR_MESH_INTERFACE (ESP_ERR_MESH_BASE + 19) /**< low-level WiFi interface error */
|
||||
#define ESP_ERR_MESH_DISCARD_DUPLICATE (ESP_ERR_MESH_BASE + 20) /**< discard the packet due to the duplicate sequence number */
|
||||
#define ESP_ERR_MESH_DISCARD (ESP_ERR_MESH_BASE + 21) /**< discard the packet */
|
||||
#define ESP_ERR_MESH_VOTING (ESP_ERR_MESH_BASE + 22) /**< vote in progress */
|
||||
|
||||
/**
|
||||
* @brief flags used with esp_mesh_send() and esp_mesh_recv()
|
||||
@ -138,7 +139,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief option definitions for esp_mesh_send() and esp_mesh_recv()
|
||||
*/
|
||||
#define MESH_OPT_SEND_GROUP (7) /**< data transmission by group; used with esp_mesh_send() and must have payload */
|
||||
#define MESH_OPT_SEND_GROUP (7) /**< data transmission by group; used with esp_mesh_send() and shall have payload */
|
||||
#define MESH_OPT_RECV_DS_ADDR (8) /**< return a remote IP address; used with esp_mesh_send() and esp_mesh_recv() */
|
||||
|
||||
/*******************************************************
|
||||
@ -438,11 +439,21 @@ typedef struct {
|
||||
} mesh_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief vote
|
||||
* @brief vote address configuration
|
||||
*/
|
||||
typedef union {
|
||||
int attempts; /**< max vote attempts */
|
||||
mesh_addr_t rc_addr; /**< root address specified by users for API esp_mesh_waive_root() */
|
||||
int attempts; /**< max vote attempts before a new root is elected automatically by mesh network. (min:15, 15 by default) */
|
||||
mesh_addr_t rc_addr; /**< a new root address specified by users for API esp_mesh_waive_root() */
|
||||
} mesh_rc_config_t;
|
||||
|
||||
/**
|
||||
* @brief vote
|
||||
*/
|
||||
typedef struct {
|
||||
float percentage; /**< vote percentage threshold for approval of being a root */
|
||||
bool is_rc_specified; /**< if true, rc_addr shall be specified(Unimplemented).
|
||||
if false, attempts value shall be specified to make network start root election. */
|
||||
mesh_rc_config_t config; /**< vote address configuration */
|
||||
} mesh_vote_t;
|
||||
|
||||
/**
|
||||
@ -1080,8 +1091,8 @@ bool esp_mesh_is_root_conflicts_allowed(void);
|
||||
/**
|
||||
* @brief set group ID addresses
|
||||
*
|
||||
* @param addr pointer to new addresses
|
||||
* @param num number of addresses
|
||||
* @param addr pointer to new group ID addresses
|
||||
* @param num the number of group ID addresses
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
@ -1092,8 +1103,8 @@ esp_err_t esp_mesh_set_group_id(const mesh_addr_t *addr, const int num);
|
||||
/**
|
||||
* @brief delete group ID addresses
|
||||
*
|
||||
* @param addr pointer to deleted address
|
||||
* @param num number of addresses
|
||||
* @param addr pointer to deleted group ID address
|
||||
* @param num the number of group ID addresses
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
@ -1111,8 +1122,8 @@ int esp_mesh_get_group_num(void);
|
||||
/**
|
||||
* @brief get group ID addresses
|
||||
*
|
||||
* @param addr pointer to group address
|
||||
* @param num number of addresses
|
||||
* @param addr pointer to group ID addresses
|
||||
* @param num the number of group ID addresses
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
@ -1161,29 +1172,30 @@ esp_err_t esp_mesh_set_ie_crypto_funcs(const mesh_crypto_funcs_t *crypto_funcs);
|
||||
/**
|
||||
* @brief set mesh ie crypto key
|
||||
*
|
||||
* @attention This API should be called before esp_mesh_start().
|
||||
* @attention This API should be called after esp_mesh_set_config() and before esp_mesh_start().
|
||||
*
|
||||
* @param key crypto key
|
||||
* @param len the present implementation only supports 32
|
||||
* @param key ASCII crypto key
|
||||
* @param len length in bytes, range:8~64
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_NOT_ALLOWED
|
||||
* - ESP_ERR_MESH_NOT_CONFIG
|
||||
* - ESP_MESH_ERR_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_set_ie_crypto_key(const uint8_t *key, int len);
|
||||
esp_err_t esp_mesh_set_ie_crypto_key(const char *key, int len);
|
||||
|
||||
/**
|
||||
* @brief get mesh ie crypto key
|
||||
*
|
||||
* @param key crypto key
|
||||
* @param len the present implementation only supports 32
|
||||
* @param key ASCII crypto key
|
||||
* @param len length in bytes, range:8~64
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_MESH_ERR_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_get_ie_crypto_key(uint8_t *key, int len);
|
||||
esp_err_t esp_mesh_get_ie_crypto_key(char *key, int len);
|
||||
|
||||
/**
|
||||
* @brief set delay time before starting root healing
|
||||
@ -1215,7 +1227,7 @@ esp_err_t esp_mesh_set_event_cb(const mesh_event_cb_t event_cb);
|
||||
/**
|
||||
* @brief set Root Fixed setting for nodes
|
||||
* If Root Fixed setting of nodes is enabled, they won't compete to be a root.
|
||||
* If a scenario needs a fixed root, all nodes in this network must enable this setting.
|
||||
* If a scenario needs a fixed root, all nodes in this network shall enable this setting.
|
||||
*
|
||||
* @param enable enable or not
|
||||
*
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c1d0ac3625db5da98d1e9c64b8cd0d1261443810
|
||||
Subproject commit 0503727b12bf40e5578959c6d9478f25312cdc81
|
@ -99,12 +99,11 @@ void esp_mesh_p2p_tx_main(void *arg)
|
||||
|
||||
is_running = true;
|
||||
while (is_running) {
|
||||
/* normal nodes rather than root do nothing but print */
|
||||
/* non-root do nothing but print */
|
||||
if (!esp_mesh_is_root()) {
|
||||
ESP_LOGI(MESH_TAG, "layer:%d, rtableSize:%d, %s%s", mesh_layer,
|
||||
ESP_LOGI(MESH_TAG, "layer:%d, rtableSize:%d, %s", mesh_layer,
|
||||
esp_mesh_get_routing_table_size(),
|
||||
is_mesh_connected ? "CONNECT" : "DISCONNECT",
|
||||
esp_mesh_is_root() ? "<ROOT>" : "[NODE]");
|
||||
(is_mesh_connected && esp_mesh_is_root()) ? "ROOT" : is_mesh_connected ? "NODE" : "DISCONNECT");
|
||||
vTaskDelay(10 * 1000 / portTICK_RATE_MS);
|
||||
continue;
|
||||
}
|
||||
@ -213,15 +212,18 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
mesh_addr_t group;
|
||||
#endif
|
||||
static uint8_t last_layer = 0;
|
||||
static int disconnect_count = 0;
|
||||
ESP_LOGD(MESH_TAG, "esp_event_handler:%d", event.id);
|
||||
|
||||
switch (event.id) {
|
||||
case MESH_EVENT_STARTED:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STARTED>");
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STARTED>heap:%d", esp_get_free_heap_size());
|
||||
is_mesh_connected = false;
|
||||
mesh_layer = esp_mesh_get_layer();
|
||||
break;
|
||||
case MESH_EVENT_STOPPED:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STOPPED>");
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STOPPED>heap:%d", esp_get_free_heap_size());
|
||||
is_mesh_connected = false;
|
||||
mesh_layer = esp_mesh_get_layer();
|
||||
break;
|
||||
case MESH_EVENT_CHILD_CONNECTED:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_CHILD_CONNECTED>aid:%d, "MACSTR"",
|
||||
@ -238,28 +240,24 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
event.info.routing_table.rt_size_change,
|
||||
event.info.routing_table.rt_size_new);
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROUTING_TABLE_REMOVE:
|
||||
ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_REMOVE>remove %d, new:%d",
|
||||
event.info.routing_table.rt_size_change,
|
||||
event.info.routing_table.rt_size_new);
|
||||
break;
|
||||
|
||||
case MESH_EVENT_NO_PARNET_FOUND:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARNET_FOUND>scan times:%d",
|
||||
event.info.no_parent.scan_times);
|
||||
/* TODO handler for the failure */
|
||||
break;
|
||||
|
||||
case MESH_EVENT_PARENT_CONNECTED:
|
||||
mesh_layer = event.info.connected.self_layer;
|
||||
memcpy(&mesh_parent_addr.addr, event.info.connected.connected.bssid, 6);
|
||||
ESP_LOGI(MESH_TAG,
|
||||
"<MESH_EVENT_PARENT_CONNECTED>layer:%d-->%d, parent:"MACSTR"%s, discnx:%d",
|
||||
"<MESH_EVENT_PARENT_CONNECTED>layer:%d-->%d, parent:"MACSTR"%s",
|
||||
last_layer, mesh_layer, MAC2STR(mesh_parent_addr.addr),
|
||||
esp_mesh_is_root() ? "<ROOT>" :
|
||||
(mesh_layer == 2) ? "<layer2>" : "", disconnect_count);
|
||||
disconnect_count = 0;
|
||||
(mesh_layer == 2) ? "<layer2>" : "");
|
||||
last_layer = mesh_layer;
|
||||
mesh_connected_indicator(mesh_layer);
|
||||
is_mesh_connected = true;
|
||||
@ -277,18 +275,13 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
#endif
|
||||
esp_mesh_comm_p2p_start();
|
||||
break;
|
||||
|
||||
case MESH_EVENT_PARENT_DISCONNECTED:
|
||||
ESP_LOGI(MESH_TAG,
|
||||
"<MESH_EVENT_PARENT_DISCONNECTED>reason:%d, count:%d",
|
||||
event.info.disconnected.reason, disconnect_count);
|
||||
if (event.info.disconnected.reason == 201) {
|
||||
disconnect_count++;
|
||||
}
|
||||
"<MESH_EVENT_PARENT_DISCONNECTED>reason:%d",
|
||||
event.info.disconnected.reason);
|
||||
is_mesh_connected = false;
|
||||
mesh_disconnected_indicator();
|
||||
break;
|
||||
|
||||
case MESH_EVENT_LAYER_CHANGE:
|
||||
mesh_layer = event.info.layer_change.new_layer;
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_LAYER_CHANGE>layer:%d-->%d%s",
|
||||
@ -298,12 +291,10 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
last_layer = mesh_layer;
|
||||
mesh_connected_indicator(mesh_layer);
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_ADDRESS:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_ADDRESS>rc_addr:"MACSTR"",
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_ADDRESS>root address:"MACSTR"",
|
||||
MAC2STR(event.info.root_addr.addr));
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_GOT_IP:
|
||||
/* root starts to connect to server */
|
||||
ESP_LOGI(MESH_TAG,
|
||||
@ -312,11 +303,9 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
IP2STR(&event.info.got_ip.ip_info.netmask),
|
||||
IP2STR(&event.info.got_ip.ip_info.gw));
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_LOST_IP:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_LOST_IP>");
|
||||
break;
|
||||
|
||||
case MESH_EVENT_VOTE_STARTED:
|
||||
ESP_LOGI(MESH_TAG,
|
||||
"<MESH_EVENT_VOTE_STARTED>attempts:%d, reason:%d, rc_addr:"MACSTR"",
|
||||
@ -324,34 +313,32 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||
event.info.vote_started.reason,
|
||||
MAC2STR(event.info.vote_started.rc_addr.addr));
|
||||
break;
|
||||
|
||||
case MESH_EVENT_VOTE_STOPPED:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_VOTE_DONE>");
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_VOTE_STOPPED>");
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_SWITCH_REQ:
|
||||
ESP_LOGI(MESH_TAG,
|
||||
"<MESH_EVENT_ROOT_SWITCH_REQ>reason:%d, rc_addr:"MACSTR"",
|
||||
event.info.switch_req.reason,
|
||||
MAC2STR( event.info.switch_req.rc_addr.addr));
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_SWITCH_ACK:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_SWITCH_ACK>");
|
||||
/* new root */
|
||||
mesh_layer = esp_mesh_get_layer();
|
||||
esp_mesh_get_parent_bssid(&mesh_parent_addr);
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_SWITCH_ACK>layer:%d, parent:"MACSTR"", mesh_layer, MAC2STR(mesh_parent_addr.addr));
|
||||
break;
|
||||
|
||||
case MESH_EVENT_TODS_STATE:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_TODS_REACHABLE>state:%d",
|
||||
event.info.toDS_state);
|
||||
break;
|
||||
|
||||
case MESH_EVENT_ROOT_FIXED:
|
||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_FIXED>%s",
|
||||
event.info.root_fixed.is_fixed ? "fixed" : "not fixed");
|
||||
break;
|
||||
|
||||
default:
|
||||
ESP_LOGI(MESH_TAG, "unknown");
|
||||
ESP_LOGI(MESH_TAG, "unknown id:%d", event.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user