Giter Site home page Giter Site logo

thesolarnomad / lora-serialization Goto Github PK

View Code? Open in Web Editor NEW
162.0 16.0 25.0 1.08 MB

LoraWAN serialization/deserialization library for The Things Network

License: MIT License

JavaScript 2.35% C++ 93.56% Makefile 0.03% C 0.49% CMake 1.15% Python 2.37% Shell 0.04% Ruby 0.01%
lorawan ttn serializer deserialization-library serialization-library arduino arduino-library deserialize serialize serialization

lora-serialization's People

Contributors

avbentem avatar cyberman54 avatar davidbrodrick avatar dependabot[bot] avatar joscha avatar matthias-bs avatar per1234 avatar ssippe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lora-serialization's Issues

Integration of opcodes

Hi, great library, thanks for creating!

I'm working on a setup where used sensors may change over time, meaning a static decoding on the backend won't work. Searching for a solution I found things4u's message format - which isn't implemented anywhere.

The idea is to have 6 Bit prefixes announcing the type followed by a 2 Bit length field. The decode would read the first bite and may automatically add "temperature" or whatever as a dict key.

This would increase the message size by a single Byte per transported value but allows dynamic decoding.

A possible implementation could give the LoraMessage a parameter setting the use of opcodes, or not.

Decoder in Java

Hi,

I am testing with lora serializer-deserializer. Everything's work great.
The only thing I am missing is : a deserializer written in Java.
Can you provide one in Java?

Thank you
Fred

TTN Encoder and Payload Format

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.

sign of temperature values ignored

it's impossible to decode negative temperature values; the positive value is always returned.
don't know if its an error in the decode or encode function, or both. see this code:

const ls = require('lora-serialization'),
  enc = ls.encoder, dec = ls.decoder;

const buf = enc.encode([-25.3], [enc.temperature]);

// { temperature: 25.3 }
console.log(dec.decode(buf, [dec.temperature], ['temperature']));

Missing LoraEncoder::getLength()

I am using LoraEncoder instead of LoraMessage, because a statically allocated buffer is perfectly fine for me.
Having a getLength() method would be greatly appreciated!

In my application, the data written to the buffer is configuration-dependent and I would like to avoid counting bytes in a second place.

Sending GPS data to TTN using TinyGPS++

I tried using Lora-serialisation to send GPD data from Node to TTN, but when I useencoder.writeLatLng(-33.905024, 151.26648); data transmits but when I use encoder.writeLatLng((gps.location.lat(), 6), (gps.location.lng(), 6)); data dosen't transmits. am using
`
#include <LoraEncoder.h>

byte mydata[12];

void setup() {
Serial.begin(9600);
ss.begin(9600);
LoraEncoder encoder(mydata);

while (Serial.available() > 0)
if (gps.encode(ss.read()))
if (gps.location.isValid())
{
  int32_t lt = -33.905024;
  int32_t ln =  151.26648;
  encoder.writeLatLng((gps.location.lat(), 6), (gps.location.lng(), 6));
}`

Please help me.

Is this library still active and relevant?

@joscha Is this library still active and relevant?

Hi Joscha. Great library. I noticed that not much has happened on this repo for a few years, is that because it was just so well written it doesn't need any improvements or has it faded from use?

I am trying to understand serialization and wanting to write a tutorial to use encoding and decoding on the Helium Network . This repo seems the best that I have found so far, easy enough to understand and looks useful. Any opinions?

TypeError: Object has no member 'slice' at decodeUplink

Hi!

First off, thanks for the Library, works great on Arduino / ESP Side. However I have still troubles decoding the data on the TTN side.
For the uplink formatter I have got the example code as such:

function decodeUplink(bytes) {
	data = {};
	x = 0  // starting point
	data.fPort = uint8(bytes.slice(x, x + 1))
	return data
}

/* contents from src/decoder.js */
var bytesToInt = function(bytes) {
  var i = 0;
  for (var x = 0; x < bytes.length; x++) {
    i |= +(bytes[x] << (x * 8));
  }
  return i;
};
...

However upon testing I am receiving the above error: TypeError: Object has no member 'slice' at decodeUplink (<eval>:5:32(15))
Does the bytes object need to be converted first, in order to use slice() or should I use it differently?

Thanks & BR :)

Boolean Datatype

Hello,

i really like this library and would love it another datatype: Boolean

It would be useful for stuff like "Battery Low: false/true" / "Something: on/off" / "Parking lot: occupied/free" and you could en/decode 8 Boolean datasets into 1 Byte.

message
    .addBoolean(true/false);

At the moment i have to use the uint8 datatype and do the bitshifting "by hand", it would be great to have this inside the library. Thank you very much!

Issue with library name

Hi @thesolarnomad

we have detected a discrepancy in the library name written inside library.properties
LoRa Serialization (with the capital R)
and the library name written inside inside the library manager index:
Lora Serialization

I think this is due to an error on our side when the library was registered in the library manager index (at the times this process was mostly manual).

Now we are about to introduce a change in the library manager that forbids the situation described above and the releases whose name differs from the name registered in the library index are ignored.

Is it ok for you to use the name LoRa Serialization? If yes, the library will be re-published with the name LoRa Serialization and the old Lora Serialization will be removed from the index, in this case no action is needed on your side. In absence of an answer from you we will proceed with this proposal next week.

Thanks

See also: arduino/Arduino#7127

JOB 617 - 2018/01/15 15:43:20 Scraping https://github.com/thesolarnomad/lora-serialization.git
JOB 617 - 2018/01/15 15:43:21 Checking out tag: v2.1.0
JOB 617 - 2018/01/15 15:43:21 Release LoRa Serialization:2.1.0 has wrong library name, should be Lora Serialization
JOB 617 - 2018/01/15 15:43:21 Checking out tag: v2.2.0
JOB 617 - 2018/01/15 15:43:21 Release LoRa Serialization:2.2.0 has wrong library name, should be Lora Serialization
JOB 617 - 2018/01/15 15:43:21 Checking out tag: v3.0.1
JOB 617 - 2018/01/15 15:43:21 Release LoRa Serialization:3.0.0 has wrong library name, should be Lora Serialization

Create encoder that takes encoder functions

In the decoder, you can currently do something like this:

const bytes = new Bytes(12);
const result = decoder.decode(
    bytes,
    [ decoder.latLng, decoder.unixtime ],
    [ 'coords',       'timestamp']
);
// result is { coords: [/* lat */, /* longitude */], timestamp: /* unixtime */}

It would be great if we had something similar for the Arduino side, because currently it looks like this:

byte buffer[12];
latLngToBytes(buffer   + 0, latitude, longitude);
unixtimeToBytes(buffer + 8, unixtime);
// byte has 12 define bytes

but ideally the user would not need to keep count of what position in the byte array the data is going to be written, e.g. it would be something like:

(pseudo code)

my_encoder = encoder(latLng, unixtime);
byte buffer[my_encoder.targetSize];
my_encoder.encode(buffer, latitude, longitude, timestamp);

Decoder on .cpp ?

Beautiful code, but a decoder also on .cpp would be very useful for generic usage.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.