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).
pull/181/head
JarmouniA 2021-10-05 18:47:18 +01:00
parent 61775dff09
commit d64a93d6ca
7 changed files with 626 additions and 215 deletions

View File

@ -25,7 +25,7 @@
/* ESP32 Includes */ /* ESP32 Includes */
#include "esp_system.h" #include "esp_system.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_event_loop.h" #include "esp_event.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_bt.h" #include "esp_bt.h"
#include "nvs_flash.h" #include "nvs_flash.h"
@ -111,11 +111,16 @@ static int gl_sta_ssid_len;
static uint8_t server_if; static uint8_t server_if;
static uint16_t conn_id; 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); static void blufi_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param);
void enter_blufi_config_wifi(); void enter_blufi_config_wifi();
void wifi_connect_succuess(); void wifi_connect_success();
/** /**
* @brief wifi_info_erase * @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() 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); // xEventGroupWaitBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT | WIFI_IP6_CONNECTED_BIT, false, true, portMAX_DELAY);
} }
/** /**
* @brief wifi * @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; wifi_mode_t mode;
static uint8_t connect_try_count = 0; static uint8_t connect_try_count = 0;
switch (event->event_id) { if (event_id == WIFI_EVENT_STA_START)
case SYSTEM_EVENT_STA_START: {
ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_START\n"); 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) { if (strlen((char *)sta_config.sta.ssid) != 0 && strlen((char *)sta_config.sta.password) != 0) {
ESP_ERROR_CHECK(esp_wifi_connect()); ESP_ERROR_CHECK(esp_wifi_connect());
} }
break;
case SYSTEM_EVENT_STA_STOP: } else if (event_id == WIFI_EVENT_STA_STOP) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_STOP\n"); ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_STOP\n");
break;
case SYSTEM_EVENT_STA_CONNECTED: } else if (event_id == WIFI_EVENT_STA_CONNECTED) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_CONNECTED\n"); 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; gl_sta_connected = true;
connect_try_count = 0; connect_try_count = 0;
memcpy(gl_sta_bssid, event->event_info.connected.bssid, 6); memcpy(gl_sta_bssid, event->bssid, 6);
memcpy(gl_sta_ssid, event->event_info.connected.ssid, event->event_info.connected.ssid_len); memcpy(gl_sta_ssid, event->ssid, event->ssid_len);
gl_sta_ssid_len = event->event_info.connected.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); save_info_nvs(NVS_KEY_WIFI_SSID_PASS, (void *)(sta_config.sta.ssid), WIFI_SSID_PASS_SIZE);
/* enable ipv6 */ /* enable ipv6 */
tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA); esp_netif_create_ip6_linklocal(WIFI_IF_STA);
break;
case SYSTEM_EVENT_STA_DISCONNECTED: } else if (event_id == WIFI_EVENT_STA_DISCONNECTED) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_DISCONNECTED\n"); ESP_LOGI("wifi_event_handler", "WIFI_EVENT_STA_DISCONNECTED\n");
/* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */
if (connect_try_count++ > 5 && connect_try_count < 10) { if (connect_try_count++ > 5 && connect_try_count < 10) {
// connect_try_count = 0; // connect_try_count = 0;
@ -269,12 +274,12 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
esp_wifi_connect(); esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT | WIFI_IP6_CONNECTED_BIT); 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_blufi_extra_info_t info;
ESP_LOGI("event_handler", "SYSTEM_EVENT_STA_GOT_IP\n"); ESP_LOGI("wifi_event_handler", "IP_EVENT_STA_GOT_IP\n");
ESP_LOGI("event_handler", "got ip4:%s\n", ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); 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); xEventGroupSetBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT);
esp_wifi_get_mode(&mode); 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; info.sta_ssid_len = gl_sta_ssid_len;
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info); esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info);
wifi_connect_succuess(); wifi_connect_success();
break;
}
case SYSTEM_EVENT_AP_STA_GOT_IP6: } else if (event_id == IP_EVENT_GOT_IP6) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STA_GOT_IP6\n"); ESP_LOGI("wifi_event_handler", "IP_EVENT_GOT_IP6\n");
ESP_LOGI("event_handler", "got ip6:%s\n", ip6addr_ntoa(&event->event_info.got_ip6.ip6_info.ip)); 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); xEventGroupSetBits(wifi_event_group, WIFI_IP6_CONNECTED_BIT);
break;
case SYSTEM_EVENT_AP_START: } else if (event_id == WIFI_EVENT_AP_START) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_START\n"); ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_START\n");
esp_wifi_get_mode(&mode); esp_wifi_get_mode(&mode);
/* TODO: get config or information of softap, then set to report extra_info */ /* 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 { } else {
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, 0, NULL); esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, 0, NULL);
} }
break;
case SYSTEM_EVENT_AP_STOP: } else if (event_id == WIFI_EVENT_AP_STOP) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STOP\n"); ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STOP\n");
break;
case SYSTEM_EVENT_AP_STAIPASSIGNED: } else if (event_id == IP_EVENT_AP_STAIPASSIGNED) {
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STAIPASSIGNED\n"); ESP_LOGI("wifi_event_handler", "IP_EVENT_AP_STAIPASSIGNED\n");
break;
case SYSTEM_EVENT_AP_STACONNECTED:
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STACONNECTED\n"); } else if (event_id == WIFI_EVENT_AP_STACONNECTED) {
ESP_LOGI("event_handler", "station:" MACSTR " join,AID=%d\n", ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STACONNECTED\n");
MAC2STR(event->event_info.sta_connected.mac), wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data;
event->event_info.sta_connected.aid); ESP_LOGI("wifi_event_handler", "station:" MACSTR " join, AID=%d\n",
MAC2STR(event->mac),
event->aid);
xEventGroupSetBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT); xEventGroupSetBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT);
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
ESP_LOGI("event_handler", "SYSTEM_EVENT_AP_STADISCONNECTED\n"); } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
ESP_LOGI("event_handler", "station:" MACSTR "leave,AID=%d\n", ESP_LOGI("wifi_event_handler", "WIFI_EVENT_AP_STADISCONNECTED\n");
MAC2STR(event->event_info.sta_disconnected.mac), wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
event->event_info.sta_disconnected.aid); ESP_LOGI("wifi_event_handler", "station:" MACSTR "leave, AID=%d\n",
MAC2STR(event->mac),
event->aid);
xEventGroupClearBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT); xEventGroupClearBits(wifi_event_group, WIFI_IP4_CONNECTED_BIT);
break;
case SYSTEM_EVENT_SCAN_DONE: {
uint16_t apCount = 0; } else if (event_id == WIFI_EVENT_SCAN_DONE) {
esp_wifi_scan_get_ap_num(&apCount); do {
if (apCount == 0) { uint16_t apCount = 0;
BLUFI_INFO("Nothing AP found"); esp_wifi_scan_get_ap_num(&apCount);
break; if (apCount == 0) {
} BLUFI_INFO("No AP was found");
wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount); break;
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"); wifi_ap_record_t *ap_list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
break; if (!ap_list) {
} BLUFI_ERROR("malloc error, ap_list is NULL");
for (int i = 0; i < apCount; ++i) { break;
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_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));
esp_blufi_send_wifi_list(apCount, blufi_ap_list); if (!blufi_ap_list) {
esp_wifi_scan_stop(); if (ap_list) {
free(ap_list); free(ap_list);
free(blufi_ap_list); }
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);
} while(0);
} }
default:
break;
}
#ifdef USE_MDNS
mdns_handle_system_event(ctx, event);
#endif
return ESP_OK;
} }
// wifi initialise for Software AP + Sta // wifi initialise for Software AP + Sta
void wifi_init_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(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); 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 = { wifi_config_t ap_wifi_config = {
.ap = { .ap = {
.ssid = DEFAULT_SSID, .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.ssid, sta_wifi_config.sta.ssid, WIFI_SSID_MAX_SIZE);
// memcpy(sta_config.sta.password, sta_wifi_config.sta.password, WIFI_SSID_PASS_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_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_AP, &ap_wifi_config));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &sta_config)); ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &sta_config));
ESP_ERROR_CHECK(esp_wifi_start()); 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: case ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE:
BLUFI_INFO("blufi close a gatt connection"); BLUFI_INFO("blufi close a gatt connection");
vTaskDelay(200 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
esp_blufi_close(server_if, conn_id); //esp_blufi_close(server_if, conn_id);
break; break;
case ESP_BLUFI_EVENT_DEAUTHENTICATE_STA: case ESP_BLUFI_EVENT_DEAUTHENTICATE_STA:
@ -732,7 +751,7 @@ static bool wifi_configing = false;
/** /**
* @brief wifi * @brief wifi
*/ */
void wifi_connect_succuess() void wifi_connect_success()
{ {
} }
@ -851,7 +870,7 @@ static void notice_udp_task(void *arg)
return ; 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){ while(1){
memset(udp_server_buf, 0, NOTICE_UDP_BUF_SIZE); memset(udp_server_buf, 0, NOTICE_UDP_BUF_SIZE);
@ -908,7 +927,7 @@ static void initialise_mdns(void)
{"mac", mac_str}, {"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)); sprintf(mac_str, "%02x%02x%02x%02x%02x%02x", MAC2STR(root_mac));
do { do {

View File

@ -1,30 +1,195 @@
menu "Example Configuration" menu "Example Configuration"
config ESP_WIFI_SSID menu "WiFi Settings"
string "WiFi SSID" config ESP_HOST_NAME
string "Camera Host Name"
default "" default ""
help 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 config ESP_WIFI_PASSWORD
string "WiFi Password" string "WiFi STA Password"
default "" default ""
help 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 config MAX_STA_CONN
int "Maximal STA connections" int "Maximal STA connections"
default 1 default 1
help help
Max number of the STA connects to AP. Max number of the STA connects to AP.
config ESP_WIFI_AP_CHANNEL config ESP_WIFI_AP_CHANNEL
string "WiFi AP Channel" string "WiFi AP Channel"
default "" default ""
help help
AP channel for better connection performance. AP channel for better connection performance.
config SERVER_IP config SERVER_IP
string "IP address of server" string "WiFi AP IP Address"
default "192.168.4.1" 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 endmenu

View File

@ -26,6 +26,7 @@ static const char *TAG = "app_camera";
void app_camera_init() void app_camera_init()
{ {
#if CONFIG_CAMERA_MODEL_ESP_EYE || CONFIG_CAMERA_MODEL_ESP32_CAM_BOARD
/* IO13, IO14 is designed for JTAG by default, /* IO13, IO14 is designed for JTAG by default,
* to use it as generalized input, * to use it as generalized input,
* firstly declair it as pullup input */ * firstly declair it as pullup input */
@ -38,6 +39,7 @@ void app_camera_init()
gpio_config(&conf); gpio_config(&conf);
conf.pin_bit_mask = 1LL << 14; conf.pin_bit_mask = 1LL << 14;
gpio_config(&conf); gpio_config(&conf);
#endif
camera_config_t config; camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0; config.ledc_channel = LEDC_CHANNEL_0;

View File

@ -80,16 +80,16 @@ en_fsm_state g_state = WAIT_FOR_WAKEUP;
static void restart_count_erase_timercb(void *timer) static void restart_count_erase_timercb(void *timer)
{ {
if (!xTimerStop(timer, portMAX_DELAY)) { 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)) { 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); 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() static int restart_count_get()
@ -145,7 +145,7 @@ void app_main()
} }
if (restart_count_get() > 3) { 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); wifi_info_erase(USERDATANAMESPACE);
} }
@ -156,7 +156,7 @@ void app_main()
g_state = WAIT_FOR_CONNECT; g_state = WAIT_FOR_CONNECT;
ESP_LOGI("esp-eye", "Version "VERSION); ESP_LOGI("esp-board", "Version "VERSION);
// app_wifi_init(); // app_wifi_init();
@ -169,6 +169,6 @@ void app_main()
app_facenet_main(); app_facenet_main();
app_httpserver_init(); app_httpserver_init();
printf("Mem availabe after: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL)); 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); //xTaskCreatePinnedToCore(&printTask, "printTask", 2*1024, NULL, 5, NULL, 1);
} }

View File

@ -19,154 +19,237 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <string.h> #include <string.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "freertos/event_groups.h" #include "freertos/event_groups.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_event_loop.h" #include "esp_event.h"
#include "esp_log.h" #include "esp_log.h"
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_netif.h"
#include "sdkconfig.h" #include "sdkconfig.h"
#include "lwip/err.h" #include "lwip/err.h"
#include "lwip/sys.h" #include "lwip/sys.h"
#include "app_wifi.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 If you'd rather not, just change the below entries to strings with
#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID the config you want - ie #define ESP_WIFI_SSID "mywifissid"
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD */
#define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN #define ESP_WIFI_MODE_AP 1 //TRUE:AP FALSE:STA
#define EXAMPLE_IP_ADDR CONFIG_SERVER_IP
#define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
static esp_err_t event_handler(void *ctx, system_event_t *event) #define ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
{/*{{{*/ #define ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
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);
break; #define MAX_STA_CONN CONFIG_MAX_STA_CONN
case SYSTEM_EVENT_STA_DISCONNECTED: #define SERVER_IP_ADDR CONFIG_SERVER_IP
esp_wifi_connect(); #define ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
break;
default:
break;
}
return ESP_OK;
}/*}}}*/
#if EXAMPLE_ESP_WIFI_MODE_AP /* FreeRTOS event group to signal when we are connected*/
static void wifi_init_softap() 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 (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
ESP_ERROR_CHECK(esp_wifi_connect());
if (strcmp(EXAMPLE_IP_ADDR, "192.168.4.1")) } 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;
int a, b, c, d; ESP_LOGI(TAG, "Got IP:" IPSTR, IP2STR(&event->ip_info.ip));
sscanf(EXAMPLE_IP_ADDR, "%d.%d.%d.%d", &a, &b, &c, &d); xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
tcpip_adapter_ip_info_t ip_info; } else if (event_id == WIFI_EVENT_AP_STACONNECTED) {
IP4_ADDR(&ip_info.ip, a, b, c, d); wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data;
IP4_ADDR(&ip_info.gw, a, b, c, d); ESP_LOGI(TAG, "station: " MACSTR "join, AID=%d",
IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0); MAC2STR(event->mac),
ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(WIFI_IF_AP)); event->aid);
ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(WIFI_IF_AP, &ip_info)); } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(WIFI_IF_AP)); 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(); 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)); 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]; uint8_t mac[6];
ESP_ERROR_CHECK(esp_wifi_get_mac(ESP_IF_WIFI_AP, mac)); 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; wifi_config_t wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config_t)); 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 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); snprintf((char*)wifi_config.ap.password, 64, "%s", ESP_WIFI_PASS);
wifi_config.ap.max_connection = EXAMPLE_MAX_STA_CONN; 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; 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; wifi_config.ap.authmode = WIFI_AUTH_OPEN;
} }
if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) {
if (strlen(ESP_WIFI_AP_CHANNEL)) {
int channel; int channel;
sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel); sscanf(ESP_WIFI_AP_CHANNEL, "%d", &channel);
wifi_config.ap.channel = channel; wifi_config.ap.channel = channel;
} }
esp_wifi_set_ps(WIFI_PS_NONE); esp_wifi_set_ps(WIFI_PS_NONE);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); 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_set_config(WIFI_IF_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start()); ESP_ERROR_CHECK(esp_wifi_start());
ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s", 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]; char buf[80];
sprintf(buf, "SSID:%s", wifi_config.ap.ssid); sprintf(buf, "SSID:%s", wifi_config.ap.ssid);
sprintf(buf, "PASSWORD:%s", wifi_config.ap.password); sprintf(buf, "PASSWORD:%s", wifi_config.ap.password);
} }
#else void wifi_init_sta()
static void wifi_init_sta()
{ {
tcpip_adapter_init(); /* Always use WIFI_INIT_CONFIG_DEFAULT macro to init the config to default values,
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); * 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(); 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)); ESP_ERROR_CHECK(esp_wifi_init(&cfg));
wifi_config_t wifi_config = {0}; s_wifi_event_group = xEventGroupCreate();
memset(&wifi_config, 0, sizeof(wifi_config_t));
memcpy(wifi_config.sta.ssid, EXAMPLE_ESP_WIFI_SSID, sizeof(EXAMPLE_ESP_WIFI_SSID)); ESP_ERROR_CHECK(esp_netif_init());
memcpy(wifi_config.sta.password, EXAMPLE_ESP_WIFI_PASS, sizeof(EXAMPLE_ESP_WIFI_PASS));
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_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_ERROR_CHECK(esp_wifi_start());
ESP_LOGI(TAG, "connect to ap SSID:%s password:%s", wifi_config.sta.ssid, wifi_config.sta.password); ESP_LOGI(TAG, "wifi_init_STA finished.");
char buf[80]; // Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
sprintf(buf, "SSID:%s", wifi_config.sta.ssid); // number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
sprintf(buf, "PASSWORD:%s", wifi_config.sta.password); 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 //Initialize NVS
esp_err_t ret = nvs_flash_init(); esp_err_t ret = nvs_flash_init();
@ -183,6 +266,5 @@ void app_wifi_init ()
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
wifi_init_sta(); wifi_init_sta();
#endif /*EXAMPLE_ESP_WIFI_MODE_AP*/ #endif /*EXAMPLE_ESP_WIFI_MODE_AP*/
} }

View File

@ -52,23 +52,158 @@
*/ */
#define CAMERA_FRAME_SIZE FRAMESIZE_QVGA #define CAMERA_FRAME_SIZE FRAMESIZE_QVGA
#if CONFIG_CAMERA_MODEL_WROVER_KIT
#define CAM_BOARD "WROVER-KIT"
#define PWDN_GPIO_NUM -1 #define PWDN_GPIO_NUM -1
#define RESET_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 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 SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 36 #define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 37 #define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 38 #define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39 #define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 35 #define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 14 #define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 13 #define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 34 #define Y2_GPIO_NUM 32
#define VSYNC_GPIO_NUM 5 #define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 27 #define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 25 #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 #define XCLK_FREQ 20000000

View File

@ -1,6 +1,14 @@
#include "freertos/FreeRTOS.h" #ifndef _APP_WIFI_H_
#include "freertos/event_groups.h" #define _APP_WIFI_H_
extern EventGroupHandle_t g_wifi_event_group; #ifdef __cplusplus
extern "C" {
#endif
void app_wifi_init(); void app_wifi_init();
#ifdef __cplusplus
}
#endif
#endif