mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-15 04:13:40 +00:00
lorawan/basic-demo: add debug logs at compile time with ldflags
This commit is contained in:
committed by
Ron Evans
parent
7cc32dffed
commit
d473b9e1dc
@@ -33,3 +33,12 @@ tinygo flash -target pybadge -tags featherwing ./examples/lora/lorawan/basic-dem
|
|||||||
tinygo flash -target lorae5 ./examples/lora/lorawan/basic-demo
|
tinygo flash -target lorae5 ./examples/lora/lorawan/basic-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Enable debugging
|
||||||
|
|
||||||
|
You can also enable some debug logs with ldflags :
|
||||||
|
|
||||||
|
```
|
||||||
|
$ tinygo build -ldflags="-X 'main.debug=true'" -target=lorae5
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ import (
|
|||||||
"tinygo.org/x/drivers/lora/lorawan/region"
|
"tinygo.org/x/drivers/lora/lorawan/region"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var debug string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
debug = true
|
|
||||||
LORAWAN_JOIN_TIMEOUT_SEC = 180
|
LORAWAN_JOIN_TIMEOUT_SEC = 180
|
||||||
LORAWAN_RECONNECT_DELAY_SEC = 15
|
LORAWAN_RECONNECT_DELAY_SEC = 15
|
||||||
LORAWAN_UPLINK_DELAY_SEC = 60
|
LORAWAN_UPLINK_DELAY_SEC = 60
|
||||||
@@ -88,7 +89,7 @@ func main() {
|
|||||||
// Configure AppEUI, DevEUI, APPKey
|
// Configure AppEUI, DevEUI, APPKey
|
||||||
setLorawanKeys()
|
setLorawanKeys()
|
||||||
|
|
||||||
if debug {
|
if debug != "" {
|
||||||
println("main: Network joined")
|
println("main: Network joined")
|
||||||
println("main: DevEui, " + otaa.GetDevEUI())
|
println("main: DevEui, " + otaa.GetDevEUI())
|
||||||
println("main: AppEui, " + otaa.GetAppEUI())
|
println("main: AppEui, " + otaa.GetAppEUI())
|
||||||
@@ -100,7 +101,7 @@ func main() {
|
|||||||
failMessage(err)
|
failMessage(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if debug {
|
if debug != "" {
|
||||||
println("main: NetID, " + otaa.GetNetID())
|
println("main: NetID, " + otaa.GetNetID())
|
||||||
println("main: NwkSKey, " + session.GetNwkSKey())
|
println("main: NwkSKey, " + session.GetNwkSKey())
|
||||||
println("main: AppSKey, " + session.GetAppSKey())
|
println("main: AppSKey, " + session.GetAppSKey())
|
||||||
|
|||||||
Reference in New Issue
Block a user