GithubHelp home page GithubHelp logo

tonyp7 / esp32-wifi-manager Goto Github PK

View Code? Open in Web Editor NEW
633.0 31.0 211.0 12.03 MB

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.

License: MIT License

Makefile 0.25% Batchfile 0.04% C 81.49% JavaScript 7.79% HTML 3.70% CSS 6.32% CMake 0.40%
esp32 wifi esp-idf wifi-manager espressif

esp32-wifi-manager's People

Contributors

0dd1er avatar fredrikfornstad avatar hanhdt avatar lukecyca avatar ncrmro avatar skinner927 avatar stozze avatar tamisoft avatar tonyp7 avatar trombik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-wifi-manager's Issues

Possibility to add more input fields during AP mode.

Good day. Firstly let me say thank you for the awesome code which you have developed.
I would like to use this code in one of my projects but I have the need to enter more data strings like IP address and device name and store them in NVS. Could you please let me know whether this is at all possible and how I could implement it?
Thank you.

Problem connecting iphones - esp-idf 3.1.2

Hello,

With 3.1.2 esp-idf version, I'm struggling to connect iPhones to Wifi manager while it is working fine with Androids' phones.

Does anyone face the same issue ? Any tricks ?

module getting restarted

I just build the source and do run. When I'm connecting to ESP32 wifi(STA) in mobile module getting restarted

I (5903) dns_server: Replying to DNS request for idmb-app-chat-global-xiaomi-1108233833.ap-south-1.elb.amazonaws.com... from 10.10.0.2
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4000c677 PS : 0x00060d30 A0 : 0x800e4ad9 A1 : 0x3ffc8e00
A2 : 0x00000000 A3 : 0x3f406ef8 A4 : 0x3ffc8e58 A5 : 0x00000001
A6 : 0x00000000 A7 : 0x00060523 A8 : 0x3ffcbf3d A9 : 0x00000000
A10 : 0x3ffc8e4b A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000000 A15 : 0xff000000 SAR : 0x0000001b EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff

ELF file SHA256: 7b3d40228c8d28e83ce6ff3fb53a2fdee0973d98960b768004aa153340ec50c0

Backtrace: 0x4000c674:0x3ffc8e00 |<-CORRUPTED

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

rst:0xc (SW_CPU_RESET),boot:0x13 (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:0x3fff0018,len:4
load:0x3fff001c,len:6524
load:0x40078000,len:12200
load:0x40080400,len:6640
entry 0x40080774

dynamic or static ram

Hi tony,

Does this wifi manage uses dynamic ram allocaton for wifi or static.
Where in the code I can specify not to use dynamic ram.

in my menuconfig I specify only static ram. I don't want to use dynamic ram for wifi.

but my debug logs on startup shows some dynamic ram allocations.

I (1105) wifi: Init dynamic tx buffer num: 32
I (1108) wifi: Init data frame dynamic rx buffer num: 64
I (1113) wifi: Init management frame dynamic rx buffer num: 64
I (1119) wifi: Init static tx buffer num: 12
I (1123) wifi: Init static rx buffer size: 1600
I (1127) wifi: Init static rx buffer num: 12
I (1131) wifi: Init dynamic rx buffer num: 0

Kindly do reply.

Thanks,
Naeem

Unable to get wifi list on android Phone.

I am able to connect to ESP32 AP. it open up a HTML page but there is no Wi-Fi list in that page.
I am trying this on android phone as well as on windows phone. Not working on android but the same is working on windows phone.
Can anyone help me out. Thanks in advance.

Fast scan and its implication

// configure the softAP and start it */
wifi_config_t ap_config;
ap_config.ap.ssid_len = 0;
ap_config.ap.channel = __wifi_settings.ap_channel;
ap_config.ap.authmode = (wifi_auth_mode_t)__wifi_settings.ap_authmode;
ap_config.ap.ssid_hidden = __wifi_settings.ap_ssid_hidden;
ap_config.ap.max_connection = AP_MAX_CONNECTIONS;
ap_config.ap.beacon_interval = AP_BEACON_INTERVAL;
memcpy(ap_config.ap.ssid, __wifi_settings.ap_ssid, sizeof(__wifi_settings.ap_ssid));
memcpy(ap_config.ap.password, __wifi_settings.ap_pwd, sizeof(__wifi_settings.ap_pwd));
ap_config.sta.scan_method = WIFI_FAST_SCAN;

ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));
ESP_ERROR_CHECK(esp_wifi_start());

MQTT

Hi,

Thanks again for a nice program.

I've run into an issue combining the wifi-manager with MQTT. If I use a the MQTT app (task) separately (stand alone) it is able to publish messages okay to a remote host. However, if I use MQTT app (task) with wifi-manager, the MQTT app is not able to connect to the remote host to publish messages. I've gone through the wifi-manager code, and tested different options. So far I've not found a solution to why the MQTT app will not work along aside the wifi-manager.

I have been able to use the wifi-manager to select an access point and store the access point credentials to NVM. Then on a reboot, I check to see if there are access points credential in the NVM, If there are, I used those credentials to attached to the access point and start the MQTT app. I don't start the wifi-manager up in this case. This configuration works okay.

Have you run see this issue? Do you have any recommendations on combining wifi-manager with MQTT?

Thanks,
Robert

Possible feature: ability to change AP SSID & Password over webpage

Hello, awesome work on this wifi manager btw!

I am using the wifi manager and thought it would be great to have the ability to create a new AP ssid and password over the webpage. I was trying this, but I am having major troubles modifying the wifi_manager.c file to enable saving the new credentials to the flash and retrieving them upon restarting the ESP - so I thought I would ask if you have any plans for this in the future?

all the best

Error when trying to configure the AP-AP/STA settings

Whenever I change the value in the header file Wifi_manager for the AP or AP/STA config, the program breaks and throws this error:

****ESP_ERROR_CHECK failed: esp_err_t 0xb (ERROR) at 0x400d397b
0x400d397b: wifi_manager at /home/will/esp/esp32-wifi-manager/wifi_manager/main/wifi_manager.c:527 (discriminator 1)

file: "/home/will/esp/esp32-wifi-manager/wifi_manager/main/wifi_manager.c" line 527
func: wifi_manager
expression: esp_wifi_set_config(WIFI_IF_AP, &ap_config)

Backtrace: 0x4008e78c:0x3ffbe9e0 0x4008ec3c:0x3ffbea00 0x400d397b:0x3ffbea20
0x4008e78c: invoke_abort at /home/will/esp/esp-idf/components/esp32/panic.c:649****

Even trying to change the value back and reflashing the board doesnt fix it. Any ideas?

Installation help for newbies

Hi,
I'm new to ESP32 development. I use the Arduino IDE, and would like to know how to use the Wifi manager with it.

thanks!

WiFI AP and STA connect and disconnect

Hi,

I need to keep track of now many WiFi clients are connected to my Access point. I run my application with both AP and STA modes.

I need to keep count of how many WiFi clients are connected to me via AP or STA and when it disconnect we get event. then we can decrement count.

AP not visible or not started

Hi,

I am new to ESP32, so my apologies if I am missing out something obvious.

I downloaded the esp32-wifi-manager and tried to compile the project, using vscode, ESP-IDF 3.2 and mingw32 under windows. It compiled fine, starts and using make monitor I see the attached log.

No errors present, but I do not see any Access Point when scanning for it. Hence I cannot connect and configure the STA.

esp_wifi_start() in wifi_manager.c, line 577 returns ESP_OK.

I am puzzled, what the problem might be.

I m using the Heltec esp32 wifi board.

Any help appreciated.

Kind regards
GvT
ESP_wifi_manager.txt

Board resetting

I am trying to run the example code on an esp32 and the board is resetting.
The code I get is this:

I (224) cpu_start: App cpu up.
I (254) heap_init: Initializing. RAM available for dynamic allocation:
I (261) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (267) heap_init: At 3FFB9378 len 00026C88 (155 KiB): DRAM
I (273) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (279) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (286) heap_init: At 40090188 len 0000FE78 (63 KiB): IRAM
I (292) cpu_start: Pro cpu start user code
I (11) pm_esp32: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: XTAL, Light sleep: DISABLED
I (12) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
http_server: waiting for start bit
wifi_manager: Start DHCP client for STA interface. If not already running
I (68) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (68) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
free heap: 248116

