首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android蓝牙GATT timetout with Nordic Thingy:52

Android蓝牙GATT timetout with Nordic Thingy:52
EN

Stack Overflow用户
提问于 2020-04-02 19:54:59
回答 1查看 38关注 0票数 0

我有一个安卓应用程序,通过库(Thingylib)连接到thingy52后:

代码语言:javascript
复制
BluetoothDevice dev = scanResultList.get(nordicDeviceEntityList.get(pos).getAddress());
thingySdkManager.connectToThingy(getContext(), device, BaseTService.class);

我想要读取北欧thingy:52数据和RSSI值,因此在另一个活动中,当我想要收集数据时,我附加了一个新的蓝牙GATT:

代码语言:javascript
复制
private void startDataCollection() {
        for (BluetoothDevice dev : thingySdkManager.getConnectedDevices()){
            thingySdkManager.setConstantLedMode(dev, 1, 100, 1);
            ThingyListenerHelper.registerThingyListener(getApplicationContext(), mThingyListener, dev);
            //e vents
            thingySdkManager.enableMotionNotifications(dev, true);

            gatt = dev.connectGatt(getApplicationContext(), true, gattCallback);
        }
}

之后,在thingylib的Accellerometer事件回调中,我获取数据并调用GATT来检索RSSI值:

代码语言:javascript
复制
@Override
        public void onAccelerometerValueChangedEvent(BluetoothDevice bluetoothDevice, float x, float y, float z) {
            gatt.readRemoteRssi();
        }

我发现的问题是,几秒钟后(不确定,有时是5/10s),设备断开连接,GATT上出现错误8(超时错误)。如果我在收集数据之前删除GATT链接,设备不会断开连接,并且工作正常。我想知道是否有一种方法可以防止连接的GATT超时或我做错了什么。

我的android日志:

代码语言:javascript
复制
2020-04-02 13:00:16.607 15336-15396/it.chiarani.beacon_detection D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=9 device=F5:EF:EE:8B:92:7C
2020-04-02 13:00:16.609 15336-15380/it.chiarani.beacon_detection D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=F5:EF:EE:8B:92:7C
2020-04-02 13:00:16.609 15336-15654/it.chiarani.beacon_detection D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=10 device=F5:EF:EE:8B:92:7C
2020-04-02 13:00:16.610 15336-15654/it.chiarani.beacon_detection V/ThingyConnection: Error 8 : F5:EF:EE:8B:92:7C
2020-04-02 13:00:16.611 15336-15654/it.chiarani.beacon_detection D/BluetoothGatt: close()
2020-04-02 13:00:16.611 15336-15654/it.chiarani.beacon_detection D/BluetoothGatt: unregisterApp() - mClientIf=10
2020-04-02 13:00:16.670 15336-15336/it.chiarani.beacon_detection V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-16 19:38:11

问题似乎出在设备的固件方面,就像github问题所指出的那样:https://github.com/NordicSemiconductor/Android-Nordic-Thingy/issues/22

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60990978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档