|
@@ -370,9 +370,10 @@ function connectDevice(device, callback = () => {}, fail = () => {}) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- const deviceIds = app.globalData.connectionState[device.mac_id].deviceId
|
|
|
+ const car_sn=uni.getStorageSync('car_info').car_sn
|
|
|
+ const deviceIds = app.globalData.connectionState[car_sn].deviceId
|
|
|
console.log(deviceIds,'deviceIds');
|
|
|
- const device_name=app.globalData.connectionState[device.mac_id].deviceName
|
|
|
+ const device_name=app.globalData.connectionState[car_sn].deviceName
|
|
|
// 创建蓝牙连接
|
|
|
uni.createBLEConnection({
|
|
|
deviceId: deviceIds,
|
|
@@ -637,7 +638,6 @@ function writeData(device, deviceId, data, callback = () => {}, fail = () => {})
|
|
|
// buffer = common.toArrayBuffer(data.shift());
|
|
|
|
|
|
//buffer = common.toArrayBuffer(data.shift());
|
|
|
- console.log()
|
|
|
var byteArray = data.shift()
|
|
|
const buffer = new ArrayBuffer(byteArray.length);
|
|
|
const dataView = new DataView(buffer);
|
|
@@ -1075,12 +1075,12 @@ function sendOTACommand(macid, callback = () => {}, fail = () => {}) {
|
|
|
function executeDeviceCommand(macid, commandName, callback = () => {}, fail = () => {}) {
|
|
|
console.log('test');
|
|
|
const app = getApp();
|
|
|
- const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid);
|
|
|
+ const deviceId = app.globalData.connectionState[macid].deviceId
|
|
|
if (deviceId == undefined) {
|
|
|
fail();
|
|
|
return false;
|
|
|
}
|
|
|
- const device = app.globalData.connectionState[deviceId].device;
|
|
|
+ const device = app.globalData.connectionState[macid].device;
|
|
|
if (!bluetoothDeviceConfig(device)[commandName]) {
|
|
|
fail();
|
|
|
return false;
|
|
@@ -1134,12 +1134,12 @@ function getSensitivity(macid, callback = () => {}, fail = () => {}) {
|
|
|
//设置灵敏度
|
|
|
function setSensitivity(macid,type, callback = () => {}, fail = () => {}) {
|
|
|
const app = getApp();
|
|
|
- const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid);
|
|
|
+ const deviceId = app.globalData.connectionState[macid].deviceId
|
|
|
if (deviceId == undefined) {
|
|
|
fail();
|
|
|
return false;
|
|
|
}
|
|
|
- const device = app.globalData.connectionState[deviceId].device;
|
|
|
+ const device = app.globalData.connectionState[macid].device;
|
|
|
if (!bluetoothDeviceConfig(device)[setSensitivity]) {
|
|
|
fail();
|
|
|
return false;
|