From 4a1904630168bdf6f0fd4995bb06134b398466fb Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Tue, 6 Dec 2016 23:47:53 +0100 Subject: [PATCH] Mi2: Some characteristics and opcodes for fw update --- .../devices/miband/MiBand2Service.java | 213 ++---------------- 1 file changed, 13 insertions(+), 200 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBand2Service.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBand2Service.java index dee0bf6f5..3681bc492 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBand2Service.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBand2Service.java @@ -13,6 +13,10 @@ public class MiBand2Service { public static final UUID UUID_SERVICE_MIBAND2_SERVICE = UUID.fromString(String.format(BASE_UUID, "FEE1")); public static final UUID UUID_SERVICE_HEART_RATE = UUID.fromString(String.format(BASE_UUID, "180D")); public static final UUID UUID_SERVICE_WEIGHT_SERVICE = UUID.fromString("00001530-0000-3512-2118-0009af100700"); + + public static final UUID UUID_CHARACTERISTIC_FIRMWARE = UUID.fromString("00001531-0000-3512-2118-0009af100700"); + public static final UUID UUID_CHARACTERISTIC_FIRMWARE_DATA = UUID.fromString("00001532-0000-3512-2118-0009af100700"); + public static final UUID UUID_UNKNOWN_CHARACTERISTIC0 = UUID.fromString("00000000-0000-3512-2118-0009af100700"); public static final UUID UUID_UNKNOWN_CHARACTERISTIC1 = UUID.fromString("00000001-0000-3512-2118-0009af100700"); public static final UUID UUID_UNKNOWN_CHARACTERISTIC2 = UUID.fromString("00000002-0000-3512-2118-0009af100700"); @@ -38,206 +42,6 @@ public class MiBand2Service { // set 12 hour time mode -// public static final UUID UUID_CHARACTERISTIC_DEVICE_INFO = UUID.fromString(String.format(BASE_UUID, "FF01")); -// -// public static final UUID UUID_CHARACTERISTIC_DEVICE_NAME = UUID.fromString(String.format(BASE_UUID, "FF02")); -// -// public static final UUID UUID_CHARACTERISTIC_NOTIFICATION = UUID.fromString(String.format(BASE_UUID, "FF03")); -// -// public static final UUID UUID_CHARACTERISTIC_USER_INFO = UUID.fromString(String.format(BASE_UUID, "FF04")); -// -// public static final UUID UUID_CHARACTERISTIC_CONTROL_POINT = UUID.fromString(String.format(BASE_UUID, "FF05")); -// -// public static final UUID UUID_CHARACTERISTIC_REALTIME_STEPS = UUID.fromString(String.format(BASE_UUID, "FF06")); -// -// public static final UUID UUID_CHARACTERISTIC_ACTIVITY_DATA = UUID.fromString(String.format(BASE_UUID, "FF07")); -// -// public static final UUID UUID_CHARACTERISTIC_FIRMWARE_DATA = UUID.fromString(String.format(BASE_UUID, "FF08")); -// -// public static final UUID UUID_CHARACTERISTIC_LE_PARAMS = UUID.fromString(String.format(BASE_UUID, "FF09")); -// -// public static final UUID UUID_CHARACTERISTIC_DATE_TIME = UUID.fromString(String.format(BASE_UUID, "FF0A")); -// -// public static final UUID UUID_CHARACTERISTIC_STATISTICS = UUID.fromString(String.format(BASE_UUID, "FF0B")); -// -// public static final UUID UUID_CHARACTERISTIC_BATTERY = UUID.fromString(String.format(BASE_UUID, "FF0C")); -// -// public static final UUID UUID_CHARACTERISTIC_TEST = UUID.fromString(String.format(BASE_UUID, "FF0D")); -// -// public static final UUID UUID_CHARACTERISTIC_SENSOR_DATA = UUID.fromString(String.format(BASE_UUID, "FF0E")); -// -// public static final UUID UUID_CHARACTERISTIC_PAIR = UUID.fromString(String.format(BASE_UUID, "FF0F")); -// -// public static final UUID UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT = UUID.fromString(String.format(BASE_UUID, "2A39")); -// public static final UUID UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT = UUID.fromString(String.format(BASE_UUID, "2A37")); -// -// -// -// /* FURTHER UUIDS that were mixed with the other params below. The base UUID for these is unknown */ -// -// public static final byte ALIAS_LEN = 0xa; -// -// /*NOTIFICATIONS: usually received on the UUID_CHARACTERISTIC_NOTIFICATION characteristic */ -// -// public static final byte NOTIFY_NORMAL = 0x0; -// -// public static final byte NOTIFY_FIRMWARE_UPDATE_FAILED = 0x1; -// -// public static final byte NOTIFY_FIRMWARE_UPDATE_SUCCESS = 0x2; -// -// public static final byte NOTIFY_CONN_PARAM_UPDATE_FAILED = 0x3; -// -// public static final byte NOTIFY_CONN_PARAM_UPDATE_SUCCESS = 0x4; -// -// public static final byte NOTIFY_AUTHENTICATION_SUCCESS = 0x5; -// -// public static final byte NOTIFY_AUTHENTICATION_FAILED = 0x6; -// -// public static final byte NOTIFY_FITNESS_GOAL_ACHIEVED = 0x7; -// -// public static final byte NOTIFY_SET_LATENCY_SUCCESS = 0x8; -// -// public static final byte NOTIFY_RESET_AUTHENTICATION_FAILED = 0x9; -// -// public static final byte NOTIFY_RESET_AUTHENTICATION_SUCCESS = 0xa; -// -// public static final byte NOTIFY_FW_CHECK_FAILED = 0xb; -// -// public static final byte NOTIFY_FW_CHECK_SUCCESS = 0xc; -// -// public static final byte NOTIFY_STATUS_MOTOR_NOTIFY = 0xd; -// -// public static final byte NOTIFY_STATUS_MOTOR_CALL = 0xe; -// -// public static final byte NOTIFY_STATUS_MOTOR_DISCONNECT = 0xf; -// -// public static final byte NOTIFY_STATUS_MOTOR_SMART_ALARM = 0x10; -// -// public static final byte NOTIFY_STATUS_MOTOR_ALARM = 0x11; -// -// public static final byte NOTIFY_STATUS_MOTOR_GOAL = 0x12; -// -// public static final byte NOTIFY_STATUS_MOTOR_AUTH = 0x13; -// -// public static final byte NOTIFY_STATUS_MOTOR_SHUTDOWN = 0x14; -// -// public static final byte NOTIFY_STATUS_MOTOR_AUTH_SUCCESS = 0x15; -// -// public static final byte NOTIFY_STATUS_MOTOR_TEST = 0x16; -// -// // 0x18 is returned when we cancel data sync, perhaps is an ack for this message -// -// public static final byte NOTIFY_UNKNOWN = -0x1; -// -// public static final int NOTIFY_PAIR_CANCEL = 0xef; -// -// public static final int NOTIFY_DEVICE_MALFUNCTION = 0xff; -// -// -// /* MESSAGES: unknown */ -// -// public static final byte MSG_CONNECTED = 0x0; -// -// public static final byte MSG_DISCONNECTED = 0x1; -// -// public static final byte MSG_CONNECTION_FAILED = 0x2; -// -// public static final byte MSG_INITIALIZATION_FAILED = 0x3; -// -// public static final byte MSG_INITIALIZATION_SUCCESS = 0x4; -// -// public static final byte MSG_STEPS_CHANGED = 0x5; -// -// public static final byte MSG_DEVICE_STATUS_CHANGED = 0x6; -// -// public static final byte MSG_BATTERY_STATUS_CHANGED = 0x7; -// -// /* COMMANDS: usually sent to UUID_CHARACTERISTIC_CONTROL_POINT characteristic */ -// -// public static final byte COMMAND_SET_TIMER = 0x4; -// -// public static final byte COMMAND_SET_FITNESS_GOAL = 0x5; -// -// public static final byte COMMAND_FETCH_DATA = 0x6; -// -// public static final byte COMMAND_SEND_FIRMWARE_INFO = 0x7; -// -// public static final byte COMMAND_SEND_NOTIFICATION = 0x8; -// -// public static final byte COMMAND_CONFIRM_ACTIVITY_DATA_TRANSFER_COMPLETE = 0xa; -// -// public static final byte COMMAND_SYNC = 0xb; -// -// public static final byte COMMAND_REBOOT = 0xc; -// -// public static final byte COMMAND_SET_WEAR_LOCATION = 0xf; -// -// public static final byte COMMAND_STOP_SYNC_DATA = 0x11; -// -// public static final byte COMMAND_STOP_MOTOR_VIBRATE = 0x13; -// -// public static final byte COMMAND_SET_REALTIME_STEPS_NOTIFICATION = 0x3; -// -// public static final byte COMMAND_SET_REALTIME_STEP = 0x10; -// -// // Test HR -// public static final byte COMMAND_SET_HR_SLEEP = 0x0; -// public static final byte COMMAND_SET__HR_CONTINUOUS = 0x1; -// public static final byte COMMAND_SET_HR_MANUAL = 0x2; -// -// -// /* FURTHER COMMANDS: unchecked therefore left commented -// -// -// public static final byte COMMAND_FACTORY_RESET = 0x9t; -// -// public static final int COMMAND_SET_COLOR_THEME = et; -// -// public static final byte COMMAND_GET_SENSOR_DATA = 0x12t -// -// */ -// -// /* CONNECTION: unknown -// -// public static final CONNECTION_LATENCY_LEVEL_LOW = 0x0t; -// -// public static final CONNECTION_LATENCY_LEVEL_MEDIUM = 0x1t; -// -// public static final CONNECTION_LATENCY_LEVEL_HIGH = 0x2t; -// -// */ -// -// /* MODES: probably related to the sample data structure -// */ -// -// public static final byte MODE_REGULAR_DATA_LEN_BYTE = 0x0; -// -// // was MODE_REGULAR_DATA_LEN_MINITE -// public static final byte MODE_REGULAR_DATA_LEN_MINUTE = 0x1; -// -// /* PROFILE: unknown -// -// public static final PROFILE_STATE_UNKNOWN:I = 0x0 -// -// public static final PROFILE_STATE_INITIALIZATION_SUCCESS:I = 0x1 -// -// public static final PROFILE_STATE_INITIALIZATION_FAILED:I = 0x2 -// -// public static final PROFILE_STATE_AUTHENTICATION_SUCCESS:I = 0x3 -// -// public static final PROFILE_STATE_AUTHENTICATION_FAILED:I = 0x4 -// -// */ -// -// // TEST_*: sent to UUID_CHARACTERISTIC_TEST characteristic -// -// public static final byte TEST_DISCONNECTED_REMINDER = 0x5; -// -// public static final byte TEST_NOTIFICATION = 0x3; -// -// public static final byte TEST_REMOTE_DISCONNECT = 0x1; -// -// public static final byte TEST_SELFTEST = 0x2; private static final Map MIBAND_DEBUG; @@ -284,6 +88,7 @@ public class MiBand2Service { // maybe not really activity data, but steps? public static final byte COMMAND_FETCH_ACTIVITY_DATA = 0x02; + public static final byte COMMAND_XXXX_ACTIVITY_DATA = 0x03; // maybe delete/drop activity data? public static final byte[] COMMAND_SET_FITNESS_GOAL_START = new byte[] { 0x10, 0x0, 0x0 }; public static final byte[] COMMAND_SET_FITNESS_GOAL_END = new byte[] { 0, 0 }; @@ -298,8 +103,16 @@ public class MiBand2Service { public static final byte SUCCESS = 0x01; public static final byte COMMAND_ACTIVITY_DATA_START_DATE = 0x01; + public static final byte COMMAND_ACTIVITY_DATA_XXX_DATE = 0x02; // issued on first connect, followd by COMMAND_XXXX_ACTIVITY_DATA instead of COMMAND_FETCH_ACTIVITY_DATA + + public static final byte COMMAND_FIRMWARE_INIT = 0x01; // to UUID_CHARACTERISTIC_FIRMWARE + public static final byte COMMAND_FIRMWARE_START_DATA = 0x03; // to UUID_CHARACTERISTIC_FIRMWARE + public static final byte COMMAND_FIRMWARE_UPDATE_SYNC = 0x00; // to UUID_CHARACTERISTIC_FIRMWARE + public static final byte COMMAND_FIRMWARE_FINISH = 0x04; // to UUID_CHARACTERISTIC_FIRMWARE + public static final byte COMMAND_FIRMWARE_APPLY = 0x05; // or is it REBOOT? to UUID_CHARACTERISTIC_FIRMWARE public static final byte[] RESPONSE_FINISH_SUCCESS = new byte[] {RESPONSE, 2, SUCCESS }; + public static final byte[] RESPONSE_FIRMWARE_DATA_SUCCESS = new byte[] {RESPONSE, COMMAND_FIRMWARE_START_DATA, SUCCESS }; /** * Received in response to any dateformat configuration request (byte 0 in the byte[] value. */