From 8afe5e8bc402f063290b5758a19325920e88644b Mon Sep 17 00:00:00 2001
From: Paul-Winpenny <plw1g21@soton.ac.uk>
Date: Mon, 21 Oct 2024 20:09:34 +0000
Subject: [PATCH] So this code was working, but now I need to remember which
 commands to run to enable BLE.

---
 Connectivity/RPiBluetooth.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Connectivity/RPiBluetooth.py b/Connectivity/RPiBluetooth.py
index b66dd05d..bfed730e 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()
-- 
GitLab