ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Android] UUID로 Miband2 정보 가져오기
    Android 2018. 11. 23. 13:11

    < Miband2 UUID >

    Android Code

    Miband2 의 정보를 가져오기 위해 uuid를 이용합니다.

    import java.util.UUID;

    /**
    * Created by aashari on 21/05/17.
    * This profile generated based on http://jellygom.com/2016/09/30/Mi-Band-UUID.html
    */

    public class CustomBluetoothProfile {

    public static class Basic {
    public static UUID service = UUID.fromString("0000fee0-0000-1000-8000-00805f9b34fb");
    public static UUID batteryCharacteristic = UUID.fromString("00000006-0000-3512-2118-0009af100700");
    public static UUID realtimeStepCharacteristic = UUID.fromString("00000007-0000-3512-2118-0009af100700");
    public static UUID StepDescriptor = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
    }

    public static class AlertNotification {
    public static UUID service = UUID.fromString("00001802-0000-1000-8000-00805f9b34fb");
    public static UUID alertCharacteristic = UUID.fromString("00002a06-0000-1000-8000-00805f9b34fb");
    }

    public static class HeartRate {
    public static UUID service = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
    public static UUID measurementCharacteristic = UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb");
    public static UUID descriptor = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
    public static UUID controlCharacteristic = UUID.fromString("00002a39-0000-1000-8000-00805f9b34fb");
    }

    }

    위 코드는 android에서 miband의 uuid로 배터리, 걸음수, 심박수 등의 정보를 가져와 사용할 수 있게 해줍니다.


    * 걸음 수 정보

    if (characteristic.getUuid().equals(CustomBluetoothProfile.Basic.realtimeStepCharacteristic)){
    BluetoothGattCharacteristic bchar = bluetoothGatt.getService(CustomBluetoothProfile.Basic.service)
    .getCharacteristic(CustomBluetoothProfile.Basic.realtimeStepCharacteristic);
    byte[] data1 = bchar.getValue();
    int steps = ((((data1[1] & 255) | ((data1[2] & 255) << 8))) ); //걸음수 정보를 int형으로 바꿔준다.
    Log.i(TAG, "onCharacteristicRead/setValue: " + steps);
    txtByte1.setText(""+steps+" 걸음");

    }


    => 걸음수 정보는 가공필요.



Designed by Tistory.