Open maciejs20 opened 4 years ago
What is your arduino board? It looks like it is by design. Maybe ELClient should inform esp-link about buffer size first. Have found some patch for this (simmilar problem) maybe we can use it.
This is arduino nano, but it does not matter. The buffer size is hardcoded into main HardwareSerial.h standard arduino library - so the problem is valid for all AVR boards:
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_TX_BUFFER_SIZE 16
#else
#define SERIAL_TX_BUFFER_SIZE 64
#endif
#endif
#if !defined(SERIAL_RX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_RX_BUFFER_SIZE 16
#else
#define SERIAL_RX_BUFFER_SIZE 64
#endif
Esp-Link may not expect the board to accept anything above 64bytes...
ok will try to investigate this, please change markings of log in first post as code, it will be more readable
found @dannybackx patch but it is for REST https://github.com/jeelabs/el-client/pull/37/commits/24f14c0bb340afc5330d00bf8f999fe08bd71502
I think we need first pass receive buffer size during SYNC, and if pkt is more than size of buf split it and send.
The communication between MQTT hub -> EspLink -> Arduino is broken when the MQTT hub sends data to arduino. I'm using espLink 3.2.47-g9c6530d with recent El-client libraries, connected to IBM Cloud Watson IoT Platform. All arduino-initiated PUBs/SUBs works OK, but any longer hub-initiated communication fails. I've been poking with older EspLink code and at that time any message longer than approx. 32 bytes fails; I don't know if that is the case for 3.2.47 as well but probably it's the same. Increase in EL-Client buffer does not help at all, even when set to 300bytes.
I've connected serial RX on the ESP-Arduino communication line and have collected the logs. I've also modified EL-Client for additional debug, shown below.
The reason is quite simple: when Esp-Link sends long message, the arduino serial buffer overflows. If I compile HardwareSerial with -D SERIAL_RX_BUFFER_SIZE=256, than communication is OK, but also the huge amount of arduino's ram is gone.
I think that Esp-link should divide longer packets...
What happens, how to replicate:
Arduino code subscribes for topic: "iotdm-1/mgmt/custom/TM1638/display", subscribtion succedes.
MQTT hub sends first message to this topic, it is received by EspLink [log from ESP-Link debug window]: