adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.04k stars 1.19k forks source link

allow wifi.radio.ping() to send larger packets #6926

Open vladak opened 1 year ago

vladak commented 1 year ago

Currently wifi.radio.ping() does not allow to set the ICMP packet payload size. Looking into the code for nina-FW it is hardcoded to 32 bytes:

  struct __attribute__((__packed__)) {
    struct icmp_echo_hdr header;
    uint8_t data[32];
  } request;

I'd like this to work e.g. for ESP32-S2 based boards, like https://www.adafruit.com/product/5303 and I am not sure these actually run nina-FW so the above is just an example.

Basically, I'd like to be able to call:

wifi.radio.ping(ping_addr, timeout=1, size=1280)

or such.

There are probably some limitations that need to be taken into account like limited memory size etc. (the packet is allocated on the stack in the above code)

Why do I need this ? In my environment, I have a suspicion that something is amiss with WiFi communication from the ESP32-S2 to my WiFi AP, especially when sending larger TCP packets (MQTT) and I'd like to test that hypothesis with ICMP.

anecdata commented 1 year ago

The NINA firmware is only used on ESP32 boards that are used as "Airlift" co-processors to a non-wifi board, like a SAMD51, so not relevant to the espressif port (e.g., ESP32-S2) which has native wifi. As you note, this issue would be an enhancement to the espressif port, which does not currently allow for a ping payload https://docs.circuitpython.org/en/latest/shared-bindings/wifi/index.html#wifi.Radio.ping