kandi X-RAY | MicroPythonSamples Summary
kandi X-RAY | MicroPythonSamples Summary
MicroPythonSamples
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Start the server
- Handles the WLAN client setup
- Handles a WiFi configuration request
- Sends a HTTP response
- Stop the server
- Handle 404 error
MicroPythonSamples Key Features
MicroPythonSamples Examples and Code Snippets
Community Discussions
Trending Discussions on MicroPythonSamples
QUESTION
Hi We're trying to use this WIFI Manager (https://github.com/tayfunulu/WiFiManager/blob/master/wifimgr.py) to connect an ESP 32 device to a local wifi .
The WIFI Manager basically identifies all SSID's in the local area, starts a web server on 192.168.4.1, displays the different networks and lets the user select the one they want to connect to. This process is done on mobile browsers (Android or IOS phones and any browser).
This works perfectly in Android but IOS returns an empty POST response body. I used IOS Charles and can see the Response body with the correct information but it does not make it back to the server.
This is what server received in Andriod (data in bold at end of stream):
client connected from ('192.168.4.3', 47754) Request is: b'POST /configure HTTP/1.1\r\nHost: 192.168.4.1\r\nConnection: keep-alive\r\nContent-Length: 39\r\nCache-Control: max-age=0\r\nUpgrade-Insecure-Requests: 1\r\nOrigin: http://192.168.4.1\r\nContent-Type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla/5.0 (Linux; Android 7.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile DuckDuckGo/5 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9\r\nX-Requested-With: com.duckduckgo.mobile.android\r\nReferer: http://192.168.4.1/\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-US,en;q=0.9\r\n\r\nssid=mywifi&password=abcdef1234'
This is what the server received in IOS (no data at end of stream):
client connected from ('192.168.4.2', 64482) Request is: b'POST /configure HTTP/1.1\r\nHost: 192.168.4.1\r\nOrigin: http://192.168.4.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8\r\nUser-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 DuckDuckGo/7\r\nReferer: http://192.168.4.1/\r\nContent-Length: 39\r\nAccept-Language: en-us\r\n\r\n'
I realize the Charles response header and data are different then the IOS paragraph above but it is the same result. I've made tried Safari, Chrome and FF on iphone all with same results. I've made sure that privacy setting are set to allow third party data but maybe there is another spot I missed. Provided the Form action code below (def handle_root(client) which puts up the screen to display all the local wifi networks and below that the web server start (Def start (port=80)).
Thanks, Jim
Form for user to select SSID to connect to:
...ANSWER
Answered 2020-Jul-31 at 02:42Finally figured this out. So it turns out, and maybe this is obvious to those familiar with HTTP socket protocol, but with Android mobile OS the response body is returned with the header at the end, with IOS you have to execute another "recv" to retrieve the response body. hope this helps someone and save them weeks of digging and angst.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install MicroPythonSamples
You can use MicroPythonSamples like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page