lorawan

package
v0.0.0-...-0087ba1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LORA_TX_TIMEOUT = 2000
	LORA_RX_TIMEOUT = 10000
)
View Source
const (
	Size = aes.BlockSize
)

Variables

View Source
var (
	ErrNoJoinAcceptReceived    = errors.New("no JoinAccept packet received")
	ErrNoRadioAttached         = errors.New("no LoRa radio attached")
	ErrInvalidEuiLength        = errors.New("invalid EUI length")
	ErrInvalidAppKeyLength     = errors.New("invalid AppKey length")
	ErrInvalidPacketLength     = errors.New("invalid packet length")
	ErrInvalidDevAddrLength    = errors.New("invalid DevAddr length")
	ErrInvalidMic              = errors.New("invalid Mic")
	ErrFrmPayloadTooLarge      = errors.New("FRM payload too large")
	ErrInvalidNetIDLength      = errors.New("invalid NetID length")
	ErrInvalidNwkSKeyLength    = errors.New("invalid NwkSKey length")
	ErrInvalidAppSKeyLength    = errors.New("invalid AppSKey length")
	ErrUndefinedRegionSettings = errors.New("undefined Regionnal Settings ")
)
View Source
var (
	ActiveRadio lora.Radio
	Retries     = 15
)

Functions

func GetRand16

func GetRand16() ([2]uint8, error)

GetRand16 returns 2 random bytes

func Join

func Join(otaa *Otaa, session *Session) error

Join tries to connect Lorawan Gateway

func ListenDownlink() error

func Msb

func Msb(buf []byte) uint8

Msb returns the most significant bit of the supplied data (which must be non-empty). This is the MSB(L) function of RFC 4493.

func NewCmac

func NewCmac(key []byte) (hash.Hash, error)

New returns an AES-CMAC hash using the supplied key. The key must be 16, 24, or 32 bytes long.

func PadBlock

func PadBlock(block []byte) []byte
func SendUplink(data []uint8, session *Session) error

SendUplink sends Lorawan Uplink message

func SetPublicNetwork

func SetPublicNetwork(enabled bool)

SetPublicNetwork defines Lora Sync Word according to network type (public/private)

func ShiftLeft

func ShiftLeft(b []byte) []byte

func UseRadio

func UseRadio(r lora.Radio)

UseRadio attaches Lora radio driver to Lorawan

func UseRegionSettings

func UseRegionSettings(rs region.RegionSettings)

UseRegionSettings sets current Lorawan Regional parameters

func Xor

func Xor(dst []byte, a []byte, b []byte) error

Types

type Otaa

type Otaa struct {
	DevEUI [8]uint8
	AppEUI [8]uint8
	AppKey [16]uint8

	NetID [3]uint8
	// contains filtered or unexported fields
}

Otaa is used to store Over The Air Activation data of a LoRaWAN session

func (*Otaa) DecodeJoinAccept

func (o *Otaa) DecodeJoinAccept(phyPload []uint8, s *Session) error

DecodeJoinAccept Decodes a Lora Join Accept packet

func (*Otaa) GenerateJoinRequest

func (o *Otaa) GenerateJoinRequest() ([]uint8, error)

GenerateJoinRequest Generates a LoraWAN Join request

func (*Otaa) GetAppEUI

func (o *Otaa) GetAppEUI() string

func (*Otaa) GetAppKey

func (o *Otaa) GetAppKey() string

func (*Otaa) GetDevEUI

func (o *Otaa) GetDevEUI() string

func (*Otaa) GetNetID

func (o *Otaa) GetNetID() string

func (*Otaa) Init

func (o *Otaa) Init()

Initialize DevNonce

func (*Otaa) Set

func (o *Otaa) Set(appEUI []uint8, devEUI []uint8, appKey []uint8)

Set configures the Otaa AppEUI, DevEUI, AppKey for the device

func (*Otaa) SetAppEUI

func (o *Otaa) SetAppEUI(appEUI []uint8) error

SetAppEUI configures the Otaa AppEUI

func (*Otaa) SetAppKey

func (o *Otaa) SetAppKey(appKey []uint8) error

SetAppKey configures the Otaa AppKey

func (*Otaa) SetDevEUI

func (o *Otaa) SetDevEUI(devEUI []uint8) error

SetDevEUI configures the Otaa DevEUI

func (*Otaa) SetNetID

func (o *Otaa) SetNetID(netID []uint8) error

type Session

type Session struct {
	NwkSKey    [16]uint8
	AppSKey    [16]uint8
	DevAddr    [4]uint8
	FCntDown   uint32
	FCntUp     uint32
	CFList     [16]uint8
	RXDelay    uint8
	DLSettings uint8
}

Session is used to store session data of a LoRaWAN session

func (*Session) GenMessage

func (s *Session) GenMessage(dir uint8, payload []uint8) ([]uint8, error)

GenMessage generates an uplink message.

func (*Session) GetAppSKey

func (s *Session) GetAppSKey() string

GetAppSKey returns the Session AppSKey

func (*Session) GetDevAddr

func (s *Session) GetDevAddr() string

GetDevAddr returns the Session DevAddr

func (*Session) GetNwkSKey

func (s *Session) GetNwkSKey() string

GetNwkSKey returns the Session NwkSKey

func (*Session) SetAppSKey

func (s *Session) SetAppSKey(appSKey []uint8) error

SetAppSKey configures the Session AppSKey

func (*Session) SetDevAddr

func (s *Session) SetDevAddr(devAddr []uint8) error

SetDevAddr configures the Session DevAddr

func (*Session) SetNwkSKey

func (s *Session) SetNwkSKey(nwkSKey []uint8) error

SetNwkSKey configures the Session NwkSKey

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL