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
  • Hi,

    You have to send a read request to the remote characteristic to fetch its latest value. This is done with the readCharacteristic (BluetoothGattCharacteristic characteristic) API call in Android. The operation will then call onCharacteristicRead once the remote value is read. Please refer to the documentation for BluetoothGatt [0].

    This, and more, is also explained in the Android BLE tutorial at [1]. If you familiarize yourself with everything on that single page, I think that will clear up a few things for you.

    [0] developer.android.com/.../BluetoothGatt.html

    [1] developer.android.com/.../bluetooth-le.html

  • 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

Reply
  • 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

Children
No Data
Related