Open
Description
Using version 0.10.0, the following line:
fmt.Printf("Subscribing to notifications on characteristic %s...\n", targetChar.UUID.String())
causes the following error:
./fvFlightBar.go:76:87: targetChar.UUID.String undefined (type func() bluetooth.UUID has no field or method String)
Both the docs and the code seem to think there's a String() method but the compiler begs to differ.
For more context, here's more of the code:
// 6. Discover the characteristic within that service
chars, err := targetService.DiscoverCharacteristics([]bluetooth.UUID{charUUID})
if err != nil {
log.Fatalf("Failed to discover characteristics: %v", err)
}
if len(chars) == 0 {
log.Fatalf("Characteristic %s not found", charUUID.String())
}
targetChar := chars[0]
// 7. Subscribe to notifications on the found characteristic
fmt.Printf("Subscribing to notifications on characteristic %s...\n", targetChar.UUID.String())
err = targetChar.EnableNotifications(func(value []byte) {
// Convert received bytes to a hexadecimal string
hexData := hex.EncodeToString(value)
fmt.Printf("Notification data (hex): %s\n", hexData)
})
if err != nil {
log.Fatalf("Failed to subscribe to notifications: %v", err)
}
Metadata
Assignees
Labels
No labels
Activity