zyv / huawei-lpv2

A pure Python implementation of Huawei BLE Link Protocol v2
MIT License
46 stars 13 forks source link

Failed to start,Can you take a look?thank you #7

Closed zhuibo66 closed 2 years ago

zhuibo66 commented 3 years ago

Here is the error message:

DEBUG:asyncio:Using selector: SelectSelector
DEBUG:bleak.backends.dotnet.scanner:Received 88:11:96:5C:EA:AF: Unknown.
DEBUG:bleak.backends.dotnet.scanner:Received 88:11:96:5C:EA:AF: honor Band 4-AAF.
DEBUG:bleak.backends.dotnet.client:Connecting to BLE device @ 88:11:96:5C:EA:AF
DEBUG:bleak.backends.dotnet.client:_ConnectionStatusChanged_Handler: 1
DEBUG:bleak.backends.dotnet.client:Get Services...
DEBUG:bleak.backends.dotnet.client:_ConnectionStatusChanged_Handler: 0
Traceback (most recent call last):
  File ".\band_gatt.py", line 58, in <module>
    event_loop.run_until_complete(read_data(event_loop))
  File "D:\Program Files (x86)\Python37\lib\asyncio\base_events.py", line 584, in run_until_complete
    return future.result()
  File ".\band_gatt.py", line 41, in read_data
    async with BleakClient(device_mac if platform.system() != "Darwin" else device_uuid, loop=loop) as client:     
  File "Program Files (x86)\Python37\lib\site-packages\bleak\backends\client.py", line 61, in __aenter__        
    await self.connect()
  File "Program Files (x86)\Python37\lib\site-packages\bleak\backends\dotnet\client.py", line 250, in connect   
    await self.get_services(use_cached=use_cached)
  File "Program Files (x86)\Python37\lib\site-packages\bleak\backends\dotnet\client.py", line 476, in get_services
    return_type=GattCharacteristicsResult,
  File "Program Files (x86)\Python37\lib\site-packages\bleak\backends\dotnet\utils.py", line 79, in wrap_IAsyncOperation
    raise BleakDotNetTaskError(op.ErrorCode.ToString())
bleak.exc.BleakDotNetTaskError: System.ObjectDisposedException: 该对象已关闭。 (异常来自 HRESULT:0x80000013)   

My idea is that you can directly get the data like the number of steps today and the cell phone battery through Bluetooth

zyv commented 3 years ago

Judging from your backtrace, the problem lies somewhere between your OS and the Bluetooth client that my code is using - I’m afraid that there is not much that I can do about it:

https://github.com/hbldh/bleak/issues/158

zhuibo66 commented 3 years ago

Judging from your backtrace, the problem lies somewhere between your OS and the Bluetooth client that my code is using - I’m afraid that there is not much that I can do about it:

hbldh/bleak#158

Judging from your backtrace, the problem lies somewhere between your OS and the Bluetooth client that my code is using - I’m afraid that there is not much that I can do about it:

hbldh/bleak#158

It’s okay. I really feel that your reply is taking up your time. I currently want to create a Wechat Mini Program through which I can read the data of the bracelet (such as steps, battery).

But I don’t know how to communicate with the bracelet after connection. I currently know that after the initial BLE scan and GATT read, these bytes are written, 5a000b0001010100020003000400f13b

Then, return to some messages, but it is not clear how to decrypt it.

If you need any information there, I can provide them all, thank you.

zhuibo66 commented 3 years ago

There is a new mistake

characteristics_result.Status, ""
bleak.exc.BleakDotNetTaskError: Could not get GATT characteristics for Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService: AccessDenied
zyv commented 2 years ago

Hi @zhuibo66, sorry that it's taken me so long to get back to you.

Unfortunately, since I've written this code, Huawei has changed the authentication scheme several times and the current code only supports old bands with no firmware updates applied.

However, a few days a kind soul has backported the newly reversed auth sequences from GB and submitted a PR: #8. Please check whether this works for you, I have made my changes to it and intend to merge it to master as soon as someone has tested it.

Thank you!