简体   繁体   中英

BluetoothGatt showing 10,000 identical characteristics for service

I've got a problem that I'm completely flummoxed about, mostly because of how persistent it is.

I was writing a small Android app to communicate with my Bluegiga BLE113. I've connected to this device before, but I'd recently made a GATT modification that was not being reflected on the Android device (in none of the apps I tried - and I verified from a desktop and iOS app that my GATT was updated as expected).

I tried turning off/on Bluetooth and restarting my Nexus 7, and still nothing. Finally, I got desperate and tried the solution mentioned here: https://stackoverflow.com/a/22709467/992509 which uses reflection to hit a private BluetoothGatt method called refresh.

It seemed to work perfectly, as my new service was showing up, however, what I ran into was that my service (with only 1 characteristic) was showing a few hundred characteristics with the same UUID. The number of identical characteristics climbed everytime I ran my app, and even through device restarts and BT cycling.

Finally, I got desperate and did a factory reset on my Nexus (it's a test device, so I don't care). Didn't fix a thing, and this image shows what I'm seeing (10k characteristics):

BluetoothGatt具有10k特性

My BLE113 GATT looks like this:

<service uuid="deadbeef-cdcd-cdcd-cdcd-cdcdcdcdcdcd">
    <description>Debugging Service</description>
    <characteristic uuid="deadbeef-0000-0000-0000-000000000000" id="xgatt_debug">
        <description>Debugging output</description>
        <properties read="true" notify="true" />
        <value length="20" />
    </characteristic>
</service>

The Android code is basically just a BluetoothGatt.discoverServices() (that's the first time I see this happen).

And again, I have tried resetting BT, restarting my Nexus, and doing a factory reset. Also, I've confirmed that my BLE peripheral works exactly as expected via a desktop app and iOS.

I'm on a Nexus 7, running 5.0.2, and targeting 4.4 in my app.

You are implementing a hack in order to call a method that was not made publicly available. You don't know what modifications have been made to that method for you customized firmware.

The hack worked for some (as in the Q&A you showed), but cannot be guaranteed to work everywhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM