mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
add mesh feature
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
COMPONENT_SRCDIRS := . hwcrypto
|
||||
LIBS ?=
|
||||
ifndef CONFIG_NO_BLOBS
|
||||
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy
|
||||
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
|
||||
endif
|
||||
|
||||
#Linker scripts used to link the final application.
|
||||
@@ -59,4 +59,4 @@ COMPONENT_EXTRA_CLEAN := esp32_out.ld
|
||||
|
||||
# disable stack protection in files which are involved in initialization of that feature
|
||||
stack_check.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
|
||||
cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
|
||||
cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
|
||||
|
@@ -13,6 +13,9 @@
|
||||
#if __has_include("esp_image_format.h")
|
||||
#include "esp_image_format.h"
|
||||
#endif
|
||||
#if __has_include("esp_mesh.h")
|
||||
#include "esp_mesh.h"
|
||||
#endif
|
||||
#if __has_include("esp_now.h")
|
||||
#include "esp_now.h"
|
||||
#endif
|
||||
@@ -288,6 +291,74 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||
# endif
|
||||
# ifdef ESP_ERR_ESPNOW_IF
|
||||
ERR_TBL_IT(ESP_ERR_ESPNOW_IF), /* 12396 0x306c Interface error */
|
||||
# endif
|
||||
// components/esp32/include/esp_err.h
|
||||
# ifdef ESP_ERR_MESH_BASE
|
||||
ERR_TBL_IT(ESP_ERR_MESH_BASE), /* 16384 0x4000 Starting number of MESH error codes */
|
||||
# endif
|
||||
// components/esp32/include/esp_mesh.h
|
||||
# ifdef ESP_ERR_MESH_WIFI_NOT_START
|
||||
ERR_TBL_IT(ESP_ERR_MESH_WIFI_NOT_START), /* 16385 0x4001 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NOT_INIT
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NOT_INIT), /* 16386 0x4002 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NOT_CONFIG
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NOT_CONFIG), /* 16387 0x4003 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NOT_START
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NOT_START), /* 16388 0x4004 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NOT_SUPPORT
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NOT_SUPPORT), /* 16389 0x4005 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NOT_ALLOWED
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NOT_ALLOWED), /* 16390 0x4006 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NO_MEMORY
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NO_MEMORY), /* 16391 0x4007 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_ARGUMENT
|
||||
ERR_TBL_IT(ESP_ERR_MESH_ARGUMENT), /* 16392 0x4008 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_EXCEED_MTU
|
||||
ERR_TBL_IT(ESP_ERR_MESH_EXCEED_MTU), /* 16393 0x4009 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_TIMEOUT
|
||||
ERR_TBL_IT(ESP_ERR_MESH_TIMEOUT), /* 16394 0x400a */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_DISCONNECTED
|
||||
ERR_TBL_IT(ESP_ERR_MESH_DISCONNECTED), /* 16395 0x400b */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_QUEUE_FAIL
|
||||
ERR_TBL_IT(ESP_ERR_MESH_QUEUE_FAIL), /* 16396 0x400c */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_QUEUE_FULL
|
||||
ERR_TBL_IT(ESP_ERR_MESH_QUEUE_FULL), /* 16397 0x400d */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NO_PARENT_FOUND
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NO_PARENT_FOUND), /* 16398 0x400e */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_NO_ROUTE_FOUND
|
||||
ERR_TBL_IT(ESP_ERR_MESH_NO_ROUTE_FOUND), /* 16399 0x400f */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_OPTION_NULL
|
||||
ERR_TBL_IT(ESP_ERR_MESH_OPTION_NULL), /* 16400 0x4010 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_OPTION_UNKNOWN
|
||||
ERR_TBL_IT(ESP_ERR_MESH_OPTION_UNKNOWN), /* 16401 0x4011 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_XON_NO_WINDOW
|
||||
ERR_TBL_IT(ESP_ERR_MESH_XON_NO_WINDOW), /* 16402 0x4012 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_INTERFACE
|
||||
ERR_TBL_IT(ESP_ERR_MESH_INTERFACE), /* 16403 0x4013 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_DISCARD_DUPLICATE
|
||||
ERR_TBL_IT(ESP_ERR_MESH_DISCARD_DUPLICATE), /* 16404 0x4014 */
|
||||
# endif
|
||||
# ifdef ESP_ERR_MESH_DISCARD
|
||||
ERR_TBL_IT(ESP_ERR_MESH_DISCARD), /* 16405 0x4015 */
|
||||
# endif
|
||||
// components/tcpip_adapter/include/tcpip_adapter.h
|
||||
# ifdef ESP_ERR_TCPIP_ADAPTER_BASE
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "esp_event.h"
|
||||
#include "esp_event_loop.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_mesh.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -76,6 +77,20 @@ esp_err_t esp_event_send(system_event_t *event)
|
||||
ESP_LOGE(TAG, "Event loop not initialized via esp_event_loop_init, but esp_event_send called");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (event->event_id == SYSTEM_EVENT_STA_GOT_IP || event->event_id == SYSTEM_EVENT_STA_LOST_IP) {
|
||||
if (g_mesh_event_cb) {
|
||||
mesh_event_t mevent;
|
||||
if (event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
|
||||
mevent.id = MESH_EVENT_ROOT_GOT_IP;
|
||||
memcpy(&mevent.info.got_ip, &event->event_info.got_ip, sizeof(system_event_sta_got_ip_t));
|
||||
} else {
|
||||
mevent.id = MESH_EVENT_ROOT_LOST_IP;
|
||||
}
|
||||
g_mesh_event_cb(mevent);
|
||||
}
|
||||
}
|
||||
|
||||
portBASE_TYPE ret = xQueueSendToBack(s_event_queue, event, 0);
|
||||
if (ret != pdPASS) {
|
||||
if (event) {
|
||||
|
@@ -59,3 +59,7 @@ const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs = {
|
||||
.sha256_vector = (esp_sha256_vector_t)fast_sha256_vector
|
||||
};
|
||||
|
||||
const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs = {
|
||||
.aes_128_encrypt = (esp_aes_128_encrypt_t)fast_aes_128_cbc_encrypt,
|
||||
.aes_128_decrypt = (esp_aes_128_decrypt_t)fast_aes_128_cbc_decrypt,
|
||||
};
|
||||
|
@@ -41,6 +41,7 @@ typedef int32_t esp_err_t;
|
||||
#define ESP_ERR_INVALID_MAC 0x10B
|
||||
|
||||
#define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */
|
||||
#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */
|
||||
|
||||
/**
|
||||
* @brief Returns string for esp_err_t error codes
|
||||
|
1201
components/esp32/include/esp_mesh.h
Normal file
1201
components/esp32/include/esp_mesh.h
Normal file
File diff suppressed because it is too large
Load Diff
162
components/esp32/include/esp_mesh_internal.h
Normal file
162
components/esp32/include/esp_mesh_internal.h
Normal file
@@ -0,0 +1,162 @@
|
||||
// Copyright 2017-2018 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.
|
||||
|
||||
#ifndef __ESP_MESH_INTERNAL_H__
|
||||
#define __ESP_MESH_INTERNAL_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************
|
||||
* Constants
|
||||
*******************************************************/
|
||||
|
||||
/*******************************************************
|
||||
* Structures
|
||||
*******************************************************/
|
||||
typedef struct {
|
||||
int scan; /**< minimum scan times before being a root, default:10 */
|
||||
int vote; /**< max vote times in self-healing, default:10000 */
|
||||
int fail; /**< parent selection fail times, if the scan times reach this value,
|
||||
will disconnect with associated children and join self-healing. default:60 */
|
||||
int monitor_ie; /**< acceptable times of parent ie change before update self ie, default:3 */
|
||||
} mesh_attempts_t;
|
||||
|
||||
typedef struct {
|
||||
int duration_ms; /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms,
|
||||
will switch to a better parent */
|
||||
int cnx_rssi; /* RSSI threshold for keeping a good connection with parent */
|
||||
int select_rssi; /* RSSI threshold for parent selection, should be a value greater than switch_rssi */
|
||||
int switch_rssi; /* RSSI threshold for action to reselect a better parent */
|
||||
int backoff_rssi; /* RSSI threshold for connecting to the root */
|
||||
} mesh_switch_parent_t;
|
||||
|
||||
/*******************************************************
|
||||
* Function Definitions
|
||||
*******************************************************/
|
||||
/**
|
||||
* @brief set mesh softAP beacon interval
|
||||
*
|
||||
* @param interval beacon interval(ms) (100ms ~ 60000ms)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
* - ESP_ERR_WIFI_ARG
|
||||
*/
|
||||
esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
|
||||
|
||||
/**
|
||||
* @brief get mesh softAP beacon interval
|
||||
*
|
||||
* @param interval beacon interval(ms)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_get_beacon_interval(int *interval_ms);
|
||||
|
||||
/**
|
||||
* @brief set attempts for mesh self-organized networking
|
||||
*
|
||||
* @param attempts
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts);
|
||||
|
||||
/**
|
||||
* @brief get attempts for mesh self-organized networking
|
||||
*
|
||||
* @param attempts
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts);
|
||||
|
||||
/**
|
||||
* @brief set parameters for parent switch
|
||||
*
|
||||
* @param paras parameters for parent switch
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
|
||||
|
||||
/**
|
||||
* @brief get parameters for parent switch
|
||||
*
|
||||
* @param paras parameters for parent switch
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
|
||||
|
||||
/**
|
||||
* @brief print the number of txQ waiting
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_print_txQ_waiting(void);
|
||||
|
||||
/**
|
||||
* @brief print the number of rxQ waiting
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_print_rxQ_waiting(void);
|
||||
|
||||
/**
|
||||
* @brief set passive scan time
|
||||
*
|
||||
* @param interval_ms passive scan time(ms)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
* - ESP_ERR_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_set_passive_scan_time(int time_ms);
|
||||
|
||||
/**
|
||||
* @brief get passive scan time
|
||||
*
|
||||
* @return interval_ms passive scan time(ms)
|
||||
*/
|
||||
int esp_mesh_get_passive_scan_time(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __ESP_MESH_INTERNAL_H__ */
|
@@ -300,6 +300,16 @@ typedef struct {
|
||||
esp_sha256_vector_t sha256_vector; /**< function used to do X.509v3 certificate parsing and processing */
|
||||
} wpa2_crypto_funcs_t;
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function structure used in mesh vendor IE encryption. The
|
||||
* structure can be set as software crypto or the crypto optimized by ESP32
|
||||
* hardware.
|
||||
*/
|
||||
typedef struct{
|
||||
esp_aes_128_encrypt_t aes_128_encrypt; /**< function used in mesh vendor IE encryption */
|
||||
esp_aes_128_decrypt_t aes_128_decrypt; /**< function used in mesh vendor IE decryption */
|
||||
} mesh_crypto_funcs_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Submodule components/esp32/lib updated: 152e29aa93...6657b2f40e
@@ -18,6 +18,10 @@
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_pm.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_mesh.h"
|
||||
|
||||
/* mesh event callback handler */
|
||||
mesh_event_cb_t g_mesh_event_cb = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static esp_pm_lock_handle_t s_wifi_modem_sleep_lock;
|
||||
|
Reference in New Issue
Block a user