I am developing an app using BLE where i have to send some commands to peripheral device to get response. Write characteristics code is written below:
    public void writeCustomCharacteristic(String value) {
        this.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(SERVICE_UUID);
        if (mCustomService == null) {
            Log.w(TAG, "Custom BLE Service not found");
            return;
        }
        /*get the read characteristic from the service*/
        BluetoothGattCharacteristic mWriteCharacteristic = mCustomService.getCharacteristic(CHARACTERSTICS_UUID);
        mWriteCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
        mWriteCharacteristic.setValue(value.getBytes());
        if (!mBluetoothGatt.writeCharacteristic(mWriteCharacteristic)) {
            Log.w(TAG, "Failed to write characteristic");
        }
    }
And after write characteristics i got response in following method here it returns status code 14, which is not mentioned in official document as well:
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        System.out.println("BluetoothLeService.onCharacteristicWrite");
        System.out.println(BluetoothGatt.GATT_SUCCESS + " :status: " + status);            
    }
Status code 14 probably means ATT error code 14, which is defined in Bluetooth Core specification v5.0, Vol 3, Part F, section 3.4.1.1 Table 3.3.
This error code is sent from the remote device so it's most likely no error on the Android side. Error code 14 in ATT means "Unlikely Error". You need to investigate why the remote device sends this error code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With