Skip to content

Commit

Permalink
examples: update MCU central examples to use ldflags to pass the desi…
Browse files Browse the repository at this point in the history
…red device to connect to

Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Jan 2, 2024
1 parent ec80e01 commit 8828f9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions examples/discover/mcu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import (
"time"
)

// replace this with the MAC address of the Bluetooth peripheral you want to connect to.
const deviceAddress = "E4:B7:F4:11:8D:33"
// DeviceAddress is the MAC address of the Bluetooth peripheral you want to connect to.
// Replace this by using -ldflags="-X main.DeviceAddress=[MAC ADDRESS]"
// where [MAC ADDRESS] is the actual MAC address of the peripheral.
// For example:
// tinygo flash -target circuitplay-bluefruit -ldflags="-X main.DeviceAddress=7B:36:98:8C:41:1C" ./examples/discover/
var DeviceAddress string

func connectAddress() string {
return deviceAddress
return DeviceAddress
}

// wait on baremetal, proceed immediately on desktop OS.
Expand Down
10 changes: 7 additions & 3 deletions examples/heartrate-monitor/mcu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import (
"time"
)

// replace this with the MAC address of the Bluetooth peripheral you want to connect to.
const deviceAddress = "E4:B7:F4:11:8D:33"
// DeviceAddress is the MAC address of the Bluetooth peripheral you want to connect to.
// Replace this by using -ldflags="-X main.DeviceAddress=[MAC ADDRESS]"
// where [MAC ADDRESS] is the actual MAC address of the peripheral.
// For example:
// tinygo flash -target circuitplay-bluefruit -ldflags="-X main.DeviceAddress=7B:36:98:8C:41:1C" ./examples/heartrate-monitor/
var DeviceAddress string

func connectAddress() string {
return deviceAddress
return DeviceAddress
}

// done just blocks forever, allows USB CDC reset for flashing new software.
Expand Down

0 comments on commit 8828f9b

Please sign in to comment.