Skip to content

How to use esp_wifi_internal_tx #71

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

Closed
spacehuhn opened this issue Nov 28, 2016 · 3 comments
Closed

How to use esp_wifi_internal_tx #71

spacehuhn opened this issue Nov 28, 2016 · 3 comments

Comments

@spacehuhn
Copy link

Hey can I use esp_wifi_internal_tx to send my own packets (beacon for example)? How do I use it and what packets are supported?

@igrr
Copy link
Member

igrr commented Nov 28, 2016

This function is in a header which is marked internal. So you can try calling that function, but then you are on your own.

@igrr igrr closed this as completed Nov 28, 2016
@spacehuhn
Copy link
Author

spacehuhn commented Nov 29, 2016

I would like to know which packets are supported and how to use it exectly. I can only see the header file, so I have no idea what background actions taking place. That's why I'm asking.

(As it is written in the file:)

If someone really want to use specified APIs declared in here, please contact
espressif AE/developer to make sure you know the limitations or risk of
the API, otherwise you may get unexpected behavior!!!

With the ESP8266 there was a function called wifi_send_pkt_freedom. With this you could send your own packets, but only unencrypted and it blocked managment packets.
And if you wanted to send for example beacon packets you had to change the buffer

If you really want to send beacon, please start from "0x80, 0x00 ... " which means that the first 26 bytes need to be deleted. If you start from "0x00,0x00", wifi_send_pkt_freedom will detect the 80211 header and find out that it's a management packet, and send fail.

http://bbs.espressif.com/viewtopic.php?f=7&t=1357&p=10185&hilit=wifi_send_pkt_freedom#p10185

So... are here limitations too or something else to consider?

@chrismerck
Copy link

chrismerck commented Jun 8, 2018

@spacehuhn you've probably figured it out already, but for the record, you can see that lwip's ESP32 port uses low_level_output in components/lwip/port/netif/wlanif.c, which in turn uses esp_wifi_internal_tx.

Between the esp_wifi_internal_tx documentation and the the low_level_output docs, you can figure out a lot:

/**
  * @brief  transmit the buffer via wifi driver
  *
  * @param  wifi_interface_t wifi_if : wifi interface id
  * @param  void *buffer : the buffer to be tansmit
  * @param  uint16_t len : the length of buffer
  *
  * @return
  *    - ERR_OK  : Successfully transmit the buffer to wifi driver
  *    - ERR_MEM : Out of memory
  *    - ERR_IF : WiFi driver error
  *    - ERR_ARG : Invalid argument
  */
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);

and

/**
 * This function should do the actual transmission of the packet. The packet is
 * contained in the pbuf that is passed to the function. This pbuf
 * might be chained.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
 * @return ERR_OK if the packet could be sent
 *         an err_t value if the packet couldn't be sent
 *
 * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
 *       strange results. You might consider waiting for space in the DMA queue
 *       to become availale since the stack doesn't retry to send a packet
 *       dropped because of memory failure (except for the TCP timers).
 */
static err_t ESP_IRAM_ATTR
low_level_output(struct netif *netif, struct pbuf *p)

brentru pushed a commit to adafruit/arduino-esp32 that referenced this issue Oct 22, 2024
adding targets to specify which trinket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants