diff --git a/Connectivity/RPiBluetooth.py b/Connectivity/RPiBluetooth.py index b66dd05d7b7d91c2e1c9964c36e16283ccea79cb..bfed730ebbde59b35aca446bb405d0f78c6a79c9 100644 --- a/Connectivity/RPiBluetooth.py +++ b/Connectivity/RPiBluetooth.py @@ -16,7 +16,7 @@ class PairingCharacteristic(dbus.service.Object): 'Service': dbus.ObjectPath(service.path), 'Flags': dbus.Array(['read', 'write'], signature='s') } - super().__init__(service.bus, self.path) + super().__init__(self.service.bus, self.path) # Use self.service.bus here @dbus.service.method('org.bluez.GattCharacteristic1', in_signature='', out_signature='a{sv}') def GetProperties(self): @@ -33,6 +33,7 @@ class PairingCharacteristic(dbus.service.Object): class BLEService(dbus.service.Object): def __init__(self, bus, index): + self.bus = bus # Store the bus object as an attribute of the BLEService self.path = f"/org/bluez/example/service{index}" self.props = { 'UUID': dbus.String(SERVICE_UUID), @@ -53,6 +54,7 @@ def main(): DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() + # Create the BLE service service = BLEService(bus, 0) print("BLE Service running. Press Ctrl+C to stop.") @@ -60,4 +62,4 @@ def main(): mainloop.run() if __name__ == '__main__': - main() \ No newline at end of file + main()