LoRa WAN Packet decoder / encoder. For the moment it implements the LoRa WAN v1.0.2 standard.
npm install lorapacket
- LoRaPacket
LoRa WAN Packet
- 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
LoRa WAN Packet
Kind: global class
- LoRaPacket
- new LoRaPacket(data, keys, options)
- .deriveKeys(devNonce, encoding)
- .getNwkSKey(encoding)
- .setNwkSKey(nwkSKey, encoding)
- .verifyMic(key, encoding)
- .getComputedMic(encoding, useOriginal, key)
- .getMic(encoding)
- .getAppSKey(encoding)
- .setAppSKey(appSKey, encoding)
- .getAppKey(encoding)
- .setAppKey(appKey, encoding)
- .verifyPacket()
- .getMHDR(encoding)
- .pack(encoding, useOriginal)
- .reset()
- .setMHDR(encoding)
- .getMType(encoding)
- .setMType(mtype)
- .getMajor()
- .setMajor(major)
- .getDevAddr(encoding)
- .setDevAddr(devAddr, encoding)
- .getFCnt(encoding)
- .setFCnt(fCnt, encoding)
- .hasFramePayload()
- .getFPort(encoding)
- .setFPort(fPort, encoding)
- .getFrmPayload(encoding)
- .setFrmPayload(fPort, frmPayload, encoding)
- .getDecryptedFrmPayload(encoding)
- .setFrmPayload(fPort, frmPayload, encoding)
- .setDecryptedFrmPayload(fPort, decryptedFrmPayload, encoding)
- .getFrameAdr(encoding)
- .setFrameAdr(adr)
- .getFrameAdrAckReq(encoding)
- .setFrameAdrAckReq(adrAckReq)
- .getFrameFPending(encoding)
- .setFrameFPending(fPending)
- .getFrameAck(encoding)
- .setFrameAck(ack)
- .getFrameFOptsLen(encoding)
- .setFrameFOptsLen(fOptsLen, encoding)
- .getFOpts(option, encoding)
- .setFOpts(option, fOpts, encoding)
- .getDirection(encoding)
- .isDataPacket()
- .isJoin()
- .toString(encoding)
- .toJSON(encoding)
- .getDevEUI(encoding)
- .setDevEUI(devEUI, encoding)
- .getAppEUI(encoding)
- .setAppEUI(appEUI, encoding)
- .getDevNonce(encoding)
- .setDevNonce(devNonce, encoding)
- .getAppNonce(encoding)
- .setAppNonce(appNonce, encoding)
- .getNetId(encoding)
- .setNetId(netId, encoding)
- .getRx1DRoffset(encoding)
- .setRx1DRoffset(rx1DRoffset, encoding)
- .getRx2DataRate(encoding)
- .setRx2DataRate(Rx2DataRate, encoding)
- .getRxDelay(encoding)
- .setRxDelay(rxDelay, encoding)
- .getCFList()
- .setCFList(cfList)
- .setFlag(namespace, flag, data)
- .getFlag(namespace, flag)
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 |
Derive nwkSKey and appSKey
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
devNonce | int | String |
|
encoding | String |
null for number, hex, base64 |
Get network shared key (nwkSKey)
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for buffer, hex, base64 |
Set network shared key
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
nwkSKey | String | Buffer |
|
encoding | String |
null for buffer, hex, base64 |
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 |
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 |
Get packet MIC
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Get application shared key (appSKey)
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for buffer, hex, base64 |
Set application shared key
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
appSKey | String | Buffer |
|
encoding | String |
null for buffer, hex, base64 |
Get application key (appKey)
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for buffer, hex, base64 |
Set application key
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
appKey | String | Buffer |
|
encoding | String |
null for buffer, hex, base64 |
Verify packet data
Kind: instance method of LoRaPacket
Get packet MHDR
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for object, number for actual number, hex for text |
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 |
Reset
Kind: instance method of LoRaPacket
Set packet MHDR
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for object, number for actual number, hex for text |
Get packet MType
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, string for text |
Set packet MType
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
mtype | Number | String |
number or string () |
Get packet major
Kind: instance method of LoRaPacket
Set packet major
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
major | Number |
number |
Get packet DevAddr
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex or base64 |
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 |
Get packet fPort
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet fPort
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
fCnt | Number | String |
|
encoding | String |
null for number, hex, base64 |
Verify if packet has frame payload
Kind: instance method of LoRaPacket
Get packet fPort
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet fPort
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
fPort | String | Number |
|
encoding | null for number, hex, base64 |
Get packet frmPayload
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for buffer, hex, base64 |
Set packet frmPayload
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
fPort | Number | String |
|
frmPayload | String | Buffer |
|
encoding | String |
null for buffer, hex, base64 |
Get packet decrypted frmPayload
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for buffer, hex, base64 |
Set packet frmPayload
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
fPort | Number | String |
|
frmPayload | String | Buffer |
|
encoding | String |
null for buffer, hex, base64 |
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 |
Get packet frame ADR
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, boolean |
Set packet frame ADR
Kind: instance method of LoRaPacket
Param | Type |
---|---|
adr | boolean | Number |
Get packet frame ADR ACK Req
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, boolean |
Set packet frame ADR ACK Req
Kind: instance method of LoRaPacket
Param | Type |
---|---|
adrAckReq | boolean | Number |
Get packet frame FPending
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, boolean |
Set packet frame FPending
Kind: instance method of LoRaPacket
Param | Type |
---|---|
fPending | boolean | Number |
Get packet frame ACK
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, boolean |
Set packet frame ACK
Kind: instance method of LoRaPacket
Param | Type |
---|---|
ack | boolean | Number |
Get packet frame fOptsLen
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet frame fOptsLen
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
fOptsLen | Number | String |
|
encoding | String |
null is number, hex, base64 |
Get packet fOpts
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
option | Object |
null for all options |
encoding | String |
null for object, hex, base64 |
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 |
Get packet direction
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, string |
Is packet a data packet
Kind: instance method of LoRaPacket
Is packet a join packet
Kind: instance method of LoRaPacket
Get packet in string format
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for default, hex, buffer, base64 |
Get packet in JSON format
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for default, hex, buffer, base64 |
Get packet payload DevEUI
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for hex, buffer, base64 |
Set packet payload devEUI
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
devEUI | String | Buffer |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload AppEUI
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for hex, buffer, base64 |
Set packet payload appEUI
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
appEUI | String | Buffer |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload DevNonce
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload devNonce
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
devNonce | Number | String | Buffer |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload AppNonce
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload AppNonce
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
appNonce | Number | String | Buffer |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload NetID
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload NetID
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
netId | Number | Buffer |
|
encoding | String |
null is number, hex, base64 |
Get packet payload Rx1DRoffset
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload Rx1DRoffset
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
rx1DRoffset | Number | Buffer | String |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload Rx2DataRate
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload rx2DataRate
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
Rx2DataRate | Number | Buffer | String |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload RxDelay
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
encoding | String |
null for number, hex, base64 |
Set packet payload rxDelay
Kind: instance method of LoRaPacket
Param | Type | Description |
---|---|---|
rxDelay | Number | Buffer | String |
|
encoding | String |
null is hex, buffer, base64 |
Get packet payload CFList
Kind: instance method of LoRaPacket
Set packet payload cfList
Kind: instance method of LoRaPacket
Param | Type |
---|---|
cfList | Array.<Number> |
Set flag
Kind: instance method of LoRaPacket
Param | Type |
---|---|
namespace | String |
flag | String |
data | * |
Get flag
Kind: instance method of LoRaPacket
Param | Type |
---|---|
namespace | String |
flag | String |
Pack string with 0
Kind: global function
Param | Type | Description |
---|---|---|
str | String |
string |
length | int |
the length it should have |
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 |
Try to guiess the encoding from value
Kind: global function
Param | Type | Description |
---|---|---|
value | int | String | Buffer |
the value |
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 |
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 |
Get a string with encoding from a string
Kind: global function
Param | Type | Description |
---|---|---|
str | String |
|
encoding | String |
null for hex, buffer, base64 |
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 |
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