mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-09 17:33:43 +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:
@@ -21,16 +21,16 @@ loraConnect: Connected !
|
||||
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"
|
||||
)
|
||||
|
||||
var debug string
|
||||
var (
|
||||
reg string
|
||||
debug string
|
||||
)
|
||||
|
||||
const (
|
||||
LORAWAN_JOIN_TIMEOUT_SEC = 180
|
||||
@@ -67,8 +70,16 @@ func main() {
|
||||
|
||||
// Connect the lorawan with the Lora Radio device.
|
||||
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())
|
||||
}
|
||||
|
||||
// Configure AppEUI, DevEUI, APPKey, and public/private Lorawan Network
|
||||
setLorawanKeys()
|
||||
|
||||
Reference in New Issue
Block a user