tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
648 stars 214 forks source link

to generate AP mode mode manually by pressing a button #124

Open goudam06 opened 3 years ago

goudam06 commented 3 years ago

**Actually we need to set the AP mode manually then we wants to store AP in a NVS.

we have crash when i use esp_wifi_set_mode(WIFI_MODE_APSTA) and start http and dns server manually void enter_config_mode(){ //disconnect should happen if already connected //wifi_manager_disconnect_async(); //enter AP mode

ESP_LOGE(TAG,"enter_config_mode");
esp_wifi_disconnect();
ESP_LOGE(TAG,"enter_wifi_disconnect_mode");
if(esp_wifi_set_mode(WIFI_MODE_APSTA)==ESP_OK){
    /* restart HTTP daemon */
        http_app_stop();
        http_app_start(true);

        /* start DNS */
        dns_server_start();
        ESP_LOGE(TAG,"enter_WIFI_MODE_APSTA");
}else{
    ESP_LOGE(TAG,"enter_WIFI_MODE_APSTA failed reason:%d",esp_wifi_set_mode(WIFI_MODE_APSTA));
}

//wifi_manager_destroy();

} void monitoring_task(void *pvParameter) {

for(;;){
    ESP_LOGI(TAG, "free heap: %d",esp_get_free_heap_size());
    vTaskDelay( pdMS_TO_TICKS(60000) );
    //wifi_manager_disconnect_async();
    enter_config_mode();

}

}

goudam06 commented 3 years ago

if i try this changes with your demo code. I (59628) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (59628) wifi_manager: MESSAGE: ORDER_CONNECT_STA ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x40086d6c file: "D:/IOT/Development/esp/esp-idf-v4.2/components/esp32-wifi-manager-master/src/wifi_manager.c" line 1020 func: wifi_manager expression: esp_wifi_scan_start(&scan_config, false)

abort() was called at PC 0x40086d6f on core 0

Backtrace:0x400871d3:0x3ffbdce0 0x40087871:0x3ffbdd00 0x4008e48a:0x3ffbdd20 0x40086d6f:0x3ffbdd90 0x400d640d:0x3ffbddb0 0x40087879:0x3ffbdf40

ELF file SHA256: 0f4204f40fb8bb75

