mirror of
https://github.com/google/bumble.git
synced 2026-06-01 07:37:02 +00:00
format with Black
This commit is contained in:
+23
-17
@@ -22,10 +22,7 @@ import logging
|
||||
|
||||
from bumble.device import Device, Connection
|
||||
from bumble.transport import open_transport_or_link
|
||||
from bumble.att import (
|
||||
ATT_Error,
|
||||
ATT_INSUFFICIENT_ENCRYPTION_ERROR
|
||||
)
|
||||
from bumble.att import ATT_Error, ATT_INSUFFICIENT_ENCRYPTION_ERROR
|
||||
from bumble.gatt import (
|
||||
Service,
|
||||
Characteristic,
|
||||
@@ -33,7 +30,7 @@ from bumble.gatt import (
|
||||
Descriptor,
|
||||
GATT_CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR,
|
||||
GATT_MANUFACTURER_NAME_STRING_CHARACTERISTIC,
|
||||
GATT_DEVICE_INFORMATION_SERVICE
|
||||
GATT_DEVICE_INFORMATION_SERVICE,
|
||||
)
|
||||
|
||||
|
||||
@@ -76,7 +73,9 @@ def my_custom_write_with_error(connection, value):
|
||||
# -----------------------------------------------------------------------------
|
||||
async def main():
|
||||
if len(sys.argv) < 3:
|
||||
print('Usage: run_gatt_server.py <device-config> <transport-spec> [<bluetooth-address>]')
|
||||
print(
|
||||
'Usage: run_gatt_server.py <device-config> <transport-spec> [<bluetooth-address>]'
|
||||
)
|
||||
print('example: run_gatt_server.py device1.json usb:0 E1:CA:72:48:C4:E8')
|
||||
return
|
||||
|
||||
@@ -89,17 +88,21 @@ async def main():
|
||||
device.listener = Listener(device)
|
||||
|
||||
# Add a few entries 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
|
||||
])
|
||||
custom_service1 = Service(
|
||||
'50DB505C-8AC4-4738-8448-3B1D9CC09CC5',
|
||||
[
|
||||
@@ -107,21 +110,23 @@ async def main():
|
||||
'D901B45B-4916-412E-ACCA-376ECB603B2C',
|
||||
Characteristic.READ | Characteristic.WRITE,
|
||||
Characteristic.READABLE | Characteristic.WRITEABLE,
|
||||
CharacteristicValue(read=my_custom_read, write=my_custom_write)
|
||||
CharacteristicValue(read=my_custom_read, write=my_custom_write),
|
||||
),
|
||||
Characteristic(
|
||||
'552957FB-CF1F-4A31-9535-E78847E1A714',
|
||||
Characteristic.READ | Characteristic.WRITE,
|
||||
Characteristic.READABLE | Characteristic.WRITEABLE,
|
||||
CharacteristicValue(read=my_custom_read_with_error, write=my_custom_write_with_error)
|
||||
CharacteristicValue(
|
||||
read=my_custom_read_with_error, write=my_custom_write_with_error
|
||||
),
|
||||
),
|
||||
Characteristic(
|
||||
'486F64C6-4B5F-4B3B-8AFF-EDE134A8446A',
|
||||
Characteristic.READ | Characteristic.NOTIFY,
|
||||
Characteristic.READABLE,
|
||||
'hello'
|
||||
)
|
||||
]
|
||||
'hello',
|
||||
),
|
||||
],
|
||||
)
|
||||
device.add_services([device_info_service, custom_service1])
|
||||
|
||||
@@ -142,6 +147,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