Go Down

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

vahisa

Hi

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

This works:
https://api-eu.thingpark.com/thingpark/lrc/rest/downlink?DevEUI=<myDevEUI_here>&FPort=02&Payload=010203040506

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

If I send a message like this:
https://api-eu.thingpark.com/thingpark/lrc/rest/downlink?DevEUI=<myDevEUI_here>&FPort=02&Payload=010203040006

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("- ");
}



Regards,
ana

vahisa

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?

horace

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)
Received
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