mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 06:57:48 +00:00
fa0cf6ec7f
- Remove all default loraconf default initialisation in lorawan examples (Region Settings takes care of this now) - Remove retries while receiving JoinAccept and increase LoraRX to 10s (no need to wait more than 10s) - Add constants for RegionSetting default frequencies - Standardize all lora default configurations in lora examples - Add new AT+LW=NET,(ON|OFF) command in atcmd example
50 lines
859 B
Go
50 lines
859 B
Go
//go:build stm32wlx
|
|
|
|
package common
|
|
|
|
import (
|
|
"machine"
|
|
|
|
"tinygo.org/x/drivers/lora"
|
|
"tinygo.org/x/drivers/sx126x"
|
|
)
|
|
|
|
const (
|
|
FREQ = 868100000
|
|
LORA_DEFAULT_RXTIMEOUT_MS = 1000
|
|
LORA_DEFAULT_TXTIMEOUT_MS = 5000
|
|
)
|
|
|
|
var (
|
|
loraRadio *sx126x.Device
|
|
)
|
|
|
|
var spi = machine.SPI3
|
|
|
|
func newRadioControl() sx126x.RadioController {
|
|
return sx126x.NewRadioControl()
|
|
}
|
|
|
|
// do sx126x setup here
|
|
func SetupLora() (lora.Radio, error) {
|
|
loraRadio = sx126x.New(spi)
|
|
loraRadio.SetDeviceType(sx126x.DEVICE_TYPE_SX1262)
|
|
|
|
// Create radio controller for target
|
|
loraRadio.SetRadioController(newRadioControl())
|
|
|
|
if state := loraRadio.DetectDevice(); !state {
|
|
return nil, errRadioNotFound
|
|
}
|
|
|
|
return loraRadio, nil
|
|
}
|
|
|
|
func FirmwareVersion() string {
|
|
return "sx126x"
|
|
}
|
|
|
|
func Lorarx() ([]byte, error) {
|
|
return loraRadio.Rx(LORA_DEFAULT_RXTIMEOUT_MS)
|
|
}
|