Java writeCharacteristic始终返回false
我想从android向蓝牙设备发送数据,然后单击按钮得到响应,但总是返回false。请任何人帮帮我 ////关于DeviceControlActivity.javaJava writeCharacteristic始终返回false,java,android,bluetooth,Java,Android,Bluetooth,我想从android向蓝牙设备发送数据,然后单击按钮得到响应,但总是返回false。请任何人帮帮我 ////关于DeviceControlActivity.java public void onGetButtonStatus(View v) { if(mBluetoothLeService != null) { mBluetoothLeService.writeData("btn1?".getBytes()); } } ////关于BluetoothLeSe
public void onGetButtonStatus(View v) {
if(mBluetoothLeService != null) {
mBluetoothLeService.writeData("btn1?".getBytes());
}
}
////关于BluetoothLeService.java
public void writeData(byte[] value) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
/*check if the service is available on the device*/
BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"));
if(mCustomService == null){
Log.w(TAG, "Custom BLE Service not found");
return;
}
BluetoothGattCharacteristic mWriteCharacteristic = mCustomService.getCharacteristic(UUID.fromString("6E400003-B5A3-F393-E0A9-E50E24DCCA9E"));
mWriteCharacteristic.setValue(value);
if(mBluetoothGatt.writeCharacteristic(mWriteCharacteristic) == false){
Log.w(TAG, "Failed to write characteristic");
}
}