Skip to content

Instantly share code, notes, and snippets.

@psolyca
Last active April 23, 2024 19:37
Show Gist options
  • Save psolyca/68fdfee0960737c1234f8d7f7a6c143a to your computer and use it in GitHub Desktop.
Save psolyca/68fdfee0960737c1234f8d7f7a6c143a to your computer and use it in GitHub Desktop.
Honor Band 4 RE

Introduction

Lots of works have been made to communicate with the Honor Band 3/4 in order to be used with GadgetBridge.
RE is followed in issue 1021 BTW, communication where not complete and the RE was done on BLE LPv2.
A new protocol LPv3 appeared.

Goal

RE the LPv3 BLE protocol and integrate Honor devices in GadgetBridge.

Keys

Version

BLE LPv3 appeared in Huawei Health 10.0.1.319 (HH) but LPv2 is used (For Honor Band 3 as this is the only band I have).
btsdk_sharedpreferences_name1.xml, btsdk_sharedpreferences_name2.xml and btsdk_sharedpreferences_name3.xml disappeared in HH 10.0.1.319.
LPv3 appeared on firmware 1.0.10.60 (I have 1.0.10.78). 25/09/21 : It seems recent bands use protocol version 2 (frame analyze) but LPv3 keys. 13/12/21 : Key depends on the auth version and not the protocol version.

Where to find them ?

LPv2 keys are present in libwhiteBoxJniLib.so (they were present before 10.0.1.319 but not used).
LPv3 keys are also in libwhiteBoxJniLib.so.
LPv2 keys are divided in 3 parts in libwhiteBoxJniLib.so.

  • Key1
    • part1 @00012350 : 6f 75 6a 79 6d 77 00 00
    • part2 @0001c384 : 71 34 63 6c 76 00
    • part3 @0001c739 : 39 33 37 38 79 00
  • Key2
    • part1 @00012348 : 62 31 30 6a 67 66 00 00
    • part2 @0001c38a : 64 39 79 37 76 00
    • part3 @0001c73f : 73 75 64 61 39 00

LPv3 keys are not divided in libwhiteBoxJniLib.so.

  • Key1 @0001bdbd : 35 35 20 35 33 20 38 36 20 46 43 20 36 33 20 32 30 20 30 37 20 41 41 20 38 36 20 34 39 20 33 35 20 32 32 20 42 38 20 36 41 20 45 32 20 35 43 00
  • Key2 @0001c390 : 33 33 20 30 37 20 39 42 20 43 35 20 37 41 20 38 38 20 36 44 20 33 43 20 46 35 20 36 31 20 33 37 20 30 39 20 36 46 20 32 32 20 38 30 20 30 30 00

But, thanks to @tuxuser thinking, these strings could be ASCII representation of the keys (to be checked) aka :

  • Key1 : 55 53 86 FC 63 20 07 AA 86 49 35 22 B8 6A E2 5C
  • Key2 : 33 07 9B C5 7A 88 6D 3C F5 61 37 09 6F 22 80 00

Finally these keys are:

  1. auth version 1 : 6f 75 6a 79 6d 77 71 34 63 6c 76 39 33 37 38 79 and 62 31 30 6a 67 66 64 39 79 37 76 73 75 64 61 39
  2. auth version 2 and 3 : 55 53 86 FC 63 20 07 AA 86 49 35 22 B8 6A E2 5C and 33 07 9B C5 7A 88 6D 3C F5 61 37 09 6F 22 80 00

There seems to be more keys in 3 main arrays in libwhiteBoxJniLib.so but I did not find there use yet.

  • Array1 @0001bb40
  • Array2 @0001be87 (Pointer @00110cc0)
  • Array3 @0001c477 (Pointer @00110d40)
  • Array of data with keys : @000122fc (Key1 and Key2 part 1 are here)

Final secret is stored in btsdk_sharedpreferences_name4.xml. This is not the main key (see below)

  • Before HH 10.0.1.319, the final key is stored as plain text.
  • After HH 10.0.1.319, the final key is crypted and the class containing the key EncryptData is serialized.

Master key

This applies to parsing logs from official HH app not from direct connection using https://github.com/psolyca/huawei-lpv2/blob/master/band_lpv2.py

From log

In version <11.0.4.517, master key could be reversed and find using the bonding key in Packet(service_id=1, command_id=7..).
Bonding key is the master key crypted with a secret key composed of Key1, Key2 and a key derivated from the server MAC address (aka the band). Thus, the reverse is "easy".
In version >=11.0.4.517, Packet(service_id=1, command_id=7..) is crypted, thus the bonding key is crypted and no way to reverse it. Something has changed between versions, MAC address used to be able to decrypt the packet differ from one version to another, before it was the client MAC, after it was the device MAC (to be confirmed).

From Android

There is other potential way to get master key of the device.
The key in btsdk_sharedpreferences_name4.xml is crypted with a key which is stored in Android KeyStore of the device. Getting the key from Android KeyStore...

From iOS

I do not own any iOS phone but it should be equivalent to Android in term of keys.

Crypting / Decrypting

Same as zyv works for both LPv2 and LPv3.

Bluetooth

Protocol

Reference to huawei/protocol.py
As stated, packages could be non sliced or sliced but could also be split to 256 bytes due to bluetooth maximum frame size.
The protocol has been changed to handle the partial message, sliced or not. On sliced packets, the second field (XX) is the index. 0x03 is the last one so used to check for complete message. the third field (YY) is always Unknown.

Connection and communication

In "human" readable terms, here is the way to connect and communicate to the band.

Specifications

GATT characteristics

The GATT characteristic to send the message is 0x0000fe01, the one which is received is 0x0000fe02. Some other characteristics exists 0x0000fe03 (notify) and 0x0000fe04 (unknown) but not explored yet.

Values

Values associated with the GATT characteristic are passed following a specific scheme.
More information on this scheme has already been described by @zyv in his wiki page. Also, services and commands send and received by the band/watch are described here and in Services.

Connection

Connection and pairing to band/watch is done like others BLE devices. After connecting and getting basic GATT characteristics, there is a handshake process to be completly bond to the band/watch and then everything is crypted.

Handshake is done in 4 steps:

  1. Requesting link parameters, service_id=1, command_id=1
  2. Requesting authentification, service_id=1, command_id=19
  3. Requesting bond parameters, service_id=1, command_id=15
  4. Requesting bond, service_id=1, command_id=14

Needed information for each step:

  1. Nothing
  2. Server nonce from step #1 and client nonce (generated by the app)
  3. Client serial (made from client MAC) and client MAC
  4. Client serial, device MAC (getting from pairing or connection), master key and iv (both generated by the app)

Authentification

A digest message is used to check the authentification.
This message differ for each auth version.

  1. auth version 1 : 70 FB 6C 24 03 5F DB 55 2F 38 89 8A EE DE 3F 69
  2. auth version 2 : 93 AC DE F7 6A CB 09 85 7D BF E5 26 1A AB CD 78
  3. auth version 3 : 9C 27 63 A9 CC E1 34 76 6D E3 FF 61 18 20 05 53

Communication

All communications are crypted with the master key and an Initial Vector (IV) To crypt messages sent from the app/phone, we use the Client Nonce as IV.
To uncrypt messages received from the device, we use the Server Nonce as IV, this one is sent with the message (tag=125).

Services

From HH dissassemble
Number of services : 46
Number of commands : ...
New ID added :

  • Service ID: 1
    • Command ID : 2 - SupportedServices
      • 1: Services
      • 2: ActiveServices
    • Command ID: 3 - SupportedCommands
      • 2: ServiceId
      • 3: Commands
      • 4: ActiveCommands
      • 129: SupportedCommands
    • Command ID: 7
      • 12: ProductName
      • 14: ForceSN
      • 17: CertificatModel
      • 21: HiLinkProductID
      • 22: ProductManufacture
    • Command ID: 11 - deleteDeviceAvoidDisturbingInfo
    • Command ID: 12 - onResponse (addDeviceAvoidDisturbingInfo)
    • Command ID: 14
      • 9:
    • Command ID: 16 - HandsetInfo
    • Command ID: 18 - SupportedActivity
      • 2: Activity
      • 3: SupportHeartRate
      • 129: SupportedActivity
    • Command ID: 22
      • 0: NoDualPhone
      • 1: CurentConnected
      • 2: HasBeenConnected
      • 3: DoublePhoneSituation
      • 127: NotifyDeviceOperation
    • Command ID: 23
    • Command ID: 24
    • Command ID: 25
    • Command ID: 29 - RequestDNDStatus
      • 1
    • Command ID: 33 - getDefaultSwitch
    • Command ID: 34
    • Command ID: 35
    • Command ID: 36
  • Service ID: 2
    • Command ID: 2 - NotificationConstraint
    • Command ID: 4 - NotificationEnable
    • Command ID: 5 - Capability
    • Command ID: 6 - deleteMsgToTLVS
      • 1: PromptPush
    • Command ID: 7
  • Service ID: 3
    • Command ID: 1 - setContact
    • Command ID: 2
  • Service ID: 7 - Fitness
    • Command ID: 1 - SetMotionGoalCmd
    • Command ID: 4 - GetHealthDataByFrameCountCmd
    • Command ID: 5 - GetHealthDataByFrameCompressedCmd
    • Command ID: 7 - SetActivityReminderCmd
    • Command ID: 8 - HealthDataByFrameComm
    • Command ID: 10 - GetSampleFrameCountCmd
    • Command ID: 11 - GetSampleFrameCmd
    • Command ID: 12 - GetStatusFrameCountCmd
    • Command ID: 13 - GetStatusFrameCmd
    • Command ID: 14 - SetDeviceReportThreshold
    • Command ID: 16 - SetDevCouldSummaryEnable
    • Command ID: 19 - SetHRZoneConfCmd
    • Command ID: 33 - SetMaxAndHrrHeartZoneConfCmd
    • Command ID: 24 - SleepStateCmd
    • Command ID: 28 - SetContinueMeasureHeartRateEnableCmd
    • Command ID: 30 - HeartRateRaise
    • Command ID: 34 - HeartRateRemindCmdDown
    • Command ID: 25 - dailySleepScore
    • Command ID: 26
    • Command ID: 31 - GetDesFrameCountCmd or DataFrameCommand Aw70
    • Command ID: 32 - GetDesFrameCmd or SamplePointDataCommand Aw70
  • Service ID: 8 - Alarm
    • Command ID: 1 - EventAlarm
    • Command ID: 2 - SmartAlarm
    • Command ID: 3
    • Command ID: 4
  • Service ID: 9 - OTAV2
    • Command ID: 1 - OtaAllow
    • Command ID: 2 - OtaParametersV2
    • Command ID: 3 -
    • Command ID: 4 -
    • Command ID: 6 -
    • Command ID: 9 - otaStatusNotify
    • Command ID: 11 - DeviceReadyForUpdate
  • Service ID: 10 - FileTransferTask
    • Command ID: 1 - PeriodRRIFile
    • Command ID: 2 - MaintenanceParameters
    • Command ID: 3 - FileInformation
    • Command ID: 4
    • Command ID: 6 - transfertFileEndProcess
    • Command ID: 12
  • Service ID: 11 - FindPhone
    • Command ID: 2
    • Command ID: 3 - BTLostNotification
  • Service ID: 12
    • Command ID: 2 - DeviceFontInfo
  • Service ID: 15 - Weather
    • Command ID: 2 - WeatherConstraintMsg
    • Command ID: 6 - WeatherConstraintExpandMsg
    • Command ID: 7 - WeatherErrorCode
    • Command ID: 5 - WeatherUnitToDevice
    • Command ID: 1 - WeatherToDevice
    • Command ID: 4 - DataFromDevice
    • Command ID: 3 - AtmosphereCmd2Device
  • Service ID: 22 - ExerciseAdvice
    • Command ID: 1 - RunPlanParameterforhealth
    • Command ID: 2 - RunPlanForHealth
    • Command ID: 3
    • Command ID: 4
    • Command ID: 5
    • Command ID: 12 - FitRunCourseInfo
    • Command ID: 13 - FitRunCourseData
  • Service ID: 23 - Workout
    • Command ID: 1
    • Command ID: 2 - NotificationStatusResponse
    • Command ID: 3
    • Command ID: 4
    • Command ID: 7
    • Command ID: 8 - WorkoutRecordStatistic
    • Command ID: 10 - WorkoutData
    • Command ID: 11 - RealTimeData
    • Command ID: 12 - WorkoutRecordPaceMap
    • Command ID: 13 - notificationWorkoutRecordSpeechPlayReportStatus
    • Command ID: 14
    • Command ID: 15 - RunPostureReportStatus
    • Command ID: 18 - openOrCloseReport
    • Command ID: 19 - WorkoutRecordSliceData
    • Command ID: 20 - BloodOxygenListStatistic
  • Service ID: 24 - GPSLocation
    • Command ID: 1
    • Command ID: 2 - GpsStatus
    • Command ID: 3 - GpsParameter
    • Command ID: 4
  • Service ID: 25 - HeartRate
    • Command ID: 1
    • Command ID: 3 - HeartRateResponse
  • Service ID: 26 - Wearable
    • Command ID: 1 - sendAccount
  • Service ID: 27 - Pay
    • Command ID: 1
    • Command ID: 2 - payAPDUInfo
    • Command ID: 3 - closeChannel
    • Command ID: 4 - CPLC
    • Command ID: 5 - BTCInfo
    • Command ID: 7 - transmitFile
    • Command ID: 8 - addCard
    • Command ID: 9
    • Command ID: 10
    • Command ID: 11
    • Command ID: 13
    • Command ID: 12
    • Command ID: 14
    • Command ID: 15
    • Command ID: 16
    • Command ID: 17 - NfcTagInfo
    • Command ID: 18 - NfcCommand
    • Command ID: 19 - aulthenticateMifareSector
    • Command ID: 20 - BlockData
    • Command ID: 21 - AccessCardRfInfo
    • Command ID: 22
    • Command ID: 23
  • Service ID: 28 - FileServices
    • Command ID: 1
    • Command ID: 2
    • Command ID: 3 - StarSingleFileInfor
    • Command ID: 4
    • Command ID: 5 - StarFileData
    • Command ID: 6
  • Service ID: 29 - MultiSimSendCommandUtil
    • Command ID: 1 -
    • Command ID: 3 -
    • Command ID: 6 - SimInfoQuery
    • Command ID: 7 - MultiSimStatus
    • Command ID: 8 - EsimProfileRemoveReq
  • Service ID: 31 - Ephemeris
    • Command ID: 1 -
    • Command ID: 2 - parameterConsult
    • Command ID: 3 - FileStatus
  • Service ID: 32 - StressSendCommandUtil
    • Command ID: 1 - StressRecordFrameListIndex
    • Command ID: 2 - StressRecordDetail
    • Command ID: 3 - RelaxRecordFrameListIndex
    • Command ID: 4 - RelaxRecordDetail
    • Command ID: 9 - CalibrationData
    • Command ID: 10 - AppPressInfo
  • Service ID: 33 - DeviceConfigSendCommandUtil
    • Command ID: 1 - AppStatus
    • Command ID: 2 - Return code
      • 127:
  • Service ID: 34 - OneLevelMenu
    • Command ID: 1 - BTCInfo
    • Command ID: 2 - transmitFile
  • Service ID: 35 - RriServiceSendCommandUtil
    • Command ID: 2 - AtrialAutoMeasureCommand
    • Command ID: 3 - AtrialSingleMeasureCommand
    • Command ID: 4 - ClearAtrialDataCommand
    • Command ID: 6 - EcgMeasureAuthAccountCommand
    • Command ID: 8 - EcgDetailDataCommand
  • Service ID: 36 - FitnessPosture
    • Command ID: 1 - PostureVersionInfo
    • Command ID: 4 - PostureRecord
    • Command ID: 5 - PostureRecordList
    • Command ID: 6 - CourseRecord
    • Command ID: 7 - CourseRecordList
    • Command ID: 8 - WatchStatus
    • Command ID: 9 - PostureStatusValue
    • Command ID: 10 - Reminder
    • Command ID: 11 - Result
    • Command ID: 12 - ReturnValue
  • Service ID: 37 - MusicControl
    • Command ID: 1 - AppStatus
    • Command ID: 2 - MusicInfo
    • Command ID: 3 - AppControlResponse
    • Command ID: 4 - MusicFrameCount
    • Command ID: 5 - GetMusicInfo
    • Command ID: 6 - FolderInfo
    • Command ID: 7 - OneFolderOneFrameMusicAssociation
    • Command ID: 8 - FolderMusicOperate
    • Command ID: 9 - MusicFileResponse
    • Command ID: 10 - MusicAccountInfo
    • Command ID: 11 - HistoryFrameCount
    • Command ID: 12 - GetHistoryInfo
    • Command ID: 13 - Negotiation
  • Service ID: 38 - AW70_AW70DeviceMode
    • Command ID: 1 - ModeStatus
    • COmmand ID: 2 - AutoModeDetectSwitchStatus
  • Service ID: 39 - WatchFace
    • Command ID: 1 - DeviceInfo
    • Command ID: 2 - DeviceWatchInfo
    • Command ID: 3 - OperateType
    • Command ID: 4 - InfoList
    • Command ID: 5 - reportAck
    • Command ID: 6 - GetNameCommand
    • Command ID: 7 - PreviewCommand or sendPhotoCommand
    • Command ID: 8 - PhotoWatchInfo
    • Command ID: 9 - PhotoInfoCommand
    • Command ID: 10 - TagActivate
    • Command ID: 11 - TagResult
    • Command ID: 12 - GetCapability
    • Command ID: 13 - ClipMessage
  • Service ID: 40 - CommonFile
    • Command ID: 1 - DeviceRequest
    • Command ID: 2 - FileInfo
    • Command ID: 3 - FileHashResult
    • Command ID: 4 - ConsultAck
    • Command ID: 6
    • Command ID: 7 - ResultAck
    • Command ID: 9 - CancelCommand
  • Service ID: 43 - TWS
    • Command ID: 18 - Command18
    • Command ID: 19 - FramesCommand
    • Command ID: 20 - Command20
    • Command ID: 21 - clearDeviceInfo
  • Service ID: 44 - CommonFileRequest
    • Command ID: 1 - FileInfo
    • Command ID: 2 - FileCheck
    • Command ID: 3 - RequestParameter
    • Command ID: 4 - RequestCommand
    • Command ID: 6 - RequestCommand
  • Service ID: 45 - BreathingSendCommandUtil
    • Command ID: 1 - SleepBreatheSwitch
    • Command ID: 2 - ClearSleepBreatheCommand
  • Service ID: 46 - CarNotification
    • Command ID: 1
  • Service ID: 1014

Devices

DeviceModel, DeviceId and DeviceType

  • HUAWEI B3-: "GMN-BX9", "004Z", "06E"
  • HUAWEI B3-? : "AW61", "0056", "06E"
  • HUAWEI Band 3 Pro-: "TER-B19", "002K", "06E"
  • HUAWEI Band 3i-: "ADS-B29", "005U", "06E"
  • HUAWEI Band 3e-: "AW70-B29", "004X", "06E"
  • HUAWEI Band 3e-?: "AW70-B19", "0053", "06E"
  • HUAWEI Band 3e-PRO?: "AW70-B39", "006X", "06E"
  • ?: "AW70-B39HN", "006Y", "06E"
  • HUAWEI B3 Lite-: "GRU-B09", "0050", "06E"
  • HUAWEI Sport: "ERS-B19", "0051", "06E"
  • HUAWEI B5-: "JNS-BX9", "004Y", "06E"
  • honor Band 3-: "NYX-B10", "0054", "06E"
  • HONOR Band5: "CRS-B19S", "005R", "06E"
  • HONOR Band4: "CRS-B19", "002I", "06E"
  • HONOR Band 5i-: "ADS-B19", "005T", "06E"
  • honor Watch S1-: "MES-B19", "004W", "06D"
  • honor Watch-: "TLS-B19", "002M", "06D"
  • HUAWEI WATCH GT 2 pro vidar: "LTN-B19", "005W", "06D" ??
  • MagicWatch 2 minos: "MNS-B19", "005Y", "06D"
  • ??: "HBE-B19", "005Z", "06D"
  • HUAWEI WATCH GT-: "FTN-B19", "003N", "06D"
  • PORSCHE DESIGN: "LEO-BX9", "004U", "06D"
  • HUAWEI WATCH 2: "LEO-DLXX", "004Q", "06D"
  • HUAWEI WATCH Hector: "HCT-B19", "M003", "06D"
  • HUAWEI WATCH GT 2 Diana: "DAN-B19", "005X", "06D");

Parser

Reference to parser module
Now log files could be handle with the parser module.

Documentation

Some more information about bits in DeviceConfig service (HH dissassemble) : https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/1021#issuecomment-40581

Links

To get old HH versions : https://www.apkmirror.com/uploads/?q=health

ToDo list

  • Decode HH (1.0.10.319) - Done
  • Decompile HH - WIP; easier thanks to log messages and deobfuscation
  • Dissassemble libwhiteBoxJniLib.so - WIP; find LPv3 keys done, find use of other keys
  • Log more BLE communication to decode messages
  • Enhanced huawei-lpv2 code from https://github.com/zyv/huawei-lpv2/blob/master/huawei/protocol.py
  • Create a log parser to find missing information
  • Improve the log parser to print information
  • Decode BLE handshake and find device.mAuthVersion (HH ask for it to choose protocol through BLE - to be confirmed)
  • List bands/watch and their corresponding modelID / ProductID...

Reminder list

  • service 10 command 5, service 9 command 3 and service 9 command 4 contain no tlvs
@zyv
Copy link

zyv commented Mar 28, 2021

Dump from Band 2 / old firmware:

INFO:__main__:Connected to band, current state: BandState.Connected
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=1, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('')), TLV(tag=2, value=bytes.fromhex('')), TLV(tag=3, value=bytes.fromhex('')), TLV(tag=4, value=bytes.fromhex(''))]))
DEBUG:__main__:Current state: BandState.Connected, target state: BandState.RequestedLinkParams, sending: 5A 00 0B 00 01 01 01 00 02 00 03 00 04 00 F1 3B
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00\x0b\x00\x01\x01\x01\x00\x02\x00\x03\x00\x04\x00\xf1;')
DEBUG:__main__:Waiting for response from service_id=1, command_id=1...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateNotificationStateForCharacteristic_error_
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Character Notify Update
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedLinkParams, received from '56': 5A 00 26 00 01 01 01 01 02 02 02 00 FE 03 02 00 FE 04 02 00 0A 05 12 00 01 74 39 62 54 AA 68 68 C8 13 35 2D BE 43 11 49 18 98 25
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=1, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('02')), TLV(tag=2, value=bytes.fromhex('00 FE')), TLV(tag=3, value=bytes.fromhex('00 FE')), TLV(tag=4, value=bytes.fromhex('00 0A')), TLV(tag=5, value=bytes.fromhex('00 01 74 39 62 54 AA 68 68 C8 13 35 2D BE 43 11 49 18'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:huawei.protocol:Checking function or bound method input: Command(tlvs=[TLV(tag=1, value=bytes.fromhex('02')), TLV(tag=2, value=bytes.fromhex('00 FE')), TLV(tag=3, value=bytes.fromhex('00 FE')), TLV(tag=4, value=bytes.fromhex('00 0A')), TLV(tag=5, value=bytes.fromhex('00 01 74 39 62 54 AA 68 68 C8 13 35 2D BE 43 11 49 18'))])...
INFO:huawei.services.device_config:Negotiated link parameters: 254, 254, 10, 74 39 62 54 AA 68 68 C8 13 35 2D BE 43 11 49 18
DEBUG:__main__:Response processed, attained requested state: BandState.ReceivedLinkParams
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=19, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('DD 11 92 28 CB 59 77 CD B0 27 8F BC 81 69 53 13 C7 7C F7 E6 BF D7 B5 0B 9F 2A 93 55 A2 B2 41 CD')), TLV(tag=2, value=bytes.fromhex('00 01 65 F3 1D FB 44 41 83 51 C3 BD EC 7E B3 7D 7B F9'))]))
DEBUG:__main__:Current state: BandState.ReceivedLinkParams, target state: BandState.RequestedAuthentication, sending: 5A 00 39 00 01 13 01 20 DD 11 92 28 CB 59 77 CD B0 27 8F BC 81 69 53 13 C7 7C F7 E6 BF D7 B5 0B 9F 2A 93 55 A2 B2 41 CD 02 12 00 01 65 F3 1D FB 44 41 83 51 C3 BD EC 7E B3 7D 7B F9 CA FA
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b"Z\x009\x00\x01\x13\x01 \xdd\x11\x92(\xcbYw\xcd\xb0\'\x8f\xbc\x81iS\x13\xc7|\xf7\xe6\xbf\xd7\xb5\x0b\x9f*\x93U\xa2\xb2A\xcd\x02\x12\x00\x01e\xf3\x1d\xfbDA\x83Q\xc3\xbd\xec~\xb3}{\xf9\xca\xfa")
DEBUG:__main__:Waiting for response from service_id=1, command_id=19...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAuthentication, received from '56': 5A 00 25 00 01 13 01 20 FA FE 67 82 EB 79 55 AB 6B 58 21 28 A8 0C C4 30 C0 1E A8 CC F9 1B 79 DD 06 84 B5 E5 34 4A 11 58 4C 15
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=19, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('FA FE 67 82 EB 79 55 AB 6B 58 21 28 A8 0C C4 30 C0 1E A8 CC F9 1B 79 DD 06 84 B5 E5 34 4A 11 58'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:huawei.protocol:Checking function or bound method input: Command(tlvs=[TLV(tag=1, value=bytes.fromhex('FA FE 67 82 EB 79 55 AB 6B 58 21 28 A8 0C C4 30 C0 1E A8 CC F9 1B 79 DD 06 84 B5 E5 34 4A 11 58'))])...
DEBUG:__main__:Response processed, attained requested state: BandState.ReceivedAuthentication
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=15, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('')), TLV(tag=3, value=bytes.fromhex('44 38 41 43 33 36')), TLV(tag=4, value=bytes.fromhex('02')), TLV(tag=5, value=bytes.fromhex('')), TLV(tag=7, value=bytes.fromhex('43 34 3A 42 33 3A 30 31 3A 44 38 3A 41 43 3A 33 36')), TLV(tag=9, value=bytes.fromhex(''))]))
DEBUG:__main__:Current state: BandState.ReceivedAuthentication, target state: BandState.RequestedBondParams, sending: 5A 00 27 00 01 0F 01 00 03 06 44 38 41 43 33 36 04 01 02 05 00 07 11 43 34 3A 42 33 3A 30 31 3A 44 38 3A 41 43 3A 33 36 09 00 DE 91
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b"Z\x00\'\x00\x01\x0f\x01\x00\x03\x06D8AC36\x04\x01\x02\x05\x00\x07\x11C4:B3:01:D8:AC:36\t\x00\xde\x91")
DEBUG:__main__:Waiting for response from service_id=1, command_id=15...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedBondParams, received from '56': 5A 00 16 00 01 0F 01 01 01 02 01 01 04 01 02 05 02 00 FE 09 04 00 00 00 A4 4C BB
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=15, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('01')), TLV(tag=2, value=bytes.fromhex('01')), TLV(tag=4, value=bytes.fromhex('02')), TLV(tag=5, value=bytes.fromhex('00 FE')), TLV(tag=9, value=bytes.fromhex('00 00 00 A4'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:huawei.protocol:Checking function or bound method input: Command(tlvs=[TLV(tag=1, value=bytes.fromhex('01')), TLV(tag=2, value=bytes.fromhex('01')), TLV(tag=4, value=bytes.fromhex('02')), TLV(tag=5, value=bytes.fromhex('00 FE')), TLV(tag=9, value=bytes.fromhex('00 00 00 A4'))])...
INFO:huawei.services.device_config:Negotiated bond params: 1, 1, 2, 254, 164
DEBUG:__main__:Response processed, attained requested state: BandState.ReceivedBondParams
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=14, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('')), TLV(tag=3, value=bytes.fromhex('00')), TLV(tag=5, value=bytes.fromhex('44 38 41 43 33 36')), TLV(tag=6, value=bytes.fromhex('8D 0B 1E 9C 2B 13 92 97 63 35 A0 5F 09 7E C9 FD 3F 10 11 8C E5 9D 9C CD 7A 3A 81 2B 73 B9 B6 39')), TLV(tag=7, value=bytes.fromhex('10 E4 60 4D A0 C8 FA B4 DD F2 06 C9 00 00 00 A5'))]))
DEBUG:__main__:Current state: BandState.ReceivedBondParams, target state: BandState.RequestedBond, sending: 5A 00 44 00 01 0E 01 00 03 01 00 05 06 44 38 41 43 33 36 06 20 8D 0B 1E 9C 2B 13 92 97 63 35 A0 5F 09 7E C9 FD 3F 10 11 8C E5 9D 9C CD 7A 3A 81 2B 73 B9 B6 39 07 10 10 E4 60 4D A0 C8 FA B4 DD F2 06 C9 00 00 00 A5 C5 11
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00D\x00\x01\x0e\x01\x00\x03\x01\x00\x05\x06D8AC36\x06 \x8d\x0b\x1e\x9c+\x13\x92\x97c5\xa0_\t~\xc9\xfd?\x10\x11\x8c\xe5\x9d\x9c\xcdz:\x81+s\xb9\xb69\x07\x10\x10\xe4`M\xa0\xc8\xfa\xb4\xdd\xf2\x06\xc9\x00\x00\x00\xa5\xc5\x11')
DEBUG:__main__:Waiting for response from service_id=1, command_id=14...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedBond, received from '56': 5A 00 06 00 01 0E 02 01 01 07 E1
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=14, command=Command(tlvs=[TLV(tag=2, value=bytes.fromhex('01'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:huawei.protocol:Checking function or bound method input: Command(tlvs=[TLV(tag=2, value=bytes.fromhex('01'))])...
DEBUG:__main__:Response processed, attained requested state: BandState.ReceivedBond
INFO:__main__:Handshake completed, current state: BandState.Ready
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=7, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('BD 58 01 71 CD 9C 3A F7 50 4F 1A 16 00 00 00 A6')), TLV(tag=126, value=bytes.fromhex('70 D5 D1 72 28 C8 9D 79 3A 20 29 7F A2 66 22 66 8B D9 71 C2 B9 B1 FC A4 E2 96 9A B8 3C 33 26 1F'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 3A 00 01 07 7C 01 01 7D 10 BD 58 01 71 CD 9C 3A F7 50 4F 1A 16 00 00 00 A6 7E 20 70 D5 D1 72 28 C8 9D 79 3A 20 29 7F A2 66 22 66 8B D9 71 C2 B9 B1 FC A4 E2 96 9A B8 3C 33 26 1F 7A 2B
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00:\x00\x01\x07|\x01\x01}\x10\xbdX\x01q\xcd\x9c:\xf7PO\x1a\x16\x00\x00\x00\xa6~ p\xd5\xd1r(\xc8\x9dy: )\x7f\xa2f"f\x8b\xd9q\xc2\xb9\xb1\xfc\xa4\xe2\x96\x9a\xb8<3&\x1fz+')
DEBUG:__main__:Waiting for response from service_id=1, command_id=7...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 51 00 01 07 01 06 31 2E 32 2E 34 33 02 01 0F 03 02 4E 41 04 02 4E 41 05 11 36 43 3A 42 37 3A 34 39 3A 35 39 3A 44 42 3A 36 45 06 02 4E 41 07 06 31 2E 32 2E 34 33 08 00 09 10 36 35 50 37 4E 31 37 43 31 31 30 30 30 32 38 35 0A 04 45 72 69 73 0B 00 76 60
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=7, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('31 2E 32 2E 34 33')), TLV(tag=2, value=bytes.fromhex('0F')), TLV(tag=3, value=bytes.fromhex('4E 41')), TLV(tag=4, value=bytes.fromhex('4E 41')), TLV(tag=5, value=bytes.fromhex('36 43 3A 42 37 3A 34 39 3A 35 39 3A 44 42 3A 36 45')), TLV(tag=6, value=bytes.fromhex('4E 41')), TLV(tag=7, value=bytes.fromhex('31 2E 32 2E 34 33')), TLV(tag=8, value=bytes.fromhex('')), TLV(tag=9, value=bytes.fromhex('36 35 50 37 4E 31 37 43 31 31 30 30 30 32 38 35')), TLV(tag=10, value=bytes.fromhex('45 72 69 73')), TLV(tag=11, value=bytes.fromhex(''))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
INFO:__main__:Command(tlvs=[TLV(tag=1, value=bytes.fromhex('31 2E 32 2E 34 33')), TLV(tag=2, value=bytes.fromhex('0F')), TLV(tag=3, value=bytes.fromhex('4E 41')), TLV(tag=4, value=bytes.fromhex('4E 41')), TLV(tag=5, value=bytes.fromhex('36 43 3A 42 37 3A 34 39 3A 35 39 3A 44 42 3A 36 45')), TLV(tag=6, value=bytes.fromhex('4E 41')), TLV(tag=7, value=bytes.fromhex('31 2E 32 2E 34 33')), TLV(tag=8, value=bytes.fromhex('')), TLV(tag=9, value=bytes.fromhex('36 35 50 37 4E 31 37 43 31 31 30 30 30 32 38 35')), TLV(tag=10, value=bytes.fromhex('45 72 69 73')), TLV(tag=11, value=bytes.fromhex(''))])
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=8, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('7B 13 81 50 A6 5C 6E 0A 73 9C 04 89 00 00 00 A7')), TLV(tag=126, value=bytes.fromhex('0A 36 A4 73 9B 96 E0 E9 26 7D 41 73 D8 01 F1 3B'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 08 7C 01 01 7D 10 7B 13 81 50 A6 5C 6E 0A 73 9C 04 89 00 00 00 A7 7E 10 0A 36 A4 73 9B 96 E0 E9 26 7D 41 73 D8 01 F1 3B 93 06
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\x08|\x01\x01}\x10{\x13\x81P\xa6\\n\ns\x9c\x04\x89\x00\x00\x00\xa7~\x10\n6\xa4s\x9b\x96\xe0\xe9&}As\xd8\x01\xf1;\x93\x06')
DEBUG:__main__:Waiting for response from service_id=1, command_id=8...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 06 00 01 08 01 01 46 41 0B
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=8, command=Command(tlvs=[TLV(tag=1, value=bytes.fromhex('46'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:huawei.protocol:Checking function or bound method input: Command(tlvs=[TLV(tag=1, value=bytes.fromhex('46'))])...
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
INFO:__main__:Battery level: 70
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=26, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('47 23 72 E9 04 FA 81 9E 33 53 B2 9A 00 00 00 A8')), TLV(tag=126, value=bytes.fromhex('AA D1 1C 1A 2E DD A4 C2 F0 E3 C5 35 5A 3A 4E 4E'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 1A 7C 01 01 7D 10 47 23 72 E9 04 FA 81 9E 33 53 B2 9A 00 00 00 A8 7E 10 AA D1 1C 1A 2E DD A4 C2 F0 E3 C5 35 5A 3A 4E 4E B0 8A
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\x1a|\x01\x01}\x10G#r\xe9\x04\xfa\x81\x9e3S\xb2\x9a\x00\x00\x00\xa8~\x10\xaa\xd1\x1c\x1a.\xdd\xa4\xc2\xf0\xe3\xc55Z:NN\xb0\x8a')
DEBUG:__main__:Waiting for response from service_id=1, command_id=26...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 01 1A 7F 04 00 01 86 A0 6B C7
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=26, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=9, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('D9 24 2A E0 46 8E C3 C5 B5 DA 92 74 00 00 00 A9')), TLV(tag=126, value=bytes.fromhex('B4 08 D8 D5 40 93 AF 32 FB 0C 17 D3 A3 3E 32 C2'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 09 7C 01 01 7D 10 D9 24 2A E0 46 8E C3 C5 B5 DA 92 74 00 00 00 A9 7E 10 B4 08 D8 D5 40 93 AF 32 FB 0C 17 D3 A3 3E 32 C2 04 8E
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\t|\x01\x01}\x10\xd9$*\xe0F\x8e\xc3\xc5\xb5\xda\x92t\x00\x00\x00\xa9~\x10\xb4\x08\xd8\xd5@\x93\xaf2\xfb\x0c\x17\xd3\xa3>2\xc2\x04\x8e')
DEBUG:__main__:Waiting for response from service_id=1, command_id=9...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 01 09 7F 04 00 01 86 A0 84 3E
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=9, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=27, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('7A F3 F1 2C 54 D8 82 88 41 8A CE F5 00 00 00 AA')), TLV(tag=126, value=bytes.fromhex('0C B1 DA 07 FB 50 AD CB F9 52 3E AC 69 B9 88 92'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 1B 7C 01 01 7D 10 7A F3 F1 2C 54 D8 82 88 41 8A CE F5 00 00 00 AA 7E 10 0C B1 DA 07 FB 50 AD CB F9 52 3E AC 69 B9 88 92 AB 1F
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\x1b|\x01\x01}\x10z\xf3\xf1,T\xd8\x82\x88A\x8a\xce\xf5\x00\x00\x00\xaa~\x10\x0c\xb1\xda\x07\xfbP\xad\xcb\xf9R>\xaci\xb9\x88\x92\xab\x1f')
DEBUG:__main__:Waiting for response from service_id=1, command_id=27...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 01 1B 7F 04 00 01 86 A0 D3 A6
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=27, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=5, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('BE DD 14 43 5D AB ED 5B EF CC A5 DB 00 00 00 AB')), TLV(tag=126, value=bytes.fromhex('5E 58 01 2C B2 4E AE 0A 09 FF 82 CB DE 62 11 2F'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 05 7C 01 01 7D 10 BE DD 14 43 5D AB ED 5B EF CC A5 DB 00 00 00 AB 7E 10 5E 58 01 2C B2 4E AE 0A 09 FF 82 CB DE 62 11 2F 2C 39
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\x05|\x01\x01}\x10\xbe\xdd\x14C]\xab\xed[\xef\xcc\xa5\xdb\x00\x00\x00\xab~\x10^X\x01,\xb2N\xae\n\t\xff\x82\xcb\xdeb\x11/,9')
DEBUG:__main__:Waiting for response from service_id=1, command_id=5...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 01 05 7F 04 00 01 86 A0 D6 55
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=5, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:__main__:Request packet: Packet(service_id=12, command_id=1, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('BC 98 9E F5 6F 0C 7F 03 15 FE 36 59 00 00 00 AC')), TLV(tag=126, value=bytes.fromhex('4F A2 07 22 6B E1 50 E6 40 9F 8D C3 2F 6E A1 DC'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 0C 01 7C 01 01 7D 10 BC 98 9E F5 6F 0C 7F 03 15 FE 36 59 00 00 00 AC 7E 10 4F A2 07 22 6B E1 50 E6 40 9F 8D C3 2F 6E A1 DC 6B 53
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x0c\x01|\x01\x01}\x10\xbc\x98\x9e\xf5o\x0c\x7f\x03\x15\xfe6Y\x00\x00\x00\xac~\x10O\xa2\x07"k\xe1P\xe6@\x9f\x8d\xc3/n\xa1\xdckS')
DEBUG:__main__:Waiting for response from service_id=12, command_id=1...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 0C 01 7F 04 00 01 86 A0 41 F7
DEBUG:__main__:Parsed response packet: Packet(service_id=12, command_id=1, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:__main__:Request packet: Packet(service_id=1, command_id=4, command=Command(tlvs=[TLV(tag=124, value=bytes.fromhex('01')), TLV(tag=125, value=bytes.fromhex('C6 20 C7 09 36 F6 38 EC D9 93 BC 30 00 00 00 AD')), TLV(tag=126, value=bytes.fromhex('1C 9B E8 42 B9 40 62 1C EC E1 A4 D4 C8 74 05 17'))]))
DEBUG:__main__:Current state: BandState.Ready, target state: BandState.RequestedAck, sending: 5A 00 2A 00 01 04 7C 01 01 7D 10 C6 20 C7 09 36 F6 38 EC D9 93 BC 30 00 00 00 AD 7E 10 1C 9B E8 42 B9 40 62 1C EC E1 A4 D4 C8 74 05 17 7D ED
DEBUG:bleak.backends.corebluetooth.client:Write Characteristic 0000fe01-0000-1000-8000-00805f9b34fb : bytearray(b'Z\x00*\x00\x01\x04|\x01\x01}\x10\xc6 \xc7\t6\xf68\xec\xd9\x93\xbc0\x00\x00\x00\xad~\x10\x1c\x9b\xe8B\xb9@b\x1c\xec\xe1\xa4\xd4\xc8t\x05\x17}\xed')
DEBUG:__main__:Waiting for response from service_id=1, command_id=4...
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:peripheral_didUpdateValueForCharacteristic_error_
DEBUG:__main__:Current state: BandState.RequestedAck, received from '56': 5A 00 09 00 01 04 7F 04 00 01 86 A0 6E 34
DEBUG:__main__:Parsed response packet: Packet(service_id=1, command_id=4, command=Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))]))
DEBUG:bleak.backends.corebluetooth.PeripheralDelegate:Read characteristic value
DEBUG:__main__:Response processed, attained requested state: BandState.Ready
DEBUG:huawei.protocol:Checking coroutine result: Command(tlvs=[TLV(tag=127, value=bytes.fromhex('00 01 86 A0'))])...
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDisconnectPeripheral_error_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Peripheral Device disconnected!
DEBUG:bleak.backends.corebluetooth.client:Received disconnection callback...
INFO:__main__:Stopped notifications, current state: BandState.Disconnected

@tuxuser
Copy link

tuxuser commented Sep 21, 2021

Error 1

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:bleak.backends.bluezdbus.client:Connecting to device @ 1C:1F:F1:88:83:81 with hci0
DEBUG:bleak.backends.bluezdbus.scanner:cached devices: {'/org/bluez/hci0/dev_1C_1F_F1_88_83_81': {'Address': '1C:1F:F1:88:83:81', 'AddressType': 'public', 'Name': 'HUAWEI Band 6-371', 'Alias': 'HUAWEI Band 6-371', 'Paired': True, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {637: b'\x01\x03\x00\xff\xff'}, 'ServiceData': {'00003802-0000-1000-8000-00805f9b34fb': b'\x1c\x1f\xf1\x95sq', '0000fdee-0000-1000-8000-00805f9b34fb': b'\x01\x01\x01\x10\r\x11\xf8\x12M0A0'}, 'ServicesResolved': False}}
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F4:92:BF:84:75:7E)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Alias': <dbus_next.signature.Variant ('s', F4-92-BF-84-75-7E)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -71)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['d83b80e3-e81f-4f66-879b-779be5f6a693'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000252a-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\xf4\x92\xbf\x84uw')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -67)>, 'TxPower': <dbus_next.signature.Variant ('n', 4)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'00003802-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\x1c\x1f\xf1\x95sq')>, '0000fdee-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\x01\x01\x01\x10\x0e\x11\xf8\x12M0A0')>})>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F4_92_BF_84_75_7E): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {}, ['TxPower', 'RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'Connected': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.client:_remove_signal_handlers(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:_disconnect_message_bus(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
Traceback (most recent call last):
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 344, in <module>
    main()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 338, in main
    event_loop.run_until_complete(run(config[DEVICE_NAME], event_loop))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 275, in run
    async with BleakClient(device_mac if platform.system() != "Darwin" else device_uuid, loop=loop) as client:
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/client.py", line 61, in __aenter__
    await self.connect()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 298, in connect
    assert_reply(reply)
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort

Error 2

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:bleak.backends.bluezdbus.client:Connecting to device @ 1C:1F:F1:88:83:81 with hci0
DEBUG:bleak.backends.bluezdbus.scanner:cached devices: {'/org/bluez/hci0/dev_1C_1F_F1_88_83_81': {'Address': '1C:1F:F1:88:83:81', 'AddressType': 'public', 'Name': 'HUAWEI Band 6-371', 'Alias': 'HUAWEI Band 6-371', 'Paired': True, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {637: b'\x01\x03\x00\xff\xff'}, 'ServiceData': {'00003802-0000-1000-8000-00805f9b34fb': b'\x1c\x1f\xf1\x95sq', '0000fdee-0000-1000-8000-00805f9b34fb': b'\x01\x01\x01\x10\x0e\x11\xf8\x12M0A0'}, 'ServicesResolved': False}}
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_6A_DB_0E_92_65_F2', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', 6A:DB:0E:92:65:F2)>, 'AddressType': <dbus_next.signature.Variant ('s', random)>, 'Alias': <dbus_next.signature.Variant ('s', 6A-DB-0E-92-65-F2)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -93)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fd6f-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000fd6f-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\x98\xf0\xee\xde\x06q\x7fv\x89\x11=T\x942\x90\x8f\x8fX\xe3\xa4')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F4:92:BF:84:75:7E)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Alias': <dbus_next.signature.Variant ('s', F4-92-BF-84-75-7E)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -69)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['d83b80e3-e81f-4f66-879b-779be5f6a693'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000252a-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\xf4\x92\xbf\x84uw')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -57)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_44_D2_FB_A0_97_A4', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', 44:D2:FB:A0:97:A4)>, 'AddressType': <dbus_next.signature.Variant ('s', random)>, 'Alias': <dbus_next.signature.Variant ('s', 44-D2-FB-A0-97-A4)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -70)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fd6f-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000fd6f-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\xd9R3\xf8\xc1>\xd7dS\xe7I\xd4~\xc2I\xf6n\xdb\xbc\xa4')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_6A_DB_0E_92_65_F2): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_6A_DB_0E_92_65_F2', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F4_92_BF_84_75_7E): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_44_D2_FB_A0_97_A4): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_44_D2_FB_A0_97_A4', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'Connected': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Connection successful (/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:Waiting for ServicesResolved (/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:_remove_signal_handlers(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:_disconnect_message_bus(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/locks.py", line 226, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 344, in <module>
    main()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 338, in main
    event_loop.run_until_complete(run(config[DEVICE_NAME], event_loop))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 275, in run
    async with BleakClient(device_mac if platform.system() != "Darwin" else device_uuid, loop=loop) as client:
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/client.py", line 61, in __aenter__
    await self.connect()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 337, in connect
    await self.get_services()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 648, in get_services
    await asyncio.wait_for(self._services_resolved_event.wait(), 5)
  File "/usr/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<BleakClientBlueZDBus._disconnect_monitor() running at /home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py:355> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f3475d55970>()]>>

Error 3

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:bleak.backends.bluezdbus.client:Connecting to device @ 1C:1F:F1:88:83:81 with hci0
DEBUG:bleak.backends.bluezdbus.scanner:cached devices: {'/org/bluez/hci0/dev_1C_1F_F1_88_83_81': {'Address': '1C:1F:F1:88:83:81', 'AddressType': 'public', 'Name': 'HUAWEI Band 6-371', 'Alias': 'HUAWEI Band 6-371', 'Paired': True, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': True, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {637: b'\x01\x03\x00\xff\xff'}, 'ServiceData': {'00003802-0000-1000-8000-00805f9b34fb': b'\x1c\x1f\xf1\x95sq', '0000fdee-0000-1000-8000-00805f9b34fb': b'\x01\x01\x01\x10\x0e\x11\xf8\x12M0A0'}, 'ServicesResolved': False}}
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F4:92:BF:84:75:7E)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Name': <dbus_next.signature.Variant ('s', UDM)>, 'Alias': <dbus_next.signature.Variant ('s', UDM)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -60)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['d83b80e3-e81f-4f66-879b-779be5f6a693'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000252a-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\xf4\x92\xbf\x84uw')>, '00002018-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\x7f\x00\x00\x01')>, '00002119-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b"\x00\tW'")>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_6A_DB_0E_92_65_F2', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', 6A:DB:0E:92:65:F2)>, 'AddressType': <dbus_next.signature.Variant ('s', random)>, 'Alias': <dbus_next.signature.Variant ('s', 6A-DB-0E-92-65-F2)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -87)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fd6f-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000fd6f-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\x98\xf0\xee\xde\x06q\x7fv\x89\x11=T\x942\x90\x8f\x8fX\xe3\xa4')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_6A_DB_0E_92_65_F2): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -93)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_44_D2_FB_A0_97_A4', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', 44:D2:FB:A0:97:A4)>, 'AddressType': <dbus_next.signature.Variant ('s', random)>, 'Alias': <dbus_next.signature.Variant ('s', 44-D2-FB-A0-97-A4)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -68)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fd6f-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ServiceData': <dbus_next.signature.Variant ('a{sv}', {'0000fd6f-0000-1000-8000-00805f9b34fb': <dbus_next.signature.Variant ('ay', b'\xd9R3\xf8\xc1>\xd7dS\xe7I\xd4~\xc2I\xf6n\xdb\xbc\xa4')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_44_D2_FB_A0_97_A4): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -72)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F4_92_BF_84_75_7E): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_F4_92_BF_84_75_7E', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_6A_DB_0E_92_65_F2): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_6A_DB_0E_92_65_F2', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_44_D2_FB_A0_97_A4): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_44_D2_FB_A0_97_A4', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Connection successful (/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py:135: FutureWarning: is_connected has been changed to a property. Calling it as an async method will be removed in a future version
  if not await self.client.is_connected():
DEBUG:bleak.backends.bluezdbus.client:Disconnecting (/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_1C_1F_F1_88_83_81): ['org.bluez.Device1', {'Connected': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Device disconnected (/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:_remove_signal_handlers(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
DEBUG:bleak.backends.bluezdbus.client:_disconnect_message_bus(/org/bluez/hci0/dev_1C_1F_F1_88_83_81)
Traceback (most recent call last):
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 344, in <module>
    main()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 338, in main
    event_loop.run_until_complete(run(config[DEVICE_NAME], event_loop))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 278, in run
    await band.connect()
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/band_lpv2.py", line 137, in connect
    await self.client.start_notify(GATT_READ, self._receive_data)
  File "/home/e99/Development/personal/huawei_band/huawei-lpv2/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 971, in start_notify
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 0000fe02-0000-1000-8000-00805f9b34fb could not be found!

@zyv
Copy link

zyv commented Sep 21, 2021

@tuxuser are you able to communicate with any BLE devices at all? Your error messages do not seem to have anything to do with the project.

@psolyca
Copy link
Author

psolyca commented Sep 21, 2021

Error 2 is usually the result of a previous script not completed (Error 1) as I have found yesterday, so when you have this message, restart BT communication.
Error 3, I never had this one. I hope they did not change GATT characteristics !!
@zyv as you are here, what was your process before using band-lpv2.py script ? Is this bluetoothctl commands as described here

@zyv
Copy link

zyv commented Sep 21, 2021

Hi @psolyca , yes I’m getting new comment notifications per email :-) just read about your achievements in GB thread - thank you very much for the update and congratulations for re-cracking the protocol, this is really some great work! I hope that one day I will get time to steal your code and integrate it in my repository - right now I’m using my Band Pro 4 with HH and it sucks…

Regarding my procedure, I’m sorry to disappoint you, but I have never tried it under Linux - I did my best to write compatible code, but my development platform was a Mac. So for me everything worked out of the box - bleak wraps Apple Core Bluetooth framework, so you don’t even need to pair - just run the discovery, select device UUID and communicate with it directly. I also didn’t use WireShark, because I reverse engineered the protocol by reading the decompiled HH code and trying to talk to the band. So I never had to actually run HH (didn’t even know what it looks like back then) and extract bonding keys & so on…

@psolyca
Copy link
Author

psolyca commented Sep 21, 2021

Ok
For your information, these previous error are from a Band 6.
I have a log from Android. It seems that Characteristic with UUID 0000fe02-0000-1000-8000-00805f9b34fb could not be found! is in the log so I do not know why it is not found.
Moreover, frames are 256 bits (32 bytes) long max so maybe something to check !

EDIT : Found the 32 bytes size, BLE 4.1 of the phone is limited. 256 bytes has been introduced in 4.2 BLE.

@zyv
Copy link

zyv commented Sep 22, 2021

I would suggest the Band 6 user to scan his device for services and characteristics, sample code is here:

hbldh/bleak#58

Maybe this way you can quickly learn something new. In addition to that, you can decompile HH supporting Band 6 and look at the connection routines. If something has changed, you will be able to see it there, and the new characteristics must be hard coded in the app. The functions you have to search for are in Android BLE framework documentation.

@psolyca
Copy link
Author

psolyca commented Sep 22, 2021

Thanks.
Logging the bluetooth and parsing it seems to work.
It seems also that some crypted commands are sent before the key is retrieved ^^;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment