mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-21 06:59:00 +00:00
examples/lora/lorawan: modify atcmd and basic demo to support choosing
any one of the supported regions at compile time by using ldflags. Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -23,20 +23,20 @@ Builds/flashes atcmd console application with simulator instead of actual LoRa r
|
|||||||
tinygo flash -target pico ./examples/lora/lorawan/atcmd/
|
tinygo flash -target pico ./examples/lora/lorawan/atcmd/
|
||||||
```
|
```
|
||||||
|
|
||||||
## PyBadge with LoRa Featherwing
|
## PyBadge with LoRa Featherwing for EU868 region
|
||||||
|
|
||||||
Builds/flashes atcmd console application on PyBadge using LoRa Featherwing (RFM95/SX1276).
|
Builds/flashes atcmd console application on PyBadge using LoRa Featherwing (RFM95/SX1276).
|
||||||
|
|
||||||
```
|
```
|
||||||
tinygo flash -target pybadge -tags featherwing ./examples/lora/lorawan/atcmd/
|
tinygo flash -target pybadge -tags featherwing -ldflags="-X main.reg=EU868" ./examples/lora/lorawan/atcmd/
|
||||||
```
|
```
|
||||||
|
|
||||||
## LoRa-E5
|
## LoRa-E5 for US915 region
|
||||||
|
|
||||||
Builds/flashes atcmd console application on Lora-E5 using onboard SX126x.
|
Builds/flashes atcmd console application on Lora-E5 using onboard SX126x.
|
||||||
|
|
||||||
```
|
```
|
||||||
tinygo flash -target lorae5 ./examples/lora/lorawan/atcmd/
|
tinygo flash -target lorae5 -ldflags="-X main.reg=US915" ./examples/lora/lorawan/atcmd/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Joining a Public Lorawan Network
|
## Joining a Public Lorawan Network
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ var (
|
|||||||
defaultTimeout uint32 = 1000
|
defaultTimeout uint32 = 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var reg string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
uart.Configure(machine.UARTConfig{TX: tx, RX: rx})
|
uart.Configure(machine.UARTConfig{TX: tx, RX: rx})
|
||||||
|
|
||||||
@@ -45,7 +47,16 @@ func main() {
|
|||||||
otaa = &lorawan.Otaa{}
|
otaa = &lorawan.Otaa{}
|
||||||
lorawan.UseRadio(radio)
|
lorawan.UseRadio(radio)
|
||||||
|
|
||||||
lorawan.UseRegionSettings(region.EU868())
|
switch reg {
|
||||||
|
case "AU915":
|
||||||
|
lorawan.UseRegionSettings(region.AU915())
|
||||||
|
case "EU868":
|
||||||
|
lorawan.UseRegionSettings(region.EU868())
|
||||||
|
case "US915":
|
||||||
|
lorawan.UseRegionSettings(region.US915())
|
||||||
|
default:
|
||||||
|
lorawan.UseRegionSettings(region.EU868())
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if uart.Buffered() > 0 {
|
if uart.Buffered() > 0 {
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ loraConnect: Connected !
|
|||||||
tinygo flash -target pico ./examples/lora/lorawan/basic-demo
|
tinygo flash -target pico ./examples/lora/lorawan/basic-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
## PyBadge with LoRa Featherwing
|
## PyBadge with LoRa Featherwing for EU868 region
|
||||||
|
|
||||||
```
|
```
|
||||||
tinygo flash -target pybadge -tags featherwing ./examples/lora/lorawan/basic-demo
|
tinygo flash -target pybadge -tags featherwing -ldflags="-X main.reg=EU868" ./examples/lora/lorawan/basic-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
## LoRa-E5
|
## LoRa-E5 for US915 region
|
||||||
|
|
||||||
```
|
```
|
||||||
tinygo flash -target lorae5 ./examples/lora/lorawan/basic-demo
|
tinygo flash -target lorae5 -ldflags="-X main.reg=US915" ./examples/lora/lorawan/basic-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import (
|
|||||||
"tinygo.org/x/drivers/lora/lorawan/region"
|
"tinygo.org/x/drivers/lora/lorawan/region"
|
||||||
)
|
)
|
||||||
|
|
||||||
var debug string
|
var (
|
||||||
|
reg string
|
||||||
|
debug string
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LORAWAN_JOIN_TIMEOUT_SEC = 180
|
LORAWAN_JOIN_TIMEOUT_SEC = 180
|
||||||
@@ -67,8 +70,16 @@ func main() {
|
|||||||
|
|
||||||
// Connect the lorawan with the Lora Radio device.
|
// Connect the lorawan with the Lora Radio device.
|
||||||
lorawan.UseRadio(radio)
|
lorawan.UseRadio(radio)
|
||||||
|
switch reg {
|
||||||
lorawan.UseRegionSettings(region.EU868())
|
case "AU915":
|
||||||
|
lorawan.UseRegionSettings(region.AU915())
|
||||||
|
case "EU868":
|
||||||
|
lorawan.UseRegionSettings(region.EU868())
|
||||||
|
case "US915":
|
||||||
|
lorawan.UseRegionSettings(region.US915())
|
||||||
|
default:
|
||||||
|
lorawan.UseRegionSettings(region.EU868())
|
||||||
|
}
|
||||||
|
|
||||||
// Configure AppEUI, DevEUI, APPKey, and public/private Lorawan Network
|
// Configure AppEUI, DevEUI, APPKey, and public/private Lorawan Network
|
||||||
setLorawanKeys()
|
setLorawanKeys()
|
||||||
|
|||||||
Reference in New Issue
Block a user