Reputation: 1
I'm doing my thesis on “Creating secure fitness apps”. My program connects to Mi Band 3, and I've already been able to get heart rate data. The problem arose when I tried to activate notifications for real-time steps - the error “BluetoothGattCharacteristic with the specified UUID was not found” appears. Here is the code to enable notifications for steps:
public void enableRealtimeStepsNotify() {
Log.d(TAG, "Enabling realtime steps notifications...");
this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.ENABLE_REALTIME_STEPS_NOTIFY, new ActionCallback() {
@Override
public void onSuccess(Object data) {
Log.d(TAG, "Realtime steps notifications enabled successfully.");
}
@Override
public void onFailure(int errorCode, String msg) {
Log.e(TAG, "Failed to enable realtime steps notifications. Error: " + msg);
}
});
}
public static final UUID UUID_CHAR_CONTROL_POINT = UUID.fromString("0000ff05-0000-1000-8000-00805f9b34fb");
public static final UUID UUID_CHAR_STEPS = UUID.fromString("00000007-0000-3512-2118-0009af100700");
I don't understand what the problem is, the authorization was successful, the clock does not disconnect. Maybe someone who understood this topic can advise me if I'm doing something wrong.
I tried to get the heart rate and succeeded, unlike the steps. Here is what the code looks like:
public void startHeartRateScan() {
try {
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_CONTROL, new byte[]{0x15, 0x02, 0x00}, null);
Thread.sleep(1000);
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_CONTROL, new byte[]{0x15, 0x01, 0x00}, null);
Thread.sleep(1000);
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_CHAR, new byte[]{0x01, 0x03, 0x19}, null);
Thread.sleep(1000);
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_DESCRIPTOR, new byte[]{0x01, 0x00}, null);
Thread.sleep(1000);
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_CONTROL, new byte[]{0x15, 0x01, 0x01}, null);
Thread.sleep(1000);
MiBand.this.io.writeCharacteristic(Profile.UUID_HEART_SERVICE, Profile.UUID_HEART_CHAR, new byte[]{0x02}, null);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Upvotes: 0
Views: 25