-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TTN Encoder and Payload Format #24
Comments
hi @coastalplain , sorry I haven't had time to look at this yet in detail. The error message suggests that the setup is wrong, have you seen the images in the readme with the examples? |
Hi @joscha: No worries, thank you for your time. edit: Yes, the images helped with the decoder. However, the TTN-side Payload Format encoder is currently my sticking point (to send downlinks). I have tried several options in the initial encoder function followed by encoder.js (I have also tried substituting |
Just had time to look at this and I see the problem now. So the names of the fields are not actually sent over the wire in the encoder. If you look at the sample in the readme you can see: var bytes = encode([timestamp, [latitude, longitude]], [unixtime, latLng]); this effectively means:
In your case the Encoder you wrote 1) doesn't actually use the json object to read the values from that you want to encode 2) uses the strings So this one would actually work: function Encoder(object, port) {
return encode([object.temperature_C, object.humidity], [temperature, humidity]);
}
// encoder.js follows: with a sample payload of: { "temperature_C": 10, "humidity": 20 } however I just tried the TTN console to run it and I am getting a |
I posted in the TTN forum to see what happened there: https://www.thethingsnetwork.org/forum/t/buffer-not-defined-any-more/30168/1 |
Thank you; I will keep an eye on the TTN forum, and try to research the |
fix: remove dependencies on Buffer (#24)
Thank you for creating these functions for TTN decoding and encoding! I have the decoding functioning properly, and I cannot figure out the encoder on the TTN console.
For the decoder, I followed most of the images to end up with this code working correctly:
function Decoder(bytes, port) {
return decode(bytes, [temperature, humidity], ['temperature_C','humidity']);
}
//insert decoder.js below
Testing with hex 09 44 1D 0F as the Payload, it correctly gives the proper JSON output:
{
"humidity": 38.69,
"temperature_C": 23.72
}
When I try to setup the encoder, I cannot figure out the proper way to set it up on TTN, with or without the
LoraMessage(encoder)
convenience class. The following is what I am trying, with several variations I don't want to enumerate. The'temperature_C',' humidity'
are my variables on arduino.function Encoder(object, port) {
return encode(object, [temperature, humidity], ['temperature_C','humidity']);
}
//lora-serialization/src/encoder.js
//lora-serialization/src/LoraMessage.js
The fields I am using are the JSON format from the decoder:
{ "humidity": 38.69, "temperature_C": 23.72 }
and the error comes out as:Internal error: Encoder threw error: TypeError("Values must be an array")
Thank you for your time.
The text was updated successfully, but these errors were encountered: