manuelbl / ttn-esp32

The Things Network device library for ESP32 (ESP-IDF) and SX127x based devices
MIT License
301 stars 64 forks source link

Downlink messages with payload type JSON arrive empty. #48

Closed Fagonar96 closed 2 years ago

Fagonar96 commented 2 years ago

Greetings, i've been working on a program that is responsible for sending data frames that I get from a BLE scan to TTN. The program works great, so I implemented that the program can receive downlinks to change the operation mode of the program. When the payload type of these downlinks come in bytes I can get it just fine. However, if I change the payload type to JSON, it seems to obtain the message on the port that I assigned but the message is empty (length = 0 bytes). Do you know what may be causing this? Or is it not implemented yet? lora_issue

Thanks in advance.

manuelbl commented 2 years ago

How do you schedule the downlink message? Did you schedule it in the TTN console?

If so, you are probably expecting that you can select JSON, enter a JSON message and have it sent unchanged to the LoRa device. I don't fully understand the TTN console. But my understanding is that a payload formatter needs to be created. It will encode the JSON message into binary form. Then the encoded payload will be transmitted. I'm guessing that you don't have a payload formatter. Thus the payload cannot be created and an empty message is sent.

Fagonar96 commented 2 years ago

Thanks for your reply. Correct, I schedule the downlinks through the TTN console. I noticed that TTN has Javascript payload formatters that allow you to write your own functions to encode or decode messages. So I'm going to try it this way. Thanks.