This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Writing to secure characteristic on nRF51822

I have a nRF51822 module programmed for custom service and characteristics. I am able to connect to this module using android 4.3 API. I can get characteristics and their properties.

One of my characteristics advertises as write with no response to which I am trying to write some value. Android shows that it successfully performed write operation but the module doesn't receive anything.

How do I solve this issue? Is it possible that a secure characteristic fails at module end with plain(non-encrypted) write? Do I need to change advertised value so that android understands that it is secure write requiring encryption?

Parents
  • Hi there,

    One of my characteristics advertises as write with no response to which I am trying to write some value. Android shows that it successfully performed write operation but the module doesn't receive anything.

    Android cannot really know if the characteristic was written to successfully since you used a Write Command (Write Without Response) and not a Write Request to write to it.

    Security could indeed be the problem, or maybe even permissions.

    Could you post the code you used to add the characteristic?

    That way we can take a look at what permissions and security you required.

    Regards,

    Carles

  • I used following code to write data to characteristic.

    //get services for device if(mBluetoothGatt != null) mBluetoothGattServices = mBluetoothGatt.getServices();

    //get characteristics for a service chars = service.getCharacteristics();

    //write hex data to characteristic mCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); mCharacteristic.setValue(dataToWrite); // ... and then "commit" changes to the peripheral mBluetoothGatt.writeCharacteristic(mCharacteristic);

Reply
  • I used following code to write data to characteristic.

    //get services for device if(mBluetoothGatt != null) mBluetoothGattServices = mBluetoothGatt.getServices();

    //get characteristics for a service chars = service.getCharacteristics();

    //write hex data to characteristic mCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); mCharacteristic.setValue(dataToWrite); // ... and then "commit" changes to the peripheral mBluetoothGatt.writeCharacteristic(mCharacteristic);

Children
No Data
Related