Skip to content
Snippets Groups Projects
Commit 8afe5e8b authored by plw1g21's avatar plw1g21
Browse files

So this code was working, but now I need to remember which commands to run to enable BLE.

parent b5b7008e
No related branches found
No related tags found
1 merge request!1App now has a basic structure and BLE support
...@@ -16,7 +16,7 @@ class PairingCharacteristic(dbus.service.Object): ...@@ -16,7 +16,7 @@ class PairingCharacteristic(dbus.service.Object):
'Service': dbus.ObjectPath(service.path), 'Service': dbus.ObjectPath(service.path),
'Flags': dbus.Array(['read', 'write'], signature='s') '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}') @dbus.service.method('org.bluez.GattCharacteristic1', in_signature='', out_signature='a{sv}')
def GetProperties(self): def GetProperties(self):
...@@ -33,6 +33,7 @@ class PairingCharacteristic(dbus.service.Object): ...@@ -33,6 +33,7 @@ class PairingCharacteristic(dbus.service.Object):
class BLEService(dbus.service.Object): class BLEService(dbus.service.Object):
def __init__(self, bus, index): 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.path = f"/org/bluez/example/service{index}"
self.props = { self.props = {
'UUID': dbus.String(SERVICE_UUID), 'UUID': dbus.String(SERVICE_UUID),
...@@ -53,6 +54,7 @@ def main(): ...@@ -53,6 +54,7 @@ def main():
DBusGMainLoop(set_as_default=True) DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus() bus = dbus.SystemBus()
# Create the BLE service
service = BLEService(bus, 0) service = BLEService(bus, 0)
print("BLE Service running. Press Ctrl+C to stop.") print("BLE Service running. Press Ctrl+C to stop.")
...@@ -60,4 +62,4 @@ def main(): ...@@ -60,4 +62,4 @@ def main():
mainloop.run() mainloop.run()
if __name__ == '__main__': if __name__ == '__main__':
main() main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment