Error :
Code: Select all
ESP_ERROR_CHECK failed: esp_err_t 0x2 (ERROR) at 0x40220064
0x40220064: _esp_error_check_failed at C:/esp/ESP8266_RTOS_SDK/components/freertos/port/esp8266/panic.c:206
file: "wifi_app.c" line 539
func: wifi_softap_config
expression: esp_wifi_set_config(ESP_IF_WIFI_AP, &ap_config)
abort() was called at PC 0x40220067 on core 0
0x40220067: _esp_error_check_failed at C:/esp/ESP8266_RTOS_SDK/components/freertos/port/esp8266/panic.c:207
Code :
Code: Select all
static void wifi_app_event_handler_init(void){
//Event loop for Wifi driver
ESP_ERROR_CHECK(esp_event_loop_create_default());
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_app_event_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &wifi_app_event_handler, NULL));
}
static void wifi_ap_app_default_wifi_init(void)
{
//Initialize TCPIP Stack
tcpip_adapter_init();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
}
static void wifi_softap_config(void)
{
wifi_config_t ap_config =
{
.ap = {
.ssid = WIFI_AP_SSID,
.ssid_len = MAX_SSID_LENGTH,
.password = WIFI_AP_PASSWORD,
.channel = WIFI_AP_CHANNEL,
.ssid_hidden = WIFI_AP_SSID_HIDDEN,
.authmode = WIFI_AUTH_WPA2_PSK,
.max_connection = WIFI_AP_MAX_CONNECTIONS,
.beacon_interval = WIFI_AP_BEACON_INTERVAL,
},
};
tcpip_adapter_ip_info_t ap_ip_info;
memset(&ap_ip_info, 0x00, sizeof(ap_ip_info));
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_AP);
inet_pton(AF_INET, WIFI_AP_IP,&ap_ip_info.ip);
inet_pton(AF_INET, WIFI_AP_GATEWAY, &ap_ip_info.gw);
inet_pton(AF_INET, WIFI_AP_NETMASK, &ap_ip_info.netmask);
//
tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &ap_ip_info);
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_AP);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &ap_config)); [b]// THIS LINE IS THROWING ERROR[/b]
}
static void wifi_ap_app_task(void *pvParameters)
{
wifi_app_queue_message_t msg;
EventBits_t eventBits;
wifi_app_event_handler_init();
wifi_ap_app_default_wifi_init();
wifi_softap_config();
ESP_ERROR_CHECK(esp_wifi_start());
wifi_app_send_message(WIFI_AP_SERVER_START);
while(1)
{
if (xQueueReceive(wifi_app_queue_handle, &msg, portMAX_DELAY))
{
switch(msg.wifi_message)
{
case WIFI_AP_SERVER_START:
ESP_LOGI(TAG, "352 WIFI_AP_START");
break;
default:
break;
}
}
}
}
void wifi_ap_app_start(void)
{
ESP_LOGI(TAG,"STARTING WIFI AP APP");
esp_log_level_set("wifi", ESP_LOG_NONE);
nvs_flash_init();
//Initialize GPIO
gpio_main();
//CREATE MESSAGE QUEUE
wifi_app_queue_handle = xQueueCreate(5,sizeof(wifi_app_queue_message_t));
//Create wifi application event group
wifi_app_event_group = xEventGroupCreate();
xTaskCreate(&wifi_ap_app_task, "wifi_ap_app_task", 4096, NULL, 5, NULL);
}