How can read all characteristic's value of my BLE device?

后端 未结 3 1241
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 06:10

I\'m building an app with Android Studio that can read the value from a device BLE. This device, have 4 services. The fourth services have 3 characteristic. I want to read t

3条回答
  •  鱼传尺愫
    2021-01-07 06:33

    First store your read characteristics, and ghatt objects. and if you want to read a value from characteristic call this method:

    private fun readDataFromCharacteristic(ghatt: BluetoothGhatt? , characteristic:BluetoothGhattCharacteristic) {
            Log.d(TAG, " readDataFromCharacteristic")
            ghatt?.readCharacteristic(characteristic)
        }
    

    if you call readCharacteristic(characteristic) on ghatt , below method will give result

    override fun onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) {}
    

提交回复
热议问题