What are the steps to get notified by Bluetooth Low Energy (BLE) device?

后端 未结 4 914
慢半拍i
慢半拍i 2021-01-31 12:20

I am working on a Bluetooth Low Energy (BLE) app. I have a BLE device (scale) which measures weight. I am able to connect with this device. But I am not getting how to read data

4条回答
  •  故里飘歌
    2021-01-31 12:48

    Refer the source code of sample application "bluetoothlegatt" provided on developer portal.

    Sample service: http://developer.android.com/samples/BluetoothLeGatt/src/com.example.android.bluetoothlegatt/BluetoothLeService.html

    Using service: http://developer.android.com/samples/BluetoothLeGatt/src/com.example.android.bluetoothlegatt/DeviceControlActivity.html

    This example contains characteristics with read and notify properties. So you definitely find your solution. Please go to section with following code:(You may figure it out)

    public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
            if (mBluetoothAdapter == null || mBluetoothGatt == null) {
                Log.w(TAG, "BluetoothAdapter not initialized");
                return;
            }
            mBluetoothGatt.readCharacteristic(characteristic);
        }
    

提交回复
热议问题