Describe the bug
I implemented a simple chat application with this library and when testing, the board often froze after sending or receiving a few messages.
Specifically, sending or receiving 15-20 messages of variable length (25-40 characters) is enough to cause my CubeCell devices to freeze.
The last log before the board often blocked was:
[I][PacketRouter.cpp] Routing packet with id: xxx crc: yyy
However, it sometimes occurred after other logs.
I suppose it's a memory leak because I added various logs during packet preparation and it often failed near instructions that allocate memory.
I used this function (with 4096 as the starting point) to try to estimate how heap memory was occupied over time, and I noticed a drastic reduction message after message.
I also tried sending a 117-character message (after a reset to free memory). It froze instantly.
Do you have any idea of where the problem is?
Thanks
To reproduce
- Add in
loop() the following
if (Serial.available() > 0) {
std::string input = Serial.readString().c_str();
sendMessage({0xff, 0xff, 0xff, 0xff}, input);
}
sendMessage() implementation
typedef std::array<byte, RM_ID_LENGTH> RadioMeshAddress;
void sendMessage(RadioMeshAddress addr, const std::string& str) {
loginfo_ln("Sending message: %s", str.c_str());
std::vector<byte> payload(str.begin(), str.end());
int rc = device->sendData(0x10, payload, addr);
if (rc == RM_E_NONE) {
loginfo_ln("Sent message: %s", str.c_str());
} else {
logerr_ln("Failed to send message.");
}
}
- Add at the end of
onPacketReceived callback the following:
loginfo_ln("Received application message, topic: 0x%02X", packet->topic);
const std::vector<byte>& data = packet->packetData;
const std::string msg(data.begin(), data.end());
loginfo_ln("%s", msg.c_str());
- Chat between CubeCell devices, inserting text with various lengths (in my own tests 15-20 messages with 25-40 characters were enough to make the board freeze).
Expected behavior
The board does not freeze.
Additional context
Boards name: CubeCell AB02, AB02A, AB01v2
Wireless module type: LoRa SX1262
Library version: 0.1.0
Edit: I used RM_LOG_INFO as log level, I might try a few tests with RM_LOG_DEBUG
Describe the bug
I implemented a simple chat application with this library and when testing, the board often froze after sending or receiving a few messages.
Specifically, sending or receiving 15-20 messages of variable length (25-40 characters) is enough to cause my CubeCell devices to freeze.
The last log before the board often blocked was:
[I][PacketRouter.cpp] Routing packet with id: xxx crc: yyyHowever, it sometimes occurred after other logs.
I suppose it's a memory leak because I added various logs during packet preparation and it often failed near instructions that allocate memory.
I used this function (with 4096 as the starting point) to try to estimate how heap memory was occupied over time, and I noticed a drastic reduction message after message.
I also tried sending a 117-character message (after a reset to free memory). It froze instantly.
Do you have any idea of where the problem is?
Thanks
To reproduce
loop()the followingsendMessage() implementation
onPacketReceivedcallback the following:Expected behavior
The board does not freeze.
Additional context
Boards name: CubeCell AB02, AB02A, AB01v2Wireless module type: LoRa SX1262Library version: 0.1.0Edit: I used
RM_LOG_INFOas log level, I might try a few tests withRM_LOG_DEBUG