android ble蓝牙接收不到数据_android BLE 40 setCharacteristicNotification接收不到数据

参考连接:http://www.codes51.com/article/detail_4021799.html

问题描述 最近在开发android BLE  读写数据

但是向设备写数据很顺利,但是在接收设备传来的数据时,死活接收不到.

/**

* Enables or disables notification on a give characteristic.

*

* @param characteristic Characteristic to act on.

* @param enabled If true, enable notification. False otherwise.

*/

public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,

boolean enabled) {

if (mBluetoothAdapter == null || mBluetoothGatt == null) {

Log.w(TAG, "BluetoothAdapter not initialized");

return;

}

mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);

}

上面这样写 是收不到数据的 ,主要是少加了mBluetoothGatt.writeDescriptor(descriptor);

下面是修改后的代码

/**

* Enables or disables notification on a give character

你可能感兴趣的:(android,ble蓝牙接收不到数据)