const common = require('./common.js'); // const permisson = require('./permisson.js'); import SystemInfoUtil from './SystemInfoUtil.js'; // 蓝牙对应的权限名称 // 蓝牙权限对应的中文名称 const app = getApp(); const bluetoothDevices = { ZX16D: require('./bluetooth/ZX16D.js'), FMBMS: require('./bluetooth/FMBMS.js'), LFBMS: require('./bluetooth/LFBMS.js'), JYBMS: require('./bluetooth/LFBMS.js'), BLFM: require('./bluetooth/BLFM.js'), ZXBT: require('./bluetooth/ZXBT.js'), LSBMS: require('./bluetooth/LSBMS.js'), LSCabinet: require('./bluetooth/LSCabinet.js'), ZXBTS: require('./bluetooth/ZXBTS.js'), AD3BTS: require('./bluetooth/AD3BTS.js'), BWJT: require('./bluetooth/ZXBT_JL.js'), JTBMS: require('./bluetooth/ZXBT_JL.js'), ZXCAR: require('./bluetooth/ZXCar.js') }; //初始化蓝牙 function initBluetooth() { //监听蓝牙适配器状态变化事件 uni.onBluetoothAdapterStateChange((res) => { console.log(res); Object.keys(app.globalData.adapterStateChangeFunc).forEach((n) => app.globalData.adapterStateChangeFunc[n](res)); }); //监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等 uni.onBLEConnectionStateChange((res) => { if (app.globalData.connectionState[res.deviceId]) { app.globalData.connectionState[res.deviceId].connected = res.connected; const device = app.globalData.connectionState[res.deviceId].device; if (app.globalData.connectionStateChangeFunc[device.mac_id]) { Object.keys(app.globalData.connectionStateChangeFunc[device.mac_id]).forEach((p) => app.globalData.connectionStateChangeFunc[device.mac_id][p](res)); } } }); //监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification uni.onBLECharacteristicValueChange((res) => { if (app.globalData.connectionState[res.deviceId]) { const device = app.globalData.connectionState[res.deviceId].device; if ( res.serviceId.toUpperCase() == bluetoothDeviceConfig(device).readServiceID.toUpperCase() && res.characteristicId.toUpperCase() == bluetoothDeviceConfig(device).readID.toUpperCase() ) { var data = bluetoothDeviceConfig(device).readData(device, res.value, app.globalData.connectionState[res.deviceId].data); if (data) { app.globalData.connectionState[res.deviceId].data = data; if (app.globalData.characteristicStateChangeFunc[device.mac_id]) { Object.keys(app.globalData.characteristicStateChangeFunc[device.mac_id]).forEach((p) => app.globalData.characteristicStateChangeFunc[device.mac_id][p](data) ); console.log(app.globalData.connectionState[res.deviceId].data); } } } } }); } function onAdapterStateChange(name, callback) { app.globalData.adapterStateChangeFunc[name] = callback; } function offAdapterStateChange(name) { delete app.globalData.adapterStateChangeFunc[name]; } function onConnectionStateChange(macid, name, callback) { if (!app.globalData.connectionStateChangeFunc[macid]) { app.globalData.connectionStateChangeFunc[macid] = {}; } app.globalData.connectionStateChangeFunc[macid][name] = callback; } function offConnectionStateChange(macid, name) { if (app.globalData.connectionStateChangeFunc[macid]) { delete app.globalData.connectionStateChangeFunc[macid][name]; } } function onCharacteristicStateChange(macid, name, callback) { if (!app.globalData.characteristicStateChangeFunc[macid]) { app.globalData.characteristicStateChangeFunc[macid] = {}; } app.globalData.characteristicStateChangeFunc[macid][name] = callback; } function offCharacteristicStateChange(macid, name) { if (app.globalData.characteristicStateChangeFunc[macid]) { delete app.globalData.characteristicStateChangeFunc[macid][name]; } } function getAdapterState(callback = () => {}, fail = () => {}) { uni.getBluetoothAdapterState({ success: (res) => { callback(res); }, fail: (res) => { console.log(res); fail(res); } }); } function openBluetoothAdapter(callback = () => {}, fail = () => {}) { uni.openBluetoothAdapter({ success: (res) => { console.log(res); callback(res); }, fail: (res) => { console.log(res); //permisson.permission_request(blePermissionName, blePermissionZhName); fail(res); } }); } function closeBluetoothAdapter(callback = () => {}, fail = () => {}) { uni.closeBluetoothAdapter({ success: (res) => { app.globalData.adapterStateChangeFunc = {}; app.globalData.connectionStateChangeFunc = {}; app.globalData.characteristicStateChangeFunc = {}; app.globalData.connectionState = {}; callback(res); }, fail: (res) => { console.log(res); fail(res); } }); } function acceptDevice(device) { return bluetoothDevices[device.bt_type] || (bluetoothDevices[device.device_type] && bluetoothDevices[device.device_type].acceptDevice(device)) ? true : false; } function isSingleBT(device) { // if (bluetoothDevices[device_type] && bluetoothDevices[device_type].isSingleBt) { // return bluetoothDevices[device_type].isSingleBt() // } // return false if (bluetoothDeviceConfig(device) && bluetoothDeviceConfig(device).isSingleBt) { return bluetoothDeviceConfig(device).isSingleBt(); } return false; } function isBuzzer(device) { if (bluetoothDeviceConfig(device) && bluetoothDeviceConfig(device).isBuzzer) { return bluetoothDeviceConfig(device).isBuzzer(); } return false; } function isVoltageToEle(device) { if (bluetoothDeviceConfig(device) && bluetoothDeviceConfig(device).voltageToEle) { return true; } return false; } function isSginleBtByMacid(macid) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); console.log(app.globalData.connectionState); if (deviceId == undefined) { return false; } return isSingleBT(app.globalData.connectionState[deviceId].device); } function haveBMSForBT(device) { if (bluetoothDeviceConfig(device) && bluetoothDeviceConfig(device).haveBms) { return bluetoothDeviceConfig(device).haveBms(); } return false; } function findDevice(device, callback = () => {}, fail = () => {}) { var deviceId = ''; if (!bluetoothDeviceConfig(device)) { return; } console.log('查找到为蓝牙设备'); uni.startBluetoothDevicesDiscovery({ success(res) { console.log(res); uni.getBluetoothDevices({ success: (res) => { console.log(res); res.devices.forEach((data) => { console.log(data); if (bluetoothDeviceConfig(device).isDevice(device, data)) { // uni.offBluetoothDeviceFound(); uni.stopBluetoothDevicesDiscovery(); deviceId = data.deviceId; if (app.globalData.connectionState[deviceId]) { app.globalData.connectionState[deviceId].device = device; } else { app.globalData.connectionState[deviceId] = { device: device, deviceId: deviceId, connected: false, data: {} }; } callback(deviceId); } }); setTimeout(function () { if (!deviceId) { // uni.offBluetoothDeviceFound(); uni.stopBluetoothDevicesDiscovery(); var res = { errCode: 9000001, errMsg: 'openBluetoothAdapter:find not device', errno: 9000002 }; fail(res); } }, 5000); }, fail(res) { uni.stopBluetoothDevicesDiscovery(); console.log(res); fail(res); } }); uni.onBluetoothDeviceFound((res) => { // console.log(res); res.devices.forEach((data) => { if (bluetoothDeviceConfig(device).isDevice(device, data)) { // uni.offBluetoothDeviceFound(); uni.stopBluetoothDevicesDiscovery(); deviceId = data.deviceId; if (app.globalData.connectionState[deviceId]) { app.globalData.connectionState[deviceId].device = device; } else { app.globalData.connectionState[deviceId] = { device: device, deviceId: deviceId, connected: false, data: {} }; } callback(deviceId); } }); }); }, fail(res) { console.log(res); fail(res); } }); } function connectDevice(device, callback = () => {}, fail = () => {}) { console.log(device); if (!bluetoothDeviceConfig(device) || !bluetoothDeviceConfig(device).acceptDevice(device)) { return; } const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == device.mac_id); if (deviceId == undefined) { findDevice( device, (deviceId) => { connectDevice(device, callback, fail); }, (res) => { fail(res); } ); return; } else { if (app.globalData.connectionState[deviceId].connected) { callback(); return; } } uni.createBLEConnection({ deviceId: deviceId, success: (res) => { app.globalData.connectionState[deviceId] = { device: device, deviceId: deviceId, connected: true, data: {} }; alterConnect( device, deviceId, (res) => { console.log(res); callback(res); }, (res) => { console.log(res); closeDevice(deviceId); fail(res); } ); }, fail(res) { console.log(res); if (res.errCode == -1) { closeDevice( deviceId, (res) => { connectDevice(device, callback, fail); }, (res) => { fail(res); } ); } else { fail(res); } } }); } function alterConnect(device, deviceId, callback = () => {}, fail = () => {}) { if (!bluetoothDeviceConfig(device) || !bluetoothDeviceConfig(device).acceptDevice(device)) { return; } uni.getBLEDeviceServices({ deviceId: deviceId, success(res) { console.log(res,'res1111'); 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,'data111111'); if (data) { writeData(device, deviceId, data, callback, fail); } 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) { fail(res); } }); }, fail(res) { fail(res); } }); } function closeDevice(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return; } else { if (!app.globalData.connectionState[deviceId].connected) { callback(); return; } } const device = app.globalData.connectionState[deviceId].device; uni.closeBLEConnection({ deviceId: deviceId, success: (res) => { console.log(res); if (app.globalData.connectionState[deviceId]) { app.globalData.connectionState[deviceId].connected = false; } callback(res); }, fail(res) { console.log(res); fail(res); } }); } function bmsInfo(macid) { console.log(macid); const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).bmsInfo) { return false; } return bluetoothDeviceConfig(device).bmsInfo(device, deviceId, app.globalData.connectionState[deviceId].data); } function bmsSet(macid, name, vars, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).bmsSet) { fail(); return false; } var data = bluetoothDeviceConfig(device).bmsSet(device, deviceId, name, vars); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function writeData(device, deviceId, data, callback = () => {}, fail = () => {}) { if (data.length == 0) { return; } var buffer; buffer = common.toArrayBuffer(data.shift()); uni.writeBLECharacteristicValue({ deviceId: deviceId, serviceId: bluetoothDeviceConfig(device).writeServiceID, characteristicId: bluetoothDeviceConfig(device).writeID, value: buffer, success(res) { console.log(res); if (data.length == 0) { callback(res); } else { setTimeout(() => { writeData(device, deviceId, data, callback, fail); }, 500); } }, fail(res) { console.log(res); fail(res); } }); } function stateUpdate(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).stateUpdate) { fail(); return false; } var data = bluetoothDeviceConfig(device).stateUpdate(device, deviceId); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function voltageToEle(macid, value, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).voltageToEle) { fail(); return false; } var data = bluetoothDeviceConfig(device).voltageToEle(device, value); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function turnOn(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).turnOn) { fail(); return false; } var data = bluetoothDeviceConfig(device).turnOn(device, deviceId); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function turnOnBuzzer(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).turnOnBuzzer) { fail(); return false; } var data = bluetoothDeviceConfig(device).turnOnBuzzer(device, deviceId); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function turnOffBuzzer(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).turnOffBuzzer) { fail(); return false; } var data = bluetoothDeviceConfig(device).turnOffBuzzer(device, deviceId); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function turnOff(macid, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).turnOff) { fail(); return false; } var data = bluetoothDeviceConfig(device).turnOff(device, deviceId); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function bmsChargingMOS(macid, value, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).bmsChargingMOS) { fail(); return false; } var data = bluetoothDeviceConfig(device).bmsChargingMOS(value - 0, device); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function bmsDischargeMOS(macid, value, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDeviceConfig(device).bmsDischargeMOS) { fail(); return false; } var data = bluetoothDeviceConfig(device).bmsDischargeMOS(value - 0, device); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function isConnected(macid) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { return false; } return app.globalData.connectionState[deviceId].connected; } function getData(macid) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { return false; } return app.globalData.connectionState[deviceId].data; } function getConnectionState(macid) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { return false; } return app.globalData.connectionState[deviceId]; } function bluetoothDeviceConfig(device) { if (bluetoothDevices[device.bt_type]) { return bluetoothDevices[device.bt_type]; } else if (bluetoothDevices[device.device_type]) { return bluetoothDevices[device.device_type]; } else { return false; } } function isUniversalBluetoothPlugin(device) { if (bluetoothDevices[device.bt_type]) { return bluetoothDevices[device.bt_type]; } else { return false; } } function sendHireCommand(macid, info, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendHireCommand) { fail(); return false; } var data = bluetoothDevices[device.device_type].sendHireCommand(info); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function sendBackCommand(macid, info, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendBackCommand) { fail(); return false; } var data = bluetoothDevices[device.device_type].sendBackCommand(info); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function sendExchangeCommand(macid, info, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendExchangeCommand) { fail(); return false; } var data = bluetoothDevices[device.device_type].sendExchangeCommand(info); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function sendGetCabinetInfoCommand(macid, info, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); console.log(deviceId,'deviceId0000'); if (deviceId == undefined) { fail(); return false; } console.log(app.globalData.connectionState[deviceId].device,'device333333'); console.log(bluetoothDevices,'deviceId11111'); console.log(bluetoothDevices['ZXCAR'].sendGetCabinetInfoCommand,'test333'); const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendGetCabinetInfoCommand) { fail(); return false; } console.log(bluetoothDevices[device.device_type].sendGetCabinetInfoCommand(info),'deviceId2222'); var data = bluetoothDevices[device.device_type].sendGetCabinetInfoCommand(info); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function sendConfirmCommand(macid, value, serialNum, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendConfirmCommand) { fail(); return false; } var data = bluetoothDevices[device.device_type].sendConfirmCommand(value, serialNum); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } function sendCancelCommand(macid, serialNum, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if (!bluetoothDevices[device.device_type].sendCancelCommand) { fail(); return false; } var data = bluetoothDevices[device.device_type].sendCancelCommand(serialNum); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } async function sendOTACommand(macid, value, callback = () => {}, fail = () => {}) { const deviceId = Object.keys(app.globalData.connectionState).find((i) => app.globalData.connectionState[i].device.mac_id == macid); if (deviceId == undefined) { fail(); return false; } const device = app.globalData.connectionState[deviceId].device; if ( await !bluetoothDeviceConfig(device).otaUpgrade) { fail(); return false; } var data = await bluetoothDeviceConfig(device).otaUpgrade(value - 0, device); if (data) { writeData(device, deviceId, data, callback, fail); return true; } fail(); return false; } module.exports = { initBluetooth: initBluetooth, onAdapterStateChange: onAdapterStateChange, offAdapterStateChange: offAdapterStateChange, onConnectionStateChange: onConnectionStateChange, offConnectionStateChange: offConnectionStateChange, onCharacteristicStateChange: onCharacteristicStateChange, offCharacteristicStateChange: offCharacteristicStateChange, getAdapterState: getAdapterState, openBluetoothAdapter: openBluetoothAdapter, closeBluetoothAdapter: closeBluetoothAdapter, acceptDevice: acceptDevice, findDevice: findDevice, connectDevice: connectDevice, closeDevice: closeDevice, stateUpdate: stateUpdate, turnOn: turnOn, turnOff: turnOff, turnOnBuzzer: turnOnBuzzer, turnOffBuzzer: turnOffBuzzer, bmsInfo: bmsInfo, bmsSet: bmsSet, isConnected: isConnected, getData: getData, isSingleBT: isSingleBT, isBuzzer: isBuzzer, haveBMSForBT: haveBMSForBT, isSginleBtByMacid: isSginleBtByMacid, getConnectionState: getConnectionState, bmsChargingMOS: bmsChargingMOS, bmsDischargeMOS: bmsDischargeMOS, bluetoothDeviceConfig: bluetoothDeviceConfig, voltageToEle: voltageToEle, isVoltageToEle: isVoltageToEle, isUniversalBluetoothPlugin: isUniversalBluetoothPlugin, //机柜协议增加 sendHireCommand: sendHireCommand, sendBackCommand: sendBackCommand, sendExchangeCommand: sendExchangeCommand, sendGetCabinetInfoCommand: sendGetCabinetInfoCommand, sendConfirmCommand: sendConfirmCommand, sendCancelCommand: sendCancelCommand, //蓝牙中控 sendOTACommand };