Skip to content

Commit

Permalink
Change if statement to switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Elara6331 committed Apr 27, 2024
1 parent 4557b5d commit 4f54e74
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gattc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,17 @@ func (c DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) err
if sig.Name == "org.freedesktop.DBus.Properties.PropertiesChanged" {
interfaceName := sig.Body[0].(string)

if interfaceName == "org.bluez.Device1" && sig.Path == devicePath {
switch {
case interfaceName == "org.bluez.Device1" && sig.Path == devicePath:
changes := sig.Body[1].(map[string]dbus.Variant)

if connected, ok := changes["Connected"].Value().(bool); ok && !connected {
c.EnableNotifications(nil)
return
}
} else if interfaceName != "org.bluez.GattCharacteristic1" {
case interfaceName != "org.bluez.GattCharacteristic1":
continue
}

if sig.Path != c.characteristic.Path() {
case sig.Path != c.characteristic.Path():
continue
}

Expand Down

0 comments on commit 4f54e74

Please sign in to comment.