Skip to content

Latest commit

 

History

History
985 lines (677 loc) · 28.9 KB

DOCUMENTATION.md

File metadata and controls

985 lines (677 loc) · 28.9 KB

LoRaPacket

LoRa WAN Packet decoder / encoder. For the moment it implements the LoRa WAN v1.0.2 standard.

Install

npm install lorapacket

API

Classes

LoRaPacket

LoRa WAN Packet

Functions

zero(str, length)

Pack string with 0

getNumberFromEncoding(value, encoding)

Get a number from a string / int with encoded as encoding

getEncoding(value)

Try to guiess the encoding from value

getNumberWithEncoding(number, encoding)

Get a number with encoding from an int

getStringFromEncoding(value, encoding)

Get a string from a string / int / buffer with encoded as encoding

getStringWithEncoding(str, encoding)

Get a string with encoding from a string

getBufferFromEncoding(value, encoding)

Get a buffer from a string / buffer with encoded as encoding

getBufferWithEncoding(buf, encoding)

Get a string with encoding from a buffer / int with encoded as encoding

LoRaPacket

LoRa WAN Packet

Kind: global class

new LoRaPacket(data, keys, options)

LoRaPacket

Param Type Description
data string | buffer
keys object
keys.appSKey * Application Shared Key
keys.nwkSKey * Network Shared Key
keys.appKey * Application Key
keys.encoding String keys encoding, base64 / hex / buffer
options object
options.encoding String base64 / hex
options.rejectIfMicFail boolean reject packet if mic fails

loRaPacket.deriveKeys(devNonce, encoding)

Derive nwkSKey and appSKey

Kind: instance method of LoRaPacket

Param Type Description
devNonce int | String
encoding String null for number, hex, base64

loRaPacket.getNwkSKey(encoding)

Get network shared key (nwkSKey)

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64

loRaPacket.setNwkSKey(nwkSKey, encoding)

Set network shared key

Kind: instance method of LoRaPacket

Param Type Description
nwkSKey String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.verifyMic(key, encoding)

verify mic

Kind: instance method of LoRaPacket

Param Type Description
key String | Buffer use this key instad of packet's nwkSKey
encoding String null, base64, hex

loRaPacket.getComputedMic(encoding, useOriginal, key)

Get computed packet MIC

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64
useOriginal boolean use the original buffer is available
key String | Buffer use this key instead of the nwkSKey

loRaPacket.getMic(encoding)

Get packet MIC

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.getAppSKey(encoding)

Get application shared key (appSKey)

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64

loRaPacket.setAppSKey(appSKey, encoding)

Set application shared key

Kind: instance method of LoRaPacket

Param Type Description
appSKey String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.getAppKey(encoding)

Get application key (appKey)

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64

loRaPacket.setAppKey(appKey, encoding)

Set application key

Kind: instance method of LoRaPacket

Param Type Description
appKey String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.verifyPacket()

Verify packet data

Kind: instance method of LoRaPacket

loRaPacket.getMHDR(encoding)

Get packet MHDR

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for object, number for actual number, hex for text

loRaPacket.pack(encoding, useOriginal)

pack

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64
useOriginal boolean use the original buffer if it is available

loRaPacket.reset()

Reset

Kind: instance method of LoRaPacket

loRaPacket.setMHDR(encoding)

Set packet MHDR

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for object, number for actual number, hex for text

loRaPacket.getMType(encoding)

Get packet MType

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, string for text

loRaPacket.setMType(mtype)

Set packet MType

Kind: instance method of LoRaPacket

Param Type Description
mtype Number | String number or string ()

loRaPacket.getMajor()

Get packet major

Kind: instance method of LoRaPacket

loRaPacket.setMajor(major)

Set packet major

Kind: instance method of LoRaPacket

Param Type Description
major Number number

loRaPacket.getDevAddr(encoding)

Get packet DevAddr

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex or base64

loRaPacket.setDevAddr(devAddr, encoding)

Set packet DevAddr

Kind: instance method of LoRaPacket

Param Type Description
devAddr Number | String number or string
encoding String null for number or hex, base64

