esp8266-sniffer icon indicating copy to clipboard operation
esp8266-sniffer copied to clipboard

Optimization?

Open toncho11 opened this issue 5 years ago • 5 comments

Hi,

Is sdk_wifi_promiscuous_enable the best way to handle all incoming packages. Isn't it better to handle the packages in the loop of the Arduino program somehow?

toncho11 avatar Sep 03 '20 18:09 toncho11

Why? what makes loop() better than the proper way using sdk_wifi_set_promiscuous_rx_cb?

https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf

kalanda avatar Sep 03 '20 22:09 kalanda

Btw @toncho11, don't open an issue for each answer :)

kalanda avatar Sep 03 '20 22:09 kalanda

Sorry. I need a forum or e-mail.

I need a realtime execution (or as fast as possible) for a medical experiment, so that is why I need to understand if there is a better way.

toncho11 avatar Sep 04 '20 07:09 toncho11

If you use the loop for all the work, you will obtain worse results since the main loop is blocking other processes and consuming high cpu cycles. Using a the sdk_wifi_set_promiscuous_rx_cb, it will only call your callback function when is needed because packets were received, in such a way of an interruption, leaving the main loop on hold in the meantime and getting back to the main loop after that.

Anyway, I'm not an expert so I recommend you to explore and ask in the official forums https://bbs.espressif.com/search.php?keywords=sdk_wifi_set_promiscuous_rx_cb&sid=19e580006660c7ec05cc11e72b6a469f

kalanda avatar Sep 04 '20 09:09 kalanda

I need a realtime execution (or as fast as possible) for a medical experiment, so that is why I need to understand if there is a better way.

Then you need to get out of the Arduino ecosystem and write a proper interrupt driven state machine. You're NEVER going to get deterministic functionality out of polled IO and blocking functions like delay(). Both bad practice when real time is a requirement.

playaspec avatar Oct 31 '21 18:10 playaspec