ライブラリ(thingylib)を介してthingy52に接続した後、Androidアプリケーションがあります。
BluetoothDevice dev = scanResultList.get(nordicDeviceEntityList.get(pos).getAddress());
thingySdkManager.connectToThingy(getContext(), device, BaseTService.class);
北欧のthingy:52データをRSSI値と一緒に読みたいので、別のアクティビティで、データを収集するときに、新しいBluetoothGATTを添付します。
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値を取得します。
@Override
public void onAccelerometerValueChangedEvent(BluetoothDevice bluetoothDevice, float x, float y, float z) {
gatt.readRemoteRssi();
}
私が見つけた問題は、数秒後(決定論的ではなく、時には5/10秒)にデバイスがGATTのエラー8(タイムアウトエラー)で切断されることです。データを収集する前にGATTリンクを削除すると、デバイスが切断されず、完全に機能します。 接続されたGATTがタイムアウトするのを防ぐ方法があるのか、それとも何か間違ったことをしているのか知りたかったのです。
私のAndroidログ:
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
関連した質問
- 電卓アプリでDecimalFormatのエラーを解決する方法
- GPIO制御にJavaクラスを使用して、AndroidOSで実行されるアプリケーションを作成する方法
- Android(Kotlin):オブザーバーのタイプの不一致
- Androidプロジェクトで使用されるJARからのロギング
- 応答を処理するKotlinRetrofit
- 作成中のスレッドがデーモンである場合に限り、Javaスレッドはデーモンですか?
- AlertDilogからMainActivtyにデータリターンを渡します
- RectFがCanvasの境界線から外れます
- (解決済み)デフォルトのandroid RecyclerView ViewHolder NPE shouldIgnore()
このgithubの問題に示されているように、問題はデバイスのファームウェア側にあるようです:https://github.com/NordicSemiconductor/Android-Nordic-Thingy/issues/22