admin管理员组文章数量:1391947
Continuously send data 1000 times using the notify method, with an MTU of 512 and each packet being 244 bytes. The onNotificationSent callback is only received after all data has been sent, and there is an issue where status=129 occurs in the notification. At this point, the data has already been sent, making it impossible to stop at the problematic data and perform the corresponding handling. The current approach is to send one data packet using notifyCharacteristicChanged, then wait for the onNotificationSent callback to confirm success before sending the next packet. I would like to ask if there is a better approach to achieve the fastest transmission speed.
// Send 1000 times.
charForIndicate?.let {
for (device in subscribedDevices) {
for (i in 0 until 1000) {
it.value = byteArray
result = gattServer?.notifyCharacteristicChanged(device, it, false)
}
}
}
// BluetoothGattServerCallback.
override fun onNotificationSent(device: BluetoothDevice, status: Int) {
handler.post {
Log.e("CameraDirecrt", "onNotificationSent status=$status")
}
}
The error status=129 occurs when sending 1000 times.
The approach is modified to send one data packet using notifyCharacteristicChanged, and then wait for the onNotificationSent callback to confirm success before sending the next packet.
本文标签:
版权声明:本文标题:bluetooth lowenergy - Android BLE Peripheral encounters issues when continuously sending data using the notify method - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744672507a2618909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论