Closed mcspr closed 4 years ago
For sources of the behaviour, see bugs.md and compile any of the examples WITHOUT using #define USE_PANGOLIN. This will compile with AsyncMqttClient which exhibits the behaviour by passing an invalid pointer every time resulting in the many "random" bugs it has.
_"I was under the assumption that tcpwrite from the add() / write() always copies data into buffer created by the lwip (hence, the space() usage)" : I guess the author of AsyncMqttClient was using the same (wrong) assumption, which is why it broke so often and the very reason I wrote Pangolin.
Also, the behaviour of ESPAsyncTCP is not relevant - its just passes onto LwIP whatever you give it. The key issue is LwIP configuration settings for you environment.
"Enqueues the data pointed to by the argument dataptr. The length of the data is passed as the len parameter. The apiflags can be one or more of:
IF your installation / settings does indeed copy - then nothing is lost. Pangolin will work either way of course.
Quoting https://github.com/philbowles/PangolinMQTT/blob/ff68b5ff114d35c5b873da02e9761f91fafda15f/src/PangolinMQTT.h#L97-L115
Can you please provide a pointer to the lwip documentation / source of the behaviour? Previously, I was under the assumption that tcp_write from the add() / write() always copies data into buffer created by the lwip (hence, the space() usage). Unless I am thinking of something completely different.
ESPAsyncTCP default for add() is indeed 0, without any specific flags for copy or not, but we also have LWIP_NETIF_TX_SINGLE_PBUF set to 1 for both esp8266 and esp32 Cores, so while it is not technically correct to assume lwip will always copy, in practice it always does: https://github.com/d-a-v/esp82xx-nonos-linklayer/blob/61b01638dde63088cbcdfe3c37ac036b75bf7a7e/glue-lwip/arduino/lwipopts.h#L1665 http://git.savannah.nongnu.org/cgit/lwip.git/tree/src/core/tcp_out.c?h=STABLE-2_1_2_RELEASE#n361 http://git.savannah.nongnu.org/cgit/lwip.git/tree/src/core/tcp_out.c?h=STABLE-2_1_2_RELEASE#n422 (see comment on 4 lines after that)