我尝试了暗淡的开发团队的例子。但是设备昨天连接了两次,但是从昨天下午开始就不能再连接了。根据文档广告,它是10.248s。我尝试了20s,但是仍然不能连接到asyncTimeouterror
import asyncio
import platform
import sys
import bleak.exc
from bleak import BleakClient, BleakScanner
from bleak.exc import BleakError
ADDRESS = (
"F5:8B:A2:4C:AD:9C"
if platform.system() != "Darwin"
else "B9EA5233-37EF-4DD6-87A8-2A875E821C46"
)
async def main(ble_address: str):
try:
device = await BleakScanner.find_device_by_address(ble_address, timeout=10.0)
if not device:
raise BleakError(f"A device with address {ble_address} could not be found.")
async with BleakClient(device, timeout=22.0) as client:
print("Services:")
for service in client.services:
print(service)
except bleak.exc.BleakError as e:
print(e)
while True:
asyncio.run(main(sys.argv[1] if len(sys.argv) == 2 else ADDRESS))
我认为问题出在广告时间上,但我尝试过许多不同的超时,但都不起作用
1条答案
按热度按时间ohfgkhjo1#
我想你可以查一下: