ChipChop Support Forum
Log in
Log out
Join the forum
My Details
REPLIES: 1
VIEWS: 56
BACK
REPLY TO THIS POST
Swapfile
25 Jan 2025
Testing WiFi Portal

I did some more tests and this is the serial output.

When I connect to the Hotspot it does not ask for a password.

Line 25 mywifi is just a dummy <name> <password> does not excist.



--- Terminal on COM1 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
[ 1040][E][WiFiGeneric.cpp:1583] hostByName(): DNS Failed for api1.chipchop.io
[ 1048][E][WiFiClient.cpp:320] setSocketOption(): fail on -1, errno: 9, "Bad file number"
ChipChop => Waiting to establish socket connection
ChipChopPluginsManager::start
LittleFS started
fileSystemOK: 1
3
Keep Alive => ChipChop socket is closed...starting monitoring
Configuring access point...
AP IP address: 8.8.8.8
HTTP server started
Credentials_loaded
Updating credentials
Networks found: #Omni20_Setup_1BC#Afrihost LTE MDB#Mfundo Wifi#HUAWEI-B315-2690#
mywifi
<ssid name>
Connecting to wifi...mywifi
Connection response: 1
Keep Alive => ChipChop socket is closed...starting monitoring
Networks found: #
mywifi
<ssid name>
Trying to reconnect
Keep Alive => ChipChop socket is closed...starting monitoring
Networks found: #
mywifi
<ssid name>

//=========Stop here until Phone connects to Hotspot====================


//========When Phone connects to Hotspot================================
[]
[162939][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
[]
[]
[170989][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
[171411][E][WebServer.cpp:638] _handleRequest(): request handler not found
[]
[]
[171482][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
[]
[176435][E][WebServer.cpp:638] _handleRequest(): request handler not found
[]
[]
[176523][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
Trying to reconnect
Keep Alive => ChipChop socket is closed...starting monitoring
Networks found: #
mywifi
<ssid name>
[]
[]
[181240][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
[181253][E][WebServer.cpp:638] _handleRequest(): request handler not found
[]
[181363][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
[181377][E][WebServer.cpp:638] _handleRequest(): request handler not found
[]
[]
[181746][E][WiFiClient.cpp:429] write(): fail on fd 50, errno: 104, "Connection reset by peer"
Closing Portal
Trying to reconnect
Keep Alive => ChipChop socket is closed...starting monitoring
Networks found: #
mywifi
<ssid name>
restarting portal

//=========Hotspot dissconects from Phone===============================




Gizmo
29 Jan 2025

Yes, the hotspot doesn't need a password (it can be set if you need to)

The messages that you are getting are normal but I can see that when it tries to open the portal it can't find the networks again.

The way it works is the same as when you connect to a wifi in a restaurant, hotel, airport.... You connect to the hotel's hotspot and it should open on your phone a "captive portal" that is usually asking you to register or something before it gives you access to the internet.
Here, the difference is that the page it opens should display all wifi networks it can find so you can pick the new one and enter the password for it and the esp will remember it and try to connect to it.

The "captive portal" mechanism works differently from phone to phone and Android/iOS versions

This is what you need to do:

1. On Android if you open the wifi list from the top shortcut click on the Details button at the bottom to get to the full wifi settings page

2. connect to the hotspot

3.
    Option 1
    wait a little bit and after 10-15 seconds you should get a tiny little popup saying something about "sign in....blah blah" and you should hear like a notification sound
Click on the little popup and wait. The esp will try to do a wifi scan and you should get a page with the wifi list to chose from

    if you don't see that popup it's a shitty design on android and sometimes it goes behind the screen. Have a look in the notifications (swipe down from the top) and you may see a notification saying the same thing to sign in...click on it

    Option 2
    After you connect to the hotspot open the browser on the phone and go to 8.8.8.8 (or http://8.8.8.8) to manually open the captive portal page

I have noticed that there were some changes on what android is requesting from the esp in order to open the portal, it shouldn't affect the explanation above, I've tested it on all my phones and it works fine but the amount of requests that android is sending in only couple of seconds is insane and it can overwhelm the esp so it can take a while

Anyway, I am going to try and rewrite the code to reduce the flood of these initial requests to speed up the process.

I will let you know when I'm done so you can try it. Bear in mind that this is not something you would be using every day, once the esp connects to an ssid successfully it will remember it and next time will connect automatically.

Also, bear in mind that the default timeout for the portal is 2 minutes so it may close itself if the esp is already connected to an ssid
Basically if you are already connected successfully then the portal is open for 2 minutes, if you are not connected to anything it will stay open permanently. The timeout can be changed.