Giter Site home page Giter Site logo

dubanoze / lorawan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brocaar/lorawan

0.0 2.0 0.0 76 KB

Package lorawan provides structures and tools to read and write LoraWAN messages from and to a slice of bytes.

License: MIT License

Go 100.00%

lorawan's Introduction

LoRaWAN (Go)

Build Status GoDoc

Package lorawan provides structures and tools to read and write LoraWAN messages from and to a slice of bytes.

The following structures are implemented (+ fields):

* PHYPayload    (MHDR | MACPayload | MIC)
* MACPayload    (FHDR | FPort | FRMPayload)
* FHDR          (DevAddr | FCtrl | FCnt | FOpts)

The Following message types (MType) are implemented:

* JoinRequest
* JoinAccept
* UnconfirmedDataUp
* UnconfirmedDataDown
* ConfirmedDataUp
* ConfirmedDataDown
* Proprietary

The following MAC commands (and their optional payloads) are implemented:

* LinkCheckReq
* LinkCheckAns
* LinkADRReq
* LinkADRAns
* DutyCycleReq
* DutyCycleAns
* RXParamSetupReq
* RXParamSetupAns
* DevStatusReq
* DevStatusAns
* NewChannelReq
* NewChannelAns
* RXTimingSetupReq
* RXTimingSetupAns
* Support for proprietary commands (0x80 - 0xFF) will be implemented in the
  future (mapping between CID and payload (size) is already done in a map
  called macPayloadRegistry)

Support for calculating and setting the MIC is done by calling SetMIC():

err := phyPayload.SetMIC(key)

Validating the MIC is done by calling ValidateMIC():

valid, err := phyPayload.ValidateMIC(key)

Encryption and decryption of the MACPayload (for join-accept) is done by calling EncryptMACPayload() and DecryptMACPayload(). Note that you need to call SetMIC BEFORE encryption.

err := phyPayload.EncryptMACPayload(key)
err := phyPayload.DecryptMACPayload(key)

Encryption and decryption of the FRMPayload is done by calling EncryptFRMPayload() and DecryptFRMPayload(). After encryption (and thus before decryption), the bytes are stored in the DataPayload struct.

err := macPayload.EncryptFRMPayload(key)
err := macPayload.DecryptFRMPayload(key)

All payloads implement the Payload interface. Based on the MIC value, you should be able to know to which type to cast the Payload value, so you will be able to access its fields.

See the examples section of the documentation for concrete usage examples of this package.

When using this package, knowledge about the LoRaWAN specification is needed. You can request the LoRaWAN specification here: https://www.lora-alliance.org/For-Developers/LoRaWANDevelopers

Documentation

See https://godoc.org/github.com/brocaar/lorawan. There is also an examples section with usage examples.

Todo

Although this package is based on the LoRaWAN spec (1.0) and contains a lot of testcases, testing with real hardware is needed to validate that it works correctly. I will have a gateway soon and be able to do more testing.

License

This package is licensed under the MIT license which can be found in LICENSE. LoRaWAN is a trademark of the LoRa Alliance Inc. (https://www.lora-alliance.org/).

lorawan's People

Contributors

brocaar avatar

Watchers

James Cloos avatar Denis avatar

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.