Rebooting... ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1e (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:4 load:0x3fff0034,len:7164 load:0x40078000,len:13212 ho 0 tail 12 room 4 load:0x40080400,len:4568 entry 0x400806f4 I (31) boot: ESP-IDF v4.2-dirty 2nd stage bootloader I (31) boot: compile time 17:56:15 I (31) boot: chip revision: 1 I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0 I (41) boot.esp32: SPI Speed : 40MHz I (46) boot.esp32: SPI Mode : DIO I (50) boot.esp32: SPI Flash Size : 2MB I (55) boot: Enabling RNG early entropy source... I (60) boot: Partition Table: I (64) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 00100000 I (94) boot: End of partition table I (98) boot_comm: chip revision: 1, min. application chip revision: 0 I (105) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1f544 (128324) map I (163) esp_image: segment 1: paddr=0x0002f56c vaddr=0x3ffb0000 size=0x00aac ( 2732) load I (164) esp_image: segment 2: paddr=0x00030020 vaddr=0x400d0020 size=0x7b028 (503848) map I (361) esp_image: segment 3: paddr=0x000ab050 vaddr=0x3ffb0aac size=0x02f58 ( 12120) load I (366) esp_image: segment 4: paddr=0x000adfb0 vaddr=0x40080000 size=0x00404 ( 1028) load I (368) esp_image: segment 5: paddr=0x000ae3bc vaddr=0x40080404 size=0x15244 ( 86596) load I (426) boot: Loaded app from partition at offset 0x10000 I (427) boot: Disabling RNG early entropy source... I (427) cpu_start: Pro cpu up. I (431) cpu_start: Application information: I (435) cpu_start: Project name: scan I (440) cpu_start: App version: 1 I (445) cpu_start: Compile time: Feb 3 2021 17:52:50 I (451) cpu_start: ELF file SHA256: 0f4204f40fb8bb75... I (457) cpu_start: ESP-IDF: v4.2-dirty I (462) cpu_start: Starting app cpu, entry point is 0x400818ac I (453) cpu_start: App cpu up. I (473) heap_init: Initializing. RAM available for dynamic allocation: I (479) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (485) heap_init: At 3FFB8000 len 00028000 (160 KiB): DRAM I (492) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (498) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (504) heap_init: At 40095648 len 0000A9B8 (42 KiB): IRAM I (511) cpu_start: Pro cpu start user code I (529) spi_flash: detected chip: generic I (530) spi_flash: flash io: dio W (530) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (540) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (628) wifi_manager: Set STA IP String to: 0.0.0.0 I (628) main: free heap: 251772 I (638) system_api: Base MAC address is not set I (638) system_api: read default base MAC address from EFUSE I (658) wifi_init: rx ba win: 6 I (658) wifi_init: tcpip mbox: 32 I (658) wifi_init: udp mbox: 6 I (658) wifi_init: tcp mbox: 6 I (658) wifi_init: tcp tx win: 5744 I (668) wifi_init: tcp rx win: 5744 I (668) wifi_init: tcp mss: 1440 I (678) wifi_init: WiFi IRAM OP enabled I (678) wifi_init: WiFi RX IRAM OP enabled I (1548) phy: phy_version: 4500, 0cd6843, Sep 17 2020, 15:37:07, 0, 0 I (1558) wifi_manager: I (1558) http_server: Registering URI handlers I (1558) wifi_manager: MESSAGE: ORDER_LOAD_AND_RESTORE_STA I (1568) wifi_manager: wifi_manager_fetch_wifi_sta_config: ssid:Le 1s password:anthonis I (1568) wifi_manager: Saved wifi found on startup. Will attempt to connect. I (1578) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (3628) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (3638) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (3638) wifi_manager: Set STA IP String to: 0.0.0.0 I (3638) main: Connnection disconnected 201 I (8638) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (8638) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (10688) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (10688) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (10688) wifi_manager: Set STA IP String to: 0.0.0.0 I (10698) main: Connnection disconnected 201 I (15698) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (15698) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (17748) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (17748) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (17748) wifi_manager: Set STA IP String to: 0.0.0.0 I (17758) main: Connnection disconnected 201 I (22758) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (22758) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (24808) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (24808) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (24808) wifi_manager: Set STA IP String to: 0.0.0.0 I (24818) main: Connnection disconnected 201 I (24818) wifi_manager: MESSAGE: ORDER_START_AP I (24828) wifi_manager: WIFI_EVENT_AP_START I (24938) http_server: Registering URI handlers I (24938) dns_server: DNS Server listening on 53/udp I (29818) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (29818) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (32258) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (32258) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (32268) wifi_manager: Set STA IP String to: 0.0.0.0 I (32268) main: Connnection disconnected 201 I (37268) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (37268) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (39708) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (39708) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (39718) wifi_manager: Set STA IP String to: 0.0.0.0 I (39718) main: Connnection disconnected 201 I (44718) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (44718) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (47158) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (47158) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (47168) wifi_manager: Set STA IP String to: 0.0.0.0 I (47168) main: Connnection disconnected 201 I (52168) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (52168) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (54608) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (54608) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 201 I (54618) wifi_manager: Set STA IP String to: 0.0.0.0 I (54618) main: Connnection disconnected 201 I (59618) wifi_manager: Retry Timer Tick! Sending ORDER_CONNECT_STA with reason CONNECTION_REQUEST_AUTO_RECONNECT I (59618) wifi_manager: MESSAGE: ORDER_CONNECT_STA E (60628) main: enter_config_mode E (60628) main: enter_wifi_disconnect_mode I (60728) http_server: Registering URI handlers E (60728) main: enter_WIFI_MODE_APSTA I (60728) main: free heap: 213020 I (83528) wifi_manager: WIFI_EVENT_AP_STACONNECTED I (83538) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 10.10.0.2 I (84398) dns_server: Replying to DNS request for www.msftconnecttest.com from 10.10.0.2 I (84718) dns_server: Replying to DNS request for www.msftconnecttest.com from 10.10.0.2 I (86138) dns_server: Replying to DNS request for www.msftconnecttest.com from 10.10.0.2 I (86288) dns_server: Replying to DNS request for www.msftconnecttest.com from 10.10.0.2 I (86328) dns_server: Replying to DNS request for go.microsoft.com from 10.10.0.2 I (86338) dns_server: Replying to DNS request for www.msn.com from 10.10.0.2 I (87748) dns_server: Replying to DNS request for nav.smartscreen.microsoft.com from 10.10.0.2