-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend "WiFi" class with support for access point mode #57
Comments
Does this mean a captive portal etc, or is there another purpose? |
In the first use case I want to use the ESP32s for some home automation (switching light, garden pump, robot mower etc.) - in this case the station mode is needed. In a second use case I plan to implement a wireless module for an industrial device; here the ESP32 needs to be in access point mode and communicates via serial interface with the device. In this application the performance (throughput) is quite important in order to have a fluffy user experience. For this I need to transmit small telegrams (~~20 bytes) in request/response mode as fast as possible (e.g. <10ms). For this I need websocket communication in order to reduce overhead. Additionally I plan to transmit bigger data chunks (~170kB?) from the device to the browser - the faster the better. |
Industrial device? Now it got serious :) As to the response times, I've not done any real bench marking, have you? |
The industrial device is an electrical drive. The wireless interface for it in the first step shall be some kind of a proof of concept in order to check the possibilities it will give. But for the moment it is just my personal hobby. Then we will see. If it shall become a product we need to find a solution how to deal with the license of this library (GPL). Either the complete source code must be published or a different library has to be developed. |
If it comes to that I'm open for discussion.
I'd dare say you can stop worrying about that. It's an old fallacy that keeps popping up for no good reason. Sure, it might be possible to write specialized algorithms that performs better for a specific task, but generally the stl-algorithms do a better job than most programmers ever will. |
I am currently implementing the access point support. Here I have a few questions:
|
There are a few subscribers to the GOT_IP, but mainly the SocketDispatcher that handles all sockets. It's the signal it uses to know when to restart server sockets etc. For sockets to function correctly, GOT_IP and DISCONNECTED must be published accordingly. Yes, it is legacy, I haven't gotten around to change it to the new API. I suggest you stick to the legacy one, then it can be changed out later as part of another enhancement effort. |
I now implemented the support for wifi in access point mode. So far it was not so difficult. But unfortunately I am encountering a problem when disconnecting a station from this access point. In the log I see the error message:
I guess this is related to the fact that there needs to be some additional action in the SocketDispatcher. But I currently can not find out how to react on this event. |
Hm, so this is when, for example, a phone disconnects its WiFi from the ESP32? I'd not expect he disconnected event to be received then, since the network is still intact, right? Or is it so that the SoftAP only can handle a single client and that the network is restarted when one connects? As to the error itself, I think the case is that the SocketDispatcher receives the disconnected event after the socket already has been closed by the underlying network layer, i.e. the socket ID (54 in this case) is no longer a valid ID. I don't think the error itself is critical, but it'd of course be best if it didn't happen. Is there an event to listen to when the SoftAP net is closed that comes before the one triggering the error? If so, listening to that too and closing sockets then might help. |
I think the wifi-event |
Have the socket dispatcher liten to that event too, just like it does for
the other one. The operation to perform is the same so I think there is
just an if-statement to adjust. Heading to bed so can't check details now.
…On Tue, 13 Aug 2019, 22:23 Lothar, ***@***.***> wrote:
I think the wifi-event SYSTEM_EVENT_AP_STADISCONNECTED occurs before the
SocketDispatcher event. I can try to close the socket in the wifi event
handler. What do I have to call in order to close the socket?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#57?email_source=notifications&email_token=AAU2LLACTOBVSENEXEGHP7TQEMJ5FA5CNFSM4IKYVVL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4G36KI#issuecomment-520994601>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAU2LLE7QDWCDDL6TRE3RQLQEMJ5FANCNFSM4IKYVVLQ>
.
|
I think here the problem is:
I am trying to find out how this can be accomplished. For this it seems I have to dig deeper into the implementation of the socket connections and the according events. |
Perhaps its as simple as not sending the disconnected event at all when in AP-mode? Or at least only when the AP is taken offline? Any socket that otherwise disconnects from a client will be closed and properly handled anyway. |
I tested the following:
|
Yeah, GOT_IP still needs to be published, otherwise the SocketDispatcher won't know that there's an active network. I've seen those ampdu-messages too, but never given them any thought as they are logged as "informational". |
After fighting with some stability problems I updated my http_server_test with your latest version. Now I was able to get the wifi AP code running.
But as already mentioned this happens in AP mode and in STA mode. |
Are you still using the fixed libc.a from espressif/esp-idf#3624 (comment) ? |
yes, at least I did not change anything on the toolchain since I copied the libc.a into esp32-psram directory. Is there anything new available? |
Another question: I was also testing the upload test in http_server_test. Here I noticed that the filenames of the uploaded files are always named "file_to_upload" and "second_file_to_upload" and not the original filename. In order to achieve this I modified "MIMEParser.cpp" in line 220 to: |
No, not that I know of. Can you reproduce it? I've had no crashes since I started using the new libc.a, though I'm thinking that since Espressif still haven't released it they are still working out some kinks with it.
Well, it depends - on the server side you need to know which file belongs to which field so that you do the right thing with the right file. Perhaps both should be passed to the callback? |
Concerning the crash I did many tests yesterday evening. Sometimes the server works for a long time without any problems and sometimes it crashes quite soon after a few page loads. I tested both with AP and STA mode and it seems that it crashes more frequently/faster in AP mode. Additionally in AP mode I have still the problem that sometimes messages |
👍 As to the crash - at this time it is impossible to say where the problem originates. What does the periodic system statistics print to the console? |
@squonk11 I've pushed pretty significant changes to Smooth into master regarding the build system. It now uses Espressif's standard way of building components etc so you'll have to adjust any project you are using Smooth in. I've added instructions in the readme.md file so it should be fairly simple. If you're just building the test projects all you'll need to do is to select the project to build and regenerate the build files, also as per readme.md. |
I used your sources already with a different build setup because I had difficulties using your build setup under Windows. Currently I am not hat home - I will update this evening. |
Ok, hopefully this will make it easier. Also, just committed #62 for the file name change. |
I still have problems with wifi. The following log happened in station mode:
After this happened the log is ongoing but the browser is not able to get any new connection to the server.
Obviously there is an issue with allocating memory during file read. Do I need to increase some space for stack or heap somewhere? Edit 2: Here is also the log of the memory usage:
The minimum free heap is 7584 bytes only - but isn't this enough for a malloc for reading a file? |
Starting from the last question:
The server is out of memory. You can see that you only have 11kb available:
Regarding WiFi:
This is a problem in IDF, waiting for a fix: espressif/esp-idf#3592 Apparently they have having issues with their CI/CD so it's not yet synced. |
Since I assume/hope that also the crashes in AP mode are related to the same issue, I suggest to make now a PR for the modifications on wifi.cpp for the AP mode. |
Sure, go ahead and make the PR and I'll have a look. Just a quick thought: How about letting |
yes, you are right. I also thought about this possibility. But now I read your comment too late. Maybe you can do this while reviewing? |
Now I also included your suggestion to have start_softap() with a parameter for the maximum number of connections. Additionally I made some cosmetic changes. |
Cool. I just tried using the latest IDF mater, unfortunately the problem with I'll have a look at the PR now. |
Closing this issue since #65 is merged. |
In my application for wifi both modes (station and access point) are needed. The current implementation of the WiFi class supports the station mode only. So, an extension of the WiFi class for access point mode is needed. I will try to implement it and provide a PR.
The text was updated successfully, but these errors were encountered: