mesh: update libs
1. use pbkdf2_sha1() to encrypted mesh ie key. 2. fix esp_mesh_waive_root(). 3. fix esp_mesh_stop(). 4. fix xon issues.
This commit is contained in:
parent
1f7b41e206
commit
bb9e73c864
4 changed files with 54 additions and 52 deletions
|
@ -359,6 +359,9 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||||
# endif
|
# endif
|
||||||
# ifdef ESP_ERR_MESH_DISCARD
|
# ifdef ESP_ERR_MESH_DISCARD
|
||||||
ERR_TBL_IT(ESP_ERR_MESH_DISCARD), /* 16405 0x4015 */
|
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
|
# endif
|
||||||
// components/tcpip_adapter/include/tcpip_adapter.h
|
// components/tcpip_adapter/include/tcpip_adapter.h
|
||||||
# ifdef ESP_ERR_TCPIP_ADAPTER_BASE
|
# 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_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_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_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()
|
* @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()
|
* @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() */
|
#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;
|
} mesh_cfg_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief vote
|
* @brief vote address configuration
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
int attempts; /**< max vote attempts */
|
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; /**< root address specified by users for API esp_mesh_waive_root() */
|
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;
|
} mesh_vote_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1080,8 +1091,8 @@ bool esp_mesh_is_root_conflicts_allowed(void);
|
||||||
/**
|
/**
|
||||||
* @brief set group ID addresses
|
* @brief set group ID addresses
|
||||||
*
|
*
|
||||||
* @param addr pointer to new addresses
|
* @param addr pointer to new group ID addresses
|
||||||
* @param num number of addresses
|
* @param num the number of group ID addresses
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK
|
* - 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
|
* @brief delete group ID addresses
|
||||||
*
|
*
|
||||||
* @param addr pointer to deleted address
|
* @param addr pointer to deleted group ID address
|
||||||
* @param num number of addresses
|
* @param num the number of group ID addresses
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK
|
* - ESP_OK
|
||||||
|
@ -1111,8 +1122,8 @@ int esp_mesh_get_group_num(void);
|
||||||
/**
|
/**
|
||||||
* @brief get group ID addresses
|
* @brief get group ID addresses
|
||||||
*
|
*
|
||||||
* @param addr pointer to group address
|
* @param addr pointer to group ID addresses
|
||||||
* @param num number of addresses
|
* @param num the number of group ID addresses
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK
|
* - 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
|
* @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 key ASCII crypto key
|
||||||
* @param len the present implementation only supports 32
|
* @param len length in bytes, range:8~64
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK
|
* - ESP_OK
|
||||||
* - ESP_ERR_MESH_NOT_ALLOWED
|
* - ESP_ERR_MESH_NOT_ALLOWED
|
||||||
|
* - ESP_ERR_MESH_NOT_CONFIG
|
||||||
* - ESP_MESH_ERR_ARGUMENT
|
* - 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
|
* @brief get mesh ie crypto key
|
||||||
*
|
*
|
||||||
* @param key crypto key
|
* @param key ASCII crypto key
|
||||||
* @param len the present implementation only supports 32
|
* @param len length in bytes, range:8~64
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK
|
* - ESP_OK
|
||||||
* - ESP_MESH_ERR_ARGUMENT
|
* - 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
|
* @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
|
* @brief set Root Fixed setting for nodes
|
||||||
* If Root Fixed setting of nodes is enabled, they won't compete to be a root.
|
* 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
|
* @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;
|
is_running = true;
|
||||||
while (is_running) {
|
while (is_running) {
|
||||||
/* normal nodes rather than root do nothing but print */
|
/* non-root do nothing but print */
|
||||||
if (!esp_mesh_is_root()) {
|
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(),
|
esp_mesh_get_routing_table_size(),
|
||||||
is_mesh_connected ? "CONNECT" : "DISCONNECT",
|
(is_mesh_connected && esp_mesh_is_root()) ? "ROOT" : is_mesh_connected ? "NODE" : "DISCONNECT");
|
||||||
esp_mesh_is_root() ? "<ROOT>" : "[NODE]");
|
|
||||||
vTaskDelay(10 * 1000 / portTICK_RATE_MS);
|
vTaskDelay(10 * 1000 / portTICK_RATE_MS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -213,15 +212,18 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||||
mesh_addr_t group;
|
mesh_addr_t group;
|
||||||
#endif
|
#endif
|
||||||
static uint8_t last_layer = 0;
|
static uint8_t last_layer = 0;
|
||||||
static int disconnect_count = 0;
|
|
||||||
ESP_LOGD(MESH_TAG, "esp_event_handler:%d", event.id);
|
ESP_LOGD(MESH_TAG, "esp_event_handler:%d", event.id);
|
||||||
|
|
||||||
switch (event.id) {
|
switch (event.id) {
|
||||||
case MESH_EVENT_STARTED:
|
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;
|
break;
|
||||||
case MESH_EVENT_STOPPED:
|
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;
|
break;
|
||||||
case MESH_EVENT_CHILD_CONNECTED:
|
case MESH_EVENT_CHILD_CONNECTED:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_CHILD_CONNECTED>aid:%d, "MACSTR"",
|
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_change,
|
||||||
event.info.routing_table.rt_size_new);
|
event.info.routing_table.rt_size_new);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROUTING_TABLE_REMOVE:
|
case MESH_EVENT_ROUTING_TABLE_REMOVE:
|
||||||
ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_REMOVE>remove %d, new:%d",
|
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_change,
|
||||||
event.info.routing_table.rt_size_new);
|
event.info.routing_table.rt_size_new);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_NO_PARNET_FOUND:
|
case MESH_EVENT_NO_PARNET_FOUND:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARNET_FOUND>scan times:%d",
|
ESP_LOGI(MESH_TAG, "<MESH_EVENT_NO_PARNET_FOUND>scan times:%d",
|
||||||
event.info.no_parent.scan_times);
|
event.info.no_parent.scan_times);
|
||||||
/* TODO handler for the failure */
|
/* TODO handler for the failure */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_PARENT_CONNECTED:
|
case MESH_EVENT_PARENT_CONNECTED:
|
||||||
mesh_layer = event.info.connected.self_layer;
|
mesh_layer = event.info.connected.self_layer;
|
||||||
memcpy(&mesh_parent_addr.addr, event.info.connected.connected.bssid, 6);
|
memcpy(&mesh_parent_addr.addr, event.info.connected.connected.bssid, 6);
|
||||||
ESP_LOGI(MESH_TAG,
|
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),
|
last_layer, mesh_layer, MAC2STR(mesh_parent_addr.addr),
|
||||||
esp_mesh_is_root() ? "<ROOT>" :
|
esp_mesh_is_root() ? "<ROOT>" :
|
||||||
(mesh_layer == 2) ? "<layer2>" : "", disconnect_count);
|
(mesh_layer == 2) ? "<layer2>" : "");
|
||||||
disconnect_count = 0;
|
|
||||||
last_layer = mesh_layer;
|
last_layer = mesh_layer;
|
||||||
mesh_connected_indicator(mesh_layer);
|
mesh_connected_indicator(mesh_layer);
|
||||||
is_mesh_connected = true;
|
is_mesh_connected = true;
|
||||||
|
@ -277,18 +275,13 @@ void esp_mesh_event_handler(mesh_event_t event)
|
||||||
#endif
|
#endif
|
||||||
esp_mesh_comm_p2p_start();
|
esp_mesh_comm_p2p_start();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_PARENT_DISCONNECTED:
|
case MESH_EVENT_PARENT_DISCONNECTED:
|
||||||
ESP_LOGI(MESH_TAG,
|
ESP_LOGI(MESH_TAG,
|
||||||
"<MESH_EVENT_PARENT_DISCONNECTED>reason:%d, count:%d",
|
"<MESH_EVENT_PARENT_DISCONNECTED>reason:%d",
|
||||||
event.info.disconnected.reason, disconnect_count);
|
event.info.disconnected.reason);
|
||||||
if (event.info.disconnected.reason == 201) {
|
|
||||||
disconnect_count++;
|
|
||||||
}
|
|
||||||
is_mesh_connected = false;
|
is_mesh_connected = false;
|
||||||
mesh_disconnected_indicator();
|
mesh_disconnected_indicator();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_LAYER_CHANGE:
|
case MESH_EVENT_LAYER_CHANGE:
|
||||||
mesh_layer = event.info.layer_change.new_layer;
|
mesh_layer = event.info.layer_change.new_layer;
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_LAYER_CHANGE>layer:%d-->%d%s",
|
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;
|
last_layer = mesh_layer;
|
||||||
mesh_connected_indicator(mesh_layer);
|
mesh_connected_indicator(mesh_layer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_ADDRESS:
|
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));
|
MAC2STR(event.info.root_addr.addr));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_GOT_IP:
|
case MESH_EVENT_ROOT_GOT_IP:
|
||||||
/* root starts to connect to server */
|
/* root starts to connect to server */
|
||||||
ESP_LOGI(MESH_TAG,
|
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.netmask),
|
||||||
IP2STR(&event.info.got_ip.ip_info.gw));
|
IP2STR(&event.info.got_ip.ip_info.gw));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_LOST_IP:
|
case MESH_EVENT_ROOT_LOST_IP:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_LOST_IP>");
|
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_LOST_IP>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_VOTE_STARTED:
|
case MESH_EVENT_VOTE_STARTED:
|
||||||
ESP_LOGI(MESH_TAG,
|
ESP_LOGI(MESH_TAG,
|
||||||
"<MESH_EVENT_VOTE_STARTED>attempts:%d, reason:%d, rc_addr:"MACSTR"",
|
"<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,
|
event.info.vote_started.reason,
|
||||||
MAC2STR(event.info.vote_started.rc_addr.addr));
|
MAC2STR(event.info.vote_started.rc_addr.addr));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_VOTE_STOPPED:
|
case MESH_EVENT_VOTE_STOPPED:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_VOTE_DONE>");
|
ESP_LOGI(MESH_TAG, "<MESH_EVENT_VOTE_STOPPED>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_SWITCH_REQ:
|
case MESH_EVENT_ROOT_SWITCH_REQ:
|
||||||
ESP_LOGI(MESH_TAG,
|
ESP_LOGI(MESH_TAG,
|
||||||
"<MESH_EVENT_ROOT_SWITCH_REQ>reason:%d, rc_addr:"MACSTR"",
|
"<MESH_EVENT_ROOT_SWITCH_REQ>reason:%d, rc_addr:"MACSTR"",
|
||||||
event.info.switch_req.reason,
|
event.info.switch_req.reason,
|
||||||
MAC2STR( event.info.switch_req.rc_addr.addr));
|
MAC2STR( event.info.switch_req.rc_addr.addr));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_SWITCH_ACK:
|
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;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_TODS_STATE:
|
case MESH_EVENT_TODS_STATE:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_TODS_REACHABLE>state:%d",
|
ESP_LOGI(MESH_TAG, "<MESH_EVENT_TODS_REACHABLE>state:%d",
|
||||||
event.info.toDS_state);
|
event.info.toDS_state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESH_EVENT_ROOT_FIXED:
|
case MESH_EVENT_ROOT_FIXED:
|
||||||
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_FIXED>%s",
|
ESP_LOGI(MESH_TAG, "<MESH_EVENT_ROOT_FIXED>%s",
|
||||||
event.info.root_fixed.is_fixed ? "fixed" : "not fixed");
|
event.info.root_fixed.is_fixed ? "fixed" : "not fixed");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ESP_LOGI(MESH_TAG, "unknown");
|
ESP_LOGI(MESH_TAG, "unknown id:%d", event.id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue