diff --git a/app/app.iml b/app/app.iml
index 9c3c1b5..fd1fe07 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -84,6 +84,7 @@
+
diff --git a/app/src/androidTest/java/com/zhaoxiaodan/mibanddemo/ApplicationTest.java b/app/src/androidTest/java/com/zhaoxiaodan/mibanddemo/ApplicationTest.java
index 00a3e07..3078966 100644
--- a/app/src/androidTest/java/com/zhaoxiaodan/mibanddemo/ApplicationTest.java
+++ b/app/src/androidTest/java/com/zhaoxiaodan/mibanddemo/ApplicationTest.java
@@ -6,10 +6,8 @@
/**
* Testing Fundamentals
*/
-public class ApplicationTest extends ApplicationTestCase
-{
- public ApplicationTest()
- {
- super(Application.class);
- }
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cf3bfaf..fffc026 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,16 +1,16 @@
>
+ android:versionCode="1"
+ android:versionName="1.0">>
+ android:label="@string/app_name">
+ android:label="@string/app_name">
@@ -19,9 +19,9 @@
-
+ android:label="@string/app_name">
+
diff --git a/app/src/main/java/com/zhaoxiaodan/mibanddemo/MainActivity.java b/app/src/main/java/com/zhaoxiaodan/mibanddemo/MainActivity.java
index 2c91d24..bc0db75 100644
--- a/app/src/main/java/com/zhaoxiaodan/mibanddemo/MainActivity.java
+++ b/app/src/main/java/com/zhaoxiaodan/mibanddemo/MainActivity.java
@@ -1,9 +1,5 @@
package com.zhaoxiaodan.mibanddemo;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-
import android.app.Activity;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothDevice;
@@ -30,286 +26,212 @@
import com.zhaoxiaodan.miband.model.UserInfo;
import com.zhaoxiaodan.miband.model.VibrationMode;
-public class MainActivity extends Activity
-{
- private static final String TAG = "==[mibandtest]==";
- private MiBand miband;
-
- private static final int Message_What_ShowLog = 1;
-
- private TextView logView ;
-
- private Handler handler = new Handler(Looper.getMainLooper()){
- public void handleMessage(Message m) {
- switch (m.what)
- {
- case Message_What_ShowLog:
- String text = (String)m.obj;
- logView.setText(text);
- break;
- }
- }
- };
-
- static final String[] BUTTONS = new String[] {
- "Connect",
- "showServicesAndCharacteristics",
- "read_rssi",
- "battery_info",
- "setUserInfo",
- "setHeartRateNotifyListener",
- "startHeartRateScan",
- "miband.startVibration(VibrationMode.VIBRATION_WITH_LED);",
- "miband.startVibration(VibrationMode.VIBRATION_WITHOUT_LED);",
- "miband.startVibration(VibrationMode.VIBRATION_10_TIMES_WITH_LED);",
- "stopVibration",
- "setNormalNotifyListener",
- "setRealtimeStepsNotifyListener",
- "enableRealtimeStepsNotify",
- "disableRealtimeStepsNotify",
- "miband.setLedColor(LedColor.ORANGE);",
- "miband.setLedColor(LedColor.BLUE);",
- "miband.setLedColor(LedColor.RED);",
- "miband.setLedColor(LedColor.GREEN);",
- "setSensorDataNotifyListener",
- "enableSensorDataNotify",
- "disableSensorDataNotify",
- "pair",
- };
-
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
-
- this.logView = (TextView)findViewById(R.id.textView);
-
- Intent intent=this.getIntent();
- final BluetoothDevice device = intent.getParcelableExtra("device");
-
-
- miband = new MiBand(this);
- ListView lv = (ListView)findViewById(R.id.listView);
- lv.setAdapter(new ArrayAdapter(this, R.layout.item, BUTTONS));
- lv.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView> parent, View view, int position, long id)
- {
- int menuIndex = 0;
- if (position == menuIndex++)
- {
- final ProgressDialog pd = ProgressDialog.show(MainActivity.this, "", "努力运行中, 请稍后......");
- miband.connect(device, new ActionCallback()
- {
-
- @Override
- public void onSuccess(Object data)
- {
- pd.dismiss();
- Log.d(TAG,
- "连接成功!!!");
-
- miband.setDisconnectedListener(new NotifyListener()
- {
- @Override
- public void onNotify(byte[] data)
- {
- Log.d(TAG,
- "连接断开!!!");
- }
- });
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- pd.dismiss();
- Log.d(TAG, "connect fail, code:" + errorCode + ",mgs:" + msg);
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.showServicesAndCharacteristics();
- }
- else if (position == menuIndex++)
- {
- miband.readRssi(new ActionCallback()
- {
-
- @Override
- public void onSuccess(Object data)
- {
- Log.d(TAG, "rssi:" + (int) data);
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- Log.d(TAG, "readRssi fail");
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.getBatteryInfo(new ActionCallback()
- {
-
- @Override
- public void onSuccess(Object data)
- {
- BatteryInfo info = (BatteryInfo) data;
- Log.d(TAG, info.toString());
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- Log.d(TAG, "getBatteryInfo fail");
- }
- });
- }
- else if (position == menuIndex++)
- {
- UserInfo userInfo = new UserInfo(20271234, 1, 32, 160, 40, "1哈哈", 0);
- Log.d(TAG, "setUserInfo:" + userInfo.toString() + ",data:" + Arrays.toString(userInfo.getBytes(miband.getDevice().getAddress())));
- miband.setUserInfo(userInfo);
- }
-
- else if (position == menuIndex++)
- {
-
- miband.setHeartRateScanListener(new HeartRateNotifyListener()
- {
- @Override
- public void onNotify(int heartRate)
- {
- Log.d(TAG, "heart rate: "+ heartRate);
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.startHeartRateScan();
- }
- else if (position == menuIndex++)
- {
- miband.startVibration(VibrationMode.VIBRATION_WITH_LED);
- }
- else if (position == menuIndex++)
- {
- miband.startVibration(VibrationMode.VIBRATION_WITHOUT_LED);
- }
- else if (position == menuIndex++)
- {
- miband.startVibration(VibrationMode.VIBRATION_10_TIMES_WITH_LED);
- }
- else if (position == menuIndex++)
- {
- miband.stopVibration();
- }
- else if (position == menuIndex++)
- {
- miband.setNormalNotifyListener(new NotifyListener()
- {
-
- @Override
- public void onNotify(byte[] data)
- {
- Log.d(TAG, "NormalNotifyListener:" + Arrays.toString(data));
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.setRealtimeStepsNotifyListener(new RealtimeStepsNotifyListener()
- {
-
- @Override
- public void onNotify(int steps)
- {
- Log.d(TAG, "RealtimeStepsNotifyListener:" + steps);
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.enableRealtimeStepsNotify();
- }
- else if (position == menuIndex++)
- {
- miband.disableRealtimeStepsNotify();
- }
- else if (position == menuIndex++)
- {
- miband.setLedColor(LedColor.ORANGE);
- }
- else if (position == menuIndex++)
- {
- miband.setLedColor(LedColor.BLUE);
- }
- else if (position == menuIndex++)
- {
- miband.setLedColor(LedColor.RED);
- }
- else if (position == menuIndex++)
- {
- miband.setLedColor(LedColor.GREEN);
- }
- else if (position == menuIndex++)
- {
- miband.setSensorDataNotifyListener(new NotifyListener()
- {
- @Override
- public void onNotify(byte[] data)
- {
- ByteBuffer byteBuffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
- int i = 0;
-
- int index = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
- int d1 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
- int d2 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
- int d3 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
-
- Message m = new Message();
- m.what = Message_What_ShowLog;
- m.obj = index + "," + d1 + "," + d2 + "," + d3;
-
- handler.sendMessage(m);
- }
- });
- }
- else if (position == menuIndex++)
- {
- miband.enableSensorDataNotify();
- }
- else if (position == menuIndex++)
- {
- miband.disableSensorDataNotify();
- }
- else if (position == menuIndex++)
- {
- miband.pair(new ActionCallback()
- {
-
- @Override
- public void onSuccess(Object data)
- {
- Log.d(TAG, "pair succ");
- }
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Arrays;
- @Override
- public void onFail(int errorCode, String msg)
- {
- Log.d(TAG, "pair fail");
- }
- });
- }
- }
- });
-
- }
+public class MainActivity extends Activity {
+ static final String[] BUTTONS = new String[]{
+ "Connect",
+ "showServicesAndCharacteristics",
+ "read_rssi",
+ "battery_info",
+ "setUserInfo",
+ "setHeartRateNotifyListener",
+ "startHeartRateScan",
+ "miband.startVibration(VibrationMode.VIBRATION_WITH_LED);",
+ "miband.startVibration(VibrationMode.VIBRATION_WITHOUT_LED);",
+ "miband.startVibration(VibrationMode.VIBRATION_10_TIMES_WITH_LED);",
+ "stopVibration",
+ "setNormalNotifyListener",
+ "setRealtimeStepsNotifyListener",
+ "enableRealtimeStepsNotify",
+ "disableRealtimeStepsNotify",
+ "miband.setLedColor(LedColor.ORANGE);",
+ "miband.setLedColor(LedColor.BLUE);",
+ "miband.setLedColor(LedColor.RED);",
+ "miband.setLedColor(LedColor.GREEN);",
+ "setSensorDataNotifyListener",
+ "enableSensorDataNotify",
+ "disableSensorDataNotify",
+ "pair",
+ };
+ private static final String TAG = "==[mibandtest]==";
+ private static final int Message_What_ShowLog = 1;
+ private MiBand miband;
+ private TextView logView;
+ private Handler handler = new Handler(Looper.getMainLooper()) {
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case Message_What_ShowLog:
+ String text = (String) m.obj;
+ logView.setText(text);
+ break;
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+
+ this.logView = (TextView) findViewById(R.id.textView);
+
+ Intent intent = this.getIntent();
+ final BluetoothDevice device = intent.getParcelableExtra("device");
+
+
+ miband = new MiBand(this);
+ ListView lv = (ListView) findViewById(R.id.listView);
+ lv.setAdapter(new ArrayAdapter(this, R.layout.item, BUTTONS));
+ lv.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ int menuIndex = 0;
+ if (position == menuIndex++) {
+ final ProgressDialog pd = ProgressDialog.show(MainActivity.this, "", "努力运行中, 请稍后......");
+ miband.connect(device, new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ pd.dismiss();
+ Log.d(TAG,
+ "连接成功!!!");
+
+ miband.setDisconnectedListener(new NotifyListener() {
+ @Override
+ public void onNotify(byte[] data) {
+ Log.d(TAG,
+ "连接断开!!!");
+ }
+ });
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ pd.dismiss();
+ Log.d(TAG, "connect fail, code:" + errorCode + ",mgs:" + msg);
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.showServicesAndCharacteristics();
+ } else if (position == menuIndex++) {
+ miband.readRssi(new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ Log.d(TAG, "rssi:" + (int) data);
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ Log.d(TAG, "readRssi fail");
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.getBatteryInfo(new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ BatteryInfo info = (BatteryInfo) data;
+ Log.d(TAG, info.toString());
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ Log.d(TAG, "getBatteryInfo fail");
+ }
+ });
+ } else if (position == menuIndex++) {
+ UserInfo userInfo = new UserInfo(20271234, 1, 32, 160, 40, "1哈哈", 0);
+ Log.d(TAG, "setUserInfo:" + userInfo.toString() + ",data:" + Arrays.toString(userInfo.getBytes(miband.getDevice().getAddress())));
+ miband.setUserInfo(userInfo);
+ } else if (position == menuIndex++) {
+
+ miband.setHeartRateScanListener(new HeartRateNotifyListener() {
+ @Override
+ public void onNotify(int heartRate) {
+ Log.d(TAG, "heart rate: " + heartRate);
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.startHeartRateScan();
+ } else if (position == menuIndex++) {
+ miband.startVibration(VibrationMode.VIBRATION_WITH_LED);
+ } else if (position == menuIndex++) {
+ miband.startVibration(VibrationMode.VIBRATION_WITHOUT_LED);
+ } else if (position == menuIndex++) {
+ miband.startVibration(VibrationMode.VIBRATION_10_TIMES_WITH_LED);
+ } else if (position == menuIndex++) {
+ miband.stopVibration();
+ } else if (position == menuIndex++) {
+ miband.setNormalNotifyListener(new NotifyListener() {
+
+ @Override
+ public void onNotify(byte[] data) {
+ Log.d(TAG, "NormalNotifyListener:" + Arrays.toString(data));
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.setRealtimeStepsNotifyListener(new RealtimeStepsNotifyListener() {
+
+ @Override
+ public void onNotify(int steps) {
+ Log.d(TAG, "RealtimeStepsNotifyListener:" + steps);
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.enableRealtimeStepsNotify();
+ } else if (position == menuIndex++) {
+ miband.disableRealtimeStepsNotify();
+ } else if (position == menuIndex++) {
+ miband.setLedColor(LedColor.ORANGE);
+ } else if (position == menuIndex++) {
+ miband.setLedColor(LedColor.BLUE);
+ } else if (position == menuIndex++) {
+ miband.setLedColor(LedColor.RED);
+ } else if (position == menuIndex++) {
+ miband.setLedColor(LedColor.GREEN);
+ } else if (position == menuIndex++) {
+ miband.setSensorDataNotifyListener(new NotifyListener() {
+ @Override
+ public void onNotify(byte[] data) {
+ ByteBuffer byteBuffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
+ int i = 0;
+
+ int index = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
+ int d1 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
+ int d2 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
+ int d3 = (data[i++] & 0xFF) | (data[i++] & 0xFF) << 8;
+
+ Message m = new Message();
+ m.what = Message_What_ShowLog;
+ m.obj = index + "," + d1 + "," + d2 + "," + d3;
+
+ handler.sendMessage(m);
+ }
+ });
+ } else if (position == menuIndex++) {
+ miband.enableSensorDataNotify();
+ } else if (position == menuIndex++) {
+ miband.disableSensorDataNotify();
+ } else if (position == menuIndex++) {
+ miband.pair(new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ Log.d(TAG, "pair succ");
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ Log.d(TAG, "pair fail");
+ }
+ });
+ }
+ }
+ });
+
+ }
}
diff --git a/app/src/main/java/com/zhaoxiaodan/mibanddemo/ScanActivity.java b/app/src/main/java/com/zhaoxiaodan/mibanddemo/ScanActivity.java
index 1f885a6..bcf5363 100644
--- a/app/src/main/java/com/zhaoxiaodan/mibanddemo/ScanActivity.java
+++ b/app/src/main/java/com/zhaoxiaodan/mibanddemo/ScanActivity.java
@@ -1,19 +1,13 @@
package com.zhaoxiaodan.mibanddemo;
import android.app.Activity;
-import android.app.ProgressDialog;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult;
import android.content.Intent;
-import android.database.DataSetObserver;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
import android.util.Log;
import android.view.View;
-import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@@ -21,108 +15,85 @@
import android.widget.ListView;
import android.widget.TextView;
-import com.zhaoxiaodan.miband.ActionCallback;
import com.zhaoxiaodan.miband.MiBand;
-import com.zhaoxiaodan.miband.listeners.NotifyListener;
-import com.zhaoxiaodan.miband.listeners.RealtimeStepsNotifyListener;
-import com.zhaoxiaodan.miband.model.BatteryInfo;
-import com.zhaoxiaodan.miband.model.LedColor;
-import com.zhaoxiaodan.miband.model.UserInfo;
-import com.zhaoxiaodan.miband.model.VibrationMode;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
+
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-public class ScanActivity extends Activity
-{
- private static final String TAG = "==[mibandtest]==";
- private MiBand miband;
-
-
- HashMap devices = new HashMap();
-
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.scan);
-
- miband = new MiBand(this);
-
- final ArrayAdapter adapter = new ArrayAdapter(this, R.layout.item, new ArrayList());
-
- final ScanCallback scanCallback = new ScanCallback()
- {
- @Override
- public void onScanResult(int callbackType, ScanResult result)
- {
- BluetoothDevice device = result.getDevice();
- Log.d(TAG,
- "找到附近的蓝牙设备: name:" + device.getName() + ",uuid:"
- + device.getUuids() + ",add:"
- + device.getAddress() + ",type:"
- + device.getType() + ",bondState:"
- + device.getBondState() + ",rssi:" + result.getRssi());
-
- String item = device.getName() + "|" + device.getAddress();
- if (!devices.containsKey(item))
- {
- devices.put(item, device);
- adapter.add(item);
- }
-
- }
- };
-
-
- ((Button) findViewById(R.id.starScanButton)).setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- Log.d(TAG, "开始扫描附近的Le蓝牙设备...");
- MiBand.startScan(scanCallback);
- }
- });
-
- ((Button)findViewById(R.id.stopScanButton)).setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- Log.d(TAG, "停止扫描...");
- MiBand.stopScan(scanCallback);
- }
- });
-
-
- ListView lv = (ListView)findViewById(R.id.listView);
- lv.setAdapter(adapter);
- lv.setOnItemClickListener(new OnItemClickListener()
- {
- public void onItemClick(AdapterView> parent, View view, int position, long id)
- {
- String item = ((TextView)view).getText().toString();
- if (devices.containsKey(item))
- {
-
- Log.d(TAG, "停止扫描...");
- MiBand.stopScan(scanCallback);
-
- BluetoothDevice device = devices.get(item);
- Intent intent = new Intent();
- intent.putExtra("device",device);
- intent.setClass(ScanActivity.this, MainActivity.class);
- ScanActivity.this.startActivity(intent);
- ScanActivity.this.finish();
- }
- }
- });
-
- }
+public class ScanActivity extends Activity {
+ private static final String TAG = "==[mibandtest]==";
+ private MiBand miband;
+
+
+ HashMap devices = new HashMap();
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.scan);
+
+ miband = new MiBand(this);
+
+ final ArrayAdapter adapter = new ArrayAdapter(this, R.layout.item, new ArrayList());
+
+ final ScanCallback scanCallback = new ScanCallback() {
+ @Override
+ public void onScanResult(int callbackType, ScanResult result) {
+ BluetoothDevice device = result.getDevice();
+ Log.d(TAG,
+ "找到附近的蓝牙设备: name:" + device.getName() + ",uuid:"
+ + device.getUuids() + ",add:"
+ + device.getAddress() + ",type:"
+ + device.getType() + ",bondState:"
+ + device.getBondState() + ",rssi:" + result.getRssi());
+
+ String item = device.getName() + "|" + device.getAddress();
+ if (!devices.containsKey(item)) {
+ devices.put(item, device);
+ adapter.add(item);
+ }
+
+ }
+ };
+
+
+ ((Button) findViewById(R.id.starScanButton)).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.d(TAG, "开始扫描附近的Le蓝牙设备...");
+ MiBand.startScan(scanCallback);
+ }
+ });
+
+ ((Button) findViewById(R.id.stopScanButton)).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.d(TAG, "停止扫描...");
+ MiBand.stopScan(scanCallback);
+ }
+ });
+
+
+ ListView lv = (ListView) findViewById(R.id.listView);
+ lv.setAdapter(adapter);
+ lv.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ String item = ((TextView) view).getText().toString();
+ if (devices.containsKey(item)) {
+
+ Log.d(TAG, "停止扫描...");
+ MiBand.stopScan(scanCallback);
+
+ BluetoothDevice device = devices.get(item);
+ Intent intent = new Intent();
+ intent.putExtra("device", device);
+ intent.setClass(ScanActivity.this, MainActivity.class);
+ ScanActivity.this.startActivity(intent);
+ ScanActivity.this.finish();
+ }
+ }
+ });
+
+ }
}
diff --git a/app/src/main/res/layout/item.xml b/app/src/main/res/layout/item.xml
index 8f99bce..e15c1a4 100644
--- a/app/src/main/res/layout/item.xml
+++ b/app/src/main/res/layout/item.xml
@@ -3,6 +3,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"
- android:textSize="16sp" >
+ android:textSize="16sp">
\ No newline at end of file
diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml
index e773bb0..52f5b7a 100644
--- a/app/src/main/res/layout/main.xml
+++ b/app/src/main/res/layout/main.xml
@@ -1,7 +1,7 @@
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ android:layout_alignParentLeft="true" />
+ android:layout_marginTop="31dp" />
diff --git a/app/src/main/res/layout/scan.xml b/app/src/main/res/layout/scan.xml
index c267c36..fa208cf 100644
--- a/app/src/main/res/layout/scan.xml
+++ b/app/src/main/res/layout/scan.xml
@@ -1,7 +1,7 @@
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ android:layout_alignParentLeft="true" />
+ android:layout_alignParentStart="true" />
+ android:layout_alignStart="@+id/textView" />
+ android:layout_marginEnd="52dp" />
diff --git a/miband-sdk/miband-sdk.iml b/miband-sdk/miband-sdk.iml
index 4aa26a6..f22032e 100644
--- a/miband-sdk/miband-sdk.iml
+++ b/miband-sdk/miband-sdk.iml
@@ -91,6 +91,7 @@
+
diff --git a/miband-sdk/src/androidTest/java/com/zhaoxiaodan/miband/ApplicationTest.java b/miband-sdk/src/androidTest/java/com/zhaoxiaodan/miband/ApplicationTest.java
index e24ccf0..9b9eae3 100644
--- a/miband-sdk/src/androidTest/java/com/zhaoxiaodan/miband/ApplicationTest.java
+++ b/miband-sdk/src/androidTest/java/com/zhaoxiaodan/miband/ApplicationTest.java
@@ -6,10 +6,8 @@
/**
* Testing Fundamentals
*/
-public class ApplicationTest extends ApplicationTestCase
-{
- public ApplicationTest()
- {
- super(Application.class);
- }
+public class ApplicationTest extends ApplicationTestCase {
+ public ApplicationTest() {
+ super(Application.class);
+ }
}
\ No newline at end of file
diff --git a/miband-sdk/src/main/AndroidManifest.xml b/miband-sdk/src/main/AndroidManifest.xml
index 019ebe2..d04083e 100644
--- a/miband-sdk/src/main/AndroidManifest.xml
+++ b/miband-sdk/src/main/AndroidManifest.xml
@@ -1,13 +1,14 @@
+ package="com.zhaoxiaodan.miband"
+ android:versionCode="1"
+ android:versionName="1.0">
-
+
+
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/ActionCallback.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/ActionCallback.java
index bb0d9d6..1bd0add 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/ActionCallback.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/ActionCallback.java
@@ -1,7 +1,7 @@
package com.zhaoxiaodan.miband;
-public interface ActionCallback
-{
- public void onSuccess(Object data);
- public void onFail(int errorCode, String msg);
+public interface ActionCallback {
+ public void onSuccess(Object data);
+
+ public void onFail(int errorCode, String msg);
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/BluetoothIO.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/BluetoothIO.java
index eac7bea..5ea8104 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/BluetoothIO.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/BluetoothIO.java
@@ -1,277 +1,223 @@
package com.zhaoxiaodan.miband;
-import java.util.HashMap;
-import java.util.UUID;
-
-import com.zhaoxiaodan.miband.listeners.NotifyListener;
-import com.zhaoxiaodan.miband.model.Profile;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothAdapter.LeScanCallback;
-import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
-import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothProfile;
-import android.bluetooth.le.BluetoothLeScanner;
-import android.bluetooth.le.ScanCallback;
import android.content.Context;
import android.util.Log;
-class BluetoothIO extends BluetoothGattCallback
-{
- private static final String TAG = "BluetoothIO";
- BluetoothGatt gatt;
- ActionCallback currentCallback;
-
- HashMap notifyListeners = new HashMap();
- NotifyListener disconnectedListener = null;
+import com.zhaoxiaodan.miband.listeners.NotifyListener;
+import com.zhaoxiaodan.miband.model.Profile;
+
+import java.util.HashMap;
+import java.util.UUID;
+
+class BluetoothIO extends BluetoothGattCallback {
+ private static final String TAG = "BluetoothIO";
+ BluetoothGatt gatt;
+ ActionCallback currentCallback;
+
+ HashMap notifyListeners = new HashMap();
+ NotifyListener disconnectedListener = null;
+
+ public void connect(final Context context, BluetoothDevice device, final ActionCallback callback) {
+ BluetoothIO.this.currentCallback = callback;
+ device.connectGatt(context, false, BluetoothIO.this);
+ }
+
+ public void setDisconnectedListener(NotifyListener disconnectedListener) {
+ this.disconnectedListener = disconnectedListener;
+ }
+
+ public BluetoothDevice getDevice() {
+ if (null == gatt) {
+ Log.e(TAG, "connect to miband first");
+ return null;
+ }
+ return gatt.getDevice();
+ }
+
+ public void writeAndRead(final UUID uuid, byte[] valueToWrite, final ActionCallback callback) {
+ ActionCallback readCallback = new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object characteristic) {
+ BluetoothIO.this.readCharacteristic(uuid, callback);
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ callback.onFail(errorCode, msg);
+ }
+ };
+ this.writeCharacteristic(uuid, valueToWrite, readCallback);
+ }
+
+ public void writeCharacteristic(UUID characteristicUUID, byte[] value, ActionCallback callback) {
+ writeCharacteristic(Profile.UUID_SERVICE_MILI, characteristicUUID, value, callback);
+ }
+
+ public void writeCharacteristic(UUID serviceUUID, UUID characteristicUUID, byte[] value, ActionCallback callback) {
+ try {
+ if (null == gatt) {
+ Log.e(TAG, "connect to miband first");
+ throw new Exception("connect to miband first");
+ }
+ this.currentCallback = callback;
+ BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(characteristicUUID);
+ if (null == chara) {
+ this.onFail(-1, "BluetoothGattCharacteristic " + characteristicUUID + " is not exsit");
+ return;
+ }
+ chara.setValue(value);
+ if (false == this.gatt.writeCharacteristic(chara)) {
+ this.onFail(-1, "gatt.writeCharacteristic() return false");
+ }
+ } catch (Throwable tr) {
+ Log.e(TAG, "writeCharacteristic", tr);
+ this.onFail(-1, tr.getMessage());
+ }
+ }
+
+ public void readCharacteristic(UUID serviceUUID, UUID uuid, ActionCallback callback) {
+ try {
+ if (null == gatt) {
+ Log.e(TAG, "connect to miband first");
+ throw new Exception("connect to miband first");
+ }
+ this.currentCallback = callback;
+ BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(uuid);
+ if (null == chara) {
+ this.onFail(-1, "BluetoothGattCharacteristic " + uuid + " is not exsit");
+ return;
+ }
+ if (false == this.gatt.readCharacteristic(chara)) {
+ this.onFail(-1, "gatt.readCharacteristic() return false");
+ }
+ } catch (Throwable tr) {
+ Log.e(TAG, "readCharacteristic", tr);
+ this.onFail(-1, tr.getMessage());
+ }
+ }
+
+ public void readCharacteristic(UUID uuid, ActionCallback callback) {
+ this.readCharacteristic(Profile.UUID_SERVICE_MILI, uuid, callback);
+ }
+
+ public void readRssi(ActionCallback callback) {
+ try {
+ if (null == gatt) {
+ Log.e(TAG, "connect to miband first");
+ throw new Exception("connect to miband first");
+ }
+ this.currentCallback = callback;
+ this.gatt.readRemoteRssi();
+ } catch (Throwable tr) {
+ Log.e(TAG, "readRssi", tr);
+ this.onFail(-1, tr.getMessage());
+ }
+
+ }
+
+ public void setNotifyListener(UUID serviceUUID, UUID characteristicId, NotifyListener listener) {
+ if (null == gatt) {
+ Log.e(TAG, "connect to miband first");
+ return;
+ }
+
+ BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(characteristicId);
+ if (chara == null) {
+ Log.e(TAG, "characteristicId " + characteristicId.toString() + " not found in service " + serviceUUID.toString());
+ return;
+ }
+
+
+ this.gatt.setCharacteristicNotification(chara, true);
+ BluetoothGattDescriptor descriptor = chara.getDescriptor(Profile.UUID_DESCRIPTOR_UPDATE_NOTIFICATION);
+ descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
+ this.gatt.writeDescriptor(descriptor);
+ this.notifyListeners.put(characteristicId, listener);
+ }
+
+ @Override
+ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
+ super.onConnectionStateChange(gatt, status, newState);
+
+ if (newState == BluetoothProfile.STATE_CONNECTED) {
+ gatt.discoverServices();
+ } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
+ gatt.close();
+ if (this.disconnectedListener != null)
+ this.disconnectedListener.onNotify(null);
+ }
+ }
+
+ @Override
+ public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
+ super.onCharacteristicRead(gatt, characteristic, status);
+ if (BluetoothGatt.GATT_SUCCESS == status) {
+ this.onSuccess(characteristic);
+ } else {
+ this.onFail(status, "onCharacteristicRead fail");
+ }
+ }
+
+ @Override
+ public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
+ super.onCharacteristicWrite(gatt, characteristic, status);
+ if (BluetoothGatt.GATT_SUCCESS == status) {
+ this.onSuccess(characteristic);
+ } else {
+ this.onFail(status, "onCharacteristicWrite fail");
+ }
+ }
+
+ @Override
+ public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
+ super.onReadRemoteRssi(gatt, rssi, status);
+ if (BluetoothGatt.GATT_SUCCESS == status) {
+ this.onSuccess(rssi);
+ } else {
+ this.onFail(status, "onCharacteristicRead fail");
+ }
+ }
- public void connect(final Context context, BluetoothDevice device, final ActionCallback callback)
- {
- BluetoothIO.this.currentCallback = callback;
- device.connectGatt(context, false, BluetoothIO.this);
- }
+ @Override
+ public void onServicesDiscovered(BluetoothGatt gatt, int status) {
+ super.onServicesDiscovered(gatt, status);
+ if (status == BluetoothGatt.GATT_SUCCESS) {
+ this.gatt = gatt;
+ this.onSuccess(null);
+ } else {
+ this.onFail(status, "onServicesDiscovered fail");
+ }
+ }
- public void setDisconnectedListener(NotifyListener disconnectedListener)
- {
- this.disconnectedListener = disconnectedListener;
- }
-
- public BluetoothDevice getDevice()
- {
- if(null == gatt)
- {
- Log.e(TAG,"connect to miband first");
- return null;
- }
- return gatt.getDevice();
- }
-
- public void writeAndRead(final UUID uuid, byte[] valueToWrite, final ActionCallback callback)
- {
- ActionCallback readCallback = new ActionCallback() {
-
- @Override
- public void onSuccess(Object characteristic)
- {
- BluetoothIO.this.readCharacteristic(uuid, callback);
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- callback.onFail(errorCode, msg);
- }
- };
- this.writeCharacteristic(uuid, valueToWrite, readCallback);
- }
+ @Override
+ public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
+ super.onCharacteristicChanged(gatt, characteristic);
+ if (this.notifyListeners.containsKey(characteristic.getUuid())) {
+ this.notifyListeners.get(characteristic.getUuid()).onNotify(characteristic.getValue());
+ }
+ }
- public void writeCharacteristic(UUID characteristicUUID, byte[] value, ActionCallback callback)
- {
- writeCharacteristic(Profile.UUID_SERVICE_MILI, characteristicUUID, value, callback);
- }
-
- public void writeCharacteristic(UUID serviceUUID, UUID characteristicUUID, byte[] value, ActionCallback callback)
- {
- try
- {
- if(null == gatt)
- {
- Log.e(TAG,"connect to miband first");
- throw new Exception("connect to miband first");
- }
- this.currentCallback = callback;
- BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(characteristicUUID);
- if (null == chara)
- {
- this.onFail(-1, "BluetoothGattCharacteristic " + characteristicUUID + " is not exsit");
- return;
- }
- chara.setValue(value);
- if (false == this.gatt.writeCharacteristic(chara))
- {
- this.onFail(-1, "gatt.writeCharacteristic() return false");
- }
- } catch (Throwable tr)
- {
- Log.e(TAG, "writeCharacteristic", tr);
- this.onFail(-1, tr.getMessage());
- }
- }
-
- public void readCharacteristic(UUID serviceUUID, UUID uuid, ActionCallback callback)
- {
- try
- {
- if(null == gatt)
- {
- Log.e(TAG,"connect to miband first");
- throw new Exception("connect to miband first");
- }
- this.currentCallback = callback;
- BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(uuid);
- if (null == chara)
- {
- this.onFail(-1, "BluetoothGattCharacteristic " + uuid + " is not exsit");
- return;
- }
- if (false == this.gatt.readCharacteristic(chara))
- {
- this.onFail(-1, "gatt.readCharacteristic() return false");
- }
- } catch (Throwable tr)
- {
- Log.e(TAG, "readCharacteristic", tr);
- this.onFail(-1, tr.getMessage());
- }
- }
+ private void onSuccess(Object data) {
+ if (this.currentCallback != null) {
+ ActionCallback callback = this.currentCallback;
+ this.currentCallback = null;
+ callback.onSuccess(data);
+ }
+ }
- public void readCharacteristic(UUID uuid, ActionCallback callback)
- {
- this.readCharacteristic(Profile.UUID_SERVICE_MILI,uuid,callback);
- }
-
- public void readRssi(ActionCallback callback)
- {
- try
- {
- if(null == gatt)
- {
- Log.e(TAG,"connect to miband first");
- throw new Exception("connect to miband first");
- }
- this.currentCallback = callback;
- this.gatt.readRemoteRssi();
- } catch (Throwable tr)
- {
- Log.e(TAG, "readRssi", tr);
- this.onFail(-1, tr.getMessage());
- }
-
- }
-
- public void setNotifyListener(UUID serviceUUID, UUID characteristicId, NotifyListener listener)
- {
- if(null == gatt)
- {
- Log.e(TAG, "connect to miband first");
- return;
- }
-
- BluetoothGattCharacteristic chara = gatt.getService(serviceUUID).getCharacteristic(characteristicId);
- if (chara == null){
- Log.e(TAG,"characteristicId "+characteristicId.toString() +" not found in service " + serviceUUID.toString());
- return;
- }
+ private void onFail(int errorCode, String msg) {
+ if (this.currentCallback != null) {
+ ActionCallback callback = this.currentCallback;
+ this.currentCallback = null;
+ callback.onFail(errorCode, msg);
+ }
+ }
-
- this.gatt.setCharacteristicNotification(chara, true);
- BluetoothGattDescriptor descriptor = chara.getDescriptor(Profile.UUID_DESCRIPTOR_UPDATE_NOTIFICATION);
- descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- this.gatt.writeDescriptor(descriptor);
- this.notifyListeners.put(characteristicId, listener);
- }
-
- @Override
- public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
- {
- super.onConnectionStateChange(gatt, status, newState);
-
- if (newState == BluetoothProfile.STATE_CONNECTED)
- {
- gatt.discoverServices();
- }else if(newState == BluetoothProfile.STATE_DISCONNECTED){
- gatt.close();
- if(this.disconnectedListener != null)
- this.disconnectedListener.onNotify(null);
- }
- }
-
- @Override
- public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
- {
- super.onCharacteristicRead(gatt, characteristic, status);
- if (BluetoothGatt.GATT_SUCCESS == status)
- {
- this.onSuccess(characteristic);
- } else
- {
- this.onFail(status, "onCharacteristicRead fail");
- }
- }
-
- @Override
- public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
- {
- super.onCharacteristicWrite(gatt, characteristic, status);
- if (BluetoothGatt.GATT_SUCCESS == status)
- {
- this.onSuccess(characteristic);
- } else
- {
- this.onFail(status, "onCharacteristicWrite fail");
- }
- }
-
- @Override
- public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status)
- {
- super.onReadRemoteRssi(gatt, rssi, status);
- if (BluetoothGatt.GATT_SUCCESS == status)
- {
- this.onSuccess(rssi);
- } else
- {
- this.onFail(status, "onCharacteristicRead fail");
- }
- }
-
- @Override
- public void onServicesDiscovered(BluetoothGatt gatt, int status)
- {
- super.onServicesDiscovered(gatt, status);
- if (status == BluetoothGatt.GATT_SUCCESS)
- {
- this.gatt = gatt;
- this.onSuccess(null);
- } else
- {
- this.onFail(status, "onServicesDiscovered fail");
- }
- }
-
- @Override
- public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
- {
- super.onCharacteristicChanged(gatt, characteristic);
- if (this.notifyListeners.containsKey(characteristic.getUuid()))
- {
- this.notifyListeners.get(characteristic.getUuid()).onNotify(characteristic.getValue());
- }
- }
-
- private void onSuccess(Object data)
- {
- if (this.currentCallback != null)
- {
- ActionCallback callback = this.currentCallback;
- this.currentCallback = null;
- callback.onSuccess(data);
- }
- }
-
- private void onFail(int errorCode, String msg)
- {
- if (this.currentCallback != null)
- {
- ActionCallback callback = this.currentCallback;
- this.currentCallback = null;
- callback.onFail(errorCode, msg);
- }
- }
-
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/MiBand.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/MiBand.java
index 5ed06a9..357f69c 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/MiBand.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/MiBand.java
@@ -1,8 +1,5 @@
package com.zhaoxiaodan.miband;
-import java.util.Arrays;
-import java.util.UUID;
-
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
@@ -23,336 +20,291 @@
import com.zhaoxiaodan.miband.model.UserInfo;
import com.zhaoxiaodan.miband.model.VibrationMode;
-public class MiBand
-{
-
- private static final String TAG = "miband-android";
-
- private Context context;
- private BluetoothIO io;
-
- public MiBand(Context context)
- {
- this.context = context;
- this.io = new BluetoothIO();
- }
-
- public static void startScan(ScanCallback callback)
- {
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if(null == adapter)
- {
- Log.e(TAG,"BluetoothAdapter is null");
- return;
- }
- BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
- if(null == scanner){
- Log.e(TAG,"BluetoothLeScanner is null");
- return;
- }
- scanner.startScan(callback);
- }
-
- public static void stopScan(ScanCallback callback)
- {
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if(null == adapter)
- {
- Log.e(TAG,"BluetoothAdapter is null");
- return;
- }
- BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
- if(null == scanner){
- Log.e(TAG,"BluetoothLeScanner is null");
- return;
- }
- scanner.stopScan(callback);
- }
-
- /**
- * 连接指定的手环
- *
- * @param callback
- */
- public void connect(BluetoothDevice device, final ActionCallback callback)
- {
- this.io.connect(context, device, callback);
- }
-
- public void setDisconnectedListener(NotifyListener disconnectedListener)
- {
- this.io.setDisconnectedListener(disconnectedListener);
- }
-
- /**
- * 和手环配对, 实际用途未知, 不配对也可以做其他的操作
- *
- * @return data = null
- */
- public void pair(final ActionCallback callback)
- {
- ActionCallback ioCallback = new ActionCallback() {
-
- @Override
- public void onSuccess(Object data)
- {
- BluetoothGattCharacteristic characteristic = (BluetoothGattCharacteristic) data;
- Log.d(TAG, "pair result " + Arrays.toString(characteristic.getValue()));
- if (characteristic.getValue().length == 1 && characteristic.getValue()[0] == 2)
- {
- callback.onSuccess(null);
- } else
- {
- callback.onFail(-1, "respone values no succ!");
- }
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- callback.onFail(errorCode, msg);
- }
- };
- this.io.writeAndRead(Profile.UUID_CHAR_PAIR, Protocol.PAIR, ioCallback);
- }
-
- public BluetoothDevice getDevice()
- {
- return this.io.getDevice();
- }
-
- /**
- * 读取和连接设备的信号强度RSSI值
- *
- * @param callback
- * @return data : int, rssi值
- */
- public void readRssi(ActionCallback callback)
- {
- this.io.readRssi(callback);
- }
-
- /**
- * 读取手环电池信息
- *
- * @return {@link BatteryInfo}
- */
- public void getBatteryInfo(final ActionCallback callback)
- {
- ActionCallback ioCallback = new ActionCallback() {
-
- @Override
- public void onSuccess(Object data)
- {
- BluetoothGattCharacteristic characteristic = (BluetoothGattCharacteristic) data;
- Log.d(TAG, "getBatteryInfo result " + Arrays.toString(characteristic.getValue()));
- if (characteristic.getValue().length == 10)
- {
- BatteryInfo info = BatteryInfo.fromByteData(characteristic.getValue());
- callback.onSuccess(info);
- } else
- {
- callback.onFail(-1, "result format wrong!");
- }
- }
-
- @Override
- public void onFail(int errorCode, String msg)
- {
- callback.onFail(errorCode, msg);
- }
- };
- this.io.readCharacteristic(Profile.UUID_CHAR_BATTERY, ioCallback);
- }
-
- /**
- * 让手环震动
- */
- public void startVibration(VibrationMode mode)
- {
- byte[] protocal;
- switch (mode)
- {
- case VIBRATION_WITH_LED:
- protocal = Protocol.VIBRATION_WITH_LED;
- break;
- case VIBRATION_10_TIMES_WITH_LED:
- protocal = Protocol.VIBRATION_10_TIMES_WITH_LED;
- break;
- case VIBRATION_WITHOUT_LED:
- protocal = Protocol.VIBRATION_WITHOUT_LED;
- break;
- default:
- return;
- }
- this.io.writeCharacteristic(Profile.UUID_SERVICE_VIBRATION, Profile.UUID_CHAR_VIBRATION, protocal, null);
- }
-
- /**
- * 停止以模式Protocol.VIBRATION_10_TIMES_WITH_LED 开始的震动
- */
- public void stopVibration()
- {
- this.io.writeCharacteristic(Profile.UUID_SERVICE_VIBRATION, Profile.UUID_CHAR_VIBRATION, Protocol.STOP_VIBRATION, null);
- }
-
- public void setNormalNotifyListener(NotifyListener listener)
- {
- this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_NOTIFICATION, listener);
- }
-
- /**
- * 重力感应器数据通知监听, 设置完之后需要另外使用 {@link MiBand#enableRealtimeStepsNotify} 开启 和
- * {@link MiBand##disableRealtimeStepsNotify} 关闭通知
- *
- * @param listener
- */
- public void setSensorDataNotifyListener(final NotifyListener listener)
- {
- this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_SENSOR_DATA, new NotifyListener()
- {
-
- @Override
- public void onNotify(byte[] data)
- {
- listener.onNotify(data);
- }
- });
- }
-
- /**
- * 开启重力感应器数据通知
- */
- public void enableSensorDataNotify()
- {
- this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.ENABLE_SENSOR_DATA_NOTIFY, null);
- }
-
- /**
- * 关闭重力感应器数据通知
- */
- public void disableSensorDataNotify()
- {
- this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.DISABLE_SENSOR_DATA_NOTIFY, null);
- }
-
- /**
- * 实时步数通知监听器, 设置完之后需要另外使用 {@link MiBand#enableRealtimeStepsNotify} 开启 和
- * {@link MiBand##disableRealtimeStepsNotify} 关闭通知
- *
- * @param listener
- */
- public void setRealtimeStepsNotifyListener(final RealtimeStepsNotifyListener listener)
- {
- this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_REALTIME_STEPS, new NotifyListener()
- {
-
- @Override
- public void onNotify(byte[] data)
- {
- Log.d(TAG, Arrays.toString(data));
- if (data.length == 4)
- {
- int steps = data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF);
- listener.onNotify(steps);
- }
- }
- });
- }
-
- /**
- * 开启实时步数通知
- */
- public void enableRealtimeStepsNotify()
- {
- this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.ENABLE_REALTIME_STEPS_NOTIFY, null);
- }
-
- /**
- * 关闭实时步数通知
- */
- public void disableRealtimeStepsNotify()
- {
- this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.DISABLE_REALTIME_STEPS_NOTIFY, null);
- }
-
- /**
- * 设置led灯颜色
- */
- public void setLedColor(LedColor color)
- {
- byte[] protocal;
- switch (color)
- {
- case RED:
- protocal = Protocol.SET_COLOR_RED;
- break;
- case BLUE:
- protocal = Protocol.SET_COLOR_BLUE;
- break;
- case GREEN:
- protocal = Protocol.SET_COLOR_GREEN;
- break;
- case ORANGE:
- protocal = Protocol.SET_COLOR_ORANGE;
- break;
- default:
- return;
- }
- this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, protocal, null);
- }
-
- /**
- * 设置用户信息
- *
- * @param userInfo
- */
- public void setUserInfo(UserInfo userInfo)
- {
- BluetoothDevice device = this.io.getDevice();
- byte[] data = userInfo.getBytes(device.getAddress());
- this.io.writeCharacteristic(Profile.UUID_CHAR_USER_INFO, data, null);
- }
-
- public void showServicesAndCharacteristics()
- {
- for(BluetoothGattService service : this.io.gatt.getServices())
- {
- Log.d(TAG, "onServicesDiscovered:" + service.getUuid());
-
- for(BluetoothGattCharacteristic characteristic:service.getCharacteristics())
- {
- Log.d(TAG, " char:" + characteristic.getUuid());
-
- for(BluetoothGattDescriptor descriptor:characteristic.getDescriptors())
- {
- Log.d(TAG, " descriptor:" + descriptor.getUuid());
- }
- }
- }
- }
-
- public void setHeartRateScanListener(final HeartRateNotifyListener listener)
- {
- this.io.setNotifyListener(Profile.UUID_SERVICE_HEARTRATE, Profile.UUID_NOTIFICATION_HEARTRATE, new NotifyListener()
- {
- @Override
- public void onNotify(byte[] data)
- {
- Log.d(TAG, Arrays.toString(data));
- if (data.length == 2 && data[0] == 6)
- {
- int heartRate = data[1] & 0xFF;
- listener.onNotify(heartRate);
- }
- }
- });
- }
-
- public void startHeartRateScan()
- {
-
- MiBand.this.io.writeCharacteristic(Profile.UUID_SERVICE_HEARTRATE, Profile.UUID_CHAR_HEARTRATE, Protocol.START_HEART_RATE_SCAN, null);
- }
-
+import java.util.Arrays;
+
+public class MiBand {
+
+ private static final String TAG = "miband-android";
+
+ private Context context;
+ private BluetoothIO io;
+
+ public MiBand(Context context) {
+ this.context = context;
+ this.io = new BluetoothIO();
+ }
+
+ public static void startScan(ScanCallback callback) {
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ if (null == adapter) {
+ Log.e(TAG, "BluetoothAdapter is null");
+ return;
+ }
+ BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
+ if (null == scanner) {
+ Log.e(TAG, "BluetoothLeScanner is null");
+ return;
+ }
+ scanner.startScan(callback);
+ }
+
+ public static void stopScan(ScanCallback callback) {
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ if (null == adapter) {
+ Log.e(TAG, "BluetoothAdapter is null");
+ return;
+ }
+ BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
+ if (null == scanner) {
+ Log.e(TAG, "BluetoothLeScanner is null");
+ return;
+ }
+ scanner.stopScan(callback);
+ }
+
+ /**
+ * 连接指定的手环
+ *
+ * @param callback
+ */
+ public void connect(BluetoothDevice device, final ActionCallback callback) {
+ this.io.connect(context, device, callback);
+ }
+
+ public void setDisconnectedListener(NotifyListener disconnectedListener) {
+ this.io.setDisconnectedListener(disconnectedListener);
+ }
+
+ /**
+ * 和手环配对, 实际用途未知, 不配对也可以做其他的操作
+ *
+ * @return data = null
+ */
+ public void pair(final ActionCallback callback) {
+ ActionCallback ioCallback = new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ BluetoothGattCharacteristic characteristic = (BluetoothGattCharacteristic) data;
+ Log.d(TAG, "pair result " + Arrays.toString(characteristic.getValue()));
+ if (characteristic.getValue().length == 1 && characteristic.getValue()[0] == 2) {
+ callback.onSuccess(null);
+ } else {
+ callback.onFail(-1, "respone values no succ!");
+ }
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ callback.onFail(errorCode, msg);
+ }
+ };
+ this.io.writeAndRead(Profile.UUID_CHAR_PAIR, Protocol.PAIR, ioCallback);
+ }
+
+ public BluetoothDevice getDevice() {
+ return this.io.getDevice();
+ }
+
+ /**
+ * 读取和连接设备的信号强度RSSI值
+ *
+ * @param callback
+ * @return data : int, rssi值
+ */
+ public void readRssi(ActionCallback callback) {
+ this.io.readRssi(callback);
+ }
+
+ /**
+ * 读取手环电池信息
+ *
+ * @return {@link BatteryInfo}
+ */
+ public void getBatteryInfo(final ActionCallback callback) {
+ ActionCallback ioCallback = new ActionCallback() {
+
+ @Override
+ public void onSuccess(Object data) {
+ BluetoothGattCharacteristic characteristic = (BluetoothGattCharacteristic) data;
+ Log.d(TAG, "getBatteryInfo result " + Arrays.toString(characteristic.getValue()));
+ if (characteristic.getValue().length == 10) {
+ BatteryInfo info = BatteryInfo.fromByteData(characteristic.getValue());
+ callback.onSuccess(info);
+ } else {
+ callback.onFail(-1, "result format wrong!");
+ }
+ }
+
+ @Override
+ public void onFail(int errorCode, String msg) {
+ callback.onFail(errorCode, msg);
+ }
+ };
+ this.io.readCharacteristic(Profile.UUID_CHAR_BATTERY, ioCallback);
+ }
+
+ /**
+ * 让手环震动
+ */
+ public void startVibration(VibrationMode mode) {
+ byte[] protocal;
+ switch (mode) {
+ case VIBRATION_WITH_LED:
+ protocal = Protocol.VIBRATION_WITH_LED;
+ break;
+ case VIBRATION_10_TIMES_WITH_LED:
+ protocal = Protocol.VIBRATION_10_TIMES_WITH_LED;
+ break;
+ case VIBRATION_WITHOUT_LED:
+ protocal = Protocol.VIBRATION_WITHOUT_LED;
+ break;
+ default:
+ return;
+ }
+ this.io.writeCharacteristic(Profile.UUID_SERVICE_VIBRATION, Profile.UUID_CHAR_VIBRATION, protocal, null);
+ }
+
+ /**
+ * 停止以模式Protocol.VIBRATION_10_TIMES_WITH_LED 开始的震动
+ */
+ public void stopVibration() {
+ this.io.writeCharacteristic(Profile.UUID_SERVICE_VIBRATION, Profile.UUID_CHAR_VIBRATION, Protocol.STOP_VIBRATION, null);
+ }
+
+ public void setNormalNotifyListener(NotifyListener listener) {
+ this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_NOTIFICATION, listener);
+ }
+
+ /**
+ * 重力感应器数据通知监听, 设置完之后需要另外使用 {@link MiBand#enableRealtimeStepsNotify} 开启 和
+ * {@link MiBand##disableRealtimeStepsNotify} 关闭通知
+ *
+ * @param listener
+ */
+ public void setSensorDataNotifyListener(final NotifyListener listener) {
+ this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_SENSOR_DATA, new NotifyListener() {
+
+ @Override
+ public void onNotify(byte[] data) {
+ listener.onNotify(data);
+ }
+ });
+ }
+
+ /**
+ * 开启重力感应器数据通知
+ */
+ public void enableSensorDataNotify() {
+ this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.ENABLE_SENSOR_DATA_NOTIFY, null);
+ }
+
+ /**
+ * 关闭重力感应器数据通知
+ */
+ public void disableSensorDataNotify() {
+ this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.DISABLE_SENSOR_DATA_NOTIFY, null);
+ }
+
+ /**
+ * 实时步数通知监听器, 设置完之后需要另外使用 {@link MiBand#enableRealtimeStepsNotify} 开启 和
+ * {@link MiBand##disableRealtimeStepsNotify} 关闭通知
+ *
+ * @param listener
+ */
+ public void setRealtimeStepsNotifyListener(final RealtimeStepsNotifyListener listener) {
+ this.io.setNotifyListener(Profile.UUID_SERVICE_MILI, Profile.UUID_CHAR_REALTIME_STEPS, new NotifyListener() {
+
+ @Override
+ public void onNotify(byte[] data) {
+ Log.d(TAG, Arrays.toString(data));
+ if (data.length == 4) {
+ int steps = data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF);
+ listener.onNotify(steps);
+ }
+ }
+ });
+ }
+
+ /**
+ * 开启实时步数通知
+ */
+ public void enableRealtimeStepsNotify() {
+ this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.ENABLE_REALTIME_STEPS_NOTIFY, null);
+ }
+
+ /**
+ * 关闭实时步数通知
+ */
+ public void disableRealtimeStepsNotify() {
+ this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, Protocol.DISABLE_REALTIME_STEPS_NOTIFY, null);
+ }
+
+ /**
+ * 设置led灯颜色
+ */
+ public void setLedColor(LedColor color) {
+ byte[] protocal;
+ switch (color) {
+ case RED:
+ protocal = Protocol.SET_COLOR_RED;
+ break;
+ case BLUE:
+ protocal = Protocol.SET_COLOR_BLUE;
+ break;
+ case GREEN:
+ protocal = Protocol.SET_COLOR_GREEN;
+ break;
+ case ORANGE:
+ protocal = Protocol.SET_COLOR_ORANGE;
+ break;
+ default:
+ return;
+ }
+ this.io.writeCharacteristic(Profile.UUID_CHAR_CONTROL_POINT, protocal, null);
+ }
+
+ /**
+ * 设置用户信息
+ *
+ * @param userInfo
+ */
+ public void setUserInfo(UserInfo userInfo) {
+ BluetoothDevice device = this.io.getDevice();
+ byte[] data = userInfo.getBytes(device.getAddress());
+ this.io.writeCharacteristic(Profile.UUID_CHAR_USER_INFO, data, null);
+ }
+
+ public void showServicesAndCharacteristics() {
+ for (BluetoothGattService service : this.io.gatt.getServices()) {
+ Log.d(TAG, "onServicesDiscovered:" + service.getUuid());
+
+ for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
+ Log.d(TAG, " char:" + characteristic.getUuid());
+
+ for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
+ Log.d(TAG, " descriptor:" + descriptor.getUuid());
+ }
+ }
+ }
+ }
+
+ public void setHeartRateScanListener(final HeartRateNotifyListener listener) {
+ this.io.setNotifyListener(Profile.UUID_SERVICE_HEARTRATE, Profile.UUID_NOTIFICATION_HEARTRATE, new NotifyListener() {
+ @Override
+ public void onNotify(byte[] data) {
+ Log.d(TAG, Arrays.toString(data));
+ if (data.length == 2 && data[0] == 6) {
+ int heartRate = data[1] & 0xFF;
+ listener.onNotify(heartRate);
+ }
+ }
+ });
+ }
+
+ public void startHeartRateScan() {
+
+ MiBand.this.io.writeCharacteristic(Profile.UUID_SERVICE_HEARTRATE, Profile.UUID_CHAR_HEARTRATE, Protocol.START_HEART_RATE_SCAN, null);
+ }
+
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/HeartRateNotifyListener.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/HeartRateNotifyListener.java
index c4b9188..53b022a 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/HeartRateNotifyListener.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/HeartRateNotifyListener.java
@@ -1,6 +1,5 @@
package com.zhaoxiaodan.miband.listeners;
-public interface HeartRateNotifyListener
-{
- public void onNotify(int heartRate);
+public interface HeartRateNotifyListener {
+ public void onNotify(int heartRate);
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/NotifyListener.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/NotifyListener.java
index 5c2033d..bd20ba4 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/NotifyListener.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/NotifyListener.java
@@ -1,6 +1,5 @@
package com.zhaoxiaodan.miband.listeners;
-public interface NotifyListener
-{
- public void onNotify(byte[] data);
+public interface NotifyListener {
+ public void onNotify(byte[] data);
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/RealtimeStepsNotifyListener.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/RealtimeStepsNotifyListener.java
index 15dbf8e..d4ac65d 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/RealtimeStepsNotifyListener.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/listeners/RealtimeStepsNotifyListener.java
@@ -1,6 +1,5 @@
package com.zhaoxiaodan.miband.listeners;
-public interface RealtimeStepsNotifyListener
-{
- public void onNotify(int steps);
+public interface RealtimeStepsNotifyListener {
+ public void onNotify(int steps);
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/BatteryInfo.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/BatteryInfo.java
index 126b4ba..d6f7e9d 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/BatteryInfo.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/BatteryInfo.java
@@ -2,114 +2,101 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Date;
import java.util.Locale;
/**
* 手环电池相关信息类
*/
-public class BatteryInfo
-{
- /**
- * 电池当前所在的状态
- */
- static enum Status
- {
- UNKNOWN, LOW, FULL, CHARGING, NOT_CHARGING;
-
- public static Status fromByte(byte b)
- {
- switch (b)
- {
- case 1:
- return LOW;
- case 2:
- return CHARGING;
- case 3:
- return FULL;
- case 4:
- return NOT_CHARGING;
-
- default:
- return UNKNOWN;
- }
- }
- }
-
- private int level;
- private int cycles;
- private Status status;
- private Calendar lastChargedDate;
-
- private BatteryInfo()
- {
-
- }
-
- public static BatteryInfo fromByteData(byte[] data)
- {
- if (data.length < 10)
- {
- return null;
- }
- BatteryInfo info = new BatteryInfo();
-
- info.level = data[0];
- info.status = Status.fromByte(data[9]);
- info.cycles = 0xffff & (0xff & data[7] | (0xff & data[8]) << 8);
- info.lastChargedDate = Calendar.getInstance();
-
- info.lastChargedDate.set(Calendar.YEAR, data[1] + 2000);
- info.lastChargedDate.set(Calendar.MONTH, data[2]);
- info.lastChargedDate.set(Calendar.DATE, data[3]);
-
- info.lastChargedDate.set(Calendar.HOUR_OF_DAY, data[4]);
- info.lastChargedDate.set(Calendar.MINUTE, data[5]);
- info.lastChargedDate.set(Calendar.SECOND, data[6]);
-
- return info;
- }
-
- public String toString()
- {
- return "cycles:" + this.getCycles()
- + ",level:" + this.getLevel()
- + ",status:" + this.getStatus()
- + ",last:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:SS", Locale.CHINA).format(this.getLastChargedDate().getTime());
- }
-
- /**
- * 电池电量百分比, level=40 表示有40%的电量
- */
- public int getLevel()
- {
- return level;
- }
-
- /**
- * 充电循环次数
- */
- public int getCycles()
- {
- return cycles;
- }
-
- /**
- * 当前状态
- *
- * @see Status
- */
- public Status getStatus()
- {
- return status;
- }
-
- /**
- * 最后充电时间
- */
- public Calendar getLastChargedDate()
- {
- return lastChargedDate;
- }
-
+public class BatteryInfo {
+ /**
+ * 电池当前所在的状态
+ */
+ static enum Status {
+ UNKNOWN, LOW, FULL, CHARGING, NOT_CHARGING;
+
+ public static Status fromByte(byte b) {
+ switch (b) {
+ case 1:
+ return LOW;
+ case 2:
+ return CHARGING;
+ case 3:
+ return FULL;
+ case 4:
+ return NOT_CHARGING;
+
+ default:
+ return UNKNOWN;
+ }
+ }
+ }
+
+ private int level;
+ private int cycles;
+ private Status status;
+ private Calendar lastChargedDate;
+
+ private BatteryInfo() {
+
+ }
+
+ public static BatteryInfo fromByteData(byte[] data) {
+ if (data.length < 10) {
+ return null;
+ }
+ BatteryInfo info = new BatteryInfo();
+
+ info.level = data[0];
+ info.status = Status.fromByte(data[9]);
+ info.cycles = 0xffff & (0xff & data[7] | (0xff & data[8]) << 8);
+ info.lastChargedDate = Calendar.getInstance();
+
+ info.lastChargedDate.set(Calendar.YEAR, data[1] + 2000);
+ info.lastChargedDate.set(Calendar.MONTH, data[2]);
+ info.lastChargedDate.set(Calendar.DATE, data[3]);
+
+ info.lastChargedDate.set(Calendar.HOUR_OF_DAY, data[4]);
+ info.lastChargedDate.set(Calendar.MINUTE, data[5]);
+ info.lastChargedDate.set(Calendar.SECOND, data[6]);
+
+ return info;
+ }
+
+ public String toString() {
+ return "cycles:" + this.getCycles()
+ + ",level:" + this.getLevel()
+ + ",status:" + this.getStatus()
+ + ",last:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:SS", Locale.CHINA).format(this.getLastChargedDate().getTime());
+ }
+
+ /**
+ * 电池电量百分比, level=40 表示有40%的电量
+ */
+ public int getLevel() {
+ return level;
+ }
+
+ /**
+ * 充电循环次数
+ */
+ public int getCycles() {
+ return cycles;
+ }
+
+ /**
+ * 当前状态
+ *
+ * @see Status
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * 最后充电时间
+ */
+ public Calendar getLastChargedDate() {
+ return lastChargedDate;
+ }
+
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LeParams.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LeParams.java
index ec85ccb..1677307 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LeParams.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LeParams.java
@@ -1,30 +1,29 @@
package com.zhaoxiaodan.miband.model;
-public class LeParams
-{
- public int connIntMin;
- public int connIntMax;
- public int connInt;
-
- public int latency;
- public int timeout;
- public int advInt;
+public class LeParams {
+ public int connIntMin;
+ public int connIntMax;
+ public int connInt;
- public static LeParams fromByte(byte[] b) {
- LeParams params = new LeParams();
+ public int latency;
+ public int timeout;
+ public int advInt;
- params.connIntMax = 0xffff & (0xff & b[0] | (0xff & b[1]) << 8);
- params.connIntMax = 0xffff & (0xff & b[2] | (0xff & b[3]) << 8);
- params.latency = 0xffff & (0xff & b[4] | (0xff & b[5]) << 8);
- params.timeout = 0xffff & (0xff & b[6] | (0xff & b[7]) << 8);
- params.connInt = 0xffff & (0xff & b[8] | (0xff & b[9]) << 8);
- params.advInt = 0xffff & (0xff & b[10] | (0xff & b[11]) << 8);
+ public static LeParams fromByte(byte[] b) {
+ LeParams params = new LeParams();
- params.connIntMin *= 1.25;
- params.connIntMax *= 1.25;
- params.advInt *= 0.625;
- params.timeout *= 10;
+ params.connIntMax = 0xffff & (0xff & b[0] | (0xff & b[1]) << 8);
+ params.connIntMax = 0xffff & (0xff & b[2] | (0xff & b[3]) << 8);
+ params.latency = 0xffff & (0xff & b[4] | (0xff & b[5]) << 8);
+ params.timeout = 0xffff & (0xff & b[6] | (0xff & b[7]) << 8);
+ params.connInt = 0xffff & (0xff & b[8] | (0xff & b[9]) << 8);
+ params.advInt = 0xffff & (0xff & b[10] | (0xff & b[11]) << 8);
- return params;
- }
+ params.connIntMin *= 1.25;
+ params.connIntMax *= 1.25;
+ params.advInt *= 0.625;
+ params.timeout *= 10;
+
+ return params;
+ }
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LedColor.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LedColor.java
index 8e31421..88f52a0 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LedColor.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/LedColor.java
@@ -1,8 +1,6 @@
-
package com.zhaoxiaodan.miband.model;
-public enum LedColor
-{
- RED,BLUE,ORANGE,GREEN,
+public enum LedColor {
+ RED, BLUE, ORANGE, GREEN,
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Profile.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Profile.java
index 00fb3ef..c5757be 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Profile.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Profile.java
@@ -2,100 +2,98 @@
import java.util.UUID;
-public class Profile
-{
- // ========================== 服务部分 ============================
- /**
- * 主要的service
- */
- public static final UUID UUID_SERVICE_MILI = UUID.fromString("0000fee0-0000-1000-8000-00805f9b34fb");
-
- /**
- * 震动
- */
- public static final UUID UUID_SERVICE_VIBRATION = UUID.fromString("00001802-0000-1000-8000-00805f9b34fb");
-
- /**
- * 心率
- */
- public static final UUID UUID_SERVICE_HEARTRATE = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
-
-
-
- /**
- * 未知作用
- */
- public static final UUID UUID_SERVICE_UNKNOWN1 = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_SERVICE_UNKNOWN2 = UUID.fromString("00001801-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_SERVICE_UNKNOWN4 = UUID.fromString("0000fee1-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_SERVICE_UNKNOWN5 = UUID.fromString("0000fee7-0000-1000-8000-00805f9b34fb");
- // ========================== 服务部分 end ============================
-
- // ========================== 描述部分 ============================
- public static final UUID UUID_DESCRIPTOR_UPDATE_NOTIFICATION = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
-
- public static final UUID UUID_NOTIFICATION_HEARTRATE = UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb");
-
- // ========================== 描述部分 end ============================
-
- // ========================== 特性部分 ============================
- public static final UUID UUID_CHAR_DEVICE_INFO = UUID.fromString("0000ff01-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_CHAR_DEVICE_NAME = UUID.fromString("0000ff02-0000-1000-8000-00805f9b34fb");
- /**
- * 通用通知
- */
- public static final UUID UUID_CHAR_NOTIFICATION = UUID.fromString("0000ff03-0000-1000-8000-00805f9b34fb");
-
- /**
- * 用户信息,读写
- */
- public static final UUID UUID_CHAR_USER_INFO = UUID.fromString("0000ff04-0000-1000-8000-00805f9b34fb");
-
- /**
- * 控制,如震动等
- */
- public static final UUID UUID_CHAR_CONTROL_POINT = UUID.fromString("0000ff05-0000-1000-8000-00805f9b34fb");
-
- /**
- * 实时步数通知 通知
- */
- public static final UUID UUID_CHAR_REALTIME_STEPS = UUID.fromString("0000ff06-0000-1000-8000-00805f9b34fb");
-
-
- public static final UUID UUID_CHAR_ACTIVITY = UUID.fromString("0000ff07-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_CHAR_FIRMWARE_DATA = UUID.fromString("0000ff08-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_CHAR_LE_PARAMS = UUID.fromString("0000ff09-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_CHAR_DATA_TIME = UUID.fromString("0000ff0a-0000-1000-8000-00805f9b34fb");
- public static final UUID UUID_CHAR_STATISTICS = UUID.fromString("0000ff0b-0000-1000-8000-00805f9b34fb");
-
- /**
- * 电池,只读,通知
- */
- public static final UUID UUID_CHAR_BATTERY = UUID.fromString("0000ff0c-0000-1000-8000-00805f9b34fb");
-
- /**
- * 自检,读写
- */
- public static final UUID UUID_CHAR_TEST = UUID.fromString("0000ff0d-0000-1000-8000-00805f9b34fb");
-
- /**
- * 配对,读写
- */
- public static final UUID UUID_CHAR_SENSOR_DATA = UUID.fromString("0000ff0e-0000-1000-8000-00805f9b34fb");
-
- /**
- * 配对,读写
- */
- public static final UUID UUID_CHAR_PAIR = UUID.fromString("0000ff0f-0000-1000-8000-00805f9b34fb");
-
- /**
- * 震动
- */
- public static final UUID UUID_CHAR_VIBRATION = UUID.fromString("00002a06-0000-1000-8000-00805f9b34fb");
-
- /**
- * 心率
- */
- public static final UUID UUID_CHAR_HEARTRATE = UUID.fromString("00002a39-0000-1000-8000-00805f9b34fb");
- // ========================== 特性部分 end ============================
+public class Profile {
+ // ========================== 服务部分 ============================
+ /**
+ * 主要的service
+ */
+ public static final UUID UUID_SERVICE_MILI = UUID.fromString("0000fee0-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 震动
+ */
+ public static final UUID UUID_SERVICE_VIBRATION = UUID.fromString("00001802-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 心率
+ */
+ public static final UUID UUID_SERVICE_HEARTRATE = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
+
+
+ /**
+ * 未知作用
+ */
+ public static final UUID UUID_SERVICE_UNKNOWN1 = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_SERVICE_UNKNOWN2 = UUID.fromString("00001801-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_SERVICE_UNKNOWN4 = UUID.fromString("0000fee1-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_SERVICE_UNKNOWN5 = UUID.fromString("0000fee7-0000-1000-8000-00805f9b34fb");
+ // ========================== 服务部分 end ============================
+
+ // ========================== 描述部分 ============================
+ public static final UUID UUID_DESCRIPTOR_UPDATE_NOTIFICATION = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
+
+ public static final UUID UUID_NOTIFICATION_HEARTRATE = UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb");
+
+ // ========================== 描述部分 end ============================
+
+ // ========================== 特性部分 ============================
+ public static final UUID UUID_CHAR_DEVICE_INFO = UUID.fromString("0000ff01-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_CHAR_DEVICE_NAME = UUID.fromString("0000ff02-0000-1000-8000-00805f9b34fb");
+ /**
+ * 通用通知
+ */
+ public static final UUID UUID_CHAR_NOTIFICATION = UUID.fromString("0000ff03-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 用户信息,读写
+ */
+ public static final UUID UUID_CHAR_USER_INFO = UUID.fromString("0000ff04-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 控制,如震动等
+ */
+ public static final UUID UUID_CHAR_CONTROL_POINT = UUID.fromString("0000ff05-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 实时步数通知 通知
+ */
+ public static final UUID UUID_CHAR_REALTIME_STEPS = UUID.fromString("0000ff06-0000-1000-8000-00805f9b34fb");
+
+
+ public static final UUID UUID_CHAR_ACTIVITY = UUID.fromString("0000ff07-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_CHAR_FIRMWARE_DATA = UUID.fromString("0000ff08-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_CHAR_LE_PARAMS = UUID.fromString("0000ff09-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_CHAR_DATA_TIME = UUID.fromString("0000ff0a-0000-1000-8000-00805f9b34fb");
+ public static final UUID UUID_CHAR_STATISTICS = UUID.fromString("0000ff0b-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 电池,只读,通知
+ */
+ public static final UUID UUID_CHAR_BATTERY = UUID.fromString("0000ff0c-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 自检,读写
+ */
+ public static final UUID UUID_CHAR_TEST = UUID.fromString("0000ff0d-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 配对,读写
+ */
+ public static final UUID UUID_CHAR_SENSOR_DATA = UUID.fromString("0000ff0e-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 配对,读写
+ */
+ public static final UUID UUID_CHAR_PAIR = UUID.fromString("0000ff0f-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 震动
+ */
+ public static final UUID UUID_CHAR_VIBRATION = UUID.fromString("00002a06-0000-1000-8000-00805f9b34fb");
+
+ /**
+ * 心率
+ */
+ public static final UUID UUID_CHAR_HEARTRATE = UUID.fromString("00002a39-0000-1000-8000-00805f9b34fb");
+ // ========================== 特性部分 end ============================
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Protocol.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Protocol.java
index f48677b..3a9948a 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Protocol.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/Protocol.java
@@ -1,24 +1,23 @@
package com.zhaoxiaodan.miband.model;
-public class Protocol
-{
- public static final byte[] PAIR = { 2 };
- public static final byte[] VIBRATION_WITH_LED = { 1 };
- public static final byte[] VIBRATION_10_TIMES_WITH_LED = { 2 };
- public static final byte[] VIBRATION_WITHOUT_LED = { 4 };
- public static final byte[] STOP_VIBRATION = { 0 };
- public static final byte[] ENABLE_REALTIME_STEPS_NOTIFY = { 3, 1 };
- public static final byte[] DISABLE_REALTIME_STEPS_NOTIFY = { 3, 0 };
- public static final byte[] ENABLE_SENSOR_DATA_NOTIFY = { 18, 1 };
- public static final byte[] DISABLE_SENSOR_DATA_NOTIFY = { 18, 0 };
- public static final byte[] SET_COLOR_RED = { 14, 6, 1, 2, 1 };
- public static final byte[] SET_COLOR_BLUE = { 14, 0, 6, 6, 1 };
- public static final byte[] SET_COLOR_ORANGE = { 14, 6, 2, 0, 1 };
- public static final byte[] SET_COLOR_GREEN = { 14, 4, 5, 0, 1 };
- public static final byte[] START_HEART_RATE_SCAN = { 21, 2, 1 };
-
- public static final byte[] REBOOT = { 12 };
- public static final byte[] REMOTE_DISCONNECT = { 1 };
- public static final byte[] FACTORY_RESET = { 9 };
- public static final byte[] SELF_TEST = { 2 };
+public class Protocol {
+ public static final byte[] PAIR = {2};
+ public static final byte[] VIBRATION_WITH_LED = {1};
+ public static final byte[] VIBRATION_10_TIMES_WITH_LED = {2};
+ public static final byte[] VIBRATION_WITHOUT_LED = {4};
+ public static final byte[] STOP_VIBRATION = {0};
+ public static final byte[] ENABLE_REALTIME_STEPS_NOTIFY = {3, 1};
+ public static final byte[] DISABLE_REALTIME_STEPS_NOTIFY = {3, 0};
+ public static final byte[] ENABLE_SENSOR_DATA_NOTIFY = {18, 1};
+ public static final byte[] DISABLE_SENSOR_DATA_NOTIFY = {18, 0};
+ public static final byte[] SET_COLOR_RED = {14, 6, 1, 2, 1};
+ public static final byte[] SET_COLOR_BLUE = {14, 0, 6, 6, 1};
+ public static final byte[] SET_COLOR_ORANGE = {14, 6, 2, 0, 1};
+ public static final byte[] SET_COLOR_GREEN = {14, 4, 5, 0, 1};
+ public static final byte[] START_HEART_RATE_SCAN = {21, 2, 1};
+
+ public static final byte[] REBOOT = {12};
+ public static final byte[] REMOTE_DISCONNECT = {1};
+ public static final byte[] FACTORY_RESET = {9};
+ public static final byte[] SELF_TEST = {2};
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/UserInfo.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/UserInfo.java
index 14a446a..27258ef 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/UserInfo.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/UserInfo.java
@@ -3,187 +3,163 @@
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
-public class UserInfo
-{
-
- private int uid;
- private byte gender;
- private byte age;
- private byte height; // cm
- private byte weight; // kg
- private String alias = "";
- private byte type;
-
- private UserInfo()
- {
-
- }
-
- public UserInfo(int uid, int gender, int age, int height, int weight, String alias, int type)
- {
- this.uid = uid;
- this.gender = (byte) gender;
- this.age = (byte) age;
- this.height = (byte) (height & 0xFF);
- this.weight = (byte) weight;
- this.alias = alias;
- this.type = (byte) type;
- }
-
- public static UserInfo fromByteData(byte[] data)
- {
- if (data.length < 20)
- {
- return null;
- }
- UserInfo info = new UserInfo();
-
- info.uid = data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF);
- info.gender = data[4];
- info.age = data[5];
- info.height = data[6];
- info.weight = data[7];
- info.type = data[8];
- try
- {
- info.alias = new String(data, 9, 8, "UTF-8");
- } catch (UnsupportedEncodingException e)
- {
- info.alias = "";
- }
-
- return info;
- }
-
- public byte[] getBytes(String mBTAddress)
- {
- byte[] aliasBytes;
- try
- {
- aliasBytes = this.alias.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e)
- {
- aliasBytes = new byte[0];
- }
- ByteBuffer bf = ByteBuffer.allocate(20);
- bf.put((byte) (uid & 0xff));
- bf.put((byte) (uid >> 8 & 0xff));
- bf.put((byte) (uid >> 16 & 0xff));
- bf.put((byte) (uid >> 24 & 0xff));
- bf.put(this.gender);
- bf.put(this.age);
- bf.put(this.height);
- bf.put(this.weight);
- bf.put(this.type);
- bf.put((byte) 4);
- bf.put((byte) 0);
-
- if (aliasBytes.length <= 8)
- {
- bf.put(aliasBytes);
- bf.put(new byte[8 - aliasBytes.length]);
- } else
- {
- bf.put(aliasBytes, 0, 8);
- }
-
- byte[] crcSequence = new byte[19];
- for (int u = 0; u < crcSequence.length; u++)
- crcSequence[u] = bf.array()[u];
-
- byte crcb = (byte) ((getCRC8(crcSequence) ^ Integer.parseInt(mBTAddress.substring(mBTAddress.length() - 2), 16)) & 0xff);
- bf.put(crcb);
- return bf.array();
- }
-
- private int getCRC8(byte[] seq)
- {
- int len = seq.length;
- int i = 0;
- byte crc = 0x00;
-
- while (len-- > 0)
- {
- byte extract = seq[i++];
- for (byte tempI = 8; tempI != 0; tempI--)
- {
- byte sum = (byte) ((crc & 0xff) ^ (extract & 0xff));
- sum = (byte) ((sum & 0xff) & 0x01);
- crc = (byte) ((crc & 0xff) >>> 1);
- if (sum != 0)
- {
- crc = (byte) ((crc & 0xff) ^ 0x8c);
- }
- extract = (byte) ((extract & 0xff) >>> 1);
- }
- }
- return (crc & 0xff);
- }
-
- public String toString()
- {
- return "uid:" + this.uid
- + ",gender:" + this.gender
- + ",age:" + this.age
- + ",height:" + this.getHeight()
- + ",weight:" + this.getWeight()
- + ",alias:" + this.alias
- + ",type:" + this.type;
- }
-
- /**
- * @return the uid
- */
- public int getUid()
- {
- return uid;
- }
-
- /**
- * @return the gender
- */
- public byte getGender()
- {
- return gender;
- }
-
- /**
- * @return the age
- */
- public byte getAge()
- {
- return age;
- }
-
- /**
- * @return the height
- */
- public int getHeight()
- {
- return (height & 0xFF);
- }
-
- /**
- * @return the weight
- */
- public int getWeight()
- {
- return weight & 0xFF;
- }
-
- /**
- * @return the alias
- */
- public String getAlias()
- {
- return alias;
- }
-
- /**
- * @return the type
- */
- public byte getType()
- {
- return type;
- }
+public class UserInfo {
+
+ private int uid;
+ private byte gender;
+ private byte age;
+ private byte height; // cm
+ private byte weight; // kg
+ private String alias = "";
+ private byte type;
+
+ private UserInfo() {
+
+ }
+
+ public UserInfo(int uid, int gender, int age, int height, int weight, String alias, int type) {
+ this.uid = uid;
+ this.gender = (byte) gender;
+ this.age = (byte) age;
+ this.height = (byte) (height & 0xFF);
+ this.weight = (byte) weight;
+ this.alias = alias;
+ this.type = (byte) type;
+ }
+
+ public static UserInfo fromByteData(byte[] data) {
+ if (data.length < 20) {
+ return null;
+ }
+ UserInfo info = new UserInfo();
+
+ info.uid = data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF);
+ info.gender = data[4];
+ info.age = data[5];
+ info.height = data[6];
+ info.weight = data[7];
+ info.type = data[8];
+ try {
+ info.alias = new String(data, 9, 8, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ info.alias = "";
+ }
+
+ return info;
+ }
+
+ public byte[] getBytes(String mBTAddress) {
+ byte[] aliasBytes;
+ try {
+ aliasBytes = this.alias.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ aliasBytes = new byte[0];
+ }
+ ByteBuffer bf = ByteBuffer.allocate(20);
+ bf.put((byte) (uid & 0xff));
+ bf.put((byte) (uid >> 8 & 0xff));
+ bf.put((byte) (uid >> 16 & 0xff));
+ bf.put((byte) (uid >> 24 & 0xff));
+ bf.put(this.gender);
+ bf.put(this.age);
+ bf.put(this.height);
+ bf.put(this.weight);
+ bf.put(this.type);
+ bf.put((byte) 4);
+ bf.put((byte) 0);
+
+ if (aliasBytes.length <= 8) {
+ bf.put(aliasBytes);
+ bf.put(new byte[8 - aliasBytes.length]);
+ } else {
+ bf.put(aliasBytes, 0, 8);
+ }
+
+ byte[] crcSequence = new byte[19];
+ for (int u = 0; u < crcSequence.length; u++)
+ crcSequence[u] = bf.array()[u];
+
+ byte crcb = (byte) ((getCRC8(crcSequence) ^ Integer.parseInt(mBTAddress.substring(mBTAddress.length() - 2), 16)) & 0xff);
+ bf.put(crcb);
+ return bf.array();
+ }
+
+ private int getCRC8(byte[] seq) {
+ int len = seq.length;
+ int i = 0;
+ byte crc = 0x00;
+
+ while (len-- > 0) {
+ byte extract = seq[i++];
+ for (byte tempI = 8; tempI != 0; tempI--) {
+ byte sum = (byte) ((crc & 0xff) ^ (extract & 0xff));
+ sum = (byte) ((sum & 0xff) & 0x01);
+ crc = (byte) ((crc & 0xff) >>> 1);
+ if (sum != 0) {
+ crc = (byte) ((crc & 0xff) ^ 0x8c);
+ }
+ extract = (byte) ((extract & 0xff) >>> 1);
+ }
+ }
+ return (crc & 0xff);
+ }
+
+ public String toString() {
+ return "uid:" + this.uid
+ + ",gender:" + this.gender
+ + ",age:" + this.age
+ + ",height:" + this.getHeight()
+ + ",weight:" + this.getWeight()
+ + ",alias:" + this.alias
+ + ",type:" + this.type;
+ }
+
+ /**
+ * @return the uid
+ */
+ public int getUid() {
+ return uid;
+ }
+
+ /**
+ * @return the gender
+ */
+ public byte getGender() {
+ return gender;
+ }
+
+ /**
+ * @return the age
+ */
+ public byte getAge() {
+ return age;
+ }
+
+ /**
+ * @return the height
+ */
+ public int getHeight() {
+ return (height & 0xFF);
+ }
+
+ /**
+ * @return the weight
+ */
+ public int getWeight() {
+ return weight & 0xFF;
+ }
+
+ /**
+ * @return the alias
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * @return the type
+ */
+ public byte getType() {
+ return type;
+ }
}
diff --git a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/VibrationMode.java b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/VibrationMode.java
index c31ef34..798ac0c 100644
--- a/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/VibrationMode.java
+++ b/miband-sdk/src/main/java/com/zhaoxiaodan/miband/model/VibrationMode.java
@@ -1,9 +1,8 @@
/**
- *
+ *
*/
package com.zhaoxiaodan.miband.model;
-public enum VibrationMode
-{
- VIBRATION_WITH_LED, VIBRATION_10_TIMES_WITH_LED,VIBRATION_WITHOUT_LED
+public enum VibrationMode {
+ VIBRATION_WITH_LED, VIBRATION_10_TIMES_WITH_LED, VIBRATION_WITHOUT_LED
}