Go Down

Topic: Downlink message containing 00 does not work (Read 1 time) previous topic - next topic



I have a working uplink and downlink works also if I send anything other than a hex string containing a zero byte:

This works:

And I receive it on the node:
Downlink message: - 01 02 03 04 05 06 -

If I send a message like this:

my node gets stuck or sometimes prints the first part of the message before the zero and continues with random looking bytes.

Is there a known problem that explains this? How to get around this error?

The receiving code is this (modified from the example code):
Code: [Select]
void LoRa::showDownlinkMessage()
    // Show downlink message
    uint8_t rcv[64];
    int i = 0;
    while (modem.available()) {
        rcv[i++] = uint8_t(modem.read());

    Serial.print("Downlink message: - ");
    for (uint8_t j = 0; j < i; j++) {
        Serial.print(rcv[j] >> 4, HEX);
        Serial.print(rcv[j] & 0xF, HEX);
        Serial.print(" ");
    Serial.println("- ");



A brief update:
I tried to use modem.readBytes() also, could not get it to work reliable. Stumbled upon a modem.format() which seems to switch something to hexMode, but that didn't affect the result at all.

I had to base64 encode the downlink message at the backend to get things working which is not optimal but works.

Is there a way to get the receiving side to work with binary data, especially data with zero bytes embedded?

It would be nice to have some kind of document on the MKRWAN library functions. Any available?


using base64 encoding I can transmit binary including 0's, e.g. using a 32u4 Lora board
Code: [Select]
Packet DS18b20 temp = 19.13
66457128: EV_TXCOMPLETE (includes waiting for RX windows)
4 bytes of payload
Data Received:  0x1 0x0 0x3 0x4

it was tested using the UNIX curl command
Code: [Select]
curl -X POST --data '{"dev_id": "ds18b20_1","payload_raw": "AQADBA=="}' https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/ds18b20_temperature_sensor/post_ds18b20?key=xxxx
where xxxx is the downlink key from the downlink_url in the uplink HTTP integration POST message

Go Up