-
Notifications
You must be signed in to change notification settings - Fork 6
同步时间(ID=93)
Harry edited this page Dec 1, 2017
·
7 revisions
一旦app连接上手环, 你应该同步手环时间,把你的手机上的正确时间发送到手环上去(注意要等手环发送完电量和版本信息之后再发送这条指令)
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
byte[] data = new byte[14];
data[0] = (byte) 0xAB;
data[1] = (byte) 0;
data[2] = (byte) 11;
data[3] = (byte) 0xff;
data[4] = (byte) 0x93;
data[5] = (byte) 0x80;
// data[6] = (byte)0;
data[7] = (byte) ((year & 0xff00) >> 8);
data[8] = (byte) (year & 0xff);
data[9] = (byte) (month & 0xff);
data[10] = (byte) (day & 0xff);
data[11] = (byte) (hour & 0xff);
data[12] = (byte) (minute & 0xff);
data[13] = (byte) (second & 0xff);
这些是你在同步时间的时候应该发送给手环的数据,如果发送成功,你会发现你的手环上的时间已经和手机上的时间保持一致了。