forked from brocaar/lorawan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
76 lines (57 loc) · 2.3 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
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 EncryptJoinAcceptPayload() and DecryptJoinAcceptPayload(). Note that you need to
call SetMIC BEFORE encryption.
err := phyPayload.EncryptJoinAcceptPayload(key)
err := phyPayload.DecryptJoinAcceptPayload(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 := phyPayload.EncryptFRMPayload(key)
err := phyPayload.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 download the LoRaWAN specification here:
https://www.lora-alliance.org/For-Developers/LoRaWANDevelopers
*/
package lorawan