From d64a93d6cab4a9934c64e4b3b9562682302f9c10 Mon Sep 17 00:00:00 2001 From: JarmouniA Date: Tue, 5 Oct 2021 18:47:18 +0100 Subject: [PATCH] face_recognition_wechat example update (esp-idf v4.3) - Migration from tcpip_adapter API to its successor ESP-NETIF. - Changes have been tested with ESP-IDF v4.3.1 on an ESP32-CAM (AI-Thinker). --- .../components/network_blufi/wechat_blufi.c | 221 ++++++++------- .../main/Kconfig.projbuild | 181 ++++++++++++- .../face_recognition_wechat/main/app_camera.c | 2 + .../face_recognition_wechat/main/app_main.c | 12 +- .../face_recognition_wechat/main/app_wifi.c | 254 ++++++++++++------ .../main/include/app_camera.h | 157 ++++++++++- .../main/include/app_wifi.h | 14 +- 7 files changed, 626 insertions(+), 215 deletions(-) diff --git a/examples/single_chip/face_recognition_wechat/components/network_blufi/wechat_blufi.c b/examples/single_chip/face_recognition_wechat/components/network_blufi/wechat_blufi.c index 2094816..10e740b 100644 --- a/examples/single_chip/face_recognition_wechat/components/network_blufi/wechat_blufi.c +++ b/examples/single_chip/face_recognition_wechat/components/network_blufi/wechat_blufi.c @@ -25,7 +25,7 @@ /* ESP32 Includes */ #include "esp_system.h" #include "esp_wifi.h" -#include "esp_event_loop.h" +#include "esp_event.h" #include "esp_log.h" #include "esp_bt.h" #include "nvs_flash.h" @@ -111,11 +111,16 @@ static int gl_sta_ssid_len; static uint8_t server_if; static uint16_t conn_id; +esp_netif_t *AP_netif; +esp_netif_t *STA_netif; + +#define SERVER_IP_ADDR CONFIG_SERVER_IP + static void blufi_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param); void enter_blufi_config_wifi(); -void wifi_connect_succuess(); +void wifi_connect_success(); /** * @brief wifi_info_erase @@ -215,45 +220,45 @@ esp_err_t save_info_nvs(char *key, void *value, size_t len) */ void wait_net_connected() { - xEventGroupWaitBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT, false, true, portMAX_DELAY); + xEventGroupWaitBits(wifi_event_group, + WIFI_IP4_CONNECTED_BIT, false, true, portMAX_DELAY); // xEventGroupWaitBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT | WIFI_IP6_CONNECTED_BIT, false, true, portMAX_DELAY); } /** * @brief wifi 事件处理函数 */ -static esp_err_t event_handler(void *ctx, system_event_t *event) +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) { wifi_mode_t mode; static uint8_t connect_try_count = 0; - switch (event->event_id) { - case SYSTEM_EVENT_STA_START: - ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_START\n"); + if (event_id == WIFI_EVENT_STA_START) + { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_START\n"); if (strlen((char *)sta_config.sta.ssid) != 0 && strlen((char *)sta_config.sta.password) != 0) { ESP_ERROR_CHECK(esp_wifi_connect()); } - break; - - case SYSTEM_EVENT_STA_STOP: - ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_STOP\n"); - break; - - case SYSTEM_EVENT_STA_CONNECTED: - ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_CONNECTED\n"); + + } else if (event_id == WIFI_EVENT_STA_STOP) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_STOP\n"); + + } else if (event_id == WIFI_EVENT_STA_CONNECTED) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_CONNECTED\n"); + wifi_event_sta_connected_t* event = (wifi_event_sta_connected_t*) event_data; gl_sta_connected = true; connect_try_count = 0; - memcpy(gl_sta_bssid, event->event_info.connected.bssid, 6); - memcpy(gl_sta_ssid, event->event_info.connected.ssid, event->event_info.connected.ssid_len); - gl_sta_ssid_len = event->event_info.connected.ssid_len; + memcpy(gl_sta_bssid, event->bssid, 6); + memcpy(gl_sta_ssid, event->ssid, event->ssid_len); + gl_sta_ssid_len = event->ssid_len; save_info_nvs(NVS_KEY_WIFI_SSID_PASS, (void *)(sta_config.sta.ssid), WIFI_SSID_PASS_SIZE); /* enable ipv6 */ - tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA); - break; + esp_netif_create_ip6_linklocal(WIFI_IF_STA); - case SYSTEM_EVENT_STA_DISCONNECTED: - ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_DISCONNECTED\n"); + } else if (event_id == WIFI_EVENT_STA_DISCONNECTED) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_DISCONNECTED\n"); /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ if (connect_try_count++ > 5 && connect_try_count < 10) { // connect_try_count = 0; @@ -269,12 +274,12 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT | WIFI_IP6_CONNECTED_BIT); } - break; - - case SYSTEM_EVENT_STA_GOT_IP: { + + } else if (event_id == IP_EVENT_STA_GOT_IP) { esp_blufi_extra_info_t info; - ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_GOT_IP\n"); - ESP_LOGI("event_handler", "got ip4:%s\n", ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); + ESP_LOGI("wifi_event_handler", "IP_EVENT_STA_GOT_IP\n"); + ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + ESP_LOGI("wifi_event_handler", "got ip4: " IPSTR, IP2STR(&event->ip_info.ip)); xEventGroupSetBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT); esp_wifi_get_mode(&mode); @@ -285,18 +290,16 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) info.sta_ssid_len = gl_sta_ssid_len; esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info); - wifi_connect_succuess(); - break; - } + wifi_connect_success(); - case SYSTEM_EVENT_AP_STA_GOT_IP6: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STA_GOT_IP6\n"); - ESP_LOGI("event_handler", "got ip6:%s\n", ip6addr_ntoa(&event->event_info.got_ip6.ip6_info.ip)); + } else if (event_id == IP_EVENT_GOT_IP6) { + ESP_LOGI("wifi_event_handler", "IP_EVENT_GOT_IP6\n"); + ip_event_got_ip6_t* event = (ip_event_got_ip6_t*) event_data; + ESP_LOGI("wifi_event_handler", "got ip6: " IPSTR, IP2STR(&event->ip6_info.ip)); xEventGroupSetBits(wifi_event_group, WIFI_IP6_CONNECTED_BIT); - break; - - case SYSTEM_EVENT_AP_START: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_START\n"); + + } else if (event_id == WIFI_EVENT_AP_START) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_START\n"); esp_wifi_get_mode(&mode); /* TODO: get config or information of softap, then set to report extra_info */ @@ -305,83 +308,98 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) } else { esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, 0, NULL); } - break; - case SYSTEM_EVENT_AP_STOP: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STOP\n"); - break; + } else if (event_id == WIFI_EVENT_AP_STOP) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STOP\n"); - case SYSTEM_EVENT_AP_STAIPASSIGNED: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STAIPASSIGNED\n"); - break; + } else if (event_id == IP_EVENT_AP_STAIPASSIGNED) { + ESP_LOGI("wifi_event_handler", "IP_EVENT_AP_STAIPASSIGNED\n"); + - case SYSTEM_EVENT_AP_STACONNECTED: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STACONNECTED\n"); - ESP_LOGI("event_handler", "station:" MACSTR " join,AID=%d\n", - MAC2STR(event->event_info.sta_connected.mac), - event->event_info.sta_connected.aid); + } else if (event_id == WIFI_EVENT_AP_STACONNECTED) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STACONNECTED\n"); + wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data; + ESP_LOGI("wifi_event_handler", "station:" MACSTR " join, AID=%d\n", + MAC2STR(event->mac), + event->aid); xEventGroupSetBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT); - break; + - case SYSTEM_EVENT_AP_STADISCONNECTED: - ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STADISCONNECTED\n"); - ESP_LOGI("event_handler", "station:" MACSTR "leave,AID=%d\n", - MAC2STR(event->event_info.sta_disconnected.mac), - event->event_info.sta_disconnected.aid); + } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { + ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STADISCONNECTED\n"); + wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data; + ESP_LOGI("wifi_event_handler", "station:" MACSTR "leave, AID=%d\n", + MAC2STR(event->mac), + event->aid); xEventGroupClearBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT); - break; + - case SYSTEM_EVENT_SCAN_DONE: { - uint16_t apCount = 0; - esp_wifi_scan_get_ap_num(&apCount); - if (apCount == 0) { - BLUFI_INFO("Nothing AP found"); - break; - } - wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount); - if (!ap_list) { - BLUFI_ERROR("malloc error, ap_list is NULL"); - break; - } - ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list)); - esp_blufi_ap_record_t *blufi_ap_list = (esp_blufi_ap_record_t *)malloc(apCount * sizeof(esp_blufi_ap_record_t)); - if (!blufi_ap_list) { - if (ap_list) { - free(ap_list); + } else if (event_id == WIFI_EVENT_SCAN_DONE) { + do { + uint16_t apCount = 0; + esp_wifi_scan_get_ap_num(&apCount); + if (apCount == 0) { + BLUFI_INFO("No AP was found"); + break; } - BLUFI_ERROR("malloc error, blufi_ap_list is NULL"); - break; - } - for (int i = 0; i < apCount; ++i) { - blufi_ap_list[i].rssi = ap_list[i].rssi; - memcpy(blufi_ap_list[i].ssid, ap_list[i].ssid, sizeof(ap_list[i].ssid)); - } - esp_blufi_send_wifi_list(apCount, blufi_ap_list); - esp_wifi_scan_stop(); - free(ap_list); - free(blufi_ap_list); - break; + wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount); + if (!ap_list) { + BLUFI_ERROR("malloc error, ap_list is NULL"); + break; + } + ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, ap_list)); + esp_blufi_ap_record_t *blufi_ap_list = (esp_blufi_ap_record_t *)malloc(apCount * sizeof(esp_blufi_ap_record_t)); + if (!blufi_ap_list) { + if (ap_list) { + free(ap_list); + } + BLUFI_ERROR("malloc error, blufi_ap_list is NULL"); + break; + } + for (int i = 0; i < apCount; ++i) { + blufi_ap_list[i].rssi = ap_list[i].rssi; + memcpy(blufi_ap_list[i].ssid, ap_list[i].ssid, sizeof(ap_list[i].ssid)); + } + esp_blufi_send_wifi_list(apCount, blufi_ap_list); + esp_wifi_scan_stop(); + free(ap_list); + free(blufi_ap_list); + } while(0); } - default: - break; - } -#ifdef USE_MDNS - mdns_handle_system_event(ctx, event); -#endif - return ESP_OK; } // wifi initialise for Software AP + Sta void wifi_init_ap_sta() { - tcpip_adapter_init(); - wifi_event_group = xEventGroupCreate(); - ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); + wifi_event_group = xEventGroupCreate(); + + /* default event loop from esp_event library */ + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + + AP_netif = esp_netif_create_default_wifi_ap(); + assert(AP_netif); + + STA_netif = esp_netif_create_default_wifi_sta(); + assert(STA_netif); + + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &wifi_event_handler, + NULL, + NULL)); + + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + ESP_EVENT_ANY_ID, + &wifi_event_handler, + NULL, + + NULL)); + wifi_config_t ap_wifi_config = { .ap = { .ssid = DEFAULT_SSID, @@ -392,11 +410,12 @@ void wifi_init_ap_sta() }, }; - // memcpy(sta_config.sta.ssid, sta_wifi_config.sta.ssid, WIFI_SSID_MAX_SIZE); // memcpy(sta_config.sta.password, sta_wifi_config.sta.password, WIFI_SSID_PASS_SIZE); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA)); + // "esp_wifi_set_config" can be called only when specified interface is enabled, + // otherwise, API fail ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &ap_wifi_config)); ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &sta_config)); ESP_ERROR_CHECK(esp_wifi_start()); @@ -501,7 +520,7 @@ static void blufi_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_ case ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE: BLUFI_INFO("blufi close a gatt connection"); vTaskDelay(200 / portTICK_PERIOD_MS); - esp_blufi_close(server_if, conn_id); + //esp_blufi_close(server_if, conn_id); break; case ESP_BLUFI_EVENT_DEAUTHENTICATE_STA: @@ -732,7 +751,7 @@ static bool wifi_configing = false; /** * @brief wifi 连接成功 */ -void wifi_connect_succuess() +void wifi_connect_success() { } @@ -851,7 +870,7 @@ static void notice_udp_task(void *arg) return ; } - ESP_ERROR_CHECK(esp_wifi_get_mac(ESP_IF_WIFI_STA, root_mac)); + ESP_ERROR_CHECK(esp_wifi_get_mac(WIFI_IF_STA, root_mac)); while(1){ memset(udp_server_buf, 0, NOTICE_UDP_BUF_SIZE); @@ -908,7 +927,7 @@ static void initialise_mdns(void) {"mac", mac_str}, }; - ESP_ERROR_CHECK(esp_wifi_get_mac(ESP_IF_WIFI_STA, root_mac)); + ESP_ERROR_CHECK(esp_wifi_get_mac(WIFI_IF_STA, root_mac)); sprintf(mac_str, "%02x%02x%02x%02x%02x%02x", MAC2STR(root_mac)); do { diff --git a/examples/single_chip/face_recognition_wechat/main/Kconfig.projbuild b/examples/single_chip/face_recognition_wechat/main/Kconfig.projbuild index 8acf12f..f3d45a7 100644 --- a/examples/single_chip/face_recognition_wechat/main/Kconfig.projbuild +++ b/examples/single_chip/face_recognition_wechat/main/Kconfig.projbuild @@ -1,30 +1,195 @@ menu "Example Configuration" -config ESP_WIFI_SSID - string "WiFi SSID" +menu "WiFi Settings" +config ESP_HOST_NAME + string "Camera Host Name" default "" help - SSID (network name) for the example to connect to. + Hostname that the camera will advertise over mDNS. + +config ESP_WIFI_SSID + string "WiFi STA SSID" + default "" + help + WiFi SSID (network name) to connect to or empty for Off. config ESP_WIFI_PASSWORD - string "WiFi Password" + string "WiFi STA Password" default "" help - WiFi password (WPA or WPA2) for the example to use. + WiFi Password if WEP/WPA/WPA2 or empty if Open. config MAX_STA_CONN int "Maximal STA connections" default 1 help - Max number of the STA connects to AP. + Max number of the STA connects to AP. config ESP_WIFI_AP_CHANNEL string "WiFi AP Channel" default "" help - AP channel for better connection performance. + AP channel for better connection performance. config SERVER_IP - string "IP address of server" + string "WiFi AP IP Address" default "192.168.4.1" + help + IP address that the ESP will assign to it's AP interface. You can use this IP to connect to the camera after flashing. + +endmenu + +menu "Camera Pins" +choice CAMERA_MODEL + bool "Select Camera Pinout" + default CAMERA_MODEL_WROVER_KIT + help + Select Camera Pinout. + +config CAMERA_MODEL_WROVER_KIT + bool "WROVER-KIT With OV2640 Module" +config CAMERA_MODEL_ESP32_CAM_BOARD + bool "ESP32 Camera Development Board" +config CAMERA_MODEL_ESP_EYE + bool "ESP_EYE DevKit" +config CAMERA_MODEL_M5STACK_PSRAM + bool "M5Stack Camera With PSRAM" +config CAMERA_MODEL_M5STACK_WIDE + bool "M5Stack Camera F (Wide)" +config CAMERA_MODEL_AI_THINKER + bool "ESP32-CAM by AI-Thinker" +config CAMERA_MODEL_CUSTOM + bool "Custom Camera Pinout" +endchoice + +config CAMERA_PIN_PWDN + depends on CAMERA_MODEL_CUSTOM + int "Power Down pin" + range -1 33 + default -1 + help + Select Power Down pin or -1 for unmanaged. + +config CAMERA_PIN_RESET + depends on CAMERA_MODEL_CUSTOM + int "Reset pin" + range -1 33 + default -1 + help + Select Camera Reset pin or -1 for software reset. + +config CAMERA_PIN_XCLK + depends on CAMERA_MODEL_CUSTOM + int "XCLK pin" + range 0 33 + default 21 + help + Select Camera XCLK pin. + +config CAMERA_PIN_SIOD + depends on CAMERA_MODEL_CUSTOM + int "SIOD pin" + range 0 33 + default 26 + help + Select Camera SIOD pin. + +config CAMERA_PIN_SIOC + depends on CAMERA_MODEL_CUSTOM + int "SIOC pin" + range 0 33 + default 27 + help + Select Camera SIOC pin. + +config CAMERA_PIN_VSYNC + depends on CAMERA_MODEL_CUSTOM + int "VSYNC pin" + range 0 39 + default 25 + help + Select Camera VSYNC pin. + +config CAMERA_PIN_HREF + depends on CAMERA_MODEL_CUSTOM + int "HREF pin" + range 0 39 + default 23 + help + Select Camera HREF pin. + +config CAMERA_PIN_PCLK + depends on CAMERA_MODEL_CUSTOM + int "PCLK pin" + range 0 39 + default 25 + help + Select Camera PCLK pin. + +config CAMERA_PIN_Y2 + depends on CAMERA_MODEL_CUSTOM + int "Y2 pin" + range 0 39 + default 4 + help + Select Camera Y2 pin. + +config CAMERA_PIN_Y3 + depends on CAMERA_MODEL_CUSTOM + int "Y3 pin" + range 0 39 + default 5 + help + Select Camera Y3 pin. + +config CAMERA_PIN_Y4 + depends on CAMERA_MODEL_CUSTOM + int "Y4 pin" + range 0 39 + default 18 + help + Select Camera Y4 pin. + +config CAMERA_PIN_Y5 + depends on CAMERA_MODEL_CUSTOM + int "Y5 pin" + range 0 39 + default 19 + help + Select Camera Y5 pin. + +config CAMERA_PIN_Y6 + depends on CAMERA_MODEL_CUSTOM + int "Y6 pin" + range 0 39 + default 36 + help + Select Camera Y6 pin. + +config CAMERA_PIN_Y7 + depends on CAMERA_MODEL_CUSTOM + int "Y7 pin" + range 0 39 + default 39 + help + Select Camera Y7 pin. + +config CAMERA_PIN_Y8 + depends on CAMERA_MODEL_CUSTOM + int "Y8 pin" + range 0 39 + default 34 + help + Select Camera Y8 pin. + +config CAMERA_PIN_Y9 + depends on CAMERA_MODEL_CUSTOM + int "Y9 pin" + range 0 39 + default 35 + help + Select Camera Y9 pin. + +endmenu + endmenu diff --git a/examples/single_chip/face_recognition_wechat/main/app_camera.c b/examples/single_chip/face_recognition_wechat/main/app_camera.c index f535419..5e5e602 100644 --- a/examples/single_chip/face_recognition_wechat/main/app_camera.c +++ b/examples/single_chip/face_recognition_wechat/main/app_camera.c @@ -26,6 +26,7 @@ static const char *TAG = "app_camera"; void app_camera_init() { +#if CONFIG_CAMERA_MODEL_ESP_EYE || CONFIG_CAMERA_MODEL_ESP32_CAM_BOARD /* IO13, IO14 is designed for JTAG by default, * to use it as generalized input, * firstly declair it as pullup input */ @@ -38,6 +39,7 @@ void app_camera_init() gpio_config(&conf); conf.pin_bit_mask = 1LL << 14; gpio_config(&conf); +#endif camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; diff --git a/examples/single_chip/face_recognition_wechat/main/app_main.c b/examples/single_chip/face_recognition_wechat/main/app_main.c index b85e6f4..d04a15b 100644 --- a/examples/single_chip/face_recognition_wechat/main/app_main.c +++ b/examples/single_chip/face_recognition_wechat/main/app_main.c @@ -80,16 +80,16 @@ en_fsm_state g_state = WAIT_FOR_WAKEUP; static void restart_count_erase_timercb(void *timer) { if (!xTimerStop(timer, portMAX_DELAY)) { - ESP_LOGD("esp-eye", "xTimerStop timer: %p", timer); + ESP_LOGD("esp-board", "xTimerStop timer: %p", timer); } if (!xTimerDelete(timer, portMAX_DELAY)) { - ESP_LOGD("esp-eye", "xTimerDelete timer: %p", timer); + ESP_LOGD("esp-board", "xTimerDelete timer: %p", timer); } wifi_info_erase(NVS_KEY_RESTART_COUNT); - ESP_LOGI("esp-eye", "Erase restart count"); + ESP_LOGI("esp-board", "Erase restart count"); } static int restart_count_get() @@ -145,7 +145,7 @@ void app_main() } if (restart_count_get() > 3) { - ESP_LOGI("esp-eye", "Erase information saved in flash"); + ESP_LOGI("esp-board", "Erase information saved in flash"); wifi_info_erase(USERDATANAMESPACE); } @@ -156,7 +156,7 @@ void app_main() g_state = WAIT_FOR_CONNECT; - ESP_LOGI("esp-eye", "Version "VERSION); + ESP_LOGI("esp-board", "Version "VERSION); // app_wifi_init(); @@ -169,6 +169,6 @@ void app_main() app_facenet_main(); app_httpserver_init(); printf("Mem availabe after: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL)); - ESP_LOGI("esp-eye", "Version "VERSION" success"); + ESP_LOGI("esp-board", "Version "VERSION" success"); //xTaskCreatePinnedToCore(&printTask, "printTask", 2*1024, NULL, 5, NULL, 1); } diff --git a/examples/single_chip/face_recognition_wechat/main/app_wifi.c b/examples/single_chip/face_recognition_wechat/main/app_wifi.c index a9893e4..1d549b3 100644 --- a/examples/single_chip/face_recognition_wechat/main/app_wifi.c +++ b/examples/single_chip/face_recognition_wechat/main/app_wifi.c @@ -19,154 +19,237 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #include + #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" #include "esp_system.h" #include "esp_wifi.h" -#include "esp_event_loop.h" +#include "esp_event.h" #include "esp_log.h" #include "nvs_flash.h" +#include "esp_netif.h" #include "sdkconfig.h" #include "lwip/err.h" #include "lwip/sys.h" + #include "app_wifi.h" -static const char *TAG = "app_wifi"; +/* The examples use WiFi configuration that you can set via 'make menuconfig'. -#define EXAMPLE_ESP_WIFI_MODE_AP 1 //TRUE:AP FALSE:STA -#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID -#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD -#define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN -#define EXAMPLE_IP_ADDR CONFIG_SERVER_IP -#define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL + If you'd rather not, just change the below entries to strings with + the config you want - ie #define ESP_WIFI_SSID "mywifissid" +*/ +#define ESP_WIFI_MODE_AP 1 //TRUE:AP FALSE:STA -static esp_err_t event_handler(void *ctx, system_event_t *event) -{/*{{{*/ - switch(event->event_id) { - case SYSTEM_EVENT_STA_START: - esp_wifi_connect(); - break; - case SYSTEM_EVENT_STA_GOT_IP: - ESP_LOGI(TAG, "got ip:%s", - ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); - break; - case SYSTEM_EVENT_AP_STACONNECTED: - ESP_LOGI(TAG, "station:" MACSTR " join, AID=%d", - MAC2STR(event->event_info.sta_connected.mac), - event->event_info.sta_connected.aid); - break; - case SYSTEM_EVENT_AP_STADISCONNECTED: - ESP_LOGI(TAG, "station:" MACSTR " leave, AID=%d", - MAC2STR(event->event_info.sta_disconnected.mac), - event->event_info.sta_disconnected.aid); +#define ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID +#define ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD - break; - case SYSTEM_EVENT_STA_DISCONNECTED: - esp_wifi_connect(); - break; - default: - break; - } - return ESP_OK; -}/*}}}*/ +#define MAX_STA_CONN CONFIG_MAX_STA_CONN +#define SERVER_IP_ADDR CONFIG_SERVER_IP +#define ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL -#if EXAMPLE_ESP_WIFI_MODE_AP -static void wifi_init_softap() +/* FreeRTOS event group to signal when we are connected*/ +static EventGroupHandle_t s_wifi_event_group; + +/* The event group allows multiple bits for each event, + * For STA events handling, we only care about two events: + * - we are connected to the AP with an IP + */ +#define WIFI_CONNECTED_BIT BIT0 + +static const char *TAG = "App_Wifi"; + +esp_netif_t *AP_netif; +esp_netif_t *STA_netif; + +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) { - tcpip_adapter_init(); - - if (strcmp(EXAMPLE_IP_ADDR, "192.168.4.1")) - { - int a, b, c, d; - sscanf(EXAMPLE_IP_ADDR, "%d.%d.%d.%d", &a, &b, &c, &d); - tcpip_adapter_ip_info_t ip_info; - IP4_ADDR(&ip_info.ip, a, b, c, d); - IP4_ADDR(&ip_info.gw, a, b, c, d); - IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0); - ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(WIFI_IF_AP)); - ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(WIFI_IF_AP, &ip_info)); - ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(WIFI_IF_AP)); + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + ESP_ERROR_CHECK(esp_wifi_connect()); + } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; + ESP_LOGI(TAG, "Got IP:" IPSTR, IP2STR(&event->ip_info.ip)); + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + } else if (event_id == WIFI_EVENT_AP_STACONNECTED) { + wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data; + ESP_LOGI(TAG, "station: " MACSTR "join, AID=%d", + MAC2STR(event->mac), + event->aid); + } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { + wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data; + ESP_LOGI(TAG, "station:" MACSTR "leave, AID=%d", + MAC2STR(event->mac), + event->aid); + } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { + ESP_ERROR_CHECK(esp_wifi_connect()); } +} - ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); - +void wifi_init_softap() +{ + /* Always use WIFI_INIT_CONFIG_DEFAULT macro to init the config to default values, + * this can guarantee all the fields got correct value when more fields are added + * into wifi_init_config_t in future release. */ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + + /* esp_wifi_init API must be called before all other WiFi API can be called */ + ESP_LOGI(TAG, "Initializing ESP Wifi"); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + /* default event loop from esp_event library */ + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + + AP_netif = esp_netif_create_default_wifi_ap(); + assert(AP_netif); + uint8_t mac[6]; ESP_ERROR_CHECK(esp_wifi_get_mac(ESP_IF_WIFI_AP, mac)); + + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &wifi_event_handler, + NULL, + NULL)); + + int a, b, c, d; + sscanf(SERVER_IP_ADDR, "%d.%d.%d.%d", &a, &b, &c, &d); + esp_netif_ip_info_t ip_info; + esp_netif_set_ip4_addr(&ip_info.ip, a, b, c, d); + esp_netif_set_ip4_addr(&ip_info.gw, a, b, c, d); + esp_netif_set_ip4_addr(&ip_info.netmask, 255, 255, 255, 0); + ESP_ERROR_CHECK(esp_netif_dhcps_stop(AP_netif)); + ESP_ERROR_CHECK(esp_netif_set_ip_info(AP_netif, &ip_info)); + ESP_ERROR_CHECK(esp_netif_dhcps_start(AP_netif)); + wifi_config_t wifi_config; memset(&wifi_config, 0, sizeof(wifi_config_t)); - if (strlen(EXAMPLE_ESP_WIFI_SSID) == 0) + + if (strlen(ESP_WIFI_SSID) == 0) { - snprintf((char *)wifi_config.ap.ssid, 32, "esp-eye-%x%x", mac[4], mac[5]); + snprintf((char *)wifi_config.ap.ssid, 32, "esp-camera-%x%x", mac[4], mac[5]); } else { - memcpy(wifi_config.ap.ssid, EXAMPLE_ESP_WIFI_SSID, sizeof(EXAMPLE_ESP_WIFI_SSID)); + snprintf((char*)wifi_config.ap.ssid, 32, "%s", ESP_WIFI_SSID); } - memcpy(wifi_config.ap.password, EXAMPLE_ESP_WIFI_PASS, sizeof(EXAMPLE_ESP_WIFI_PASS)); - wifi_config.ap.ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID); - wifi_config.ap.max_connection = EXAMPLE_MAX_STA_CONN; + + snprintf((char*)wifi_config.ap.password, 64, "%s", ESP_WIFI_PASS); + wifi_config.ap.ssid_len = strlen((char*)wifi_config.ap.ssid); + + wifi_config.ap.max_connection = MAX_STA_CONN; wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK; - if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) { + + if (strlen(ESP_WIFI_PASS) == 0) { wifi_config.ap.authmode = WIFI_AUTH_OPEN; } - if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) { + + if (strlen(ESP_WIFI_AP_CHANNEL)) { int channel; - sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel); + sscanf(ESP_WIFI_AP_CHANNEL, "%d", &channel); wifi_config.ap.channel = channel; } esp_wifi_set_ps(WIFI_PS_NONE); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); + // "esp_wifi_set_config" can be called only when specified interface is enabled, otherwise, API fail ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); - ESP_ERROR_CHECK(esp_wifi_start()); ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s", - wifi_config.ap.ssid, EXAMPLE_ESP_WIFI_PASS); + wifi_config.ap.ssid, ESP_WIFI_PASS); char buf[80]; sprintf(buf, "SSID:%s", wifi_config.ap.ssid); sprintf(buf, "PASSWORD:%s", wifi_config.ap.password); - } -#else - -static void wifi_init_sta() +void wifi_init_sta() { - tcpip_adapter_init(); - ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); - + /* Always use WIFI_INIT_CONFIG_DEFAULT macro to init the config to default values, + * this can guarantee all the fields got correct value when more fields are added + * into wifi_init_config_t in future release. */ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + + /* esp_wifi_init API must be called before all other WiFi API can be called */ + ESP_LOGI(TAG, "Initializing ESP Wifi"); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - wifi_config_t wifi_config = {0}; - memset(&wifi_config, 0, sizeof(wifi_config_t)); - memcpy(wifi_config.sta.ssid, EXAMPLE_ESP_WIFI_SSID, sizeof(EXAMPLE_ESP_WIFI_SSID)); - memcpy(wifi_config.sta.password, EXAMPLE_ESP_WIFI_PASS, sizeof(EXAMPLE_ESP_WIFI_PASS)); + s_wifi_event_group = xEventGroupCreate(); + + ESP_ERROR_CHECK(esp_netif_init()); + + ESP_ERROR_CHECK(esp_event_loop_create_default()); + + STA_netif = esp_netif_create_default_wifi_sta(); + assert(STA_netif); + + esp_event_handler_instance_t instance_any_id; + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &wifi_event_handler, + NULL, + &instance_any_id)); + + esp_event_handler_instance_t instance_got_ip; + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + IP_EVENT_STA_GOT_IP, + &wifi_event_handler, + NULL, + &instance_got_ip)); + + wifi_config_t wifi_config = { + .sta = { + .threshold.authmode = WIFI_AUTH_WPA2_PSK, + .pmf_cfg = { + .capable = true, + .required = false + }, + }, + }; + + snprintf((char*)wifi_config.sta.ssid, 32, "%s", ESP_WIFI_SSID); + snprintf((char*)wifi_config.sta.password, 64, "%s", ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); - + // "esp_wifi_set_config" can be called only when specified interface is enabled, otherwise, API fail + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start()); - ESP_LOGI(TAG, "connect to ap SSID:%s password:%s", wifi_config.sta.ssid, wifi_config.sta.password); - - char buf[80]; - sprintf(buf, "SSID:%s", wifi_config.sta.ssid); - sprintf(buf, "PASSWORD:%s", wifi_config.sta.password); + ESP_LOGI(TAG, "wifi_init_STA finished."); + // Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + // number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + if (bits & WIFI_CONNECTED_BIT) + { + wifi_ap_record_t AP_info; + ESP_ERROR_CHECK(esp_wifi_sta_get_ap_info(&AP_info)); + ESP_LOGI(TAG, "connected to AP, SSID : %s Channel : %d Strength : %d Authmode : %d", + AP_info.ssid, AP_info.primary, AP_info.rssi, AP_info.authmode); + } else { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } + + // The event will not be processed after unregister + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip)); + ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id)); + + vEventGroupDelete(s_wifi_event_group); } -#endif -void app_wifi_init () +void app_wifi_main(void) { //Initialize NVS esp_err_t ret = nvs_flash_init(); @@ -175,7 +258,7 @@ void app_wifi_init () ret = nvs_flash_init(); } ESP_ERROR_CHECK(ret); - + #if EXAMPLE_ESP_WIFI_MODE_AP ESP_LOGI(TAG, "ESP_WIFI_MODE_AP"); wifi_init_softap(); @@ -183,6 +266,5 @@ void app_wifi_init () ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); wifi_init_sta(); #endif /*EXAMPLE_ESP_WIFI_MODE_AP*/ - } diff --git a/examples/single_chip/face_recognition_wechat/main/include/app_camera.h b/examples/single_chip/face_recognition_wechat/main/include/app_camera.h index 22075f5..630a910 100644 --- a/examples/single_chip/face_recognition_wechat/main/include/app_camera.h +++ b/examples/single_chip/face_recognition_wechat/main/include/app_camera.h @@ -52,23 +52,158 @@ */ #define CAMERA_FRAME_SIZE FRAMESIZE_QVGA +#if CONFIG_CAMERA_MODEL_WROVER_KIT +#define CAM_BOARD "WROVER-KIT" #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 21 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 19 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 5 +#define Y2_GPIO_NUM 4 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +#elif CONFIG_CAMERA_MODEL_ESP32_CAM_BOARD +// The 18 pin header on the board has Y5 and Y3 swapped +#define USE_BOARD_HEADER 0 + +#define CAM_BOARD "ESP-DEVCAM" +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM 33 #define XCLK_GPIO_NUM 4 -#define SIOD_GPIO_NUM 18 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 19 +#define Y7_GPIO_NUM 21 +#define Y6_GPIO_NUM 39 +#if USE_BOARD_HEADER +#define Y5_GPIO_NUM 13 +#else +#define Y5_GPIO_NUM 35 +#endif +#define Y4_GPIO_NUM 14 +#if USE_BOARD_HEADER +#define Y3_GPIO_NUM 35 +#else +#define Y3_GPIO_NUM 13 +#endif +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#elif CONFIG_CAMERA_MODEL_ESP_EYE +#define CAM_BOARD "ESP-EYE" +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 37 +#define Y7_GPIO_NUM 38 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 35 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 13 +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#elif CONFIG_CAMERA_MODEL_M5STACK_PSRAM +#define CAM_BOARD "M5CAM" +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 #define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 36 -#define Y8_GPIO_NUM 37 -#define Y7_GPIO_NUM 38 +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 #define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 35 -#define Y4_GPIO_NUM 14 -#define Y3_GPIO_NUM 13 -#define Y2_GPIO_NUM 34 -#define VSYNC_GPIO_NUM 5 -#define HREF_GPIO_NUM 27 -#define PCLK_GPIO_NUM 25 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif CONFIG_CAMERA_MODEL_M5STACK_WIDE +#define CAM_BOARD "M5CAMW" +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif CONFIG_CAMERA_MODEL_AI_THINKER +#define CAM_BOARD "AI-THINKER" +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + + +#elif CONFIG_CAMERA_MODEL_CUSTOM +#define CAM_BOARD "CUSTOM" +#define PWDN_GPIO_NUM CONFIG_CAMERA_PIN_PWDN +#define RESET_GPIO_NUM CONFIG_CAMERA_PIN_RESET +#define XCLK_GPIO_NUM CONFIG_CAMERA_PIN_XCLK +#define SIOD_GPIO_NUM CONFIG_CAMERA_PIN_SIOD +#define SIOC_GPIO_NUM CONFIG_CAMERA_PIN_SIOC + +#define Y9_GPIO_NUM CONFIG_CAMERA_PIN_Y9 +#define Y8_GPIO_NUM CONFIG_CAMERA_PIN_Y8 +#define Y7_GPIO_NUM CONFIG_CAMERA_PIN_Y7 +#define Y6_GPIO_NUM CONFIG_CAMERA_PIN_Y6 +#define Y5_GPIO_NUM CONFIG_CAMERA_PIN_Y5 +#define Y4_GPIO_NUM CONFIG_CAMERA_PIN_Y4 +#define Y3_GPIO_NUM CONFIG_CAMERA_PIN_Y3 +#define Y2_GPIO_NUM CONFIG_CAMERA_PIN_Y2 +#define VSYNC_GPIO_NUM CONFIG_CAMERA_PIN_VSYNC +#define HREF_GPIO_NUM CONFIG_CAMERA_PIN_HREF +#define PCLK_GPIO_NUM CONFIG_CAMERA_PIN_PCLK +#endif #define XCLK_FREQ 20000000 diff --git a/examples/single_chip/face_recognition_wechat/main/include/app_wifi.h b/examples/single_chip/face_recognition_wechat/main/include/app_wifi.h index e0cf53d..e643179 100644 --- a/examples/single_chip/face_recognition_wechat/main/include/app_wifi.h +++ b/examples/single_chip/face_recognition_wechat/main/include/app_wifi.h @@ -1,6 +1,14 @@ -#include "freertos/FreeRTOS.h" -#include "freertos/event_groups.h" +#ifndef _APP_WIFI_H_ +#define _APP_WIFI_H_ -extern EventGroupHandle_t g_wifi_event_group; +#ifdef __cplusplus +extern "C" { +#endif void app_wifi_init(); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file