loRaPacket.getFCnt(encoding)

Get packet fPort

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setFCnt(fCnt, encoding)

Set packet fPort

Kind: instance method of LoRaPacket

Param Type Description
fCnt Number | String
encoding String null for number, hex, base64

loRaPacket.hasFramePayload()

Verify if packet has frame payload

Kind: instance method of LoRaPacket

loRaPacket.getFPort(encoding)

Get packet fPort

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setFPort(fPort, encoding)

Set packet fPort

Kind: instance method of LoRaPacket

Param Type Description
fPort String | Number
encoding null for number, hex, base64

loRaPacket.getFrmPayload(encoding)

Get packet frmPayload

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64

loRaPacket.setFrmPayload(fPort, frmPayload, encoding)

Set packet frmPayload

Kind: instance method of LoRaPacket

Param Type Description
fPort Number | String
frmPayload String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.getDecryptedFrmPayload(encoding)

Get packet decrypted frmPayload

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for buffer, hex, base64

loRaPacket.setFrmPayload(fPort, frmPayload, encoding)

Set packet frmPayload

Kind: instance method of LoRaPacket

Param Type Description
fPort Number | String
frmPayload String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.setDecryptedFrmPayload(fPort, decryptedFrmPayload, encoding)

Set packet decrypted frmPayload

Kind: instance method of LoRaPacket

Param Type Description
fPort Number | String
decryptedFrmPayload String | Buffer
encoding String null for buffer, hex, base64

loRaPacket.getFrameAdr(encoding)

Get packet frame ADR

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, boolean

loRaPacket.setFrameAdr(adr)

Set packet frame ADR

Kind: instance method of LoRaPacket

Param Type
adr boolean | Number

loRaPacket.getFrameAdrAckReq(encoding)

Get packet frame ADR ACK Req

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, boolean

loRaPacket.setFrameAdrAckReq(adrAckReq)

Set packet frame ADR ACK Req

Kind: instance method of LoRaPacket

Param Type
adrAckReq boolean | Number

loRaPacket.getFrameFPending(encoding)

Get packet frame FPending

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, boolean

loRaPacket.setFrameFPending(fPending)

Set packet frame FPending

Kind: instance method of LoRaPacket

Param Type
fPending boolean | Number

loRaPacket.getFrameAck(encoding)

Get packet frame ACK

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, boolean

loRaPacket.setFrameAck(ack)

Set packet frame ACK

Kind: instance method of LoRaPacket

Param Type
ack boolean | Number

loRaPacket.getFrameFOptsLen(encoding)

Get packet frame fOptsLen

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setFrameFOptsLen(fOptsLen, encoding)

Set packet frame fOptsLen

Kind: instance method of LoRaPacket

Param Type Description
fOptsLen Number | String
encoding String null is number, hex, base64

loRaPacket.getFOpts(option, encoding)

Get packet fOpts

Kind: instance method of LoRaPacket

Param Type Description
option Object null for all options
encoding String null for object, hex, base64

loRaPacket.setFOpts(option, fOpts, encoding)

Set packet fOpts

Kind: instance method of LoRaPacket

Param Type Description
option Number | String null for all options
fOpts Object
encoding String null for object, hex, base64

loRaPacket.getDirection(encoding)

Get packet direction

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, string

loRaPacket.isDataPacket()

Is packet a data packet

Kind: instance method of LoRaPacket

loRaPacket.isJoin()

Is packet a join packet

Kind: instance method of LoRaPacket

loRaPacket.toString(encoding)

Get packet in string format

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for default, hex, buffer, base64

loRaPacket.toJSON(encoding)

Get packet in JSON format

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for default, hex, buffer, base64

loRaPacket.getDevEUI(encoding)

Get packet payload DevEUI

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for hex, buffer, base64

loRaPacket.setDevEUI(devEUI, encoding)

Set packet payload devEUI

Kind: instance method of LoRaPacket

Param Type Description
devEUI String | Buffer
encoding String null is hex, buffer, base64

loRaPacket.getAppEUI(encoding)

