设备GattServer连接后停止播发 [英] The device GattServer stops advertising after connecting to it

查看:188
本文介绍了设备GattServer连接后停止播发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是到GitHub上Android Things的GATT Server示例的链接:

This is the link to the GATT Server sample for Android Things on GitHub:

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

设置在RPi-3上安装服务器很容易。

Setting up the server on RPi-3 is easy enough.

我不明白的是,为什么GATT服务器在连接后断开广告,然后断开与设备的连接(BLE

What I do not understand is why the GATT server stops advertising once you have connected to then disconnected from the device (BLE connect).

...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

The above is what shows in the LogCat for the device. First line shows that my phone was able to connect to the device. (using this free and excellent app: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp )

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

When connected I can read it's characteristics (Read CurrentType, Read LocalTimeInfo etc.)

当从设备上断开手机/应用程序的连接时,GattServerActivity表示我已断开连接并保持运行状态...

When disconnecting the phone/app from the device the GattServerActivity states that I disconnected with grace and keeps on running...

但是再次尝试从手机/应用程序扫描设备表明,RPi上的GATT服务器已经僵尸了。

But trying to scan for devices from the phone/app again reveals that the GATT Server on the RPi has gone zombie...

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

No errors in the LogCat (not in app, not in system)...

有没有人?

推荐答案

问题似乎是GATT服务器在断开连接后不会再次启动广告吗?您应该能够添加新行此处再次开始投放广告。

The issue seems to be that the GATT server doesn't start advertising again on disconnection? You should be able to add a new line here to start advertising again.

这篇关于设备GattServer连接后停止播发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