Notifications can be received out of order on Android:https://github.com/don/cordova-plugin-ble-central/issues/625
How could i achieve maximum thread safety with a read/write BLE Gatt Characteristic? :https://stackoverflow.com/questions/38922639/how-could-i-achieve-maximum-thread-safety-with-a-read-write-ble-gatt-characteris
注1:如果是sdk27以上,可以通过在connectGatt函数中指定handler来保证所有数据回调运行在一个线程中,否则,只能通过在数据包中添加编号来解决。
注2:有可能与发起连接时所用的Handler有关,如果用主线程的Handler有可能能够避免产生数据失序的问题。
本文探讨了如何在读写蓝牙LE GATT特性时实现最大线程安全,解决Android环境下通知可能乱序的问题。对于SDK 27以上的版本,可在connectGatt函数中指定Handler确保数据回调在同一线程执行;对于低版本SDK,需在数据包中添加编号以维持顺序。使用主线程的Handler连接可能有助于避免数据失序。
7594

被折叠的 条评论
为什么被折叠?