Get packet payload AppEUI

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for hex, buffer, base64

loRaPacket.setAppEUI(appEUI, encoding)

Set packet payload appEUI

Kind: instance method of LoRaPacket

Param Type Description
appEUI String | Buffer
encoding String null is hex, buffer, base64

loRaPacket.getDevNonce(encoding)

Get packet payload DevNonce

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setDevNonce(devNonce, encoding)

Set packet payload devNonce

Kind: instance method of LoRaPacket

Param Type Description
devNonce Number | String | Buffer
encoding String null is hex, buffer, base64

loRaPacket.getAppNonce(encoding)

Get packet payload AppNonce

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setAppNonce(appNonce, encoding)

Set packet payload AppNonce

Kind: instance method of LoRaPacket

Param Type Description
appNonce Number | String | Buffer
encoding String null is hex, buffer, base64

loRaPacket.getNetId(encoding)

Get packet payload NetID

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setNetId(netId, encoding)

Set packet payload NetID

Kind: instance method of LoRaPacket

Param Type Description
netId Number | Buffer
encoding String null is number, hex, base64

loRaPacket.getRx1DRoffset(encoding)

Get packet payload Rx1DRoffset

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setRx1DRoffset(rx1DRoffset, encoding)

Set packet payload Rx1DRoffset

Kind: instance method of LoRaPacket

Param Type Description
rx1DRoffset Number | Buffer | String
encoding String null is hex, buffer, base64

loRaPacket.getRx2DataRate(encoding)

Get packet payload Rx2DataRate

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setRx2DataRate(Rx2DataRate, encoding)

Set packet payload rx2DataRate

Kind: instance method of LoRaPacket

Param Type Description
Rx2DataRate Number | Buffer | String
encoding String null is hex, buffer, base64

loRaPacket.getRxDelay(encoding)

Get packet payload RxDelay

Kind: instance method of LoRaPacket

Param Type Description
encoding String null for number, hex, base64

loRaPacket.setRxDelay(rxDelay, encoding)

Set packet payload rxDelay

Kind: instance method of LoRaPacket

Param Type Description
rxDelay Number | Buffer | String
encoding String null is hex, buffer, base64

loRaPacket.getCFList()

Get packet payload CFList

Kind: instance method of LoRaPacket

loRaPacket.setCFList(cfList)

Set packet payload cfList

Kind: instance method of LoRaPacket

Param Type
cfList Array.<Number>

loRaPacket.setFlag(namespace, flag, data)

Set flag

Kind: instance method of LoRaPacket

Param Type
namespace String
flag String
data *

loRaPacket.getFlag(namespace, flag)

Get flag

Kind: instance method of LoRaPacket

Param Type
namespace String
flag String

zero(str, length)

Pack string with 0

Kind: global function

Param Type Description
str String string
length int the length it should have

getNumberFromEncoding(value, encoding)

Get a number from a string / int with encoded as encoding

Kind: global function

Param Type Description
value int | String
encoding String null for number, hex, base64

getEncoding(value)

Try to guiess the encoding from value

Kind: global function

Param Type Description
value int | String | Buffer the value

getNumberWithEncoding(number, encoding)

Get a number with encoding from an int

Kind: global function

Param Type Description
number int the number
encoding String null for number, hex, base64

getStringFromEncoding(value, encoding)

Get a string from a string / int / buffer with encoded as encoding

Kind: global function

Param Type Description
value int | String | Buffer the value
encoding String null for hex, number, buffer, base64

getStringWithEncoding(str, encoding)

Get a string with encoding from a string

Kind: global function

Param Type Description
str String
encoding String null for hex, buffer, base64

getBufferFromEncoding(value, encoding)

Get a buffer from a string / buffer with encoded as encoding

Kind: global function

Param Type Description
value String | Buffer
encoding String null for buffer, hex, base64

getBufferWithEncoding(buf, encoding)

Get a string with encoding from a buffer / int with encoded as encoding

Kind: global function

Param Type Description
buf Buffer
encoding String null for buffer, hex, base64

© 2017 Wyliodrin SRL