Documentation ¶
Overview ¶
Package lorawan provides structures and tools to read and write LoRaWAN 1.0 and 1.1 frames from and to a slice of bytes.
Index ¶
- func EncryptFOpts(nwkSEncKey AES128Key, aFCntDown, uplink bool, devAddr DevAddr, fCnt uint32, ...) ([]byte, error)
- func EncryptFRMPayload(key AES128Key, uplink bool, devAddr DevAddr, fCnt uint32, data []byte) ([]byte, error)
- func GetTXParamSetupEIRP(index uint8) (float32, error)
- func GetTXParamSetupEIRPIndex(eirp float32) uint8
- func RegisterProprietaryMACCommand(uplink bool, cid CID, payloadSize int) error
- type ADRParam
- type ADRParamSetupReqPayload
- type AES128Key
- func (k AES128Key) MarshalBinary() ([]byte, error)
- func (k AES128Key) MarshalText() ([]byte, error)
- func (k *AES128Key) Scan(src interface{}) error
- func (k AES128Key) String() string
- func (k *AES128Key) UnmarshalBinary(data []byte) error
- func (k *AES128Key) UnmarshalText(text []byte) error
- func (k AES128Key) Value() (driver.Value, error)
- type BeaconFreqAnsPayload
- type BeaconFreqReqPayload
- type CFList
- type CFListChannelMaskPayload
- type CFListChannelPayload
- type CFListType
- type CID
- type ChMask
- type DLChannelAnsPayload
- type DLChannelReqPayload
- type DLSettings
- type DataPayload
- type DevAddr
- func (a DevAddr) IsNetID(netID NetID) bool
- func (a DevAddr) MarshalBinary() ([]byte, error)
- func (a DevAddr) MarshalText() ([]byte, error)
- func (a DevAddr) NetIDType() int
- func (a DevAddr) NwkID() []byte
- func (a *DevAddr) Scan(src interface{}) error
- func (a *DevAddr) SetAddrPrefix(netID NetID)
- func (a DevAddr) String() string
- func (a *DevAddr) UnmarshalBinary(data []byte) error
- func (a *DevAddr) UnmarshalText(text []byte) error
- func (a DevAddr) Value() (driver.Value, error)
- type DevNonce
- type DevStatusAnsPayload
- type DeviceModeClass
- type DeviceModeConfPayload
- type DeviceModeIndPayload
- type DeviceTimeAnsPayload
- type DutyCycleReqPayload
- type DwellTime
- type EUI64
- func (e EUI64) MarshalBinary() ([]byte, error)
- func (e EUI64) MarshalText() ([]byte, error)
- func (e *EUI64) Scan(src interface{}) error
- func (e EUI64) String() string
- func (e *EUI64) UnmarshalBinary(data []byte) error
- func (e *EUI64) UnmarshalText(text []byte) error
- func (e EUI64) Value() (driver.Value, error)
- type FCtrl
- type FHDR
- type ForceRejoinReqPayload
- type JoinAcceptPayload
- type JoinNonce
- type JoinRequestPayload
- type JoinType
- type LinkADRAnsPayload
- type LinkADRReqPayload
- type LinkCheckAnsPayload
- type MACCommand
- type MACCommandPayload
- type MACPayload
- type MACVersion
- type MHDR
- type MIC
- type MType
- type Major
- type NetID
- func (n NetID) ID() []byte
- func (n NetID) MarshalBinary() ([]byte, error)
- func (n NetID) MarshalText() ([]byte, error)
- func (n *NetID) Scan(src interface{}) error
- func (n NetID) String() string
- func (n NetID) Type() int
- func (n *NetID) UnmarshalBinary(data []byte) error
- func (n *NetID) UnmarshalText(text []byte) error
- func (n NetID) Value() (driver.Value, error)
- type NewChannelAnsPayload
- type NewChannelReqPayload
- type PHYPayload
- func (p *PHYPayload) DecodeFOptsToMACCommands() error
- func (p *PHYPayload) DecodeFRMPayloadToMACCommands() error
- func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error
- func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error
- func (p *PHYPayload) DecryptJoinAcceptPayload(key AES128Key) error
- func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error
- func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error
- func (p *PHYPayload) EncryptJoinAcceptPayload(key AES128Key) error
- func (p PHYPayload) MarshalBinary() ([]byte, error)
- func (p PHYPayload) MarshalJSON() ([]byte, error)
- func (p PHYPayload) MarshalText() ([]byte, error)
- func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error
- func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error
- func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, ...) error
- func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error
- func (p *PHYPayload) UnmarshalBinary(data []byte) error
- func (p *PHYPayload) UnmarshalText(text []byte) error
- func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error)
- func (p PHYPayload) ValidateDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) (bool, error)
- func (p PHYPayload) ValidateUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, ...) (bool, error)
- func (p PHYPayload) ValidateUplinkDataMICF(fNwkSIntKey AES128Key) (bool, error)
- func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error)
- type Payload
- type PingSlotChannelAnsPayload
- type PingSlotChannelReqPayload
- type PingSlotInfoReqPayload
- type ProprietaryMACCommandPayload
- type RXParamSetupAnsPayload
- type RXParamSetupReqPayload
- type RXTimingSetupReqPayload
- type Redundancy
- type RejoinParamSetupAnsPayload
- type RejoinParamSetupReqPayload
- type RejoinRequestType02Payload
- type RejoinRequestType1Payload
- type RekeyConfPayload
- type RekeyIndPayload
- type ResetConfPayload
- type ResetIndPayload
- type TXParamSetupReqPayload
- type Version
Examples ¶
- PHYPayload (JoinAcceptSend)
- PHYPayload (JoinRequest)
- PHYPayload (Lorawan10Decode)
- PHYPayload (Lorawan10Encode)
- PHYPayload (Lorawan11EncryptedFoptsDecode)
- PHYPayload (Lorawan11EncryptedFoptsEncode)
- PHYPayload (Lorawan11JoinAcceptSend)
- PHYPayload (ProprietaryDecode)
- PHYPayload (ProprietaryEncode)
- PHYPayload (ReadJoinRequest)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptFOpts ¶
func EncryptFOpts(nwkSEncKey AES128Key, aFCntDown, uplink bool, devAddr DevAddr, fCnt uint32, data []byte) ([]byte, error)
EncryptFOpts encrypts the FOpts mac-commands. For uplink:
Set the aFCntDown to false and use the FCntUp
For downlink if FPort is not set or equals to 0:
Set the aFCntDown to false and use the NFCntDown
For downlink if FPort > 0:
Set the aFCntDown to true and use the AFCntDown
func EncryptFRMPayload ¶
func EncryptFRMPayload(key AES128Key, uplink bool, devAddr DevAddr, fCnt uint32, data []byte) ([]byte, error)
EncryptFRMPayload encrypts the FRMPayload (slice of bytes). Note that EncryptFRMPayload is used for both encryption and decryption.
func GetTXParamSetupEIRP ¶
GetTXParamsetupEIRP returns the EIRP (dBm) for the coded value.
func GetTXParamSetupEIRPIndex ¶
GetTXParamSetupEIRPIndex returns the coded value for the given EIRP (dBm). Note that it returns the coded value that is closest to the given EIRP, without exceeding it.
Types ¶
type ADRParam ¶
ADRParam defines the ADRParam field.
func (ADRParam) MarshalBinary ¶
MarshalBinary encodes the object into bytes.
func (*ADRParam) UnmarshalBinary ¶
UnmarshalBinary decodes the object from bytes.
type ADRParamSetupReqPayload ¶
type ADRParamSetupReqPayload struct {
ADRParam ADRParam `json:"adrParam"`
}
ADRParamSetupReqPayload represents the ADRParamReq payload.
func (ADRParamSetupReqPayload) MarshalBinary ¶
func (p ADRParamSetupReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*ADRParamSetupReqPayload) UnmarshalBinary ¶
func (p *ADRParamSetupReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type AES128Key ¶
type AES128Key [16]byte
AES128Key represents a 128 bit AES key.
func (AES128Key) MarshalBinary ¶
MarshalBinary encodes the key to a slice of bytes.
func (AES128Key) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*AES128Key) UnmarshalBinary ¶
UnmarshalBinary decodes the key from a slice of bytes.
func (*AES128Key) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type BeaconFreqAnsPayload ¶
type BeaconFreqAnsPayload struct {
BeaconFrequencyOK bool `json:"beaconFrequencyOK"`
}
BeaconFreqAnsPayload represents the BeaconFreqAns payload.
func (BeaconFreqAnsPayload) MarshalBinary ¶
func (p BeaconFreqAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*BeaconFreqAnsPayload) UnmarshalBinary ¶
func (p *BeaconFreqAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type BeaconFreqReqPayload ¶
type BeaconFreqReqPayload struct {
Frequency uint32 `json:"frequency"`
}
BeaconFreqReqPayload represents the BeaconFreqReq payload.
func (BeaconFreqReqPayload) MarshalBinary ¶
func (p BeaconFreqReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*BeaconFreqReqPayload) UnmarshalBinary ¶
func (p *BeaconFreqReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type CFList ¶
type CFList struct { Payload Payload `json:"payload"` CFListType CFListType `json:"cFListType"` }
CFList represents a list of channel frequencies or channel-masks.
func (CFList) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
func (*CFList) UnmarshalBinary ¶
UnmarshalBinary decodes the object from binary form.
type CFListChannelMaskPayload ¶
type CFListChannelMaskPayload struct {
ChannelMasks []ChMask
}
CFListChannelMaskPayload holds a list of channel-masks.
func (CFListChannelMaskPayload) MarshalBinary ¶
func (p CFListChannelMaskPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*CFListChannelMaskPayload) UnmarshalBinary ¶
func (p *CFListChannelMaskPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type CFListChannelPayload ¶
type CFListChannelPayload struct {
Channels [5]uint32
}
CFListChannelPayload holds a list of (up to 5) channel frequencies. Each frequency is in Hz and must be a multiple of 100.
func (CFListChannelPayload) MarshalBinary ¶
func (p CFListChannelPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*CFListChannelPayload) UnmarshalBinary ¶
func (p *CFListChannelPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type CFListType ¶
type CFListType uint8
CFListType defines the CFList payload type.
const ( CFListChannel CFListType = 0 CFListChannelMask CFListType = 1 )
Possible CFList types.
type CID ¶
type CID byte
CID defines the MAC command identifier.
const ( // Class-A ResetInd CID = 0x01 ResetConf CID = 0x01 LinkCheckReq CID = 0x02 LinkCheckAns CID = 0x02 LinkADRReq CID = 0x03 LinkADRAns CID = 0x03 DutyCycleReq CID = 0x04 DutyCycleAns CID = 0x04 RXParamSetupReq CID = 0x05 RXParamSetupAns CID = 0x05 DevStatusReq CID = 0x06 DevStatusAns CID = 0x06 NewChannelReq CID = 0x07 NewChannelAns CID = 0x07 RXTimingSetupReq CID = 0x08 RXTimingSetupAns CID = 0x08 TXParamSetupReq CID = 0x09 TXParamSetupAns CID = 0x09 DLChannelReq CID = 0x0A DLChannelAns CID = 0x0A RekeyInd CID = 0x0B RekeyConf CID = 0x0B ADRParamSetupReq CID = 0x0C ADRParamSetupAns CID = 0x0C DeviceTimeReq CID = 0x0D DeviceTimeAns CID = 0x0D ForceRejoinReq CID = 0x0E RejoinParamSetupReq CID = 0x0F RejoinParamSetupAns CID = 0x0F // Class-B PingSlotInfoReq CID = 0x10 PingSlotInfoAns CID = 0x10 PingSlotChannelReq CID = 0x11 PingSlotChannelAns CID = 0x11 // 0x12 has been deprecated in 1.1 BeaconFreqReq CID = 0x13 BeaconFreqAns CID = 0x13 // Class-C DeviceModeInd CID = 0x20 DeviceModeConf CID = 0x20 )
MAC commands as specified by the LoRaWAN R1.0 specs. Note that each *Req / *Ans has the same value. Based on the fact if a message is uplink or downlink you should use on or the other.
func (CID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type ChMask ¶
type ChMask [16]bool
ChMask encodes the channels usable for uplink access. 0 = channel 1, 15 = channel 16.
func (ChMask) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
func (*ChMask) UnmarshalBinary ¶
UnmarshalBinary decodes the object from binary form.
type DLChannelAnsPayload ¶
type DLChannelAnsPayload struct { UplinkFrequencyExists bool `json:"uplinkFrequencyExists"` ChannelFrequencyOK bool `json:"channelFrequencyOK"` }
DLChannelAnsPayload represents the DLChannelAns payload.
func (DLChannelAnsPayload) MarshalBinary ¶
func (p DLChannelAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*DLChannelAnsPayload) UnmarshalBinary ¶
func (p *DLChannelAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type DLChannelReqPayload ¶
DLChannelReqPayload represents the DLChannelReq payload.
func (DLChannelReqPayload) MarshalBinary ¶
func (p DLChannelReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*DLChannelReqPayload) UnmarshalBinary ¶
func (p *DLChannelReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type DLSettings ¶
type DLSettings struct { OptNeg bool `json:"optNeg"` RX2DataRate uint8 `json:"rx2DataRate"` RX1DROffset uint8 `json:"rx1DROffset"` }
DLSettings represents the DLSettings fields (downlink settings).
func (DLSettings) MarshalBinary ¶
func (s DLSettings) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (DLSettings) MarshalText ¶
func (s DLSettings) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (*DLSettings) UnmarshalBinary ¶
func (s *DLSettings) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
func (*DLSettings) UnmarshalText ¶
func (s *DLSettings) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type DataPayload ¶
type DataPayload struct {
Bytes []byte `json:"bytes"`
}
DataPayload represents a slice of bytes.
func (DataPayload) MarshalBinary ¶
func (p DataPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*DataPayload) UnmarshalBinary ¶
func (p *DataPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type DevAddr ¶
type DevAddr [4]byte
DevAddr represents the device address.
func (DevAddr) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
func (DevAddr) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*DevAddr) SetAddrPrefix ¶
SetAddrPrefix sets the NetID based AddrPrefix.
func (*DevAddr) UnmarshalBinary ¶
UnmarshalBinary decodes the object from binary form.
func (*DevAddr) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type DevNonce ¶
type DevNonce uint16
DevNonce represents the dev-nonce.
func (DevNonce) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*DevNonce) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type DevStatusAnsPayload ¶
DevStatusAnsPayload represents the DevStatusAns payload.
func (DevStatusAnsPayload) MarshalBinary ¶
func (p DevStatusAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*DevStatusAnsPayload) UnmarshalBinary ¶
func (p *DevStatusAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type DeviceModeClass ¶
type DeviceModeClass byte
DeviceModeIndClass defines the DeviceModeInd class.
const ( DeviceModeClassA DeviceModeClass = 0x00 DeviceModeRFU DeviceModeClass = 0x01 DeviceModeClassC DeviceModeClass = 0x02 )
DeviceModeInd class options.
func (DeviceModeClass) String ¶
func (i DeviceModeClass) String() string
type DeviceModeConfPayload ¶
type DeviceModeConfPayload struct {
Class DeviceModeClass
}
DeviceModeConfPayload represents the DeviceModeConf payload.
func (DeviceModeConfPayload) MarshalBinary ¶
func (p DeviceModeConfPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*DeviceModeConfPayload) UnmarshalBinary ¶
func (p *DeviceModeConfPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type DeviceModeIndPayload ¶
type DeviceModeIndPayload struct {
Class DeviceModeClass
}
DeviceModeIndPayload represents the DeviceModeInd payload.
func (DeviceModeIndPayload) MarshalBinary ¶
func (p DeviceModeIndPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*DeviceModeIndPayload) UnmarshalBinary ¶
func (p *DeviceModeIndPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type DeviceTimeAnsPayload ¶
DeviceTimeAnsPayload represents the DeviceTimeAns payload.
func (DeviceTimeAnsPayload) MarshalBinary ¶
func (p DeviceTimeAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*DeviceTimeAnsPayload) UnmarshalBinary ¶
func (p *DeviceTimeAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type DutyCycleReqPayload ¶
type DutyCycleReqPayload struct {
MaxDCycle uint8 `json:"maxDCycle"`
}
DutyCycleReqPayload represents the DutyCycleReq payload.
func (DutyCycleReqPayload) MarshalBinary ¶
func (p DutyCycleReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*DutyCycleReqPayload) UnmarshalBinary ¶
func (p *DutyCycleReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type EUI64 ¶
type EUI64 [8]byte
EUI64 data type
func (EUI64) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (EUI64) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*EUI64) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*EUI64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type FCtrl ¶
type FCtrl struct { ADR bool `json:"adr"` ADRACKReq bool `json:"adrAckReq"` ACK bool `json:"ack"` FPending bool `json:"fPending"` // only used for downlink messages ClassB bool `json:"classB"` // only used for uplink messages // contains filtered or unexported fields }
FCtrl represents the FCtrl (frame control) field. Please note that the FPending and ClassB are mapped to the same bit. This means that when unmarshaling from a byte-slice, both fields will contain the same value (either true or false).
func (FCtrl) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
func (*FCtrl) UnmarshalBinary ¶
UnmarshalBinary decodes the object from binary form.
type FHDR ¶
type FHDR struct { DevAddr DevAddr `json:"devAddr"` FCtrl FCtrl `json:"fCtrl"` FCnt uint32 `json:"fCnt"` // only the least-significant 16 bits will be marshalled FOpts []Payload `json:"fOpts"` // max. number of allowed bytes is 15 }
FHDR represents the frame header.
func (FHDR) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
type ForceRejoinReqPayload ¶
type ForceRejoinReqPayload struct { Period uint8 `json:"period"` MaxRetries uint8 `json:"maxRetries"` RejoinType uint8 `json:"rejoinType"` DR uint8 `json:"dr"` }
ForceRejoinReqPayload represents the ForceRejoinReq payload.
func (ForceRejoinReqPayload) MarshalBinary ¶
func (p ForceRejoinReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*ForceRejoinReqPayload) UnmarshalBinary ¶
func (p *ForceRejoinReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type JoinAcceptPayload ¶
type JoinAcceptPayload struct { JoinNonce JoinNonce `json:"joinNonce"` HomeNetID NetID `json:"homeNetID"` DevAddr DevAddr `json:"devAddr"` DLSettings DLSettings `json:"dlSettings"` RXDelay uint8 `json:"rxDelay"` // 0=1s, 1=1s, 2=2s, ... 15=15s CFList *CFList `json:"cFlist"` }
JoinAcceptPayload represents the join-accept message payload.
func (JoinAcceptPayload) MarshalBinary ¶
func (p JoinAcceptPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*JoinAcceptPayload) UnmarshalBinary ¶
func (p *JoinAcceptPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type JoinNonce ¶
type JoinNonce uint32
JoinNonce represents the join-nonce. Note that the max value is 2^24 - 1 = 16777215.
func (JoinNonce) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*JoinNonce) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type JoinRequestPayload ¶
type JoinRequestPayload struct { JoinEUI EUI64 `json:"joinEUI"` DevEUI EUI64 `json:"devEUI"` DevNonce DevNonce `json:"devNonce"` }
JoinRequestPayload represents the join-request message payload.
func (JoinRequestPayload) MarshalBinary ¶
func (p JoinRequestPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*JoinRequestPayload) UnmarshalBinary ¶
func (p *JoinRequestPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type JoinType ¶
type JoinType uint8
JoinType defines the join-request type.
type LinkADRAnsPayload ¶
type LinkADRAnsPayload struct { ChannelMaskACK bool `json:"channelMaskAck"` DataRateACK bool `json:"dataRateAck"` PowerACK bool `json:"powerAck"` }
LinkADRAnsPayload represents the LinkADRAns payload.
func (LinkADRAnsPayload) MarshalBinary ¶
func (p LinkADRAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*LinkADRAnsPayload) UnmarshalBinary ¶
func (p *LinkADRAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type LinkADRReqPayload ¶
type LinkADRReqPayload struct { DataRate uint8 `json:"dataRate"` TXPower uint8 `json:"txPower"` ChMask ChMask `json:"chMask"` Redundancy Redundancy `json:"redundancy"` }
LinkADRReqPayload represents the LinkADRReq payload.
func (LinkADRReqPayload) MarshalBinary ¶
func (p LinkADRReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*LinkADRReqPayload) UnmarshalBinary ¶
func (p *LinkADRReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type LinkCheckAnsPayload ¶
LinkCheckAnsPayload represents the LinkCheckAns payload.
func (LinkCheckAnsPayload) MarshalBinary ¶
func (p LinkCheckAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*LinkCheckAnsPayload) UnmarshalBinary ¶
func (p *LinkCheckAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type MACCommand ¶
type MACCommand struct { CID CID `json:"cid"` Payload MACCommandPayload `json:"payload"` }
MACCommand represents a MAC command with optional payload.
func (MACCommand) MarshalBinary ¶
func (m MACCommand) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*MACCommand) UnmarshalBinary ¶
func (m *MACCommand) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type MACCommandPayload ¶
type MACCommandPayload interface { MarshalBinary() (data []byte, err error) UnmarshalBinary(data []byte) error }
MACCommandPayload is the interface that every MACCommand payload must implement.
func GetMACPayloadAndSize ¶
func GetMACPayloadAndSize(uplink bool, c CID) (MACCommandPayload, int, error)
GetMACPayloadAndSize returns a new MACCommandPayload instance and it's size.
type MACPayload ¶
type MACPayload struct { FHDR FHDR `json:"fhdr"` FPort *uint8 `json:"fPort"` // optional, but must be set when FRMPayload is set FRMPayload []Payload `json:"frmPayload"` }
MACPayload represents the MAC payload. Use NewMACPayload for creating a new MACPayload.
func (MACPayload) MarshalBinary ¶
func (p MACPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*MACPayload) UnmarshalBinary ¶
func (p *MACPayload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type MACVersion ¶
type MACVersion byte
MACVersion defines the LoRaWAN MAC version.
const ( LoRaWAN1_0 MACVersion = iota LoRaWAN1_1 )
Supported LoRaWAN MAC versions.
type MHDR ¶
MHDR represents the MAC header.
func (MHDR) MarshalBinary ¶
MarshalBinary marshals the object in binary form.
func (*MHDR) UnmarshalBinary ¶
UnmarshalBinary decodes the object from binary form.
type MIC ¶
type MIC [4]byte
MIC represents the message integrity code.
func (MIC) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type MType ¶
type MType byte
MType represents the message type.
const ( JoinRequest MType = iota JoinAccept UnconfirmedDataUp UnconfirmedDataDown ConfirmedDataUp ConfirmedDataDown RejoinRequest Proprietary )
Supported message types (MType)
func (MType) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type Major ¶
type Major byte
Major defines the major version of data message.
const (
LoRaWANR1 Major = 0
)
Supported major versions
func (Major) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
type NetID ¶
type NetID [3]byte
NetID represents the NetID.
func (NetID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (NetID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*NetID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*NetID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type NewChannelAnsPayload ¶
type NewChannelAnsPayload struct { ChannelFrequencyOK bool `json:"channelFrequencyOK"` DataRateRangeOK bool `json:"dataRateRangeOK"` }
NewChannelAnsPayload represents the NewChannelAns payload.
func (NewChannelAnsPayload) MarshalBinary ¶
func (p NewChannelAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*NewChannelAnsPayload) UnmarshalBinary ¶
func (p *NewChannelAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type NewChannelReqPayload ¶
type NewChannelReqPayload struct { ChIndex uint8 `json:"chIndex"` Freq uint32 `json:"freq"` MaxDR uint8 `json:"maxDR"` MinDR uint8 `json:"minDR"` }
NewChannelReqPayload represents the NewChannelReq payload.
func (NewChannelReqPayload) MarshalBinary ¶
func (p NewChannelReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*NewChannelReqPayload) UnmarshalBinary ¶
func (p *NewChannelReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PHYPayload ¶
type PHYPayload struct { MHDR MHDR `json:"mhdr"` MACPayload Payload `json:"macPayload"` MIC MIC `json:"mic"` }
PHYPayload represents the physical payload.
Example (JoinAcceptSend) ¶
appKey := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} joinEUI := EUI64{8, 7, 6, 5, 4, 3, 2, 1} devNonce := DevNonce(258) phy := PHYPayload{ MHDR: MHDR{ MType: JoinAccept, Major: LoRaWANR1, }, MACPayload: &JoinAcceptPayload{ JoinNonce: 65793, HomeNetID: [3]byte{2, 2, 2}, DevAddr: DevAddr([4]byte{1, 2, 3, 4}), DLSettings: DLSettings{RX2DataRate: 0, RX1DROffset: 0}, RXDelay: 0, }, } // set the MIC before encryption if err := phy.SetDownlinkJoinMIC(JoinRequestType, joinEUI, devNonce, appKey); err != nil { panic(err) } if err := phy.EncryptJoinAcceptPayload(appKey); err != nil { panic(err) } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes)
Output: ICPPM1SJquMYPAvguqje5fM= [32 35 207 51 84 137 170 227 24 60 11 224 186 168 222 229 243]
Example (JoinRequest) ¶
appKey := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} phy := PHYPayload{ MHDR: MHDR{ MType: JoinRequest, Major: LoRaWANR1, }, MACPayload: &JoinRequestPayload{ JoinEUI: [8]byte{1, 1, 1, 1, 1, 1, 1, 1}, DevEUI: [8]byte{2, 2, 2, 2, 2, 2, 2, 2}, DevNonce: 771, }, } if err := phy.SetUplinkJoinMIC(appKey); err != nil { panic(err) } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes)
Output: AAEBAQEBAQEBAgICAgICAgIDAwm5ezI= [0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 9 185 123 50]
Example (Lorawan10Decode) ¶
nwkSKey := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} appSKey := [16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1} var phy PHYPayload // use use UnmarshalBinary when decoding a byte-slice if err := phy.UnmarshalText([]byte("gAQDAgEDAAAGcwcK4mTU9+EX0sA=")); err != nil { panic(err) } ok, err := phy.ValidateUplinkDataMIC(LoRaWAN1_0, 0, 0, 0, nwkSKey, AES128Key{}) if err != nil { panic(err) } if !ok { panic("invalid mic") } if err := phy.DecodeFOptsToMACCommands(); err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } if err := phy.DecryptFRMPayload(appSKey); err != nil { panic(err) } macPL, ok := phy.MACPayload.(*MACPayload) if !ok { panic("*MACPayload expected") } pl, ok := macPL.FRMPayload[0].(*DataPayload) if !ok { panic("*DataPayload expected") } fmt.Println(string(phyJSON)) fmt.Println(pl.Bytes)
Output: {"mhdr":{"mType":"ConfirmedDataUp","major":"LoRaWANR1"},"macPayload":{"fhdr":{"devAddr":"01020304","fCtrl":{"adr":false,"adrAckReq":false,"ack":false,"fPending":false,"classB":false},"fCnt":0,"fOpts":[{"cid":"DevStatusReq","payload":{"battery":115,"margin":7}}]},"fPort":10,"frmPayload":[{"bytes":"4mTU9w=="}]},"mic":"e117d2c0"} [1 2 3 4]
Example (Lorawan10Encode) ¶
nwkSKey := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} appSKey := [16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1} fPort := uint8(10) phy := PHYPayload{ MHDR: MHDR{ MType: ConfirmedDataUp, Major: LoRaWANR1, }, MACPayload: &MACPayload{ FHDR: FHDR{ DevAddr: DevAddr([4]byte{1, 2, 3, 4}), FCtrl: FCtrl{ ADR: false, ADRACKReq: false, ACK: false, }, FCnt: 0, FOpts: []Payload{ &MACCommand{ CID: DevStatusAns, Payload: &DevStatusAnsPayload{ Battery: 115, Margin: 7, }, }, }, }, FPort: &fPort, FRMPayload: []Payload{&DataPayload{Bytes: []byte{1, 2, 3, 4}}}, }, } if err := phy.EncryptFRMPayload(appSKey); err != nil { panic(err) } if err := phy.SetUplinkDataMIC(LoRaWAN1_0, 0, 0, 0, nwkSKey, AES128Key{}); err != nil { panic(err) } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes) fmt.Println(string(phyJSON))
Output: gAQDAgEDAAAGcwcK4mTU9+EX0sA= [128 4 3 2 1 3 0 0 6 115 7 10 226 100 212 247 225 23 210 192] {"mhdr":{"mType":"ConfirmedDataUp","major":"LoRaWANR1"},"macPayload":{"fhdr":{"devAddr":"01020304","fCtrl":{"adr":false,"adrAckReq":false,"ack":false,"fPending":false,"classB":false},"fCnt":0,"fOpts":[{"cid":"DevStatusReq","payload":{"battery":115,"margin":7}}]},"fPort":10,"frmPayload":[{"bytes":"4mTU9w=="}]},"mic":"e117d2c0"}
Example (Lorawan11EncryptedFoptsDecode) ¶
sNwkSIntKey := [16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} nwkSEncKey := [16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2} appSKey := [16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1} var phy PHYPayload if err := phy.UnmarshalText([]byte("YAQDAgEDAAAirAoB8LRo3ape0To=")); err != nil { panic(err) } ok, err := phy.ValidateDownlinkDataMIC(LoRaWAN1_1, 0, sNwkSIntKey) if err != nil { panic(err) } if !ok { panic("invalid mic") } if err := phy.DecryptFOpts(nwkSEncKey); err != nil { panic(err) } if err := phy.DecryptFRMPayload(appSKey); err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } fmt.Println(string(phyJSON))
Output: {"mhdr":{"mType":"UnconfirmedDataDown","major":"LoRaWANR1"},"macPayload":{"fhdr":{"devAddr":"01020304","fCtrl":{"adr":false,"adrAckReq":false,"ack":false,"fPending":false,"classB":false},"fCnt":0,"fOpts":[{"cid":"LinkCheckReq","payload":{"margin":7,"gwCnt":1}}]},"fPort":1,"frmPayload":[{"bytes":"AQIDBA=="}]},"mic":"aa5ed13a"}
Example (Lorawan11EncryptedFoptsEncode) ¶
sNwkSIntKey := [16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} nwkSEncKey := [16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2} appSKey := [16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1} var fport1 uint8 = 1 phy := PHYPayload{ MHDR: MHDR{ MType: UnconfirmedDataDown, Major: LoRaWANR1, }, MACPayload: &MACPayload{ FHDR: FHDR{ DevAddr: DevAddr{1, 2, 3, 4}, FOpts: []Payload{ &MACCommand{ CID: LinkCheckAns, Payload: &LinkCheckAnsPayload{ Margin: 7, GwCnt: 1, }, }, }, }, FPort: &fport1, FRMPayload: []Payload{ &DataPayload{Bytes: []byte{1, 2, 3, 4}}, }, }, } if err := phy.EncryptFOpts(nwkSEncKey); err != nil { panic(err) } if err := phy.EncryptFRMPayload(appSKey); err != nil { panic(err) } if err := phy.SetDownlinkDataMIC(LoRaWAN1_1, 0, sNwkSIntKey); err != nil { panic(err) } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes) fmt.Println(string(phyJSON))
Output: YAQDAgEDAAAirAoB8LRo3ape0To= [96 4 3 2 1 3 0 0 34 172 10 1 240 180 104 221 170 94 209 58] {"mhdr":{"mType":"UnconfirmedDataDown","major":"LoRaWANR1"},"macPayload":{"fhdr":{"devAddr":"01020304","fCtrl":{"adr":false,"adrAckReq":false,"ack":false,"fPending":false,"classB":false},"fCnt":0,"fOpts":[{"bytes":"IqwK"}]},"fPort":1,"frmPayload":[{"bytes":"8LRo3Q=="}]},"mic":"aa5ed13a"}
Example (Lorawan11JoinAcceptSend) ¶
appKey := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} joinEUI := EUI64{8, 7, 6, 5, 4, 3, 2, 1} devNonce := DevNonce(258) // note: the DLSettings OptNeg is set to true! phy := PHYPayload{ MHDR: MHDR{ MType: JoinAccept, Major: LoRaWANR1, }, MACPayload: &JoinAcceptPayload{ JoinNonce: 65793, HomeNetID: [3]byte{2, 2, 2}, DevAddr: DevAddr([4]byte{1, 2, 3, 4}), DLSettings: DLSettings{RX2DataRate: 0, RX1DROffset: 0, OptNeg: true}, RXDelay: 0, }, } // set the MIC before encryption if err := phy.SetDownlinkJoinMIC(JoinRequestType, joinEUI, devNonce, appKey); err != nil { panic(err) } if err := phy.EncryptJoinAcceptPayload(appKey); err != nil { panic(err) } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes)
Output: IHq+6gawKSDxHALQNI/PGBU= [32 122 190 234 6 176 41 32 241 28 2 208 52 143 207 24 21]
Example (ProprietaryDecode) ¶
var phy PHYPayload if err := phy.UnmarshalText([]byte("4AUGBwgJCgECAwQ=")); err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } pl, ok := phy.MACPayload.(*DataPayload) if !ok { panic("*DataPayload expected") } fmt.Println(phy.MIC) fmt.Println(pl.Bytes) fmt.Println(string(phyJSON))
Output: 01020304 [5 6 7 8 9 10] {"mhdr":{"mType":"Proprietary","major":"LoRaWANR1"},"macPayload":{"bytes":"BQYHCAkK"},"mic":"01020304"}
Example (ProprietaryEncode) ¶
phy := PHYPayload{ MHDR: MHDR{ MType: Proprietary, Major: LoRaWANR1, }, MACPayload: &DataPayload{Bytes: []byte{5, 6, 7, 8, 9, 10}}, MIC: MIC{1, 2, 3, 4}, } str, err := phy.MarshalText() if err != nil { panic(err) } bytes, err := phy.MarshalBinary() if err != nil { panic(err) } phyJSON, err := phy.MarshalJSON() if err != nil { panic(err) } fmt.Println(string(str)) fmt.Println(bytes) fmt.Println(string(phyJSON))
Output: 4AUGBwgJCgECAwQ= [224 5 6 7 8 9 10 1 2 3 4] {"mhdr":{"mType":"Proprietary","major":"LoRaWANR1"},"macPayload":{"bytes":"BQYHCAkK"},"mic":"01020304"}
Example (ReadJoinRequest) ¶
var phy PHYPayload if err := phy.UnmarshalText([]byte("AAQDAgEEAwIBBQQDAgUEAwItEGqZDhI=")); err != nil { panic(err) } jrPL, ok := phy.MACPayload.(*JoinRequestPayload) if !ok { panic("MACPayload must be a *JoinRequestPayload") } fmt.Println(phy.MHDR.MType) fmt.Println(jrPL.JoinEUI) fmt.Println(jrPL.DevEUI) fmt.Println(jrPL.DevNonce)
Output: JoinRequest 0102030401020304 0203040502030405 4141
func (*PHYPayload) DecodeFOptsToMACCommands ¶
func (p *PHYPayload) DecodeFOptsToMACCommands() error
DecodeFOptsToMACCommands decodes the (decrypted) FOpts bytes into MAC commands.
func (*PHYPayload) DecodeFRMPayloadToMACCommands ¶
func (p *PHYPayload) DecodeFRMPayloadToMACCommands() error
DecodeFRMPayloadToMACCommands decodes the (decrypted) FRMPayload bytes into MAC commands. Note that after calling DecryptFRMPayload, this method is called automatically when FPort=0.
func (*PHYPayload) DecryptFOpts ¶
func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error
DecryptFOpts decrypts the FOpts payload and decodes it into mac-command structures.
func (*PHYPayload) DecryptFRMPayload ¶
func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error
DecryptFRMPayload decrypts the FRMPayload with the given key.
func (*PHYPayload) DecryptJoinAcceptPayload ¶
func (p *PHYPayload) DecryptJoinAcceptPayload(key AES128Key) error
DecryptJoinAcceptPayload decrypts the join-accept payload with the given key. Note that you need to decrypte before you can validate the MIC.
Note: for encrypting a join-request response, use NwkKey
for rejoin-request 0, 1, 2 response, use JSEncKey
func (*PHYPayload) EncryptFOpts ¶
func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error
EncryptFOpts encrypts the FOpts with the given key.
func (*PHYPayload) EncryptFRMPayload ¶
func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error
EncryptFRMPayload encrypts the FRMPayload with the given key.
func (*PHYPayload) EncryptJoinAcceptPayload ¶
func (p *PHYPayload) EncryptJoinAcceptPayload(key AES128Key) error
EncryptJoinAcceptPayload encrypts the join-accept payload with the given key. Note that encrypted must be performed after calling SetMIC (since the MIC is part of the encrypted payload).
Note: for encrypting a join-request response, use NwkKey
for rejoin-request 0, 1, 2 response, use JSEncKey
func (PHYPayload) MarshalBinary ¶
func (p PHYPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (PHYPayload) MarshalJSON ¶
func (p PHYPayload) MarshalJSON() ([]byte, error)
MarshalJSON encodes the PHYPayload into JSON.
func (PHYPayload) MarshalText ¶
func (p PHYPayload) MarshalText() ([]byte, error)
MarshalText encodes the PHYPayload into base64.
func (*PHYPayload) SetDownlinkDataMIC ¶
func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error
SetDownlinkDataMIC calculates and sets the MIC field for downlink data frames. The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be left blank otherwise.
func (*PHYPayload) SetDownlinkJoinMIC ¶
func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error
SetDownlinkJoinMIC calculates and sets the MIC field for downlink join requests.
func (*PHYPayload) SetUplinkDataMIC ¶
func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) error
SetUplinkDataMIC calculates and sets the MIC field for uplink data frames. The confirmed frame-counter, TX data-rate TX channel index and SNwkSIntKey are only required for LoRaWAN 1.1 and can be left blank otherwise.
func (*PHYPayload) SetUplinkJoinMIC ¶
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error
SetUplinkJoinMIC calculates and sets the MIC field for uplink join requests.
func (*PHYPayload) UnmarshalBinary ¶
func (p *PHYPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
func (*PHYPayload) UnmarshalText ¶
func (p *PHYPayload) UnmarshalText(text []byte) error
UnmarshalText decodes the PHYPayload from base64.
func (PHYPayload) ValidateDownlinkDataMIC ¶
func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error)
ValidateDownlinkDataMIC validates the MIC of a downlink data frame. In order to validate the MIC, the FCnt value must first be set to the full 32 bit frame-counter value, as only the 16 least-significant bits are transmitted. The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be left blank otherwise.
func (PHYPayload) ValidateDownlinkJoinMIC ¶
func (p PHYPayload) ValidateDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) (bool, error)
ValidateDownlinkJoinMIC validates the MIC of a downlink join request.
func (PHYPayload) ValidateUplinkDataMIC ¶
func (p PHYPayload) ValidateUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) (bool, error)
ValidateUplinkDataMIC validates the MIC of an uplink data frame. In order to validate the MIC, the FCnt value must first be set to the full 32 bit frame-counter value, as only the 16 least-significant bits are transmitted. The confirmed frame-counter, TX data-rate TX channel index and SNwkSIntKey are only required for LoRaWAN 1.1 and can be left blank otherwise.
func (PHYPayload) ValidateUplinkDataMICF ¶
func (p PHYPayload) ValidateUplinkDataMICF(fNwkSIntKey AES128Key) (bool, error)
ValidateUplinkDataMICF validates the cmacF part of the uplink data MIC (LoRaWAN 1.1 only). In order to validate the MIC, the FCnt value must first be set to the full 32 bit frame-counter value, as only the 16 least-significant bits are transmitted.
func (PHYPayload) ValidateUplinkJoinMIC ¶
func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error)
ValidateUplinkJoinMIC validates the MIC of an uplink join request.
type Payload ¶
type Payload interface { MarshalBinary() (data []byte, err error) UnmarshalBinary(uplink bool, data []byte) error }
Payload is the interface that every payload needs to implement. Since it might be a MACPayload, an indication must be given if the direction is uplink or downlink (it has different payloads for the same CID, based on direction).
type PingSlotChannelAnsPayload ¶
type PingSlotChannelAnsPayload struct { DataRateOK bool `json:"dataRateOK"` ChannelFrequencyOK bool `json:"channelFrequencyOK"` }
PingSlotChannelAnsPayload represents the PingSlotChannelAns payload.
func (PingSlotChannelAnsPayload) MarshalBinary ¶
func (p PingSlotChannelAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*PingSlotChannelAnsPayload) UnmarshalBinary ¶
func (p *PingSlotChannelAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type PingSlotChannelReqPayload ¶
PingSlotChannelReqPayload represents the PingSlotChannelReq payload.
func (PingSlotChannelReqPayload) MarshalBinary ¶
func (p PingSlotChannelReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*PingSlotChannelReqPayload) UnmarshalBinary ¶
func (p *PingSlotChannelReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type PingSlotInfoReqPayload ¶
type PingSlotInfoReqPayload struct {
Periodicity uint8 `json:"periodicity"`
}
PingSlotInfoReqPayload represents the PingSlotInfoReq payload.
func (PingSlotInfoReqPayload) MarshalBinary ¶
func (p PingSlotInfoReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*PingSlotInfoReqPayload) UnmarshalBinary ¶
func (p *PingSlotInfoReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type ProprietaryMACCommandPayload ¶
type ProprietaryMACCommandPayload struct {
Bytes []byte `json:"bytes"`
}
ProprietaryMACCommandPayload represents a proprietary payload.
func (ProprietaryMACCommandPayload) MarshalBinary ¶
func (p ProprietaryMACCommandPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object into a slice of bytes.
func (*ProprietaryMACCommandPayload) UnmarshalBinary ¶
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from a slice of bytes.
type RXParamSetupAnsPayload ¶
type RXParamSetupAnsPayload struct { ChannelACK bool `json:"channelAck"` RX2DataRateACK bool `json:"rx2DataRateAck"` RX1DROffsetACK bool `json:"rx1DROffsetAck"` }
RXParamSetupAnsPayload represents the RXParamSetupAns payload.
func (RXParamSetupAnsPayload) MarshalBinary ¶
func (p RXParamSetupAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*RXParamSetupAnsPayload) UnmarshalBinary ¶
func (p *RXParamSetupAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type RXParamSetupReqPayload ¶
type RXParamSetupReqPayload struct { Frequency uint32 `json:"frequency"` DLSettings DLSettings `json:"dlSettings"` }
RXParamSetupReqPayload represents the RXParamSetupReq payload.
func (RXParamSetupReqPayload) MarshalBinary ¶
func (p RXParamSetupReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*RXParamSetupReqPayload) UnmarshalBinary ¶
func (p *RXParamSetupReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type RXTimingSetupReqPayload ¶
type RXTimingSetupReqPayload struct {
Delay uint8 `json:"delay"` // 0=1s, 1=1s, 2=2s, ... 15=15s
}
RXTimingSetupReqPayload represents the RXTimingSetupReq payload.
func (RXTimingSetupReqPayload) MarshalBinary ¶
func (p RXTimingSetupReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*RXTimingSetupReqPayload) UnmarshalBinary ¶
func (p *RXTimingSetupReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type Redundancy ¶
Redundancy represents the redundancy field.
func (Redundancy) MarshalBinary ¶
func (r Redundancy) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*Redundancy) UnmarshalBinary ¶
func (r *Redundancy) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type RejoinParamSetupAnsPayload ¶
type RejoinParamSetupAnsPayload struct {
TimeOK bool `json:"timeOK"`
}
RejoinParamSetupAnsPayload represents the RejoinParamSetupAns payload.
func (RejoinParamSetupAnsPayload) MarshalBinary ¶
func (p RejoinParamSetupAnsPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*RejoinParamSetupAnsPayload) UnmarshalBinary ¶
func (p *RejoinParamSetupAnsPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type RejoinParamSetupReqPayload ¶
type RejoinParamSetupReqPayload struct { MaxTimeN uint8 `json:"maxTimeN"` MaxCountN uint8 `json:"maxCountN"` }
RejoinParamSetupReqPayload represents the RejoinParamSetupReq payload.
func (RejoinParamSetupReqPayload) MarshalBinary ¶
func (p RejoinParamSetupReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*RejoinParamSetupReqPayload) UnmarshalBinary ¶
func (p *RejoinParamSetupReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type RejoinRequestType02Payload ¶
type RejoinRequestType02Payload struct { RejoinType JoinType `json:"rejoinType"` NetID NetID `json:"netID"` DevEUI EUI64 `json:"devEUI"` RJCount0 uint16 `json:"rjCount0"` }
RejoinRequestType02Payload represents a rejoin-request of type 0 or 2.
func (RejoinRequestType02Payload) MarshalBinary ¶
func (p RejoinRequestType02Payload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*RejoinRequestType02Payload) UnmarshalBinary ¶
func (p *RejoinRequestType02Payload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type RejoinRequestType1Payload ¶
type RejoinRequestType1Payload struct { RejoinType JoinType `json:"rejoinRequest"` JoinEUI EUI64 `json:"joinEUI"` DevEUI EUI64 `json:"devEUI"` RJCount1 uint16 `json:"rjCount1"` }
RejoinRequestType1Payload represents a rejoin-request of type 1.
func (RejoinRequestType1Payload) MarshalBinary ¶
func (p RejoinRequestType1Payload) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*RejoinRequestType1Payload) UnmarshalBinary ¶
func (p *RejoinRequestType1Payload) UnmarshalBinary(uplink bool, data []byte) error
UnmarshalBinary decodes the object from binary form.
type RekeyConfPayload ¶
type RekeyConfPayload struct {
ServLoRaWANVersion Version `json:"servLoRaWANVersion"`
}
RekeyConfPayload represents the RekeyConf payload.
func (RekeyConfPayload) MarshalBinary ¶
func (p RekeyConfPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*RekeyConfPayload) UnmarshalBinary ¶
func (p *RekeyConfPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type RekeyIndPayload ¶
type RekeyIndPayload struct {
DevLoRaWANVersion Version `json:"devLoRaWANVersion"`
}
RekeyIndPayload represents the RekeyInd payload.
func (RekeyIndPayload) MarshalBinary ¶
func (p RekeyIndPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*RekeyIndPayload) UnmarshalBinary ¶
func (p *RekeyIndPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type ResetConfPayload ¶
type ResetConfPayload struct {
ServLoRaWANVersion Version `json:"servLoRaWANVersion"`
}
ResetConfPayload represents the ResetConf payload.
func (ResetConfPayload) MarshalBinary ¶
func (p ResetConfPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*ResetConfPayload) UnmarshalBinary ¶
func (p *ResetConfPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type ResetIndPayload ¶
type ResetIndPayload struct {
DevLoRaWANVersion Version `json:"devLoRaWANVersion"`
}
ResetIndPayload represents the ResetInd payload.
func (ResetIndPayload) MarshalBinary ¶
func (p ResetIndPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into bytes.
func (*ResetIndPayload) UnmarshalBinary ¶
func (p *ResetIndPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type TXParamSetupReqPayload ¶
type TXParamSetupReqPayload struct { DownlinkDwelltime DwellTime `json:"downlinkDwellTime"` UplinkDwellTime DwellTime `json:"uplinkDwellTime"` MaxEIRP uint8 `json:"maxEIRPCoded"` }
TXParamSetupReqPayload represents the TXParamSetupReq payload. Note that the MaxEIRP holds the coded index value, not the actual EIRP. To translate from the actual EIRP to the coded index value, use the GetTXParamSetupEIRPIndex function. To translate a coded index value back to the actual EIRP, use the GetTXParamSetupEIRP function.
func (TXParamSetupReqPayload) MarshalBinary ¶
func (p TXParamSetupReqPayload) MarshalBinary() ([]byte, error)
MarshalBinary encodes the object into a bytes.
func (*TXParamSetupReqPayload) UnmarshalBinary ¶
func (p *TXParamSetupReqPayload) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from bytes.
type Version ¶
type Version struct {
Minor uint8 `json:"minor"`
}
Version defines LoRaWAN version field.
func (Version) MarshalBinary ¶
MarshalBinary encodes the object into bytes.
func (*Version) UnmarshalBinary ¶
UnmarshalBinary decodes the object from bytes.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package airtime provides a function for calculating the time on air.
|
Package airtime provides a function for calculating the time on air. |
applayer
|
|
clocksync
Package clocksync implements the Application Layer Clock Synchronization v1.0.0 over LoRaWAN.
|
Package clocksync implements the Application Layer Clock Synchronization v1.0.0 over LoRaWAN. |
firmwaremanagement
Package firmwaremanagement implements the Firmware Management Protocol v1.0.0 over LoRaWAN.
|
Package firmwaremanagement implements the Firmware Management Protocol v1.0.0 over LoRaWAN. |
fragmentation
Package fragmentation implements the Fragmented Data Block Transport v1.0.0 over LoRaWAN.
|
Package fragmentation implements the Fragmented Data Block Transport v1.0.0 over LoRaWAN. |
multicastsetup
Package multicastsetup implements the Remote Multicast Setup v1.0.0 over LoRaWAN.
|
Package multicastsetup implements the Remote Multicast Setup v1.0.0 over LoRaWAN. |
Package backend provides the LoRaWAN backend interfaces structs.
|
Package backend provides the LoRaWAN backend interfaces structs. |
joinserver
Package joinserver provides a http.Handler interface which implements the join-server API as speficied by the LoRaWAN Backend Interfaces.
|
Package joinserver provides a http.Handler interface which implements the join-server API as speficied by the LoRaWAN Backend Interfaces. |
Package band provides band specific defaults and configuration for downlink communication with end-devices.
|
Package band provides band specific defaults and configuration for downlink communication with end-devices. |
Package gps provides functions to handle Time <> GPS Epoch time conversion.
|
Package gps provides functions to handle Time <> GPS Epoch time conversion. |
Package sensitivity provides functions for calculating the LoRa sensitivity.
|
Package sensitivity provides functions for calculating the LoRa sensitivity. |