I am trying to reproduce an Android app project without much Android development or Bluetooth experience. In the code, the original author collected data from two characteristics (coming from a single service) to plot them in real time. In the original code, the author uses the following code excerpt to establish the characteristics notifications and get both data.
@Override
public void onServicesDiscovered (BluetoothGatt gatt, int status){
BluetoothGattService handservice=gatt.getService(handserviceuuic);
BluetoothGattCharacteristic plethchar=handservice.getCharacteristic(handcharuuic);
BluetoothGattCharacteristic pulsechar=handservice.getCharacteristic(pulseuuic);
gatt.setCharacteristicNotification(plethchar,true);
gatt.setCharacteristicNotification(pulsechar,true);
}
@Override
public void onCharacteristicChanged (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic{
byte[] reading=characteristic.getValue();
if(startbutton.isChecked()==true){
if(characteristic.getUuid().toString().equals("ec0a883a-4d24-11e7-b114-b2f933d5fe66")){
plethprocessingfoot(reading);
}
else{
pulseprocessingfoot(reading);
}
}
}
When I apply this code on my phone, I only get notified of the first characteristic because the only UUID that gets returned by characteristic.getUuid()
is the one for the first characteristic. If I comment out the code for the first characteristic, then I can get notified on the second characteristic just fine. How can I change this code so that I get notified of both characteristics?