|
@@ -434,127 +434,131 @@ function alterConnect(device, deviceId, callback = () => {}, fail = () => {}) {
|
|
|
}
|
|
|
console.log("xxxx2")
|
|
|
console.log(deviceId)
|
|
|
-
|
|
|
+ var data = bluetoothDeviceConfig(device).alterConnect(device, deviceId);
|
|
|
setTimeout(()=>{
|
|
|
- uni.getBLEDeviceServices({
|
|
|
- deviceId: deviceId,
|
|
|
- success(res) {
|
|
|
- console.log(res,'res1111');
|
|
|
- console.log(bluetoothDeviceConfig(device).writeServiceID)
|
|
|
-
|
|
|
- setTimeout(()=>{
|
|
|
- uni.getBLEDeviceCharacteristics({
|
|
|
- deviceId: deviceId,
|
|
|
- serviceId: bluetoothDeviceConfig(device).writeServiceID,
|
|
|
- success(res) {
|
|
|
- console.log(res,'res22222');
|
|
|
-
|
|
|
- uni.getBLEDeviceCharacteristics({
|
|
|
- deviceId: deviceId,
|
|
|
- serviceId: bluetoothDeviceConfig(device).readServiceID,
|
|
|
- success(res) {
|
|
|
- console.log(res,'res3333');
|
|
|
-
|
|
|
- uni.notifyBLECharacteristicValueChange({
|
|
|
- state: true,
|
|
|
- deviceId: deviceId,
|
|
|
- serviceId: bluetoothDeviceConfig(device).readServiceID,
|
|
|
- characteristicId: bluetoothDeviceConfig(device).readID,
|
|
|
- success(res) {
|
|
|
- console.log(res);
|
|
|
-
|
|
|
- if (bluetoothDeviceConfig(device).MTU && SystemInfoUtil.platform == SystemInfoUtil.ANDROID) {
|
|
|
-
|
|
|
- uni.setBLEMTU({
|
|
|
- deviceId: deviceId,
|
|
|
- mtu: bluetoothDeviceConfig(device).MTU,
|
|
|
- success: (res) => {
|
|
|
- console.log('setBLEMTU success>>', res);
|
|
|
-
|
|
|
- if (bluetoothDeviceConfig(device).alterConnect) {
|
|
|
- var data = bluetoothDeviceConfig(device).alterConnect(device, deviceId);
|
|
|
- console.log(data[0],'data111111');
|
|
|
-
|
|
|
- if (data) {
|
|
|
-
|
|
|
- setTimeout(()=>{
|
|
|
- writeData(device, deviceId, data, callback, fail);
|
|
|
- },100)
|
|
|
+ writeData(device, deviceId, data, callback, fail);
|
|
|
+ },3000)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- console.log('setBLEMTU fail>>', res);
|
|
|
-
|
|
|
- if (bluetoothDeviceConfig(device).alterConnect) {
|
|
|
- var data = bluetoothDeviceConfig(device).alterConnect(device, deviceId);
|
|
|
-
|
|
|
- if (data) {
|
|
|
-
|
|
|
- writeData(device, deviceId, data, callback, fail);
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
-
|
|
|
- if (bluetoothDeviceConfig(device).alterConnect) {
|
|
|
- var data = bluetoothDeviceConfig(device).alterConnect(device, deviceId);
|
|
|
-
|
|
|
- if (data) {
|
|
|
-
|
|
|
- writeData(device, deviceId, data, callback, fail);
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
-
|
|
|
- fail(res);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
-
|
|
|
- fail(res);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
- console.log('getBLEDeviceServices fail',res);
|
|
|
-
|
|
|
- fail(res);
|
|
|
- }
|
|
|
- });
|
|
|
- },500)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- fail(res);
|
|
|
- }
|
|
|
- });
|
|
|
- },500)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function closeDevice(macid, callback = () => {}, fail = () => {}) {
|
|
@@ -650,7 +654,8 @@ function writeData(device, deviceId, data, callback = () => {}, fail = () => {})
|
|
|
|
|
|
|
|
|
|
|
|
- uni.writeBLECharacteristicValue({
|
|
|
+ plus.bluetooth.writeBLECharacteristicValue({
|
|
|
+
|
|
|
deviceId: deviceId,
|
|
|
serviceId: bluetoothDeviceConfig(device).writeServiceID,
|
|
|
characteristicId: bluetoothDeviceConfig(device).writeID,
|
|
@@ -668,7 +673,7 @@ function writeData(device, deviceId, data, callback = () => {}, fail = () => {})
|
|
|
|
|
|
setTimeout(() => {
|
|
|
writeData(device, deviceId, data, callback, fail);
|
|
|
- }, 60);
|
|
|
+ }, 150);
|
|
|
}
|
|
|
},
|
|
|
|