1、测试
2 测试
初始化锁具
H5 获取到的服务id 获取服务成功! 3 at js/common.js:139
15:15:12.409 {"uuid":"00001800-0000-1000-8000-00805F9B34FB","isPrimary":true} at js/common.js:139
15:15:12.429 {"uuid":"00001801-0000-1000-8000-00805F9B34FB","isPrimary":true} at js/common.js:139
15:15:12.449 {"uuid":"6E400001-B5A3-F393-E0A9-E50E24DCCA9E","isPrimary":true} at js/common.js:139
H5 获取到的特征ID
android 中 用到的 服务id
public static UUID UUID_SERVICE = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
public static UUID UUID_WRITE = UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb");
public static UUID UUID_NOTIFY = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e");
/**
* 初始化锁具
*/
1- private void initKey() {
if (!isConn) {
ToastUtils.show(this, "请连接蓝牙");
return;
}
bLETools.initLock(0, "00330001000800001d25000000000000");
}
2- public void initLock(int type, String devCode) {
boolean isT = false;
if (type == 0) {
isT = false;
} else {
isT = true;
}
List<Byte> bytes = BLEpLocProtocol.initLock(isT, devCode); (2-1)
this.sendData(this.mainBleDevice, bytes);(2-2)
}
2-1 public static List<Byte> initLock(boolean type, String code) {
List<Byte> byteList = new ArrayList();
byteList.addAll(Plutilities.converDecStringToHexArray(code));
int lockTypeNumber = type ? 2 : 1;
byteList.add((byte)lockTypeNumber);
List<Byte> newBytes = Plutilities.getFormatByte(byteList, 162);
return newBytes;
}
2-2