I have the BleFindMeClient working on the HTC 1X+ in conjunction with the TI Mini Keyfob. I'm trying to extend it slightly to read the battery level (not register for battery updates). I can do it from the BTool, but my Android prog fails, and I get the debug message:
getCharacteristic - Service data not found
What does this mean? And where would I find out what this and other error messages mean?
Clearly I can write characteristics because I can set the alarm. But there is something rather basic that I have not grasped about reading characteristics, but I can't find example code.
Could someone throw me a better code fragment please, or spot something dumb in the following?
public class BatteryProfileClient extends BleClientProfile {
private static String TAG = "BatteryProfileClient";
static public BleGattID myUuid = new BleGattID("0000180f-0000-1000-8000-00805f9b34fb");
private static final BleGattID BATTERY_CHARACTERISTIC = new BleGattID("00002a19-0000-1000-8000-00805f9b34fb");
private BatteryServiceClient mBatteryServiceClient = new BatteryServiceClient();
public BatteryProfileClient(Context context) {
super(context, myUuid);
Log.d(TAG, "Instantiated");
ArrayList<BleClientService> services = new ArrayList<BleClientService>();
services.add(mBatteryServiceClient);
init(services, null);
}
public void batt(BluetoothDevice device) {
BleCharacteristic battLevelCharacteristic = mBatteryServiceClient.getCharacteristic(device, BATTERY_CHARACTERISTIC);
byte b[] = battLevelCharacteristic.getValue();
Log.d(TAG, "battery " + b);
}
}