I want to add a downlink payload to the network-server device queue, so I tried the post method of DeviceQueue in LoRa App REST API web page. I copied the example value of post body and changed some fields:
{
"confirmed": true,
"data": "0203",
"devEUI": "47AB41F2002A0046",
"fPort": 8,
"jsonObject":"{"Data":[1,2,3]}",
"reference":"null"
}
However, I got the response code of 400 and this error:
{
"error": "invalid character 'D' after object key:value pair",
"code": 3
}
The “jsonObject” can’t be any value ? Then how should it be evaluated ?
The following is the screenshot:
brocaar
February 23, 2019, 8:40am
#2
As the jsonObject
key expects a string, you need to escape the value, thus:
"jsonObject":"{\"Data\":[1,2,3]}",
When you have setup a JS codec, this object is passed to the encoder function and it is up to the this function how to encode this to an array of bytes.
I had a try as
{
"confirmed": true,
"data": "AQI=",
"devEUI": "47ab41f2002a0046",
"fPort": 28,
"jsonObject":"{\"Data\":[1,2,3]}"
"reference":"qwer"
}
I still got an error:
{
"error": "invalid character '\"' after object key:value pair",
"code": 3
}
brocaar
February 24, 2019, 10:21am
#4
Your JSON is invalid as you’re missing a comma at the end of the jsonObject
line.
The correct payload is:
{
"confirmed": true,
"data": "AQI=",
"devEUI": "47ab41f2002a0046",
"fPort": 28,
"jsonObject":"{\"Data\":[1,2,3]}",
"reference":"qwer"
}
Thanks!
It was most careless of me:joy:
JoseR
April 1, 2020, 3:44pm
#6
Hello.
What should I install on the server or what should I configure in chirpstack to encode / decode the json object and avoid this error message?
Traberry:
{
"error": "ReferenceError: 'Encode' is not defined",
"code": 2,
"message": "ReferenceError: 'Encode' is not defined",
"details": []
}
You need to choose right way for codec in device profile
write own custom javascript codec functions
or if you endnode device use the cayenne low power payload format choose Cayenne LPP
brocaar:
“reference”:“qwer”
@brocaar
can you please give detail about reference parameter?
changelog:
The reference field has been removed to simplify the downlink queue handling.
Correct me if i am wrong
JoseR
April 2, 2020, 4:46am
#9
Thanks.
This is my settings
[quote=“JoseR, post:3, topic:3706”]
{
“deviceQueueItem”: {
“confirmed”: true,
“data”: “AQI=”,
“devEUI”: “47ab41f2002a0046”,
“fCnt”: 0,
“fPort”: 1,
“jsonObject”: “{“Data”:[1,2,3]}”
}
}
[/quote].
To send messages to devices or nodes, is it necessary to configure a database in postgres?
As this guide indicates: https://www.chirpstack.io/application-server/integrate/sending-receiving/postgresql/
this is not necessary, if don’t want to store up/down message history.
That´s perfect to teste, have you complete the encode function on chirpstack?
Have you make the encode function on payload chirpstack?