Skip to content

Commit 89369b6

Browse files
committed
Merge branch 'feature/mesh' into 'master'
add mesh feature See merge request idf/esp-idf!1991
2 parents c842725 + 2984cdb commit 89369b6

30 files changed

+2522
-3
lines changed

components/esp32/component.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
COMPONENT_SRCDIRS := . hwcrypto
66
LIBS ?=
77
ifndef CONFIG_NO_BLOBS
8-
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy
8+
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
99
endif
1010

1111
#Linker scripts used to link the final application.
@@ -59,4 +59,4 @@ COMPONENT_EXTRA_CLEAN := esp32_out.ld
5959

6060
# disable stack protection in files which are involved in initialization of that feature
6161
stack_check.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
62-
cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
62+
cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))

components/esp32/esp_err_to_name.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#if __has_include("esp_image_format.h")
1414
#include "esp_image_format.h"
1515
#endif
16+
#if __has_include("esp_mesh.h")
17+
#include "esp_mesh.h"
18+
#endif
1619
#if __has_include("esp_now.h")
1720
#include "esp_now.h"
1821
#endif
@@ -288,6 +291,74 @@ static const esp_err_msg_t esp_err_msg_table[] = {
288291
# endif
289292
# ifdef ESP_ERR_ESPNOW_IF
290293
ERR_TBL_IT(ESP_ERR_ESPNOW_IF), /* 12396 0x306c Interface error */
294+
# endif
295+
// components/esp32/include/esp_err.h
296+
# ifdef ESP_ERR_MESH_BASE
297+
ERR_TBL_IT(ESP_ERR_MESH_BASE), /* 16384 0x4000 Starting number of MESH error codes */
298+
# endif
299+
// components/esp32/include/esp_mesh.h
300+
# ifdef ESP_ERR_MESH_WIFI_NOT_START
301+
ERR_TBL_IT(ESP_ERR_MESH_WIFI_NOT_START), /* 16385 0x4001 */
302+
# endif
303+
# ifdef ESP_ERR_MESH_NOT_INIT
304+
ERR_TBL_IT(ESP_ERR_MESH_NOT_INIT), /* 16386 0x4002 */
305+
# endif
306+
# ifdef ESP_ERR_MESH_NOT_CONFIG
307+
ERR_TBL_IT(ESP_ERR_MESH_NOT_CONFIG), /* 16387 0x4003 */
308+
# endif
309+
# ifdef ESP_ERR_MESH_NOT_START
310+
ERR_TBL_IT(ESP_ERR_MESH_NOT_START), /* 16388 0x4004 */
311+
# endif
312+
# ifdef ESP_ERR_MESH_NOT_SUPPORT
313+
ERR_TBL_IT(ESP_ERR_MESH_NOT_SUPPORT), /* 16389 0x4005 */
314+
# endif
315+
# ifdef ESP_ERR_MESH_NOT_ALLOWED
316+
ERR_TBL_IT(ESP_ERR_MESH_NOT_ALLOWED), /* 16390 0x4006 */
317+
# endif
318+
# ifdef ESP_ERR_MESH_NO_MEMORY
319+
ERR_TBL_IT(ESP_ERR_MESH_NO_MEMORY), /* 16391 0x4007 */
320+
# endif
321+
# ifdef ESP_ERR_MESH_ARGUMENT
322+
ERR_TBL_IT(ESP_ERR_MESH_ARGUMENT), /* 16392 0x4008 */
323+
# endif
324+
# ifdef ESP_ERR_MESH_EXCEED_MTU
325+
ERR_TBL_IT(ESP_ERR_MESH_EXCEED_MTU), /* 16393 0x4009 */
326+
# endif
327+
# ifdef ESP_ERR_MESH_TIMEOUT
328+
ERR_TBL_IT(ESP_ERR_MESH_TIMEOUT), /* 16394 0x400a */
329+
# endif
330+
# ifdef ESP_ERR_MESH_DISCONNECTED
331+
ERR_TBL_IT(ESP_ERR_MESH_DISCONNECTED), /* 16395 0x400b */
332+
# endif
333+
# ifdef ESP_ERR_MESH_QUEUE_FAIL
334+
ERR_TBL_IT(ESP_ERR_MESH_QUEUE_FAIL), /* 16396 0x400c */
335+
# endif
336+
# ifdef ESP_ERR_MESH_QUEUE_FULL
337+
ERR_TBL_IT(ESP_ERR_MESH_QUEUE_FULL), /* 16397 0x400d */
338+
# endif
339+
# ifdef ESP_ERR_MESH_NO_PARENT_FOUND
340+
ERR_TBL_IT(ESP_ERR_MESH_NO_PARENT_FOUND), /* 16398 0x400e */
341+
# endif
342+
# ifdef ESP_ERR_MESH_NO_ROUTE_FOUND
343+
ERR_TBL_IT(ESP_ERR_MESH_NO_ROUTE_FOUND), /* 16399 0x400f */
344+
# endif
345+
# ifdef ESP_ERR_MESH_OPTION_NULL
346+
ERR_TBL_IT(ESP_ERR_MESH_OPTION_NULL), /* 16400 0x4010 */
347+
# endif
348+
# ifdef ESP_ERR_MESH_OPTION_UNKNOWN
349+
ERR_TBL_IT(ESP_ERR_MESH_OPTION_UNKNOWN), /* 16401 0x4011 */
350+
# endif
351+
# ifdef ESP_ERR_MESH_XON_NO_WINDOW
352+
ERR_TBL_IT(ESP_ERR_MESH_XON_NO_WINDOW), /* 16402 0x4012 */
353+
# endif
354+
# ifdef ESP_ERR_MESH_INTERFACE
355+
ERR_TBL_IT(ESP_ERR_MESH_INTERFACE), /* 16403 0x4013 */
356+
# endif
357+
# ifdef ESP_ERR_MESH_DISCARD_DUPLICATE
358+
ERR_TBL_IT(ESP_ERR_MESH_DISCARD_DUPLICATE), /* 16404 0x4014 */
359+
# endif
360+
# ifdef ESP_ERR_MESH_DISCARD
361+
ERR_TBL_IT(ESP_ERR_MESH_DISCARD), /* 16405 0x4015 */
291362
# endif
292363
// components/tcpip_adapter/include/tcpip_adapter.h
293364
# ifdef ESP_ERR_TCPIP_ADAPTER_BASE

components/esp32/event_loop.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "esp_event.h"
2222
#include "esp_event_loop.h"
2323
#include "esp_task.h"
24+
#include "esp_mesh.h"
2425

2526
#include "freertos/FreeRTOS.h"
2627
#include "freertos/task.h"
@@ -76,6 +77,20 @@ esp_err_t esp_event_send(system_event_t *event)
7677
ESP_LOGE(TAG, "Event loop not initialized via esp_event_loop_init, but esp_event_send called");
7778
return ESP_ERR_INVALID_STATE;
7879
}
80+
81+
if (event->event_id == SYSTEM_EVENT_STA_GOT_IP || event->event_id == SYSTEM_EVENT_STA_LOST_IP) {
82+
if (g_mesh_event_cb) {
83+
mesh_event_t mevent;
84+
if (event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
85+
mevent.id = MESH_EVENT_ROOT_GOT_IP;
86+
memcpy(&mevent.info.got_ip, &event->event_info.got_ip, sizeof(system_event_sta_got_ip_t));
87+
} else {
88+
mevent.id = MESH_EVENT_ROOT_LOST_IP;
89+
}
90+
g_mesh_event_cb(mevent);
91+
}
92+
}
93+
7994
portBASE_TYPE ret = xQueueSendToBack(s_event_queue, event, 0);
8095
if (ret != pdPASS) {
8196
if (event) {

components/esp32/fast_crypto_ops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs = {
5959
.sha256_vector = (esp_sha256_vector_t)fast_sha256_vector
6060
};
6161

62+
const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs = {
63+
.aes_128_encrypt = (esp_aes_128_encrypt_t)fast_aes_128_cbc_encrypt,
64+
.aes_128_decrypt = (esp_aes_128_decrypt_t)fast_aes_128_cbc_decrypt,
65+
};

components/esp32/include/esp_err.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef int32_t esp_err_t;
4141
#define ESP_ERR_INVALID_MAC 0x10B
4242

4343
#define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */
44+
#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */
4445

4546
/**
4647
* @brief Returns string for esp_err_t error codes

0 commit comments

Comments
 (0)