Closed ruipalma closed 6 years ago
Will take a look, thanks for reporting
Using the TtnModemTest.ino to interact directly with the modem I can see that the modem is not transmiting the 0x00 bytes after a +RECV. So the problem seems to be in the murata firmware.
The bug is in the murata firmware. The command AT+FORMAT only apply to the sended messages, not the received ones. The received messages are processed in the function
ATEerror_t at_Receive(const char *param)
{
AT_PRINTF("+RECV=");
AT_PRINTF("%d,%d\r\n\n", ReceivedDataPort, ReceivedDataSize);
if (ReceivedDataSize)
{
AT_PRINTF("%s", ReceivedData);
ReceivedDataSize = 0;
}
AT_PRINTF("\r");
return AT_OK;
}
As you can see the received data is scanned as a string, so the 0x00 is a terminator. Maybe we can use the "format_send_v2" to process the received data also. Something like:
ATEerror_t at_Receive(const char *param)
{
AT_PRINTF("+RECV=");
if (format_send_v2==0)
{
AT_PRINTF("%d,%d\r\n\n", ReceivedDataPort, ReceivedDataSize);
if (ReceivedDataSize)
{
AT_PRINTF("%s", ReceivedData);
}
}
else
{
AT_PRINTF("%d,%d\r\n\n", ReceivedDataPort, ReceivedDataSize*2);
for (unsigned i = 0; i < ReceivedDataSize; i++)
{
AT_PRINTF("%02x", ReceivedData[i]);
}
}
ReceivedDataSize = 0;
AT_PRINTF("\r");
return AT_OK;
}
Maybe this issue should be in the mkr 1300 fw repository,
EDIT: ReceivedDataSize*2 to prevent library break.
OK. I have done the modification from the last post in the murata fw and I can confirm that its working. The modem sends a HEX string when +DFORMAT=1. I attached the modified fw. I keep the version. fw.zip
EDIT: ReceivedDataSize*2 to prevent library break.
Hi @ruipalma , would you mind adding a PR on https://github.com/arduino/mkrwan1300-fw with your modification? Thanks!
Hi @facchinm, I have done the PR.
I can confirm the behaviour reported by vahisa in https://forum.arduino.cc/index.php?topic=536628.0, The modem.read() method do not work with 0x00 payload.