Page 1 of 1

void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);"buf" point "Statitx Rx buffer" or "dynamic?

Posted: Thu Apr 19, 2018 1:48 am
by jason2
The callback function :void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type).If this callback function is registered,when received packet,The function will be called and the contents of packets will be pointed by *buf.

And I have read wifi driver from API guide from esp32 programming guide: http://esp-idf.readthedocs.io/en/latest ... /wifi.html
It is described:
The following diagram shows how buffer is allocated/freed in the RX direction:

------------- ------------- ------------- -------------
| Application | | LwIP | | Wi-Fi | | Wi-Fi |
| Task | <--------- | task | <--------- | task | <--------- | Interrupt |
------------- ------------- ------------- -------------
4> User data 3> Pbuf 2> Dynamic RX Buffer 1> Static RX Buffer
Description:

The Wi-Fi hardware receives a packet over the air and puts the packet content to the “Static Rx Buffer”, which is also called “RX DMA Buffer”.
The Wi-Fi driver allocates a “Dynamic Rx Buffer”, makes a copy of the “Static Rx Buffer”, and returns the “Static Rx Buffer” to hardware.
The Wi-Fi driver delivers the packet to the upper-layer (LwIP), and allocates a PBUF for holding the “Dynamic Rx Buffer”.
The application receives data from LwIP.


So when wifi_promiscuous_cb_t is called,where is "*buf" point?"Static Rx buffer" or "Dynamic Rx buffer"

Thanks!
Best regards!

Re: void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);"buf" point "Statitx Rx buffer" or "dyna

Posted: Thu Apr 19, 2018 2:32 am
by jason2
Please reply if you have seen ,thank you!

Re: void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);"buf" point "Statitx Rx buffer" or "dyna

Posted: Thu Apr 19, 2018 6:24 am
by ESP_Angus
Hi jason,

It's a WiFi dynamic RX buffer pointed to in the callback.

Please note that no guarantees are made about the continued validity of this buffer after the callback function returns. If you want to store the data for later use, copy it to a local buffer under your control.

Re: void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);"buf" point "Statitx Rx buffer" or "dyna

Posted: Thu Apr 19, 2018 6:46 am
by jason2
Thanks for your reply very much!