Brownout detector was triggered

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (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:0x3fff0018,len:4
load:0x3fff001c,len:5744
ho 0 tail 12 room 4
load:0x40078000,len:0
load:0x40078000,len:13992
entry 0x40079008

What am I doing wrong?

Thank you

Change to only sta mode when connected

Skimming through the code, it seems that the expected behavior is to connect to the network via web server, being the device in sta+ap mode and change to only sta mode. But this doesn't happen

Errors on ESP-IDF 3.2

Hi. I have downloaded your code and try to to run it. This is what I get:

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

rst:0xc (SW_CPU_RESET),boot:0x13 (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:1
load:0x3fff0018,len:4
load:0x3fff001c,len:8580
load:0x40078000,len:12064
load:0x40080400,len:7116
entry 0x400807a0
D (64) bootloader_flash: mmu set block paddr=0x00000000 (was 0xffffffff)
I (35) boot: ESP-IDF v4.0-dev-278-gdaee3dfa5 2nd stage bootloader
I (36) boot: compile time 23:04:18
D (36) boot: Enabling RTCWDT(9000 ms)
I (49) boot: Enabling RNG early entropy source...
D (49) boot: magic e9
D (49) boot: segments 04
D (51) boot: spi_mode 02
D (53) boot: spi_speed 0f
D (56) boot: spi_size 02
I (58) boot: SPI Speed : 80MHz
I (63) boot: SPI Mode : DIO
I (67) boot: SPI Flash Size : 4MB
D (71) bootloader_flash: mmu set paddr=00000000 count=1 size=c00 src_addr=8000 src_addr_aligned=0
D (80) boot: mapped partition table 0x8000 at 0x3f408000
D (85) flash_parts: partition table verified, 9 entries
I (90) boot: Partition Table:
I (94) boot: ## Label Usage Type ST Offset Length
D (101) boot: load partition table entry 0x3f408000
D (106) boot: type=1 subtype=2
I (109) boot: 0 nvs WiFi data 01 02 00009000 00005000
D (117) boot: load partition table entry 0x3f408020
D (122) boot: type=1 subtype=0
I (125) boot: 1 otadata OTA data 01 00 0000e000 00002000
D (132) boot: load partition table entry 0x3f408040
D (137) boot: type=0 subtype=0
I (140) boot: 2 factory factory app 00 00 00010000 00120000
D (148) boot: load partition table entry 0x3f408060
D (153) boot: type=0 subtype=10
I (156) boot: 3 app0 OTA app 00 10 00130000 00100000
D (164) boot: load partition table entry 0x3f408080
D (169) boot: type=0 subtype=11
I (172) boot: 4 app1 OTA app 00 11 00230000 00100000
D (179) boot: load partition table entry 0x3f4080a0
D (184) boot: type=1 subtype=99
I (188) boot: 5 eeprom Unknown data 01 99 00330000 00001000
D (195) boot: load partition table entry 0x3f4080c0
D (200) boot: type=1 subtype=82
I (203) boot: 6 storage Unknown data 01 82 00331000 00060000
D (211) boot: load partition table entry 0x3f4080e0
D (216) boot: type=1 subtype=4
I (219) boot: 7 nvs_key NVS keys 01 04 00391000 00001000
I (227) boot: End of partition table
D (231) boot: OTA data offset 0xe000
D (234) bootloader_flash: mmu set paddr=00000000 count=1 size=2000 src_addr=e000 src_addr_aligned=0
D (244) boot: otadata[0]: sequence values 0xffffffff
D (249) boot: otadata[1]: sequence values 0xffffffff
D (254) boot: OTA sequence numbers both empty (all-0xFF) or partition table does not have bootable ota_apps (app_count=2)
I (265) boot: Defaulting to factory image
D (269) boot: Trying partition index -1 offs 0x10000 size 0x120000
D (276) esp_image: reading image header @ 0x10000
D (280) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
D (287) esp_image: image header: 0xe9 0x06 0x02 0x02 400810c4
I (293) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2687c (157820) map
D (302) bootloader_flash: mmu set paddr=00010000 count=3 size=2687c src_addr=10020 src_addr_aligned=10000
D (358) bootloader_flash: mmu set block paddr=0x00030000 (was 0xffffffff)
I (358) esp_image: segment 1: paddr=0x000368a4 vaddr=0x3ffb0000 size=0x03080 ( 12416) load
D (362) bootloader_flash: mmu set paddr=00030000 count=1 size=3080 src_addr=368a4 src_addr_aligned=30000
D (376) bootloader_flash: mmu set block paddr=0x00030000 (was 0xffffffff)
I (379) esp_image: segment 2: paddr=0x0003992c vaddr=0x40080000 size=0x00400 ( 1024) load
0x40080000: _WindowOverflow4 at D:/msys32/home/Akoya/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (387) bootloader_flash: mmu set paddr=00030000 count=1 size=400 src_addr=3992c src_addr_aligned=30000
D (397) bootloader_flash: mmu set block paddr=0x00030000 (was 0xffffffff)
I (404) esp_image: segment 3: paddr=0x00039d34 vaddr=0x40080400 size=0x062dc ( 25308) load
D (413) bootloader_flash: mmu set paddr=00030000 count=2 size=62dc src_addr=39d34 src_addr_aligned=30000
D (431) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
I (431) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0x69d8c (433548) map
0x400d0018: _stext at ??:?

D (438) bootloader_flash: mmu set paddr=00040000 count=7 size=69d8c src_addr=40018 src_addr_aligned=40000
D (574) bootloader_flash: mmu set block paddr=0x000a0000 (was 0xffffffff)
I (574) esp_image: segment 5: paddr=0x000a9dac vaddr=0x400866dc size=0x094c4 ( 38084) load
0x400866dc: ieee80211_output_process at ??:?

D (578) bootloader_flash: mmu set paddr=000a0000 count=2 size=94c4 src_addr=a9dac src_addr_aligned=a0000
D (601) bootloader_flash: mmu set block paddr=0x000b0000 (was 0xffffffff)
D (602) esp_image: Calculated hash: b98fa9f5c444ddbec0cb523d84e1a373863507c349cdfbc20f826972c1e11be2
D (606) bootloader_flash: mmu set paddr=000b0000 count=1 size=20 src_addr=b3280 src_addr_aligned=b0000
D (616) bootloader_flash: mmu set paddr=000b0000 count=1 size=20 src_addr=b3280 src_addr_aligned=b0000
I (634) boot: Loaded app from partition at offset 0x10000
I (634) boot: Disabling RNG early entropy source...
D (637) boot: Mapping segment 0 as DROM
D (641) boot: Mapping segment 4 as IROM
D (644) boot: calling set_cache_and_start_app
D (649) boot: configure drom and irom and start
D (654) boot: start: 0x400810c4
0x400810c4: call_start_cpu0 at D:/msys32/home/Akoya/esp/esp-idf/components/esp32/cpu_start.c:121

I (657) cpu_start: Pro cpu up.
I (660) cpu_start: Application information:
I (665) cpu_start: Project name: wifi_manager
I (671) cpu_start: App version: 1
I (675) cpu_start: Compile time: Apr 16 2019 23:03:15
I (681) cpu_start: ELF file SHA256: 3deb2d4cdfbba3d6...
I (687) cpu_start: ESP-IDF: v4.0-dev-278-gdaee3dfa5
I (694) cpu_start: Starting app cpu, entry point is 0x40081070
0x40081070: call_start_cpu1 at D:/msys32/home/Akoya/esp/esp-idf/components/esp32/cpu_start.c:267

I (682) cpu_start: App cpu up.
D (704) memory_layout: Checking 7 reserved memory ranges:
D (709) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0
D (716) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb8f68
D (722) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440
D (728) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350
D (735) memory_layout: Reserved memory range 0x40070000 - 0x40078000
D (741) memory_layout: Reserved memory range 0x40078000 - 0x40080000
0x40080000: _WindowOverflow4 at D:/msys32/home/Akoya/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (748) memory_layout: Reserved memory range 0x40080000 - 0x4008fb9d
0x40080000: _WindowOverflow4 at D:/msys32/home/Akoya/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

D (754) memory_layout: Building list of available memory regions:
D (760) memory_layout: Available memory region 0x3ffae6e0 - 0x3ffb0000
D (767) memory_layout: Available memory region 0x3ffb8f68 - 0x3ffc0000
D (774) memory_layout: Available memory region 0x3ffc0000 - 0x3ffc2000
D (780) memory_layout: Available memory region 0x3ffc2000 - 0x3ffc4000
D (787) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc6000
D (793) memory_layout: Available memory region 0x3ffc6000 - 0x3ffc8000
D (800) memory_layout: Available memory region 0x3ffc8000 - 0x3ffca000
D (807) memory_layout: Available memory region 0x3ffca000 - 0x3ffcc000
D (813) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000
D (820) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000
D (826) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000
D (833) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000
D (840) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000
D (846) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000
D (853) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000
D (859) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000
D (866) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000
D (873) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000
D (879) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20
D (886) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000
D (892) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000
D (899) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000
D (905) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (912) memory_layout: Available memory region 0x3fffc000 - 0x40000000
D (919) memory_layout: Available memory region 0x4008fba0 - 0x40090000
D (925) memory_layout: Available memory region 0x40090000 - 0x40092000
D (932) memory_layout: Available memory region 0x40092000 - 0x40094000
D (938) memory_layout: Available memory region 0x40094000 - 0x40096000
D (945) memory_layout: Available memory region 0x40096000 - 0x40098000
D (952) memory_layout: Available memory region 0x40098000 - 0x4009a000
D (958) memory_layout: Available memory region 0x4009a000 - 0x4009c000
D (965) memory_layout: Available memory region 0x4009c000 - 0x4009e000
D (971) memory_layout: Available memory region 0x4009e000 - 0x400a0000
I (978) heap_init: Initializing. RAM available for dynamic allocation:
I (990) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (996) heap_init: New heap initialised at 0x3ffb8f68
I (1002) heap_init: At 3FFB8F68 len 00027098 (156 KiB): DRAM
I (1008) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1014) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (1021) heap_init: New heap initialised at 0x4008fba0
I (1026) heap_init: At 4008FBA0 len 00010460 (65 KiB): IRAM
I (1032) cpu_start: Pro cpu start user code
D (1044) clk: RTC_SLOW_CLK calibration value: 3170099
D (47) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (48) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (48) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (53) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (68) heap_init: New heap initialised at 0x3ffe0440
D (78) heap_init: New heap initialised at 0x3ffe4350
D (88) intr_alloc: Connected src 16 to int 12 (cpu 0)
D (88) nvs: nvs_flash_init_custom partition=nvs start=9 count=5
D (118) http_server: waiting for start bit
D (118) nvs: nvs_open_from_partition espwifimgr 0
D (118) tcpip_adapter: dhcp server stop successfully
D (118) tcpip_adapter: dhcp server re init
D (128) wifi_manager: wifi_manager: Start DHCP client for STA interface. If not already running

D (138) tcpip_adapter: dhcp client re init
D (138) nvs: nvs_open_from_partition misc 1
D (148) nvs: nvs_get_str_or_blob log
D (148) main: free heap: 247560
I (148) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
D (158) efuse: coding scheme 0
D (168) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (168) efuse: coding scheme 0
D (178) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (178) efuse: coding scheme 0
D (188) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (188) efuse: coding scheme 0
D (198) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (198) efuse: coding scheme 0
D (208) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (208) efuse: coding scheme 0
D (218) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (218) efuse: coding scheme 0
D (228) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
I (228) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
D (238) efuse: coding scheme 0
D (248) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (248) efuse: coding scheme 0
D (258) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (258) efuse: coding scheme 0
D (268) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (268) efuse: coding scheme 0
D (278) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (278) efuse: coding scheme 0
D (288) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (288) efuse: coding scheme 0
D (298) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (298) efuse: coding scheme 0
D (308) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
D (308) nvs: nvs_open_from_partition nvs.net80211 1
D (318) nvs: nvs_get opmode 1
D (318) nvs: nvs_get_str_or_blob sta.ssid
D (328) nvs: nvs_get_str_or_blob sta.mac
D (328) nvs: nvs_get sta.authmode 1
D (328) nvs: nvs_get_str_or_blob sta.pswd
D (338) nvs: nvs_get_str_or_blob sta.pmk
D (338) nvs: nvs_get sta.chan 1
D (338) nvs: nvs_get auto.conn 1
D (348) nvs: nvs_get bssid.set 1
D (348) nvs: nvs_get_str_or_blob sta.bssid
D (358) nvs: nvs_get sta.lis_intval 2
D (358) nvs: nvs_get sta.phym 1
D (358) nvs: nvs_get sta.phybw 1
D (368) nvs: nvs_get_str_or_blob sta.apsw
D (368) nvs: nvs_get_str_or_blob sta.apinfo
D (378) nvs: nvs_get sta.scan_method 1
D (378) nvs: nvs_get sta.sort_method 1
D (378) nvs: nvs_get sta.minrssi 1
D (388) nvs: nvs_get sta.minauth 1
D (388) nvs: nvs_get_str_or_blob ap.ssid
D (388) nvs: nvs_get_str_or_blob ap.mac
D (398) nvs: nvs_get_str_or_blob ap.passwd
D (398) nvs: nvs_get_str_or_blob ap.pmk
D (398) nvs: nvs_get ap.chan 1
D (408) nvs: nvs_get ap.authmode 1
D (408) nvs: nvs_get ap.hidden 1
D (408) nvs: nvs_get ap.max.conn 1
D (418) nvs: nvs_get bcn.interval 2
D (418) nvs: nvs_get ap.phym 1
D (418) nvs: nvs_get ap.phybw 1
D (428) nvs: nvs_get ap.sndchan 1
D (428) nvs: nvs_get lorate 1
D (428) nvs: nvs_set_blob sta.mac 6
D (448) nvs: nvs_set_blob ap.mac 6
ESP_ERROR_CHECK failed: esp_err_t 0xb (ERROR) at 0x40088008
0x40088008: _esp_error_check_failed at D:/msys32/home/Akoya/esp/esp-idf/components/esp32/panic.c:721

file: "D:/msys32/home/AKOYA/esp/wifi_manager/main/wifi_manager.c" line 580
func: wifi_manager
expression: esp_wifi_set_config(WIFI_IF_AP, &ap_config)

ELF file SHA256: 3deb2d4cdfbba3d6f9dd637f484a0e62cb697f04a7c2f9b1445014692005d6af

Backtrace: 0x40087b9c:0x3ffbef60 0x4008800b:0x3ffbef80 0x400d3c76:0x3ffbefa0 0x4008d161:0x3ffbf110
0x40087b9c: invoke_abort at D:/msys32/home/Akoya/esp/esp-idf/components/esp32/panic.c:716

0x4008800b: _esp_error_check_failed at D:/msys32/home/Akoya/esp/esp-idf/components/esp32/panic.c:722

0x400d3c76: wifi_manager at D:/msys32/home/AKOYA/esp/wifi_manager/main/wifi_manager.c:580 (discriminator 1)

0x4008d161: vPortTaskWrapper at D:/msys32/home/Akoya/esp/esp-idf/components/freertos/port.c:403
`

Any idea why it reboots at /wifi_manager.c" line 580?

Request to Create the wifi_manager_event_group On wifi_manager_start()

Hello,

Thank you for your useful contribution.

In my application I do not use the callback feature, instead I read bits from the wifi_manager_event_group.

There is a race condition where if I read from the group before wifi_manager's task is started I will crash trying to read a group that hasn't been created yet.

Why not just create it in the very first method, the start method?

`
void wifi_manager_start(){

/* disable the default wifi logging */
esp_log_level_set("wifi", ESP_LOG_NONE);

//move to here
wifi_manager_event_group = xEventGroupCreate();

`

Also, recommend that you initialize it to zero at the top of the file :)

Thanks Again,
QC

AP or STA only mode.

I need to start my application AP mode and then after scan and join another AP. I need to disconnect and connect to STA only.
Is it possible?

jquery.js

Great applications. Thanks.

I was wondering if you happen to have a human readable verions of jquery.js?

Thanks,
Robert

Setting DEFAULT_AP_PASSWORD to empty string or "\0" causes boot loop

I tried to set DEFAULT_AP_PASSWORD to "" as instructed in the comment above in wifi_manager.h but this results in a boot loop. Looks like this:

I (0) cpu_start: App cpu up.
I (446) heap_init: Initializing. RAM available for dynamic allocation:
I (453) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (459) heap_init: At 3FFB8DD8 len 00027228 (156 KiB): DRAM
I (465) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (471) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (478) heap_init: At 40091690 len 0000E970 (58 KiB): IRAM
I (484) cpu_start: Pro cpu start user code
I (166) pm_esp32: Frequency switching config: CPU_MAX: 160, APB_MAX: 80, APB_MIN: 40, Light sleep: DISABLED
I (167) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
http_server: waiting for start bit
wifi_manager: Start DHCP client for STA interface. If not already running
I (279) IOT_UNICORN: Time is not set yet. Getting time over NTP.
free heap: 249904
I (299) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (299) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
ESP_ERROR_CHECK failed: esp_err_t 0xb (ERROR) at 0x4008c74c
0x4008c74c: _esp_error_check_failed at /storage/workspace/esp/esp-idf/components/esp32/panic.c:685

file: "/storage/workspace/esp/wifi_unicorn/main/wifi_manager.c" line 576
func: wifi_manager
expression: esp_wifi_set_config(WIFI_IF_AP, &ap_config)

Backtrace: 0x4008c30c:0x3ffbe1f0 0x4008c74f:0x3ffbe210 0x400d3923:0x3ffbe230 0x4008e9d1:0x3ffbe390
0x4008c30c: invoke_abort at /storage/workspace/esp/esp-idf/components/esp32/panic.c:680

0x4008c74f: _esp_error_check_failed at /storage/workspace/esp/esp-idf/components/esp32/panic.c:686

0x400d3923: wifi_manager at /storage/workspace/esp/wifi_unicorn/main/wifi_manager.c:576 (discriminator 1)

0x4008e9d1: vPortTaskWrapper at /storage/workspace/esp/esp-idf/components/freertos/port.c:403


Rebooting...

I believe it has something to do with how the wifi_settings_t struct gets created initially. Not sure (I'm terrible with C).

STA Mode server does not host my webpage

I have included the wifi manager in my code and what my code does is it hosts a webpage but when I try to open the webpage in my browser it shows your webpage instead of mine even though I am on a home network where esp should be connected as station hosting the webpage.

Also, how can I retrieve the ssid and password from your code so I can manually start my station code thus solving the above-mentioned problem

Need for RESET connections on Start index.html screen

The following use case:

  1. Application is fresh loaded in ESP32
  2. Location A
    2.1 Start: connection from client to 192.168.1.1
    we see the list of networks, we can connect.
    The configured connection: "NetworkA"
  3. Location B, network "NetworkA" is not there.
    3.1. connection from clien to 192.168.1.1.
    No list of available connections is shown.
    A Try to manual connect does not work.
    3.2. From Postman request GET /status.json gives the name of "NetworkA"
  4. on host PC from Postman: request DELETE /connection.json
  5. 1 status is cleaned
    4.2. 192.168.1.1. gives the list of available networks

Resume:
it is not possible from HTML interface alone to reconfigure the settings.
First the request DELETE /connect.json restarts the application.
THe Button "RESET connections: with action request DELETE could fix the issue

I'm newbie in HTML and my own HTML experience are to small to fix it clean
Jan

Implementing into project with ulp.

Hello, thank you for great wifi manager!

I've got an issue, when I'm trying to append wifi manager to program with ULP I catch error with undefined reference

/home/tetenkov/esp/esp32-wifi-manager/wifi_manager/build/main/libmain.a(baremetal.o):(.literal.init_ulp_program+0x0): undefined reference to _binary_ulp_app_bin_end' /home/tetenkov/esp/esp32-wifi-manager/wifi_manager/build/main/libmain.a(baremetal.o):(.literal.init_ulp_program+0x4): undefined reference to _binary_ulp_app_bin_start'

I really change nothing in ULP programming logic, I follow Programming Guide but when I add wifi manager files it fails.

Losing wifi credentials

Hi,

I've integrated wifi manager into a battery operated mailbox detection solution. Here I've used the ESP-Wrover module because it can operate on lower voltages. It is powered by 2 x AA.

I notice from time to time that the wifi credentials are lost and needed to be re-configured with the wifi manager ui.

Any idea what can cause this behavior?

Thanks,

Suggestions

First of all, congrats to excellent coding on ESP-IDF, this is awesome ;-).

I have a few suggestions:

  • Made this as component for easy deployment
  • The password with confirmation (2nd entry for it)
  • When finished, put one button to close the captive portal

Best regards

AP IP address.

Hi,

How this application specify 192.168.1.1 as AP IPv4 address.

I cannot find source code line where It specify it.

Just to confirm It is running in both AP and STA mode. after connect to any AP.

Is web files are part of .bin image?

Enhancement: Support for 802.11 LR (aka. ESP Wifi Long Range Mode)

Hi there,

first of all "Kudos!" for such a nice project! Loving it!

I wonder if it would be possible to include support for the ESP32 WiFi Long Range Mode (https://blog.hackster.io/long-range-wifi-for-the-esp32-9429ab89f450) ?
This way this project could be used as a "WiFi LR <-to-> WiFi" Bridge and LR devices (such as ESP32 based IoT sensors and devices) could be connected to a standard Home WiFi over massive distances. That would be really nice! Distances of 1-10km can be achieved with this mode.

The WiFi-Manager would run a SoftAP with LR Mode enabled and communicate to the other WiFi networks nearby in standard WiFi Mode.

Best regards and keep up the excellent work!
Cheers!
Thomas

How to change AP ssid name and Password

Good day,
I changed the default AP_SSID in the wif_manager.h file but after I flash the file the ssid of the ap does not change?
Can you please advise on what I may be doing wrong and how to achieve this?
Thank you

recording problem

Hello friends,
I'm starting to learn how to use IDF.
I am trying to write the default_demo example but it is giving the error:
"Executing" ninja all "...
[1/5] Performing build step for 'bootloader'
ninja: no work to do.
[2/3] Linking CXX executable wifi_manager.elf
FAILED: wifi_manager.elf "

I believe I am installing the wifi_manager library the wrong way.
I'm putting the "default_demo" folder and the "scr" folder in the esp_idf root, is that it?

thank you for now

Enhancement ideas: Select AP-name, AP-channel, STA-only, WiFi-Power save & Websockets

Thanks for a great application!
I have a few more needs myself and I am trying to find my way through your code but have not yet managed to do what I want:

  1. From the main web page bring up a new page "Settings" (for instance by clicking the "WiFi header")

  2. In the Settings page be able to:
    a. Set (and store) a new name for the AP
    b. Set (and store) a new WiFi channel for the AP
    c. Select (and store) if the AP should be turned off whenever esp32 is successfully connected as a WiFi client (i.e. switch to "STA" mode instead of "APSTA" whenever connected to a WiFi router)
    d. Select (and store) if WiFi Power save mode should be enabled when in client mode

  3. In my own application, I think I will need to use websockets instead of regular Json pulls due to latency. If WiFi-manager could be changed to use websockets instead of regular Json pulls, then I guess it would make WiFi-manager:
    a. acting more in "real time" when scanning for WiFi AP's or when signal strengts varies etc
    b. easier to integrate with applications that need to read/control I/O pins in "real time" (like my app)

Any chance that you are already working on similar additions to WiFi-manager (to save me hours of work :-) )?

Time to execute esp_wifi_scan_start

Hey there,
I'm writing an application on top of wifi-manager that extends the web server such to support my own API. In development I noticed that the esp_wifi_scan_start appears to be stealing 2.5s of CPU time every time it runs (which if often). My next course of action is to disable scanning once the unit enters STA however I was wondering if it was something you've come across and if there are more event driven alternatives?

Alex

else if(uxBits & WIFI_MANAGER_REQUEST_WIFI_SCAN){			             
  int64_t timeBeforeTasks = esp_timer_get_time();
  ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, true));
  int64_t timeAfterTasks = esp_timer_get_time();
  printf("time to scan AP list: %lld ms\n", (timeAfterTasks-timeBeforeTasks)/1000);

time to scan AP list: 2500 ms
time to scan AP list: 2497 ms
time to scan AP list: 2497 ms

Example

Are there any example of how to implement this solution and it's require dependencies?

cannot build with blank password

When I try to build, make sets defaults. menuconfig lets me change those defaults, so I can change the name and password, but there is no option to change auth type. So when I leave a blank password, the esp just keeps crashing. Changes in the header dont work since they are overridden by kconfig during the build.

I need a way to set the password blank and the network type to open.

Forever 4

http_server.c line 169

if ((sizeof(host) > 0) && !strstr(host, DEFAULT_AP_IP)) {

should be

if (host && !strstr(host, DEFAULT_AP_IP)) {
or
if (lenH > 0 && !strstr(host, DEFAULT_AP_IP)) {

And if Wifi is running in STA mode, then it can't be accessed via the network.

vTaskDelete(task_wifi_manager) ?fails?

Great Work, awesome project!
I have a problem though - I can't get wifi_manager_destroy(); to work.

As for a basic test I simply added it to the callback:

void cb_connection_ok(void *pvParameter){
	ESP_LOGI(TAG, "I have a connection!");
	wifi_manager_destroy();
}

I think the problem lays within vTaskDelete() - it seems the function is entered but never left.

void wifi_manager_destroy(){
	ESP_LOGI(TAG, "trying to kill wifi manager");
	     if( task_wifi_manager != NULL ) vTaskDelete(task_wifi_manager);
		else ESP_LOGI(TAG, "This is not the Task you are looking for.");
	ESP_LOGI(TAG, "Success deleting task");
	task_wifi_manager = NULL;

Last Output is:
I (4511) wifi_manager: trying to kill wifi manager
"Success deleting task" is never printed.

I can delete other tasks on my project though (eg heap monitor).

Any Idea why this is happening? It's unclear to me.

How to use Event callbacks?

Hi,
I managed to flash wifi manager on my esp32. Now I would like to add functionality that will check if some pin is high state. If that is true just make a post request or connect to mqtt.
How would I do it?

Wifi Manager static IP and DNS configuration

Hi. I'm trying to connect to aws_iot, but I get "aws_iot: failed! mbedtls_net_connect returned -0x52" error. This error may be a network connection problem. The point I'm curious about is how the network configuration of the aws configuration is trying to connect and how I can select it.
I'm using aws embedded c sdk.

and

I call aws_set_event_start() in the following code block.

		uxBits = xEventGroupWaitBits(wifi_manager_event_group, WIFI_MANAGER_WIFI_CONNECTED_BIT | WIFI_MANAGER_STA_DISCONNECT_BIT, pdFALSE, pdFALSE, portMAX_DELAY );

			if(uxBits & (WIFI_MANAGER_WIFI_CONNECTED_BIT | WIFI_MANAGER_STA_DISCONNECT_BIT)){

				/* Update the json regardless of connection status.
				 * If connection was succesful an IP will get assigned.
				 * If the connection attempt is failed we mark it as a failed connection attempt
				 * as it is important for the front end app to distinguish failed attempt to
				 * regular disconnects
				 */
				if(wifi_manager_lock_json_buffer( portMAX_DELAY )){

					/* only save the config if the connection was successful! */
					if(uxBits & WIFI_MANAGER_WIFI_CONNECTED_BIT){

						/* generate the connection info with success */
						wifi_manager_generate_ip_info_json( UPDATE_CONNECTION_OK );

						/* save wifi config in NVS */
						wifi_manager_save_sta_config();
						#if WIFI_MANAGER_DEBUG
									printf("aws_start_Bit\n");
						#endif
						aws_set_event_start();
					}
					else{

						/* failed attempt to connect regardles of the reason */
						wifi_manager_generate_ip_info_json( UPDATE_FAILED_ATTEMPT );

						/* otherwise: reset the config */
						memset(wifi_manager_config_sta, 0x00, sizeof(wifi_config_t));
					}
					wifi_manager_unlock_json_buffer();
				}
				else{
					/* Even if someone were to furiously refresh a web resource that needs the json mutex,
					 * it seems impossible that this thread cannot obtain the mutex. Abort here is reasonnable.
					 */
					abort();
				}
			}

subscribe_publish_sample.c


/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/**
 * @file subscribe_publish_sample.c
 * @brief simple MQTT publish and subscribe on the same topic
 *
 * This example takes the parameters from the build configuration and establishes a connection to the AWS IoT MQTT Platform.
 * It subscribes and publishes to the same topic - "test_topic/esp32"
 *
 * Some setup is required. See example README for details.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>

#include "aws_iot_config.h"
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_mqtt_client_interface.h"
#include "subscribe_publish_aws.h"
#include "lufft_connect.h"
#include "wifi_manager.h"

/*****************************************************************************/
/*                           GLOBALS                                         */
/*****************************************************************************/

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/

#define TOPIC "test_topic/esp32"
#define TOPIC_LEN  strlen(TOPIC)


#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)

extern const uint8_t aws_root_ca_pem_start[] asm("_binary_aws_root_ca_pem_start");
extern const uint8_t aws_root_ca_pem_end[] asm("_binary_aws_root_ca_pem_end");
extern const uint8_t certificate_pem_crt_start[] asm("_binary_certificate_pem_crt_start");
extern const uint8_t certificate_pem_crt_end[] asm("_binary_certificate_pem_crt_end");
extern const uint8_t private_pem_key_start[] asm("_binary_private_pem_key_start");
extern const uint8_t private_pem_key_end[] asm("_binary_private_pem_key_end");

#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)

static const char * DEVICE_CERTIFICATE_PATH = CONFIG_EXAMPLE_CERTIFICATE_PATH;
static const char * DEVICE_PRIVATE_KEY_PATH = CONFIG_EXAMPLE_PRIVATE_KEY_PATH;
static const char * ROOT_CA_PATH = CONFIG_EXAMPLE_ROOT_CA_PATH;

#else
#error "Invalid method for loading certs"
#endif

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

EventGroupHandle_t aws_connect_event_group;

/**
 * @brief Default MQTT HOST URL is pulled from the aws_iot_config.h
 */
char HostAddress[255] = AWS_IOT_MQTT_HOST;

/**
 * @brief Default MQTT port is pulled from the aws_iot_config.h
 */
uint32_t port = AWS_IOT_MQTT_PORT;

AWS_IoT_Client client;

//const int CONNECTED_BIT = BIT0;

bool aws_connect_success_Flag = false;

static const char *TAG = "subpub";


/*****************************************************************************/
/*                           FUNCTIONS                                       */
/*****************************************************************************/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

void iot_subscribe_callback_handler(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen,
                                    IoT_Publish_Message_Params *params, void *pData) {
#if WIFI_MANAGER_DEBUG
    //ESP_LOGI(TAG, "Subscribe callback");
    //ESP_LOGI(TAG, "%.*s\t%.*s", topicNameLen, topicName, (int) params->payloadLen, (char *)params->payload);
    printf("Subscribe callback");
    printf("%.*s\t%.*s", topicNameLen, topicName, (int) params->payloadLen, (char *)params->payload);
#endif
}

void disconnectCallbackHandler(AWS_IoT_Client *pClient, void *data) {
#if WIFI_MANAGER_DEBUG
    //ESP_LOGW(TAG, "MQTT Disconnect");
    printf("MQTT Disconnect");
#endif
    IoT_Error_t rc = FAILURE;

    if(NULL == pClient) {
        return;
    }

    if(aws_iot_is_autoreconnect_enabled(pClient)) {
#if WIFI_MANAGER_DEBUG
        ////ESP_LOGI(TAG, "Auto Reconnect is enabled, Reconnecting attempt will start now");
        printf("Auto Reconnect is enabled, Reconnecting attempt will start now");
#endif
    } else {
#if WIFI_MANAGER_DEBUG
        ////ESP_LOGW(TAG, "Auto Reconnect not enabled. Starting manual reconnect...");
        printf("Auto Reconnect not enabled. Starting manual reconnect...");
#endif
        rc = aws_iot_mqtt_attempt_reconnect(pClient);
        if(NETWORK_RECONNECTED == rc) {
#if WIFI_MANAGER_DEBUG
            ////ESP_LOGW(TAG, "Manual Reconnect Successful");
            printf("Manual Reconnect Successful");
#endif
        } else {
#if WIFI_MANAGER_DEBUG
            ////ESP_LOGW(TAG, "Manual Reconnect Failed - %d", rc);
            printf("Manual Reconnect Failed - %d", rc);
#endif
        }
    }
}


void aws_iot_publish_message(IoT_Publish_Message_Params paramsQOS1)
{

	IoT_Error_t rc = FAILURE;
#if WIFI_MANAGER_DEBUG
	////ESP_LOGI(TAG, "mess: %s",(char*)paramsQOS1.payload);
	printf("mess: %s",(char*)paramsQOS1.payload);
#endif
	rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS1);
	if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
#if WIFI_MANAGER_DEBUG
		////ESP_LOGW(TAG, "QOS1 publish ack not received.");
		printf("QOS1 publish ack not received.");
#endif
		//rc = SUCCESS;
	}

}

void aws_set_event_start()
{
	xEventGroupSetBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0 );
}

void aws_iot_task(void *param)
{

			IoT_Error_t rc = FAILURE;

			aws_connect_event_group= xEventGroupCreate();




			IoT_Client_Init_Params mqttInitParams = iotClientInitParamsDefault;
			IoT_Client_Connect_Params connectParams = iotClientConnectParamsDefault;

		  //  IoT_Publish_Message_Params paramsQOS0;

#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "AWS IoT SDK Version %d.%d.%d-%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
		    printf( "AWS IoT SDK Version %d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
#endif
		    mqttInitParams.enableAutoReconnect = false; // We enable this later below
		    mqttInitParams.pHostURL = HostAddress;
		    mqttInitParams.port = port;

		#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
		    mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem_start;
		    mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt_start;
		    mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key_start;

		#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
		    mqttInitParams.pRootCALocation = ROOT_CA_PATH;
		    mqttInitParams.pDeviceCertLocation = DEVICE_CERTIFICATE_PATH;
		    mqttInitParams.pDevicePrivateKeyLocation = DEVICE_PRIVATE_KEY_PATH;
		#endif

		    mqttInitParams.mqttCommandTimeout_ms = 20000;
		    mqttInitParams.tlsHandshakeTimeout_ms = 5000;
		    mqttInitParams.isSSLHostnameVerify = true;
		    mqttInitParams.disconnectHandler = disconnectCallbackHandler;
		    mqttInitParams.disconnectHandlerData = NULL;

		#ifdef CONFIG_EXAMPLE_SDCARD_CERTS
#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "Mounting SD card...");
		    printf("Mounting SD card...");
#endif
		    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
		    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
		    esp_vfs_fat_sdmmc_mount_config_t mount_config = {
		        .format_if_mount_failed = false,
		        .max_files = 3,
		    };
		    sdmmc_card_t* card;
		    esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
		    if (ret != ESP_OK) {
#if WIFI_MANAGER_DEBUG
		        //ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
		        printf("Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
#endif
		        abort();
		    }
		#endif
#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "AWS init ...");
		    printf("AWS init ...\n");
#endif
		    rc = aws_iot_mqtt_init(&client, &mqttInitParams);
		    if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
		        //ESP_LOGE(TAG, "aws_iot_mqtt_init returned error : %d ", rc);
		        printf("aws_iot_mqtt_init returned error : %d ", rc);
#endif
		        abort();
		    }
#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "AWS init ...");
	//	    printf("AWS init 22 ...\n");
#endif

			#if WIFI_MANAGER_DEBUG
						//ESP_LOGI(TAG, "AWS init ...");
			//			printf("AWS init 333 ...\n");
			#endif
		    /* Wait for WiFI to show as connected */
		    xEventGroupWaitBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0,
		   													false, true, portMAX_DELAY);
			#if WIFI_MANAGER_DEBUG
						//ESP_LOGI(TAG, "AWS init ...");
				//		printf("AWS init 44 ...\n");
			#endif
		    connectParams.keepAliveIntervalInSec = 10;
		    connectParams.isCleanSession = true;
		    connectParams.MQTTVersion = MQTT_3_1_1;
		    /* Client ID is set in the menuconfig of the example */
		    connectParams.pClientID = CONFIG_AWS_EXAMPLE_CLIENT_ID;
		    connectParams.clientIDLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);
		    connectParams.isWillMsgPresent = false;
#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "Connecting to AWS...");
		    printf("Connecting to AWS...");
#endif
		    do {
		        rc = aws_iot_mqtt_connect(&client, &connectParams);
		        if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
		            //ESP_LOGE(TAG, "Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
		            printf("Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
#endif
		         //   vTaskDelay(1000 / portTICK_RATE_MS);
		        }
		    } while(SUCCESS != rc);


		    /*
		     * Enable Auto Reconnect functionality. Minimum and Maximum time of Exponential backoff are set in aws_iot_config.h
		     *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
		     *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
		     */
#if WIFI_MANAGER_DEBUG
		        //ESP_LOGI(TAG, "autoreconnect...");
		        printf("autoreconnect...");
#endif
		    rc = aws_iot_mqtt_autoreconnect_set_status(&client, true);
		    if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
		        //ESP_LOGE(TAG, "Unable to set Auto Reconnect to true - %d", rc);
		        printf("Unable to set Auto Reconnect to true - %d", rc);
#endif
		        abort();
		    }


#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "Subscribing...");
		    printf("Subscribing...");
#endif
		    rc = aws_iot_mqtt_subscribe(&client, TOPIC, TOPIC_LEN, QOS0, iot_subscribe_callback_handler, NULL);
		    if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
		        //ESP_LOGE(TAG, "Error subscribing : %d ", rc);
		        printf("Error subscribing : %d ", rc);
#endif
		        abort();
		    }
#if WIFI_MANAGER_DEBUG
		    //ESP_LOGI(TAG, "Subscribing Success.");
		    printf("Subscribing Success.");
#endif

		    if(SUCCESS == rc)
		    {
		    	aws_connect_success_Flag=true;
		    }
		    while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)) {

		        //Max time the yield function will wait for read messages
		        rc = aws_iot_mqtt_yield(&client, 100);
		        if(NETWORK_ATTEMPTING_RECONNECT == rc) {
		            // If the client is attempting to reconnect we will skip the rest of the loop.
		        	aws_connect_success_Flag=false;
		            continue;
		        }
		        if(SUCCESS == rc)
				{
					aws_connect_success_Flag=true;
				}
		        tcp_clien_connect_lufft();
		     //   //ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));

		    }

		    aws_iot_abort();

}
//void aws_iot_task(void *param) {
//    char cPayload[100];
//
//    int32_t i = 0;
//
//    IoT_Error_t rc = FAILURE;
//
//    AWS_IoT_Client client;
//    IoT_Client_Init_Params mqttInitParams = iotClientInitParamsDefault;
//    IoT_Client_Connect_Params connectParams = iotClientConnectParamsDefault;
//
//    IoT_Publish_Message_Params paramsQOS0;
//    IoT_Publish_Message_Params paramsQOS1;
//
//    ESP_LOGI(TAG, "AWS IoT SDK Version %d.%d.%d-%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
//
//    mqttInitParams.enableAutoReconnect = false; // We enable this later below
//    mqttInitParams.pHostURL = HostAddress;
//    mqttInitParams.port = port;
//
//#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
//    mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem_start;
//    mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt_start;
//    mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key_start;
//
//#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
//    mqttInitParams.pRootCALocation = ROOT_CA_PATH;
//    mqttInitParams.pDeviceCertLocation = DEVICE_CERTIFICATE_PATH;
//    mqttInitParams.pDevicePrivateKeyLocation = DEVICE_PRIVATE_KEY_PATH;
//#endif
//
//    mqttInitParams.mqttCommandTimeout_ms = 20000;
//    mqttInitParams.tlsHandshakeTimeout_ms = 5000;
//    mqttInitParams.isSSLHostnameVerify = true;
//    mqttInitParams.disconnectHandler = disconnectCallbackHandler;
//    mqttInitParams.disconnectHandlerData = NULL;
//
//#ifdef CONFIG_EXAMPLE_SDCARD_CERTS
//    ESP_LOGI(TAG, "Mounting SD card...");
//    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
//    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
//    esp_vfs_fat_sdmmc_mount_config_t mount_config = {
//        .format_if_mount_failed = false,
//        .max_files = 3,
//    };
//    sdmmc_card_t* card;
//    esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
//    if (ret != ESP_OK) {
//        ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
//        abort();
//    }
//#endif
//
//    rc = aws_iot_mqtt_init(&client, &mqttInitParams);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "aws_iot_mqtt_init returned error : %d ", rc);
//        abort();
//    }
//
//    /* Wait for WiFI to show as connected */
//    xEventGroupWaitBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0,
//                        false, true, portMAX_DELAY);
//
//    connectParams.keepAliveIntervalInSec = 10;
//    connectParams.isCleanSession = true;
//    connectParams.MQTTVersion = MQTT_3_1_1;
//    /* Client ID is set in the menuconfig of the example */
//    connectParams.pClientID = CONFIG_AWS_EXAMPLE_CLIENT_ID;
//    connectParams.clientIDLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);
//    connectParams.isWillMsgPresent = false;
//
//    ESP_LOGI(TAG, "Connecting to AWS...");
//    do {
//        rc = aws_iot_mqtt_connect(&client, &connectParams);
//        if(SUCCESS != rc) {
//            ESP_LOGE(TAG, "Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
//            vTaskDelay(1000 / portTICK_RATE_MS);
//        }
//    } while(SUCCESS != rc);
//
//    /*
//     * Enable Auto Reconnect functionality. Minimum and Maximum time of Exponential backoff are set in aws_iot_config.h
//     *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
//     *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
//     */
//    rc = aws_iot_mqtt_autoreconnect_set_status(&client, true);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "Unable to set Auto Reconnect to true - %d", rc);
//        abort();
//    }
//
//    ESP_LOGI(TAG, "Subscribing...");
//    rc = aws_iot_mqtt_subscribe(&client, TOPIC, TOPIC_LEN, QOS0, iot_subscribe_callback_handler, NULL);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "Error subscribing : %d ", rc);
//        abort();
//    }
//
//    sprintf(cPayload, "%s : %d ", "hello from SDK", i);
//
//    paramsQOS0.qos = QOS0;
//    paramsQOS0.payload = (void *) cPayload;
//    paramsQOS0.isRetained = 0;
//
//    paramsQOS1.qos = QOS1;
//    paramsQOS1.payload = (void *) cPayload;
//    paramsQOS1.isRetained = 0;
//
//    while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)) {
//
//        //Max time the yield function will wait for read messages
//        rc = aws_iot_mqtt_yield(&client, 100);
//        if(NETWORK_ATTEMPTING_RECONNECT == rc) {
//            // If the client is attempting to reconnect we will skip the rest of the loop.
//            continue;
//        }
//
//        ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
//        vTaskDelay(1000 / portTICK_RATE_MS);
//        sprintf(cPayload, "%s : %d ", "hello from ESP32 (QOS0)", i++);
//        paramsQOS0.payloadLen = strlen(cPayload);
//        rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS0);
//
//        sprintf(cPayload, "%s : %d ", "hello from ESP32 (QOS1)", i++);
//        paramsQOS1.payloadLen = strlen(cPayload);
//        rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS1);
//        if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
//            ESP_LOGW(TAG, "QOS1 publish ack not received.");
//            rc = SUCCESS;
//        }
//    }
//
//    ESP_LOGE(TAG, "An error occurred in the main loop.");
//    abort();
//}

void aws_iot_abort(void)
{
#if WIFI_MANAGER_DEBUG
	 //ESP_LOGE(TAG, "An error occurred in the main loop.");
	 printf("An error occurred in the main loop.");
#endif
	 abort();
}

/*****************************************************************************/
/* END OF FILE */
/*****************************************************************************/


no captive portal on Samsung devices

While testing my current project with different devices I noticed that there is no page splash on a samsung device.

Some digging turned out, that they behave a bit special. As solution it is suggested to answer with an empty 204 packet (??). I usually don't have to deal with DNS-stuff ^^'

Anyhow - I'm trying to implement some code to catch that problem. But any help would be highly appreciated.
I'll update this Issue as I make any progress.

readings:
tripflex/wifi-captive-portal#7

https://community.arubanetworks.com/t5/Wireless-Access/Samsung-Captive-Portal-Detection/m-p/405934#M78972

https://lemariva.com/blog/2017/11/white-hacking-wemos-captive-portal-using-micropython

https://github.com/tripflex/captive-portal/blob/master/src/mgos_captive_portal.c
starting line 367

https://socifi-doc.atlassian.net/wiki/spaces/SC/pages/94371841/DNS+Fix+to+keep+Android+Splash+Page+and+the+Captive+Portal+Notification+active

Using it as a PlatformIO library

Hi,

Thanks for sharing this great work!
I've made it run as it is but now I'd like to use it as a library. Is it possible to use it in PlatformIO? I've managed to add it to the project (with pio lib install <url>, and lib_deps = esp32-wifi-manager), but couldn't make it work there. I copied the file main.c to my src, and updated the includes inside as follows:

#include "wifi_manager/main/http_server.h"
#include "wifi_manager/main/wifi_manager.h"

I'm now getting error:

...
.pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x4c): undefined reference to `_binary_style_css_start'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32dev/firmware.elf] Error 1

What am I doing wrong? It seems to me the assets couldn't be linked. Or it is just not yet capable for library use?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.