The problem is at TinyGsmTCP.tpp, specifically on int GsmClient::available().
The function returns rx.size() + sock_available. As rx.size() returns a size_t type, which is an unsigned int and sock_available which is an uint16_t, there is some incompatibility on ESP which doesn't allow the sum of both types even that their value was 0 (what is the case).
It is crazy, but if you use the following code, the bug doesn't occur:
If you comment this line -> ESP_LOGD("", "[available] Returning rxSize %d + sock_available: %d", rxSize, socketAvailable); the bug comes back!!
It seems to be a compiler (xtensa) bug, or how the ESP32 deals with different integer types under a combination of a thousand factors (what happened in this case). Crazy!!
I already found the bug, but I'm posting this anyway to the knowledge of the developer.
What type of issues is this?
[ ] Request to support a new module
[ ] Bug or problem compiling the library [X] Bug or issue with library functionality (ie, sending data over TCP/IP)
What are you working with?
Main processor board: Doit ESP32 (ESP-WROOM-32) Modem: SIM800L TinyGSM version: 0.10.5 Code:
Scenario, steps to reproduce
Expected result
The library should return 0.
Actual result
How did I solve?
The problem is at TinyGsmTCP.tpp, specifically on int GsmClient::available(). The function returns
rx.size() + sock_available
. As rx.size() returns a size_t type, which is an unsigned int and sock_available which is an uint16_t, there is some incompatibility on ESP which doesn't allow the sum of both types even that their value was 0 (what is the case).It is crazy, but if you use the following code, the bug doesn't occur:
If you comment this line -> ESP_LOGD("", "[available] Returning rxSize %d + sock_available: %d", rxSize, socketAvailable); the bug comes back!! It seems to be a compiler (xtensa) bug, or how the ESP32 deals with different integer types under a combination of a thousand factors (what happened in this case). Crazy!!