Closed unicorn200066 closed 2 months ago
`import asyncio import logging import uuid from time import sleep from typing import Optional
from bless import *
logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(name=name)
async def test_ble_server(loop): trigger = asyncio.Event() trigger.clear() server : BlessServer = BlessServer("MyBleServer", loop=loop)
service_uuid : str = str(uuid.uuid4())
await server.add_new_service(service_uuid)
char_uuid : str = str(uuid.uuid4())
char_flags: GATTCharacteristicProperties = (
GATTCharacteristicProperties.read |
GATTCharacteristicProperties.write |
GATTCharacteristicProperties.notify
)
value: Optional[bytearray] = None
permissions: GATTAttributePermissions = (
GATTAttributePermissions.readable |
GATTAttributePermissions.writeable
)
await server.add_new_characteristic(service_uuid, char_uuid, char_flags, value, permissions)
await server.start()
logger.info(f"server name is {server.name}")
is_advertising = await server.is_advertising()
logger.info(f"server is advertising: {is_advertising}")
await trigger.wait()
if name == "main": loop = asyncio.get_event_loop() loop.run_until_complete(test_ble_server(loop))
`
I ran the code above, however while the server is running, I could not find "MyBleServer" device on my iphone
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered If applicable, provide a clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.