const _0x2260 = ['508001', 'openBluetoothAdapter', 'characteristics', 'failCode', 'readBLECharacteristicValue', '数据解析失败', 'call', 'RSSI', '断开连接成功', 'offBLEConnectionStateChange', 'successCode', 'deviceId', 'substring', 'success', 'serviceId', 'startConnectBle->', 'toString', '00002A28-0000-1000-8000-00805F9B34FB', '操作失败', 'code', 'log', 'getBLEDeviceCharacteristics->', '已连接', 'slice', 'characteristicId', '0000180A-0000-1000-8000-00805F9B34FB', 'charAt', '执行成功', '发送ICC指令', 'errMsg', 'deviceList', 'fail', '蓝牙搜索已停止', '获取蓝牙版本号失败', 'localName', '认证成功', 'devices', 'closeBluetoothAdapter', 'noTargetCharacteristic', 'length', 'padStart', '0000FF03-0000-1000-8000-00805F9B34FB', 'msg', 'createBLEConnection', 'notifyBLECharacteristicValueChange', '认证失败', '发送ESAM指令', 'receiveData->', 'data', 'services', 'onIsEnable', '5080', 'writeBLECharacteristicValue', 'name', 'function', '断开连接失败', 'uuid', 'onBLECharacteristicValueChange', 'push', '未连接', '5000', 'value', 'stopBluetoothDevicesDiscovery', 'sendData->', 'padEnd', 'join', 'getBluetoothVersionUUID->', 'buffer', '蓝牙状态正常' ]; const _0x5b64 = function(_0x2260b7, _0x5b649a) { _0x2260b7 = _0x2260b7 - 0x0; let _0x4ba33a = _0x2260[_0x2260b7]; return _0x4ba33a; }; module['exports'] = { 'scanBle': scanBle, 'closBluetooth': closBluetooth, 'connectDevice': connectDevice, 'disconnectDevice': disconnectDevice, 'transCmd': transCmd, 'disconnectDeviceBluetooth': disconnectDeviceBluetooth }; var deviceList = []; var onIsEnable = toResObject(0x0, _0x5b64('0x44')); var scanBleTimer; function toResObject(_0x30005a, _0x54b515) { return { 'code': _0x30005a, 'msg': _0x54b515 }; } function scanBle(_0x7fe242, _0x1d0507) { this[_0x5b64('0x1e')] = []; this['onIsEnable'] = toResObject(0x0, _0x5b64('0x44')); scanBleTimer = setTimeout(() => { wx['stopBluetoothDevicesDiscovery'](); _0x1d0507(this[_0x5b64('0x1e')], this[_0x5b64('0x32')]); }, _0x7fe242); wx[_0x5b64('0x1')]({ 'success': _0x572619 => { wx['startBluetoothDevicesDiscovery']({ 'allowDuplicatesKey': !![], 'interval': 0x64, 'success': _0x10b54e => { wx['onBluetoothDeviceFound'](_0x4a78d0 => { for (let _0x44b154 = 0x0; _0x44b154 < _0x4a78d0['devices'][ _0x5b64('0x27') ]; _0x44b154++) { let _0x57d361 = ![]; if (_0x4a78d0['devices'][_0x44b154][_0x5b64('0x22')] == undefined || _0x4a78d0['devices'][_0x44b154][ 'localName'] == '' || _0x4a78d0[_0x5b64('0x24')][ _0x44b154 ][_0x5b64('0x22')] == '') { break; } for (let _0x3b119a = 0x0; _0x3b119a < this[_0x5b64('0x1e')][ 'length' ]; _0x3b119a++) { if (_0x4a78d0['devices'][_0x44b154]['deviceId'] == this[ _0x5b64('0x1e')][_0x3b119a][_0x5b64('0xb')]) { _0x57d361 = !![]; break; } } if (_0x57d361 == ![]) { let _0x9edd5e = {}; _0x9edd5e[_0x5b64('0x35')] = _0x4a78d0[_0x5b64('0x24')][ _0x44b154 ]['localName']; _0x9edd5e['deviceId'] = _0x4a78d0['devices'][_0x44b154][ 'deviceId' ]; _0x9edd5e['RSSI'] = _0x4a78d0['devices'][_0x44b154][ _0x5b64('0x7') ]; this['deviceList'][_0x5b64('0x3a')](_0x9edd5e); } } }); }, 'fail': _0x2301b8 => { this[_0x5b64('0x1e')] = []; this['onIsEnable'] = toResObject(-0x1, _0x2301b8['errMsg']); clearTimeout(scanBleTimer); _0x1d0507(this[_0x5b64('0x1e')], this[_0x5b64('0x32')]); } }); }, 'fail': _0x1ffde9 => { this['deviceList'] = []; this[_0x5b64('0x32')] = toResObject(-0x1, _0x1ffde9[_0x5b64('0x1d')]); clearTimeout(scanBleTimer); _0x1d0507(this[_0x5b64('0x1e')], this['onIsEnable']); } }); } function closBluetooth(_0x3b3fd8) { clearTimeout(scanBleTimer); wx[_0x5b64('0x3e')]({ 'success': _0xbfa7ce => { _0x3b3fd8(toResObject(0x0, _0x5b64('0x20'))); }, 'fail': _0x30c2dd => { _0x3b3fd8(toResObject(-0x1, _0x30c2dd['errMsg'])); } }); } function connectDevice(_0x41e7c0, _0x47415a, _0x29a97e) { wx['onBLEConnectionStateChange'](_0x504a3b => { if (_0x504a3b['connected']) { _0x29a97e(toResObject(0x0, _0x5b64('0x16'))); } else { _0x29a97e(toResObject(-0x1, _0x5b64('0x3b'))); } }); connectAndInit(_0x41e7c0, { 'success': _0x279aa9 => { if (_0x279aa9[_0x5b64('0x13')] == 0x3e8 || _0x279aa9['statusCode'] == 0x3e8) { _0x47415a(toResObject(0x0, '连接成功')); } }, 'fail': _0x5eadb0 => { _0x47415a(toResObject(-0x1, _0x5eadb0[_0x5b64('0x2a')])); } }, 0x1f40); } function disconnectDevice(_0x1061b0) { disconnectBleDevice({ 'success': _0xff64d4 => { this['connectDeviceId'] = undefined; _0x1061b0(toResObject(0x0, '已断连')); wx[_0x5b64('0x9')](); wx[_0x5b64('0x25')](); }, 'fail': _0x340760 => { _0x1061b0(toResObject(-0x1, _0x340760[_0x5b64('0x2a')])); wx['offBLEConnectionStateChange'](); wx[_0x5b64('0x25')](); } }); } function transCmd(_0x5ac97d, _0x5740ad, _0x9016d) { if (connectDeviceId == undefined) { let _0x11c43d = toResObject(-0x1, '未连接设备'); _0x11c43d[_0x5b64('0x30')] = undefined; _0x9016d(_0x11c43d); return; } if (_0x5740ad == '10') { postCommand(0x1, _0x5ac97d, { 'success': _0x5200ce => { let _0x7cf1e4 = toResObject(0x0, _0x5b64('0x1b')); _0x7cf1e4['data'] = _0x5200ce['data']; _0x9016d(_0x7cf1e4); }, 'fail': _0x38dd09 => { let _0x54734e = toResObject(-0x1, _0x38dd09[_0x5b64('0x2a')]); _0x54734e['data'] = undefined; _0x9016d(_0x54734e); } }, 0xfa0); } if (_0x5740ad == '20') { postCommand(0x2, _0x5ac97d, { 'success': _0x20023e => { let _0x2a29f3 = toResObject(0x0, _0x5b64('0x1b')); _0x2a29f3['data'] = _0x20023e[_0x5b64('0x30')]; _0x9016d(_0x2a29f3); }, 'fail': _0x1cb7d7 => { let _0x281084 = toResObject(-0x1, _0x1cb7d7['msg']); _0x281084['data'] = undefined; _0x9016d(_0x281084); } }, 0xfa0); } } function disconnectDeviceBluetooth(_0x4af6f2) { deviceChannel('C3', { 'success': _0x358f1c => { _0x4af6f2(toResObject(0x0, '已断连')); wx['offBLEConnectionStateChange'](); wx[_0x5b64('0x25')](); }, 'fail': _0x52e776 => { _0x4af6f2(toResObject(0x0, '已断连')); wx['offBLEConnectionStateChange'](); wx[_0x5b64('0x25')](); } }, 0xfa0); } const codeEnum = { 'successCode': 0x3e8, 'failCode': 0xfa0, 'timeout': 0x64 }; const FUNCTION = _0x5b64('0x36'); const serviceUUID = '0000FF17-0000-1000-8000-00805F9B34FB'; const writeUUID = '0000FF02-0000-1000-8000-00805F9B34FB'; const readUUID = _0x5b64('0x29'); const UUIDCHAR1 = _0x5b64('0x19'); const UUIDCHAR2 = _0x5b64('0x11'); var hasChar1 = ![]; var hasChar2 = ![]; var version = ''; var connectDeviceId; var connectCallback; var connectTimer; var sendIndex = 0x0; function toObject(_0x393655, _0x3e1476, _0x497697) { return { 'code': _0x393655, 'data': _0x3e1476, 'msg': _0x497697 }; } function connectAndInit(_0x37ca85, _0xb9650d, _0x18988f) { hasChar1 = ![]; hasChar1 = ![]; version = ''; connectDeviceId = _0x37ca85[_0x5b64('0xb')]; connectCallback = _0xb9650d; if (connectTimer != undefined) { clearTimeout(connectTimer); } connectTimer = setTimeout(() => { connectTimer = undefined; typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(0x7d2, undefined, '连接超时')); }, _0x18988f); startConnectBle(); } function disconnectBleDevice(_0xfa48b3) { const _0x20ed38 = String(connectDeviceId); wx['closeBLEConnection']({ 'deviceId': _0x20ed38, 'success'(_0x1af5b5) { if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof _0xfa48b3[_0x5b64('0xd')] == FUNCTION && _0xfa48b3[_0x5b64('0xd')](toObject(codeEnum[ 'successCode'], _0x1af5b5, _0x5b64('0x8'))); }, 'fail'(_0x5446d8) { console[_0x5b64('0x14')]('disconnectDevice->', _0x5446d8); if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof _0xfa48b3[_0x5b64('0x1f')] == FUNCTION && _0xfa48b3[_0x5b64('0x1f')](toObject(codeEnum[ 'failCode'], _0x5446d8, _0x5b64('0x37'))); } }); } function startConnectBle() { if (connectTimer == undefined) { return; } wx[_0x5b64('0x2b')]({ 'deviceId': connectDeviceId, 'success': _0x1926c5 => { startGetAndCheckService(); }, 'fail': _0x4bee2a => { console['log'](_0x5b64('0xf'), _0x4bee2a); if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[_0x5b64( '0x3')], undefined, 'creatConnectionFailure')); } }); } function startGetAndCheckService() { if (connectTimer == undefined) { return; } wx['getBLEDeviceServices']({ 'deviceId': connectDeviceId, 'success': _0x160c13 => { for (let _0x173858 = 0x0; _0x173858 < _0x160c13[_0x5b64('0x31')][_0x5b64( '0x27')]; _0x173858++) { let _0x2bf2c9 = _0x160c13[_0x5b64('0x31')][_0x173858][_0x5b64('0x38')]; if (_0x2bf2c9 == UUIDCHAR1) { hasChar1 = !![]; getBluetoothVersionUUID(); break; } } let _0x2bffe9 = ![]; for (let _0x3f6092 = 0x0; _0x3f6092 < _0x160c13['services'][_0x5b64('0x27')]; _0x3f6092++) { let _0x43d377 = _0x160c13[_0x5b64('0x31')][_0x3f6092][_0x5b64('0x38')]; if (_0x43d377 == serviceUUID) { _0x2bffe9 = !![]; break; } } if (_0x2bffe9 == !![]) { startGetAndCheckCharacterisitc(); } else { if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback['fail'](toObject( codeEnum['failCode'], undefined, 'noTargetServiceId')); } } }, 'fail': _0x28f606 => { console['log']('getBLEDeviceServices->', _0x28f606); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[ _0x5b64('0x3')], undefined, _0x28f606[_0x5b64('0x1d')])); } } }); } function startGetAndCheckCharacterisitc() { if (connectTimer == undefined) { return; } wx['getBLEDeviceCharacteristics']({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'success': _0x330c9f => { let _0x452b54 = ![]; let _0x147f84 = ![]; for (let _0x56dcdf = 0x0; _0x56dcdf < _0x330c9f[_0x5b64('0x2')]['length']; _0x56dcdf++) { let _0xab10a6 = _0x330c9f['characteristics'][_0x56dcdf]['uuid']; if (_0xab10a6 == readUUID) { _0x452b54 = !![]; } else if (_0xab10a6 == writeUUID) { _0x147f84 = !![]; } if (_0x452b54 == !![] && _0x147f84 == !![]) { break; } } if (_0x452b54 == !![] && _0x147f84 == !![]) { monitorNotification(); } else { if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback[_0x5b64('0x1f')]( toObject(codeEnum['failCode'], undefined, _0x5b64('0x26'))); } } }, 'fail': _0x27e5f3 => { console['log'](_0x5b64('0x15'), _0x27e5f3); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[ 'failCode'], undefined, _0x27e5f3[_0x5b64('0x1d')])); } } }); } function monitorNotification() { if (connectTimer == undefined) { return; } wx[_0x5b64('0x2c')]({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'characteristicId': readUUID, 'state': !![], 'success': _0x397f51 => { if (typeof connectTimer != undefined) { clearTimeout(connectTimer); } wx[_0x5b64('0x39')](function(_0xa1119e) { if (_0xa1119e['deviceId'] = connectDeviceId && _0xa1119e['serviceId'] == serviceUUID && _0xa1119e[_0x5b64('0x18')] == readUUID) { let _0x102714 = arrayBuffer2hex(_0xa1119e[_0x5b64('0x3d')]); analyticData(_0x102714); } }); setTimeout(() => { typeof connectCallback[_0x5b64('0xd')] == FUNCTION && connectCallback[_0x5b64( '0xd')](toObject(codeEnum['successCode'], undefined, '连接成功,握手成功')); }, 0x3e8); }, 'fail': _0x3ad67f => { console[_0x5b64('0x14')]('notifyBLECharacteristicValueChange->', _0x3ad67f); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x5b64('0x1f')](toObject( codeEnum['failCode'], undefined, _0x3ad67f[_0x5b64('0x1d')])); } } }); } function getBluetoothVersionUUID() { wx['getBLEDeviceCharacteristics']({ 'deviceId': connectDeviceId, 'serviceId': UUIDCHAR1, 'success': _0x5722c6 => { for (let _0x32d58e = 0x0; _0x32d58e < _0x5722c6['characteristics']['length']; _0x32d58e++) { let _0x3bce97 = _0x5722c6['characteristics'][_0x32d58e]['uuid']; if (_0x3bce97 == UUIDCHAR2) { hasChar2 = !![]; break; } } }, 'fail': _0x1498ae => { console['log'](_0x5b64('0x42'), _0x1498ae); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[ 'failCode'], undefined, _0x5b64('0x21'))); } } }); } function readBLECharacteristicValue() { wx[_0x5b64('0x4')]({ 'deviceId': connectDeviceId, 'serviceId': UUIDCHAR1, 'characteristicId': UUIDCHAR2, 'success': _0x313e20 => { console[_0x5b64('0x14')]('readBLECharacteristicValueSuccess->', _0x313e20); }, 'fail': _0x5b0ea9 => { console['log']('readBLECharacteristicValueFail->', _0x5b0ea9); } }); } function onBLECharacteristicValueChange() { wx['onBLECharacteristicValueChange'](_0x26a854 => { console['log']('receiveData->', arrayBuffer2hex(_0x26a854[_0x5b64('0x3d')])); if (_0x26a854['deviceId'] == connectDeviceId && _0x26a854[_0x5b64('0xe')] == serviceUUID && _0x26a854[ _0x5b64('0x18')] == readUUID) { let _0x50e6b5 = arrayBuffer2hex(_0x26a854[_0x5b64('0x3d')]); analyticData(_0x50e6b5); } else if (_0x26a854[_0x5b64('0xb')] == connectDeviceId && _0x26a854['serviceId'] == UUIDCHAR1 && _0x26a854[_0x5b64('0x18')] == UUIDCHAR2) { let _0x364d00 = arrayBuffer2hex(_0x26a854['value'])['toUpperCase'](); if (connectTimer != undefined) { clearTimeout(connectTimer); if (_0x364d00 != '') { typeof connectCallback['success'] == FUNCTION && connectCallback[_0x5b64('0xd')](toObject( codeEnum[_0x5b64('0xa')], _0x364d00, '连接成功')); } else { typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback[_0x5b64('0x1f')]( toObject(codeEnum['successCode'], undefined, '连接失败')); } } } }); } var dataArrays; var dataIndex = 0x0; var sendArrays = 0x0; var mCallBack; var transTimer; var receivePacketCount = 0x0; var receivePacketData = ''; var receiveLength = 0x0; var receiveData = ''; function analyticData(_0x2b3ef4) { if (_0x2b3ef4[_0x5b64('0x17')](0x0, 0x2) == '50' && (_0x2b3ef4[_0x5b64('0x17')](0x2, 0x4) == '80' || _0x2b3ef4[ _0x5b64('0x17')](0x2, 0x4) == '00') && (_0x2b3ef4['length'] < 0x28 || _0x2b3ef4['length'] == 0x28)) { receiveLength = parseInt(_0x2b3ef4['slice'](0x6, 0xa), 0x10); if (_0x2b3ef4[_0x5b64('0x17')](0x2, 0x4) == '80') { receivePacketCount = parseInt(_0x2b3ef4[_0x5b64('0x17')](0x4, 0x6), 0x10); } } if (receiveLength != 0x0) { receiveData += _0x2b3ef4; } console[_0x5b64('0x14')](_0x5b64('0x2f'), receiveData); if (receiveData[_0x5b64('0x17')](0xa, receiveData['length'] - 0x2)['length'] == receiveLength * 0x2) { if (receiveData[_0x5b64('0x17')](0x0, 0x2) == '50' && receiveData[_0x5b64('0x17')](0x2, 0x4) == '80' && receiveData[_0x5b64('0x17')](0xa, 0xc) == '97') { if (receiveData[_0x5b64('0x17')](0xa, 0xc) == '00' && receiveData[_0x5b64('0x17')](0x14, 0x16) == '00') { updateRead(!![]); } else { updateRead(![]); } receiveData = ''; } else { receivePacketData += receiveData['slice'](0xa, receiveData['length'] - 0x2); receiveData = ''; receiveLength = 0x0; receivePacketCount--; if (receivePacketCount > 0x0) { return; } let _0xbc3109 = receivePacketData; receivePacketData = ''; receivePacketCount = ''; if (_0xbc3109['slice'](0x0, 0x2) == '92') { cosDataRead(_0xbc3109); } else if (_0xbc3109['slice'](0x0, 0x2) == '91') { deviceChannelRead(_0xbc3109); } else if (_0xbc3109['slice'](0x0, 0x2) == '94') { authCodeRead(_0xbc3109); } } } } function updateRead(_0x5bdeed) { if (_0x5bdeed) { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x5b64('0xa')], null, '成功')); } else { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(codeEnum[_0x5b64('0x3')], null, '失败')); } } function cosDataRead(_0x44b0d9) { let _0x4aad28 = _0x44b0d9[_0x5b64('0x17')](0x4, 0x6); let _0x25c75b = ''; if (_0x4aad28 == '10') { _0x25c75b = _0x5b64('0x1c'); } else { _0x25c75b = _0x5b64('0x2e'); } let _0x57001e = parseInt(_0x44b0d9['slice'](0x6, 0xa), 0x10); if (_0x44b0d9['slice'](0xa)[_0x5b64('0x27')] == _0x57001e * 0x2) { let _0x2f7894 = new Array(); let _0x4c82b7 = _0x44b0d9[_0x5b64('0x17')](0xa); let _0x10a3f3 = _0x4c82b7[_0x5b64('0x17')](0x0, 0x2); let _0x5ee3c2 = 0x0; while (_0x10a3f3 == '81') { _0x5ee3c2++; _0x10a3f3 = _0x4c82b7[_0x5b64('0x17')](_0x5ee3c2 * 0x2, _0x5ee3c2 * 0x2 + 0x2); } let _0x4668d0 = _0x4c82b7['slice'](_0x5ee3c2 * 0x2 + 0x2); let _0x408d1d = parseInt(_0x4668d0['slice'](0x2, 0x4), 0x10) * 0x2; _0x2f7894['push'](_0x4668d0[_0x5b64('0x17')](0x4, 0x4 + _0x408d1d)); let _0x5187a9 = _0x4668d0[_0x5b64('0xc')](0x4 + _0x408d1d); while (_0x5187a9 != '') { _0x408d1d = parseInt(_0x5187a9[_0x5b64('0x17')](0x2, 0x4), 0x10) * 0x2; _0x2f7894[_0x5b64('0x3a')](_0x5187a9['slice'](0x4, 0x4 + _0x408d1d)); _0x5187a9 = _0x5187a9['substring'](0x4 + _0x408d1d); } if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], _0x2f7894, _0x25c75b + '成功')); } else { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['fail'] == FUNCTION && mCallBack['fail'](toObject(codeEnum[_0x5b64('0x3')], null, _0x5b64( '0x5'))); } } function deviceChannelRead(_0x58f05f) { let _0x58a563 = _0x58f05f['slice'](0x2, 0x4); if (transTimer != undefined) { clearTimeout(transTimer); } if (_0x58a563 == '00') { typeof mCallBack['success'] == FUNCTION && mCallBack[_0x5b64('0xd')](toObject(codeEnum['successCode'], _0x58f05f['slice'](0xa), '操作成功')); } else { typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null, _0x5b64('0x12'))); } } function authCodeRead(_0x42a6be) { let _0x274035 = _0x42a6be[_0x5b64('0x17')](0x2, 0x4); if (transTimer != undefined) { clearTimeout(transTimer); } if (_0x274035 == '00') { typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack[_0x5b64('0xd')](toObject(codeEnum['successCode'], _0x42a6be['slice'](0xa), _0x5b64('0x23'))); } else { typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x5b64('0xa')], null, _0x5b64('0x2d'))); } } function postCommand(_0x11f84c, _0x18df9d, _0x6519e2, _0x423e32) { mCallBack = _0x6519e2; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined, '发送指令超时')); }, _0x423e32); dataArrays = new Array(); dataIndex = 0x0; let _0x3348d9 = getCosData(_0x18df9d); let _0x1bb0bc = '82' + _0x11f84c[_0x5b64('0x10')](0x10)[_0x5b64('0x40')](0x2, '0') + (_0x3348d9['length'] / 0x2)[ _0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x3348d9; let _0x122d26 = 0x50 * 0x2; if (_0x1bb0bc['length'] < _0x122d26) { _0x1bb0bc = _0x5b64('0x0') + (_0x1bb0bc[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x1bb0bc; dataArrays[0x0] = _0x1bb0bc + CRC8(_0x1bb0bc); } else { let _0x1713bd = parseInt(_0x1bb0bc['length'] % _0x122d26 == 0x0 ? _0x1bb0bc['length'] / _0x122d26 : _0x1bb0bc[ _0x5b64('0x27')] / _0x122d26 + 0x1); for (let _0x3b09d6 = 0x0; _0x3b09d6 < _0x1713bd; _0x3b09d6++) { let _0x2692f8 = _0x3b09d6 + 0x1; let _0x429c3a = ''; if (_0x3b09d6 == _0x1713bd - 0x1) { _0x429c3a = _0x1bb0bc['slice'](_0x3b09d6 * _0x122d26); } else { _0x429c3a = _0x1bb0bc[_0x5b64('0x17')](_0x3b09d6 * _0x122d26, _0x2692f8 * _0x122d26); } if (_0x3b09d6 == 0x0) { _0x429c3a = '5080' + _0x1713bd['toString'](0x10)[_0x5b64('0x28')](0x2, '0') + (_0x429c3a[_0x5b64( '0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x429c3a; } else { _0x429c3a = _0x5b64('0x3c') + _0x2692f8[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x429c3a[ _0x5b64('0x27')] / 0x2)['toString'](0x10)[_0x5b64('0x28')](0x4, '0') + _0x429c3a; } dataArrays[_0x3b09d6] = _0x429c3a + CRC8(_0x429c3a); } } initReadValue(); write(dataArrays[dataIndex]); } function getCosData(_0x2a3a45) { let _0x31c510 = ''; for (let _0x4c0e88 = 0x0; _0x4c0e88 < _0x2a3a45[_0x5b64('0x27')]; _0x4c0e88++) { _0x31c510 += (_0x4c0e88 + 0x1)[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x2a3a45[_0x4c0e88]['length'] / 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x2, '0') + _0x2a3a45[_0x4c0e88]; } return '80' + (_0x31c510[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + _0x31c510; } function deviceChannel(_0x337446, _0x18f599, _0x24f468) { mCallBack = _0x18f599; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined, '操作超时')); }, _0x24f468); dataArrays = new Array(); dataIndex = 0x0; let _0x46bbdf = '81' + (_0x337446['length'] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x337446; let _0x2394ed = 0x50 * 0x2; if (_0x46bbdf[_0x5b64('0x27')] < _0x2394ed) { _0x46bbdf = '508001' + (_0x46bbdf['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x46bbdf; dataArrays[0x0] = _0x46bbdf + CRC8(_0x46bbdf); } else { let _0x46eab8 = parseInt(_0x46bbdf['length'] % _0x2394ed == 0x0 ? _0x46bbdf['length'] / _0x2394ed : _0x46bbdf[ _0x5b64('0x27')] / _0x2394ed + 0x1); for (let _0xb02dd0 = 0x0; _0xb02dd0 < _0x46eab8; _0xb02dd0++) { let _0x4d5564 = _0xb02dd0 + 0x1; let _0x15f379 = ''; if (_0xb02dd0 == _0x46eab8 - 0x1) { _0x15f379 = _0x46bbdf['slice'](_0xb02dd0 * _0x2394ed); } else { _0x15f379 = _0x46bbdf[_0x5b64('0x17')](_0xb02dd0 * _0x2394ed, _0x4d5564 * _0x2394ed); } if (_0xb02dd0 == 0x0) { _0x15f379 = '5080' + _0x46eab8[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x15f379['length'] / 0x2)['toString'](0x10)[_0x5b64('0x28')](0x4, '0') + _0x15f379; } else { _0x15f379 = '5000' + _0x4d5564[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x15f379['length'] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x15f379; } dataArrays[_0xb02dd0] = _0x15f379 + CRC8(_0x15f379); } } initReadValue(); write(dataArrays[dataIndex]); } function authObu(_0x1f28e7, _0x35d7c0, _0x11bbc2) { mCallBack = _0x35d7c0; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack[_0x5b64('0x1f')] == FUNCTION && mCallBack['fail'](toObject(0x7d0, undefined, '认证超时')); }, _0x11bbc2); dataArrays = new Array(); dataIndex = 0x0; let _0xe07a30 = '84' + (_0x1f28e7['length'] / 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x4, '0') + _0x1f28e7; let _0x40835c = 0x50 * 0x2; if (_0xe07a30['length'] < _0x40835c) { _0xe07a30 = _0x5b64('0x0') + (_0xe07a30[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x4, '0') + _0xe07a30; dataArrays[0x0] = _0xe07a30 + CRC8(_0xe07a30); } else { let _0x1e9df4 = parseInt(_0xe07a30[_0x5b64('0x27')] % _0x40835c == 0x0 ? _0xe07a30['length'] / _0x40835c : _0xe07a30[_0x5b64('0x27')] / _0x40835c + 0x1); for (let _0xe2e9d7 = 0x0; _0xe2e9d7 < _0x1e9df4; _0xe2e9d7++) { let _0x15129c = _0xe2e9d7 + 0x1; let _0x16c078 = ''; if (_0xe2e9d7 == _0x1e9df4 - 0x1) { _0x16c078 = _0xe07a30['slice'](_0xe2e9d7 * _0x40835c); } else { _0x16c078 = _0xe07a30[_0x5b64('0x17')](_0xe2e9d7 * _0x40835c, _0x15129c * _0x40835c); } if (_0xe2e9d7 == 0x0) { _0x16c078 = _0x5b64('0x33') + _0x1e9df4['toString'](0x10)[_0x5b64('0x28')](0x2, '0') + (_0x16c078[ 'length'] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x16c078; } else { _0x16c078 = _0x5b64('0x3c') + _0x15129c[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x16c078[ _0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x16c078; } dataArrays[_0xe2e9d7] = _0x16c078 + CRC8(_0x16c078); } } initReadValue(); write(dataArrays[dataIndex]); } function sendUpgradeData(_0x4617fc, _0x12dfd4, _0xc38619) { mCallBack = _0x12dfd4; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack[_0x5b64('0x1f')] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined, '升级超时')); }, _0xc38619); let _0x132fa1 = '87' + (_0x4617fc[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x4617fc; let _0x4b195e = _0x132fa1[_0x5b64('0x27')]; let _0x2c1d58 = 0xb8; let _0x28a861 = parseInt(_0x4b195e / _0x2c1d58 + 0x1); dataArrays = new Array(); dataIndex = 0x0; for (var _0x4f8d46 = 0x0; _0x4f8d46 < _0x28a861; _0x4f8d46++) { let _0x3a862f = ''; if (_0x4f8d46 + 0x1 == _0x28a861) { _0x3a862f = _0x132fa1[_0x5b64('0x17')](_0x4f8d46 * _0x2c1d58); } else { _0x3a862f = _0x132fa1[_0x5b64('0x17')](_0x4f8d46 * _0x2c1d58, (_0x4f8d46 + 0x1) * _0x2c1d58); } let _0x4fce2c = ''; if (_0x4f8d46 == 0x0) { _0x4fce2c = '80' + _0x28a861['toString'](0x10)['padStart'](0x2, '0'); } else { _0x4fce2c = '00' + (_0x4f8d46 + 0x1)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x2, '0'); } let _0x49072f = '50' + _0x4fce2c + parseInt(_0x3a862f[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'] (0x2, '0') + _0x3a862f; dataArrays[_0x5b64('0x3a')](_0x49072f + CRC8(_0x49072f)); } write(dataArrays[dataIndex]); } function initReadValue() { receivePacketCount = 0x0; receivePacketData = ''; receiveLength = 0x0; receiveData = ''; } function write(_0x55036b) { if (dataIndex < dataArrays[_0x5b64('0x27')]) { dataIndex++; sendArrays = new Array(); let _0x450b62 = 0x28; let _0x4908a8 = parseInt(_0x55036b[_0x5b64('0x27')] / _0x450b62 + 0x1); for (var _0x3a3653 = 0x0; _0x3a3653 < _0x4908a8; _0x3a3653++) { if (_0x3a3653 + 0x1 == _0x4908a8) { sendArrays[_0x5b64('0x3a')](_0x55036b[_0x5b64('0x17')](_0x3a3653 * _0x450b62)); } else { sendArrays['push'](_0x55036b['slice'](_0x3a3653 * _0x450b62, (_0x3a3653 + 0x1) * _0x450b62)); } } sendIndex = 0x0; runSendData(); } else { console['log']('Packet\x20send\x20complete.'); } } function runSendData() { console[_0x5b64('0x14')](_0x5b64('0x3f'), sendArrays[sendIndex]); let _0x54f524 = hex2ArrayBuffer(sendArrays[sendIndex]); wx[_0x5b64('0x34')]({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'characteristicId': writeUUID, 'value': _0x54f524, 'success': _0x420952 => { sendIndex++; if (sendIndex < sendArrays[_0x5b64('0x27')]) { runSendData(); } else { write(dataArrays[dataIndex]); } }, 'fail': _0x12d4eb => { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['fail'] == FUNCTION && mCallBack['fail'](toObject(codeEnum['failCode'], null, _0x12d4eb[_0x5b64('0x1d')])); } }); } function CRC8(_0x1b496e) { let _0x479cf7 = new Uint8Array(hex2ArrayBuffer(_0x1b496e)); let _0x4ff77a = 0x0; for (let _0x2c0921 of _0x479cf7) { _0x4ff77a ^= _0x2c0921; } return _0x4ff77a[_0x5b64('0x10')](0x10)['padStart'](0x2, '0')['toUpperCase'](); } function CRC16(_0x3bed35) { let _0x17d0e0 = 0xffff; for (let _0x52f618 of _0x3bed35) { _0x17d0e0 ^= _0x52f618 & 0xff; for (var _0x44b8fb = 0x0; _0x44b8fb < 0x8; _0x44b8fb++) { if ((_0x17d0e0 & 0x1) > 0x0) { _0x17d0e0 = _0x17d0e0 >> 0x1; _0x17d0e0 = _0x17d0e0 ^ 0x8408; } else { _0x17d0e0 = _0x17d0e0 >> 0x1; } } } return (_0x17d0e0 ^ 0xffff)[_0x5b64('0x10')](0x10); } function hex2ArrayBuffer(_0x302f62) { var _0x3c036b = new Uint8Array(_0x302f62['match'](/[\da-f]{2}/gi)['map'](function(_0x5df096) { return parseInt(_0x5df096, 0x10); })); return _0x3c036b[_0x5b64('0x43')]; } function arrayBuffer2hex(_0x13cb49) { const _0x51a173 = Array['prototype']['map'][_0x5b64('0x6')](new Uint8Array(_0x13cb49), function(_0x48413b) { return ('00' + _0x48413b['toString'](0x10))[_0x5b64('0x17')](-0x2); }); return _0x51a173[_0x5b64('0x41')](''); } function littleEndian(_0x3af579) { if (_0x3af579 != '' && _0x3af579 != undefined) { var _0x3dc2bd = ''; for (var _0x197e01 = _0x3af579[_0x5b64('0x27')]; _0x197e01 >= 0x0; _0x197e01 = _0x197e01 - 0x2) { _0x3dc2bd += _0x3af579['charAt'](_0x197e01); _0x3dc2bd += _0x3af579[_0x5b64('0x1a')](_0x197e01 + 0x1); } return _0x3dc2bd; } else { return _0x3af579; } }