Compare commits

..

No commits in common. "2def4b13ace19df30a3eef332ac01f3a4189887d" and "bebd1017c5322715dadf3cd95950832d7fba01ca" have entirely different histories.

4 changed files with 0 additions and 58 deletions

View File

@ -73,7 +73,6 @@ func (a *Agent) RequestPasskey(device dbus.ObjectPath) (uint32, *dbus.Error) {
if a.ReqPasskey == nil { if a.ReqPasskey == nil {
return 0, errAuthFailed return 0, errAuthFailed
} }
log.Debug().Msg("Passkey requested, calling onReqPasskey callback")
passkey, err := a.ReqPasskey() passkey, err := a.ReqPasskey()
if err != nil { if err != nil {
return 0, errAuthFailed return 0, errAuthFailed

10
dfu.go
View File

@ -313,7 +313,6 @@ func (dfu *DFU) Reset() {
// on waits for the given command to be received on // on waits for the given command to be received on
// the control point characteristic, then runs the callback. // the control point characteristic, then runs the callback.
func (dfu *DFU) on(cmd []byte, onCmdCb func(data []byte) error) error { func (dfu *DFU) on(cmd []byte, onCmdCb func(data []byte) error) error {
log.Debug().Hex("expecting", cmd).Msg("Waiting for command")
// Use for loop in case of invalid property // Use for loop in case of invalid property
for { for {
select { select {
@ -325,10 +324,6 @@ func (dfu *DFU) on(cmd []byte, onCmdCb func(data []byte) error) error {
} }
// Assert propery value as byte slice // Assert propery value as byte slice
data := propChanged.Value.([]byte) data := propChanged.Value.([]byte)
log.Debug().
Hex("expecting", cmd).
Hex("received", data).
Msg("Received command")
// If command has prefix of given command // If command has prefix of given command
if bytes.HasPrefix(data, cmd) { if bytes.HasPrefix(data, cmd) {
// Return callback with data after command // Return callback with data after command
@ -413,7 +408,6 @@ func (dfu *DFU) stepSeven() error {
if err != nil { if err != nil {
return err return err
} }
log.Debug().Msg("Sent firmware image segment")
// Increment bytes sent by amount read // Increment bytes sent by amount read
dfu.bytesSent += len(segment) dfu.bytesSent += len(segment)
} }
@ -421,10 +415,6 @@ func (dfu *DFU) stepSeven() error {
err := dfu.on(DFUNotifPktRecvd, func(data []byte) error { err := dfu.on(DFUNotifPktRecvd, func(data []byte) error {
// Set bytes received to data returned by InfiniTime // Set bytes received to data returned by InfiniTime
dfu.bytesRecvd = int(binary.LittleEndian.Uint32(data)) dfu.bytesRecvd = int(binary.LittleEndian.Uint32(data))
log.Debug().
Int("sent", dfu.bytesSent).
Int("rcvd", dfu.bytesRecvd).
Msg("Received packet receipt notification")
if dfu.bytesRecvd != dfu.bytesSent { if dfu.bytesRecvd != dfu.bytesSent {
return ErrDFUSizeMismatch return ErrDFUSizeMismatch
} }

View File

@ -18,11 +18,6 @@ import (
"go.arsenm.dev/infinitime/blefs" "go.arsenm.dev/infinitime/blefs"
) )
// This global is used to store the logger.
// log.Logger is not used as it would interfere
// with the package importing the library
var log zerolog.Logger
const BTName = "InfiniTime" const BTName = "InfiniTime"
const ( const (
@ -95,8 +90,6 @@ func Connect(opts *Options) (*Device, error) {
opts = DefaultOptions opts = DefaultOptions
} }
log = opts.Logger.Level(opts.LogLevel)
// Set passkey request callback // Set passkey request callback
setOnPasskeyReq(opts.OnReqPasskey) setOnPasskeyReq(opts.OnReqPasskey)
@ -136,25 +129,16 @@ func connect(opts *Options, first bool) (dev *device.Device1, err error) {
// device, skip // device, skip
if opts.WhitelistEnabled && if opts.WhitelistEnabled &&
!contains(opts.Whitelist, listDev.Properties.Address) { !contains(opts.Whitelist, listDev.Properties.Address) {
log.Debug().
Str("mac", listDev.Properties.Address).
Msg("InfiniTime device skipped as it is not in whitelist")
continue continue
} }
// Set device // Set device
dev = listDev dev = listDev
log.Debug().
Str("mac", dev.Properties.Address).
Msg("InfiniTime device found in list")
break break
} }
// If device not set // If device not set
if dev == nil { if dev == nil {
log.Debug().Msg("No device found in list, attempting to discover")
// Discover devices on adapter // Discover devices on adapter
discoverCh, cancel, err := bt.Discover(defaultAdapter, &adapter.DiscoveryFilter{Transport: "le"}) discoverCh, cancel, err := bt.Discover(defaultAdapter, &adapter.DiscoveryFilter{Transport: "le"})
if err != nil { if err != nil {
@ -182,18 +166,11 @@ func connect(opts *Options, first bool) (dev *device.Device1, err error) {
// device, skip // device, skip
if opts.WhitelistEnabled && if opts.WhitelistEnabled &&
!contains(opts.Whitelist, discovered.Properties.Address) { !contains(opts.Whitelist, discovered.Properties.Address) {
log.Debug().
Str("mac", discovered.Properties.Address).
Msg("Discovered InfiniTime device skipped as it is not in whitelist")
continue continue
} }
// Set device // Set device
dev = discovered dev = discovered
log.Debug().
Str("mac", dev.Properties.Address).
Msg("InfiniTime device discovered")
break break
} }
// Stop discovery // Stop discovery
@ -210,7 +187,6 @@ func connect(opts *Options, first bool) (dev *device.Device1, err error) {
reconnRequired := false reconnRequired := false
// If device is not connected // If device is not connected
if !dev.Properties.Connected { if !dev.Properties.Connected {
log.Debug().Msg("Device not connected, connecting")
// Connect to device // Connect to device
err = dev.Connect() err = dev.Connect()
if err != nil { if err != nil {
@ -222,7 +198,6 @@ func connect(opts *Options, first bool) (dev *device.Device1, err error) {
// If device is not paired // If device is not paired
if !dev.Properties.Paired { if !dev.Properties.Paired {
log.Debug().Msg("Device not paired, pairing")
// Pair device // Pair device
err = dev.Pair() err = dev.Pair()
if err != nil { if err != nil {
@ -240,7 +215,6 @@ func connect(opts *Options, first bool) (dev *device.Device1, err error) {
// was required, and the OnReconnect callback exists, // was required, and the OnReconnect callback exists,
// run it // run it
if !first && reconnRequired && opts.OnReconnect != nil { if !first && reconnRequired && opts.OnReconnect != nil {
log.Debug().Msg("Reconnected to device, running OnReconnect callback")
opts.OnReconnect() opts.OnReconnect()
} }
@ -362,7 +336,6 @@ func (i *Device) resolveChars() error {
} }
// For every discovered characteristics // For every discovered characteristics
for _, char := range chars { for _, char := range chars {
charResolved := true
// Set correct characteristics // Set correct characteristics
switch char.Properties.UUID { switch char.Properties.UUID {
case NewAlertChar: case NewAlertChar:
@ -401,13 +374,6 @@ func (i *Device) resolveChars() error {
i.fsVersionChar = char i.fsVersionChar = char
case WeatherDataChar: case WeatherDataChar:
i.weatherDataChar = char i.weatherDataChar = char
default:
charResolved = false
}
if charResolved {
log.Debug().
Str("uuid", char.Properties.UUID).
Msg("Resolved characteristic")
} }
} }
return nil return nil
@ -510,7 +476,6 @@ func (i *Device) WatchHeartRate() (<-chan uint8, func(), error) {
for { for {
select { select {
case <-done: case <-done:
log.Debug().Str("func", "WatchMotion").Msg("Received done signal")
close(out) close(out)
close(done) close(done)
i.heartRateChar.StopNotify() i.heartRateChar.StopNotify()
@ -521,7 +486,6 @@ func (i *Device) WatchHeartRate() (<-chan uint8, func(), error) {
// Send heart rate to channel // Send heart rate to channel
out <- uint8(event.Value.([]byte)[1]) out <- uint8(event.Value.([]byte)[1])
} else if event.Name == "Notifying" && !event.Value.(bool) { } else if event.Name == "Notifying" && !event.Value.(bool) {
log.Debug().Str("func", "WatchMotion").Msg("Notifications stopped, restarting")
i.heartRateChar.StartNotify() i.heartRateChar.StartNotify()
} }
} }
@ -556,7 +520,6 @@ func (i *Device) WatchBatteryLevel() (<-chan uint8, func(), error) {
for { for {
select { select {
case <-done: case <-done:
log.Debug().Str("func", "WatchMotion").Msg("Received done signal")
close(out) close(out)
close(done) close(done)
i.battLevelChar.StopNotify() i.battLevelChar.StopNotify()
@ -567,7 +530,6 @@ func (i *Device) WatchBatteryLevel() (<-chan uint8, func(), error) {
// Send heart rate to channel // Send heart rate to channel
out <- uint8(event.Value.([]byte)[0]) out <- uint8(event.Value.([]byte)[0])
} else if event.Name == "Notifying" && !event.Value.(bool) { } else if event.Name == "Notifying" && !event.Value.(bool) {
log.Debug().Str("func", "WatchMotion").Msg("Notifications stopped, restarting")
i.battLevelChar.StartNotify() i.battLevelChar.StartNotify()
} }
} }
@ -602,7 +564,6 @@ func (i *Device) WatchStepCount() (<-chan uint32, func(), error) {
for { for {
select { select {
case <-done: case <-done:
log.Debug().Str("func", "WatchMotion").Msg("Received done signal")
close(out) close(out)
close(done) close(done)
i.stepCountChar.StopNotify() i.stepCountChar.StopNotify()
@ -613,7 +574,6 @@ func (i *Device) WatchStepCount() (<-chan uint32, func(), error) {
// Send step count to channel // Send step count to channel
out <- binary.LittleEndian.Uint32(event.Value.([]byte)) out <- binary.LittleEndian.Uint32(event.Value.([]byte))
} else if event.Name == "Notifying" && !event.Value.(bool) { } else if event.Name == "Notifying" && !event.Value.(bool) {
log.Debug().Str("func", "WatchMotion").Msg("Notifications stopped, restarting")
i.stepCountChar.StartNotify() i.stepCountChar.StartNotify()
} }
} }
@ -648,7 +608,6 @@ func (i *Device) WatchMotion() (<-chan MotionValues, func(), error) {
for { for {
select { select {
case <-done: case <-done:
log.Debug().Str("func", "WatchMotion").Msg("Received done signal")
close(out) close(out)
close(done) close(done)
i.motionValChar.StopNotify() i.motionValChar.StopNotify()
@ -661,7 +620,6 @@ func (i *Device) WatchMotion() (<-chan MotionValues, func(), error) {
// Send step count to channel // Send step count to channel
out <- motionVals out <- motionVals
} else if event.Name == "Notifying" && !event.Value.(bool) { } else if event.Name == "Notifying" && !event.Value.(bool) {
log.Debug().Str("func", "WatchMotion").Msg("Notifications stopped, restarting")
i.motionValChar.StartNotify() i.motionValChar.StartNotify()
} }
} }
@ -798,13 +756,11 @@ func (i *Device) AddWeatherEvent(event interface{}) error {
return err return err
} }
log.Debug().Interface("event", event).Msg("Adding weather event")
// Write data to weather data characteristic // Write data to weather data characteristic
return i.weatherDataChar.WriteValue(data, nil) return i.weatherDataChar.WriteValue(data, nil)
} }
func (i *Device) checkStatus(char *gatt.GattCharacteristic1) error { func (i *Device) checkStatus(char *gatt.GattCharacteristic1) error {
log.Debug().Msg("Checking characteristic status")
connected, err := i.device.GetConnected() connected, err := i.device.GetConnected()
if err != nil { if err != nil {
return err return err
@ -813,9 +769,7 @@ func (i *Device) checkStatus(char *gatt.GattCharacteristic1) error {
return ErrNotConnected return ErrNotConnected
} }
if char == nil { if char == nil {
log.Debug().Msg("Characteristic not available (nil)")
return ErrCharNotAvail return ErrCharNotAvail
} }
log.Debug().Str("uuid", char.Properties.UUID).Msg("Characteristic available")
return nil return nil
} }

View File

@ -72,7 +72,6 @@ func (mc MusicCtrl) WatchEvents() (<-chan MusicEvent, error) {
for event := range ch { for event := range ch {
// If value changes // If value changes
if event.Name == "Value" { if event.Name == "Value" {
log.Debug().Bytes("value", event.Value.([]byte)).Msg("Received music event from watch")
// Send music event to channel // Send music event to channel
musicEventCh <- MusicEvent(event.Value.([]byte)[0]) musicEventCh <- MusicEvent(event.Value.([]byte)[0])
} }