-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Add configurations to send data over wifi #299
Comments
I will not implement this, because i am not convinced that this makes sense, since there will be a huge trade off in using the 2,4Ghz airtime for sniffing versus transmitting data. But you're welcome to bring a pull request for this feature, i will be lucky reviewing it. |
I see your point |
You can reuse existing pieces of code to implement this:
Downsides will be:
Thus i would expect a trade-off. |
What you can do to decrease the tradeoff: use compiler directives to compile the code without the LoRa LMIC stack, set HAS_LORA to not defined (= comment out) in the board's hal file. This will free up resources on Core 1 and RAM. If you implement coexist sniffing and transferring via Wifi be aware of race conditions when accessing the wifi subsystem. The wifi logic of paxcounter is running on Core 0. |
this could be a good occasion to develop this point too: I'm on the 250, it is somehow required |
Unfortunately the whole code needs some refactoring, because it was grown without a roadmap. Thus the #includes got confusing. But the code works :-) |
If you scan wifi for 5 minutes, then you need around 5 seconds to switch from monitor mode to client mode, connect to wifi, get ip address via dhcp and send the data. You loose 5 seconds of scanning time, but in 5 minute window this is totally acceptable. For some even 5 seconds of 1 minute would be acceptable. |
@valentt It's not necessary to manage a wifi connection while sniffing MACs. Sniffing operates in the background, even while a wifi connection is established and in use. But of course it is necessary to stop wifi channel rotation while a wifi connection is established. This could easyly be implemented using ESP32 wifi events, calling Stopping wifi channel rotation will, however, reduce the MAC discovery rate, theoretically by ~90% (1/13). Besides this, an established wifi connection could perhaps impact the sniffer performance, causing packet loss. This is an assumption, i never tested this. A way to compensate this effect could be increasing sniffing performance by using a queue for MAC processing. You're welcome to create a PR for the wifi data transfer feature. |
@davidex720 we have some news here. In development branch there is an enhancement with mqtt client, sending pax telemetrics data over ethernet interface. |
Hi, Should that work? Best regards |
as stated above: wifi connect during runtime is not yet implemented. MQTT only works via Ethernet PHY. |
@cyberman54, #define MQTT_ETHERNET 0 // select PHY: set 0 for Wifi, 1 for ethernet will not work for wifi, because it is not implemented now. Best regards, Holger |
Comment added. Thanks for the hint. |
Hello, I would also need this feature. Before considering a PR, I would like to know if the approach described by @cyberman54 here is still the right one. |
@raomin Yes, it is. An approach would be like this:
|
I see I cannot/should not call set_wifiscan but go through void rcommand(const uint8_t *cmd, const size_t cmdlength) There are no implementation of this function call for a specific parameter and the implementation is not obvious at first glance... In the meantime, I exposed Thanks |
set_wifiscan(0) stops wifi sniffing, (1) starts Note: of you use set_wifiscan, you don't need to take care of the channel rotation. This is done in libpax, called by set_wifiscan. |
This I saw (and did). It's just that only |
yes, use the private function and declare it as public, that should work. |
don't touch ota.cpp and ota.h, both are not needed here. |
See my fork here. On your advice, I switched to an esp32s3. That's so much better. Now the MQTT message is a byte version encoded in base64. |
/ping @davidex720 i made some edits in this comment
|
I'll put a a quick doc update to clarify MQTT use and this last point. Also a bit of code cleanup and it should be ready for PR. |
So, I'm trying to get something working on esp32 (no psram). Here are my findings on memory consumption: Sure, I could remove display, and it would work, or just stick to psram... But is it hopeless to slim up libpax memory consumption? |
That's strange. Libpax assigns 2KB of DRAM as bitmap for storing identifiers. It does not load a wifi stack, neither a bluetooth stack. It does not include any external libraries. How did you create the memory map? |
ESP.getFreeHeap() at every step of the setup. |
Thanks for investigating this. Wifi_sniffer_init in libpax calls esp32 idf functions, i wouldn't expect that these cause such big impact on RAM. Maybe it's the promiscous mode callback which is called with every wifi packet arriving. How many wifi devices are counted in your test environment by paxcounter? |
That's memory usage during setup(). No packets are received at this level. |
Libpax is using static memory. It's assigned to a bitmap array, at this point in code: |
@raomin
|
Just to clarify what I'm doing for memory measurement, at every step of |
Maybe a false positive?
Found here: https://esp32.com/viewtopic.php?t=27780 |
Not really, after my init on a tdisplay, with DISP, BLE, WIFI and MQTT, I tried with WIFICOUNTER to 0 and free heap is now 74kb more than when WIFICOUNTER is to 1. |
Did some investigation. The esp32 wifi driver consumes around 71 KB of RAM. It's memory footprint can be lowered by tuning some buffer sizes, see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#why-buffer-configuration-is-important I found that this can free up 10 - 15 KB of RAM. |
So I guess we should see with WiFi.useStaticBuffers(true); ... in main.cpp |
Paxcounter generally does not use Wifi class, except for OTA and Boot-Menu, but it then reboots before to stop libpax and free RAM, before running ota.cpp / boot.cpp. |
But then, is the sniffer actually using these buffers? |
Not sure. I did not find a documentation source yet which explains the sniffer mode of esp32 api. |
@raomin You should not use Arduino WIFI class function calls from within paxcounter code, because paxcounter delegates control of wifi to the libpax library. Libpax is based on esp32 api wifi function calls, not on Arduino WIFI class. Exceptions are ota.cpp and boot.cpp which are using Arduino WIFI class to establish a tcp/ip connect over wifi, but this happenes in a dedicated runmode, after the module is rebooted for, thus libpax is not active while ota.cpp or boot.cpp is running. Regarding memory buffers for wifi usage, what Arduino WIFI class does is setting the RX/TX buffer values to it's own configuration, found here. In libpax code buffer adjustments would need to happen here. Libpax lib does not expose this to it's api, so there won't be a straight forward way to modify wifi buffers from within paxcounter code. Regarding your feature, establishing a tcp/ip connection over wifi to send payload, the flow would be: That's an awful workaround. Reason is that paxcounter and libpax originally were development to transmit payload not on Wifi, but on other channels like Lorawan or SPI or logging to SD card. Since Wifi is used for sniffing. But with the above scheme both could be combined. You're welcome to post a PR for this! |
Thanks for the clarification. That's more or less what I did already with |
A preliminary version of this feature can be found in branch mqtt-over-wifi |
I think it could be useful to have the possibility to choose between sending the payload over lora or wifi.
In many countries lora has still some problems and this option could really benefit this project
The text was updated successfully, but these errors were encountered: