fix(ble): read ESPHome proxy pre-decoded GATT uuid (#229)#234
Merged
Conversation
@2colors/esphome-native-api 1.3.6 runs every message through mapMessageByType(), which for BluetoothGATTGetServicesResponse strips the raw uuidList uint64 pair off each service/characteristic and replaces it with a pre-decoded `uuid` string. The Phase 2 GATT bridge still read `ch.uuidList`, so esphomeUuidToString() ran `.length` on undefined and threw "Cannot read properties of undefined (reading 'length')" right after a successful connect and service discovery, aborting every GATT read over the proxy. Resolve the characteristic UUID from the library's `uuid` string, keeping the uuidList [high, low] decoder as a fallback for other library versions, and skip any characteristic whose UUID cannot be resolved instead of crashing the whole session. esphomeUuidToString() now returns '' for a missing/empty list rather than throwing. The previous test fixture invented a uuidList shape that matched neither the real library nor raw google-protobuf, so CI was green while real hardware crashed. The fixture now mirrors the actual 1.3.6 output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#229 ESPHome proxy GATT crash:
Cannot read properties of undefined (reading 'length')Root cause
@2colors/esphome-native-api1.3.6 passes every message throughmapMessageByType(). ForBluetoothGATTGetServicesResponseit strips the rawuuidListuint64 pair off each service/characteristic and replaces it with a pre-decodeduuidstring. The Phase 2 GATT bridge still readch.uuidList(nowundefined) and passed it toesphomeUuidToString(), which ran.lengthon undefined and threw, aborting every GATT read over the proxy right after a successful connect + service discovery.Why CI missed it
The old test fixture invented a
uuidListshape that matched neither the real library nor raw google-protobuf, so it only exercised an imaginary contract. Green CI, crashing hardware. This was the first real-HW test of the GATT path.Fix
uuidstring; keep theuuidList[high, low]decoder as a fallback for other library versions.esphomeUuidToString()returns''for a missing/empty list rather than throwing.No adapter changes. 1630 tests green, lint/tsc/prettier clean.
Closes nothing yet on purpose: stays open until the reporter confirms on the Beurer BF788.