mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
examples: move atcmd into lorawan
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
errRadioNotFound = errors.New("radio not found")
|
||||
errRxTimeout = errors.New("radio RX timeout")
|
||||
)
|
||||
|
||||
type LoraRadio interface {
|
||||
Reset()
|
||||
Tx(pkt []uint8, timeoutMs uint32) error
|
||||
Rx(timeoutMs uint32) ([]uint8, error)
|
||||
SetFrequency(freq uint32)
|
||||
SetIqMode(mode uint8)
|
||||
SetCodingRate(cr uint8)
|
||||
SetBandwidth(bw uint8)
|
||||
SetCrc(enable bool)
|
||||
SetSpreadingFactor(sf uint8)
|
||||
}
|
||||
@@ -11,6 +11,9 @@ package main
|
||||
import (
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers/lora"
|
||||
"tinygo.org/x/drivers/lora/lorawan"
|
||||
)
|
||||
|
||||
// change these to test a different UART or pins if available
|
||||
@@ -20,7 +23,10 @@ var (
|
||||
rx = machine.UART_RX_PIN
|
||||
input = make([]byte, 0, 64)
|
||||
|
||||
radio LoraRadio
|
||||
radio lora.Radio
|
||||
session *lorawan.Session
|
||||
otaa *lorawan.Otaa
|
||||
|
||||
defaultTimeout uint32 = 1000
|
||||
)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
errRadioNotFound = errors.New("radio not found")
|
||||
errRxTimeout = errors.New("radio RX timeout")
|
||||
)
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
import "tinygo.org/x/drivers/lora"
|
||||
|
||||
// do simulator setup here
|
||||
func setupLora() (LoraRadio, error) {
|
||||
func setupLora() (lora.Radio, error) {
|
||||
return &SimLoraRadio{}, nil
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ var (
|
||||
)
|
||||
|
||||
// do sx126x setup here
|
||||
func setupLora() (LoraRadio, error) {
|
||||
func setupLora() (lora.Radio, error) {
|
||||
loraRadio = sx126x.New(machine.SPI3)
|
||||
loraRadio.SetDeviceType(sx126x.DEVICE_TYPE_SX1262)
|
||||
|
||||
@@ -28,7 +28,7 @@ var (
|
||||
)
|
||||
|
||||
// do sx127x setup here
|
||||
func setupLora() (LoraRadio, error) {
|
||||
func setupLora() (lora.Radio, error) {
|
||||
rstPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
csPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
dio0Pin.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
|
||||
Reference in New Issue
Block a user