feat: add protocol prefixes to log messages
Prefix log output with 'ant:', 'bt:', or 'usb:' to distinguish between ANT+, Bluetooth LE, and USB device messages.
This commit is contained in:
+3
-3
@@ -41,7 +41,7 @@ func ListenForTrainer(vendorId uint16, productId uint16, deviceNumber uint32,
|
|||||||
}
|
}
|
||||||
defer drv.Close()
|
defer drv.Close()
|
||||||
|
|
||||||
logMsg("device opened")
|
logMsg("ant: device opened")
|
||||||
|
|
||||||
if err := resetAndWait(drv); err != nil {
|
if err := resetAndWait(drv); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -49,12 +49,12 @@ func ListenForTrainer(vendorId uint16, productId uint16, deviceNumber uint32,
|
|||||||
if err := device.StartRxScanModeWait(drv); err != nil {
|
if err := device.StartRxScanModeWait(drv); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
logMsg("scan mode started")
|
logMsg("ant: scan mode started")
|
||||||
|
|
||||||
msgs := make(chan ant.BroadcastMessage, 100)
|
msgs := make(chan ant.BroadcastMessage, 100)
|
||||||
go device.DumpBroadcastMessages(context.Background(), drv, msgs)
|
go device.DumpBroadcastMessages(context.Background(), drv, msgs)
|
||||||
|
|
||||||
logMsg("listening...")
|
logMsg("ant: listening...")
|
||||||
for msg := range msgs {
|
for msg := range msgs {
|
||||||
if msg.DeviceNumber() != deviceNumber {
|
if msg.DeviceNumber() != deviceNumber {
|
||||||
logPrintf("Received msg from ignored ant+ device %v\n", msg.DeviceNumber())
|
logPrintf("Received msg from ignored ant+ device %v\n", msg.DeviceNumber())
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func ExposeBluetooth(events <-chan Event) {
|
|||||||
ServiceUUIDs: []bluetooth.UUID{bluetooth.New16BitUUID(bleCyclingPowerServiceUUID)},
|
ServiceUUIDs: []bluetooth.UUID{bluetooth.New16BitUUID(bleCyclingPowerServiceUUID)},
|
||||||
}))
|
}))
|
||||||
must(adapter.DefaultAdvertisement().Start())
|
must(adapter.DefaultAdvertisement().Start())
|
||||||
logMsg("BLE advertising...")
|
logMsg("bt: BLE advertising...")
|
||||||
|
|
||||||
var totalRevs float64
|
var totalRevs float64
|
||||||
var lastCompletedRev float64 // time in 1/1024s of last completed revolution
|
var lastCompletedRev float64 // time in 1/1024s of last completed revolution
|
||||||
@@ -85,5 +85,5 @@ func ExposeBluetooth(events <-chan Event) {
|
|||||||
logPrintf("bt: watts: %d rpm: %.0f completedRevs: %.0f lastRevTime: %.0f processingTime: %v\n",
|
logPrintf("bt: watts: %d rpm: %.0f completedRevs: %.0f lastRevTime: %.0f processingTime: %v\n",
|
||||||
watts, rpm, completedRevs, lastCompletedRev, time.Now().Sub(now))
|
watts, rpm, completedRevs, lastCompletedRev, time.Now().Sub(now))
|
||||||
}
|
}
|
||||||
logMsg("BLE advertising stopped")
|
logMsg("bt: BLE advertising stopped")
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -62,15 +62,15 @@ This allows these trainers to be used with modern devices that don't support ANT
|
|||||||
c.deviceNumber = uint32(deviceNumber)
|
c.deviceNumber = uint32(deviceNumber)
|
||||||
|
|
||||||
logMsgf("ANT Bridge %s built %s", Version, BuildTime)
|
logMsgf("ANT Bridge %s built %s", Version, BuildTime)
|
||||||
logMsgf("vendor: 0x%04x/%d", vendorID, vendorID)
|
logMsgf("usb: vendor: 0x%04x/%d", vendorID, vendorID)
|
||||||
logMsgf("product: 0x%04x/%d", productID, productID)
|
logMsgf("usb: product: 0x%04x/%d", productID, productID)
|
||||||
logMsgf("device: 0x%03x/%d", deviceNumber, deviceNumber)
|
logMsgf("ant: device: 0x%03x/%d", deviceNumber, deviceNumber)
|
||||||
|
|
||||||
if err := exec.Command("hciconfig", "hci0", "down").Run(); err != nil {
|
if err := exec.Command("hciconfig", "hci0", "down").Run(); err != nil {
|
||||||
logPrintf("hciconfig down failed: %v\n", err)
|
logPrintf("bt: hciconfig down failed: %v\n", err)
|
||||||
}
|
}
|
||||||
if err := exec.Command("hciconfig", "hci0", "up").Run(); err != nil {
|
if err := exec.Command("hciconfig", "hci0", "up").Run(); err != nil {
|
||||||
logPrintf("hciconfig up failed: %v\n", err)
|
logPrintf("bt: hciconfig up failed: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events := make(chan Event, 1)
|
events := make(chan Event, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user