gpt4 book ai didi

android - 设备 GattServer 连接后停止广播

转载 作者:行者123 更新时间:2023-11-29 19:04:50 25 4
gpt4 key购买 nike

这是 GitHub 上 Android Things 的 GATT 服务器示例的链接:

https://github.com/androidthings/sample-bluetooth-le-gattserver

在 RPi-3 上设置服务器非常简单。

我不明白的是,为什么 GATT 服务器会在您连接到设备然后断开连接(BLE 连接)后停止广播。

...gattserver I/GattServerActivity: BluetoothDevice CONNECTED: 67:2F:1A:B4:1F:86
...gattserver D/BluetoothGattServer: onConnectionUpdated() - Device=67:2F:1A:B4:1F:86 interval=6 latency=0 timeout=2000 status=0
...gattserver D/BluetoothGattServer: onConnectionUpdated() - Device=67:2F:1A:B4:1F:86 interval=39 latency=0 timeout=2000 status=0
...gattserver I/GattServerActivity: Read CurrentTime
...gattserver I/GattServerActivity: Read CurrentTime
...gattserver I/GattServerActivity: Read CurrentTime
...gattserver I/GattServerActivity: Read CurrentTime
...gattserver I/GattServerActivity: Read CurrentTime
...gattserver D/GattServerActivity: Config descriptor read
...gattserver I/GattServerActivity: Read LocalTimeInfo
...gattserver D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=67:2F:1A:B4:1F:86
...gattserver I/GattServerActivity: BluetoothDevice DISCONNECTED: 67:2F:1A:B4:1F:86
...gattserver I/GattServerActivity: No subscribers registered

以上是设备的 LogCat 中显示的内容。第一行显示我的手机能够连接到设备。(使用这个免费且优秀的应用程序:https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp)

连接后我可以读取它的特征(读取 CurrentType、读取 LocalTimeInfo 等)

当断开电话/应用程序与设备的连接时,GattServerActivity 声明我优雅地断开连接并继续运行...

但是再次尝试从手机/应用程序中扫描设备会发现 RPi 上的 GATT 服务器已经变成僵尸...

LogCat 中没有错误(不在应用程序中,不在系统中)...

有什么想法吗?

最佳答案

问题似乎是 GATT 服务器在断开连接时不会再次开始广告?您应该能够添加一个新行 here重新开始转换广告。

关于android - 设备 GattServer 连接后停止广播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47676988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com