mirror of
https://github.com/google/bumble.git
synced 2026-06-10 09:02:27 +00:00
format with Black
This commit is contained in:
+21
-10
@@ -32,8 +32,12 @@ from bumble.transport import open_transport_or_link
|
||||
# -----------------------------------------------------------------------------
|
||||
async def main():
|
||||
if len(sys.argv) != 4:
|
||||
print('Usage: run_controller.py <controller-address> <device-config> <transport-spec>')
|
||||
print('example: run_controller.py F2:F3:F4:F5:F6:F7 device1.json udp:0.0.0.0:22333,172.16.104.161:22333')
|
||||
print(
|
||||
'Usage: run_controller.py <controller-address> <device-config> <transport-spec>'
|
||||
)
|
||||
print(
|
||||
'example: run_controller.py F2:F3:F4:F5:F6:F7 device1.json udp:0.0.0.0:22333,172.16.104.161:22333'
|
||||
)
|
||||
return
|
||||
|
||||
print('>>> connecting to HCI...')
|
||||
@@ -44,11 +48,13 @@ async def main():
|
||||
link = LocalLink()
|
||||
|
||||
# Create a first controller using the packet source/sink as its host interface
|
||||
controller1 = Controller('C1', host_source = hci_source, host_sink = hci_sink, link = link)
|
||||
controller1 = Controller(
|
||||
'C1', host_source=hci_source, host_sink=hci_sink, link=link
|
||||
)
|
||||
controller1.random_address = sys.argv[1]
|
||||
|
||||
# Create a second controller using the same link
|
||||
controller2 = Controller('C2', link = link)
|
||||
controller2 = Controller('C2', link=link)
|
||||
|
||||
# Create a host for the second controller
|
||||
host = Host()
|
||||
@@ -59,17 +65,21 @@ async def main():
|
||||
device.host = host
|
||||
|
||||
# Add some basic services to the device's GATT server
|
||||
descriptor = Descriptor(GATT_CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR, Descriptor.READABLE, 'My Description')
|
||||
descriptor = Descriptor(
|
||||
GATT_CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR,
|
||||
Descriptor.READABLE,
|
||||
'My Description',
|
||||
)
|
||||
manufacturer_name_characteristic = Characteristic(
|
||||
GATT_MANUFACTURER_NAME_STRING_CHARACTERISTIC,
|
||||
Characteristic.READ,
|
||||
Characteristic.READABLE,
|
||||
"Fitbit",
|
||||
[descriptor]
|
||||
[descriptor],
|
||||
)
|
||||
device_info_service = Service(
|
||||
GATT_DEVICE_INFORMATION_SERVICE, [manufacturer_name_characteristic]
|
||||
)
|
||||
device_info_service = Service(GATT_DEVICE_INFORMATION_SERVICE, [
|
||||
manufacturer_name_characteristic
|
||||
])
|
||||
device.add_service(device_info_service)
|
||||
|
||||
# Debug print
|
||||
@@ -82,6 +92,7 @@ async def main():
|
||||
|
||||
await hci_source.wait_for_termination()
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
logging.basicConfig(level = os.environ.get('BUMBLE_LOGLEVEL', 'DEBUG').upper())
|
||||
logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'DEBUG').upper())
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user