mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 21:23:58 +00:00
lorawan: set devNonce to new random value on each attempt to join
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -21,6 +21,10 @@ type Otaa struct {
|
|||||||
func (o *Otaa) Init() {
|
func (o *Otaa) Init() {
|
||||||
o.buf = make([]uint8, 0)
|
o.buf = make([]uint8, 0)
|
||||||
|
|
||||||
|
o.generateDevNonce()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Otaa) generateDevNonce() {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
rnd, _ := GetRand16()
|
rnd, _ := GetRand16()
|
||||||
o.devNonce[0] = rnd[0]
|
o.devNonce[0] = rnd[0]
|
||||||
@@ -95,6 +99,8 @@ func (o *Otaa) SetNetID(netID []uint8) error {
|
|||||||
|
|
||||||
// GenerateJoinRequest Generates a LoraWAN Join request
|
// GenerateJoinRequest Generates a LoraWAN Join request
|
||||||
func (o *Otaa) GenerateJoinRequest() ([]uint8, error) {
|
func (o *Otaa) GenerateJoinRequest() ([]uint8, error) {
|
||||||
|
o.generateDevNonce()
|
||||||
|
|
||||||
// TODO: Add checks
|
// TODO: Add checks
|
||||||
o.buf = o.buf[:0]
|
o.buf = o.buf[:0]
|
||||||
o.buf = append(o.buf, 0x00)
|
o.buf = append(o.buf, 0x00)
|
||||||
|
|||||||
Reference in New Issue
Block a user