Downlink message containing 00 does not work

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

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

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

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

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

Wow,
I am struggeling with exact this problem! Spend whole day on it and could not solve it ;-(

The code crashes on the statement (modem.available) when a "00" in the download message.
It does not get further than this statement in the code.

Does anyone has found a solution yet?

This topic is more than 120 days old but if anyone could help me (oct 29th 2019) would be great!!
thx,

Yeah, there is a problem with the underlying modem firmware. It transmits data using a printf format (%s) function which stops sending data when it encounters the null character. I had a look at v1.2.2 of the ST modem firmware stack and the problem still exists there.

You can use the format() method and set the data format to ASCII HEX. If you have control over how the data is sent, this may be helpful.

Otherwise, using base64 encoding would work as well which I think is more efficient than ASCII HEX.