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

recuperate a characteristic 's value from a Nordic device

I am trying to develop an application for the Android that will communicate via BLE to a Nordic device. I'm able to read the characteristic's value by BluetoothGattCharacteristic characteristic ; final byte[] data = characteristic.getValue();

but this method returns a value that is local to the application, when the Nordic device change the value of the caracteristic , the application is not able to recuperate it ! is there any one who can help me please? I have been having troubles with this for some time .thank you

Parents Reply Children
  • thanks for your answer ulrlich but i'm sorry maybe i didn't explain my question very well, in fact i'm able to read the characteristic's value from the Nordic device, but when the device changes it , the application is no more able to read the new value . what should i do then ? My method to read the major's characteristic is

    public void readMajorCharacteristic() {

    	if (mBluetoothGatt == null)
    
    		return;
    
    	if (mMajorCharacteristic != null) 
    
    		mBluetoothGatt.readCharacteristic(mMajorCharacteristic);
    }
    

    but this method is reading the located value to the application ...

    i think it's something related to a BluetoothGattCallBack or onCharacteristicChange maybe but i'm not really sure what can it be

  • @rosa: When the characteristic changed the value locally (on the server), it's not possible for the client (the phone for example) to know that. You would need to notify the client by sending a notification from the server to the client. When the client receive the notification, you will have onCharacteristicChange callback. You can have a look at our ble_app_hrs example where we notify the heart rate measurement and the battery level.

  • @Hung Bui : the server is sending a notification to the mobile, i can verify this by the master control (using a dungle) but the application is not notified yet , i'm looking for the best function that can detect the new Major's value

  • @rosa: You can try to test with the Master Control panel app on the phone.

    I would suggest you to test and have a look at the source code of either the nRFToolbox - heart rate profile, or the nRFUART. In both apps we receive notification and display it on the app.

Related