Reading a gatt characteristic value in android studio notification

冷暖自知 提交于 2021-02-08 11:41:34

问题


I want to read a GATT characteristic value by the way of notification.

This means I need to set that characteristic to notify and then read the data.

I wish to do this in a function from an onclick.

When I run my activity the characteristics are found and added to this arraylist

private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics =
            new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

I have the UUIDs of the service and characteristic values how do I get a characteristic out of this?

What I want is something like below:


BluetoothGattCharacteristic mycharacterisic;
 mycharacterisic = mGattCharacteristics.get(1).get(1);
mBluetoothLeService.setCharacteristicNotification(mycharacterisic, true);
//output to a text box via notification

The get(1).get(1) are just random parameters I have entered. How do I do it via the UUIDs?

Thanks

来源:https://stackoverflow.com/questions/60992229/reading-a-gatt-characteristic-value-in-android-studio-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!