From 4f54e74b090cdc58f86b6fcd30161fd2b67f062e Mon Sep 17 00:00:00 2001 From: Elara6331 Date: Sat, 27 Apr 2024 13:32:48 -0700 Subject: [PATCH] Change if statement to switch statement --- gattc_linux.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gattc_linux.go b/gattc_linux.go index eb39877..e5a51c2 100644 --- a/gattc_linux.go +++ b/gattc_linux.go @@ -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 }