const _0x4a4b = ['name', 'charAt', '断开连接成功', '蓝牙搜索已停止', 'receiveData->', '已断连', 'RSSI', 'toUpperCase', 'notifyBLECharacteristicValueChange->', 'log', 'errMsg', 'onBLECharacteristicValueChange', 'deviceId', '未连接', 'closeBLEConnection', 'noTargetServiceId', '5080', 'length', 'successCode', 'disconnectDevice->', 'data', 'localName', '0000FEE7-0000-1000-8000-00805F9B34FB', '蓝牙状态正常', 'services', 'statusCode', '执行成功', '认证成功', 'call', 'connected', 'toString', 'padStart', 'uuid', 'deviceList', 'sendData->', 'success', 'onBluetoothDeviceFound', '发送指令超时', 'characteristics', 'characteristicId', 'readBLECharacteristicValueFail->', 'closeBluetoothAdapter', 'substring', 'getBLEDeviceCharacteristics', 'slice', '508001', '认证超时', 'value', 'msg', '连接超时', 'startConnectBle->', '获取蓝牙版本号失败', 'exports', '数据解析失败', '00002A28-0000-1000-8000-00805F9B34FB', 'noTargetCharacteristic', '5000', 'devices', 'createBLEConnection', 'failCode', 'getBLEDeviceServices->', '操作失败', 'code', 'push', 'fail', 'offBLEConnectionStateChange', 'join', 'padEnd', 'readBLECharacteristicValue', 'stopBluetoothDevicesDiscovery', 'serviceId', '断开连接失败', 'onIsEnable', 'function', 'notifyBLECharacteristicValueChange' ]; const _0x4472 = function(_0x4a4b21, _0x447294) { _0x4a4b21 = _0x4a4b21 - 0x0; let _0x186588 = _0x4a4b[_0x4a4b21]; return _0x186588; }; module[_0x4472('0x34')] = { 'scanBle': scanBle, 'closBluetooth': closBluetooth, 'connectDevice': connectDevice, 'disconnectDevice': disconnectDevice, 'transCmd': transCmd, 'disconnectDeviceBluetooth': disconnectDeviceBluetooth }; var deviceList = []; var onIsEnable = toResObject(0x0, '蓝牙状态正常'); var scanBleTimer; function toResObject(_0x1d50f8, _0x18421d) { return { 'code': _0x1d50f8, 'msg': _0x18421d }; } function scanBle(_0x4b76df, _0x185be1) { this[_0x4472('0x21')] = []; this[_0x4472('0x48')] = toResObject(0x0, _0x4472('0x17')); scanBleTimer = setTimeout(() => { wx[_0x4472('0x45')](); _0x185be1(this['deviceList'], this['onIsEnable']); }, _0x4b76df); wx['openBluetoothAdapter']({ 'success': _0x4dcb5e => { wx['startBluetoothDevicesDiscovery']({ 'allowDuplicatesKey': !![], 'interval': 0x64, 'success': _0x346f55 => { wx[_0x4472('0x24')](_0x1b44eb => { for (let _0x43f7b0 = 0x0; _0x43f7b0 < _0x1b44eb['devices'][ _0x4472('0x11') ]; _0x43f7b0++) { let _0xb249a1 = ![]; if (_0x1b44eb[_0x4472('0x39')][_0x43f7b0][_0x4472( '0x15')] == undefined || _0x1b44eb[_0x4472('0x39')][ _0x43f7b0 ][_0x4472('0x15')] == '' || _0x1b44eb['devices'][ _0x43f7b0 ]['localName'] == '') { continue; } for (let _0xc00c8c = 0x0; _0xc00c8c < this['deviceList'][ 'length' ]; _0xc00c8c++) { if (_0x1b44eb[_0x4472('0x39')][_0x43f7b0][_0x4472( '0xc')] == this[_0x4472('0x21')][_0xc00c8c][ 'deviceId' ]) { _0xb249a1 = !![]; continue; } } if (_0xb249a1 == ![]) { let _0x37639f = {}; _0x37639f[_0x4472('0x0')] = _0x1b44eb['devices'][ _0x43f7b0 ]['localName']; _0x37639f['deviceId'] = _0x1b44eb['devices'][_0x43f7b0][ 'deviceId' ]; _0x37639f[_0x4472('0x6')] = _0x1b44eb['devices'][ _0x43f7b0 ][_0x4472('0x6')]; this['deviceList'][_0x4472('0x3f')](_0x37639f); } } }); }, 'fail': _0x28beb4 => { this[_0x4472('0x21')] = []; this['onIsEnable'] = toResObject(-0x1, _0x28beb4['errMsg']); clearTimeout(scanBleTimer); _0x185be1(this[_0x4472('0x21')], this[_0x4472('0x48')]); } }); }, 'fail': _0x1e7ba6 => { this['deviceList'] = []; this[_0x4472('0x48')] = toResObject(-0x1, _0x1e7ba6[_0x4472('0xa')]); clearTimeout(scanBleTimer); _0x185be1(this[_0x4472('0x21')], this['onIsEnable']); } }); } function closBluetooth(_0x27c990) { clearTimeout(scanBleTimer); wx['stopBluetoothDevicesDiscovery']({ 'success': _0x3139be => { _0x27c990(toResObject(0x0, _0x4472('0x3'))); }, 'fail': _0x36e2e0 => { _0x27c990(toResObject(-0x1, _0x36e2e0[_0x4472('0xa')])); } }); } function connectDevice(_0x2d6013, _0x936e65, _0x589d51) { wx['onBLEConnectionStateChange'](_0x1202cc => { if (_0x1202cc[_0x4472('0x1d')]) { _0x589d51(toResObject(0x0, '已连接')); } else { _0x589d51(toResObject(-0x1, _0x4472('0xd'))); } }); connectAndInit(_0x2d6013, { 'success': _0x4deb5e => { if (_0x4deb5e[_0x4472('0x3e')] == 0x3e8 || _0x4deb5e[_0x4472('0x19')] == 0x3e8) { _0x936e65(toResObject(0x0, '连接成功')); } }, 'fail': _0xd633fb => { _0x936e65(toResObject(-0x1, _0xd633fb['msg'])); } }, 0x1f40); } function disconnectDevice(_0x2ea989) { disconnectBleDevice({ 'success': _0x33240a => { this['connectDeviceId'] = undefined; _0x2ea989(toResObject(0x0, _0x4472('0x5'))); wx['offBLEConnectionStateChange'](); wx['closeBluetoothAdapter'](); }, 'fail': _0x5694aa => { _0x2ea989(toResObject(-0x1, _0x5694aa['msg'])); wx[_0x4472('0x41')](); wx[_0x4472('0x29')](); } }); } function transCmd(_0x5a4809, _0x259a28, _0x4c4bb9) { if (connectDeviceId == undefined) { let _0x47e0ad = toResObject(-0x1, '未连接设备'); _0x47e0ad['data'] = undefined; _0x4c4bb9(_0x47e0ad); return; } if (_0x259a28 == '10') { postCommand(0x1, _0x5a4809, { 'success': _0x15e935 => { let _0x3a739e = toResObject(0x0, _0x4472('0x1a')); _0x3a739e[_0x4472('0x14')] = _0x15e935['data']; _0x4c4bb9(_0x3a739e); }, 'fail': _0x3fb131 => { let _0x5b4e9b = toResObject(-0x1, _0x3fb131[_0x4472('0x30')]); _0x5b4e9b[_0x4472('0x14')] = undefined; _0x4c4bb9(_0x5b4e9b); } }, 0xfa0); } if (_0x259a28 == '20') { postCommand(0x2, _0x5a4809, { 'success': _0x2a1d8c => { let _0x1946b1 = toResObject(0x0, _0x4472('0x1a')); _0x1946b1[_0x4472('0x14')] = _0x2a1d8c['data']; _0x4c4bb9(_0x1946b1); }, 'fail': _0x40ec18 => { let _0x2b0a41 = toResObject(-0x1, _0x40ec18['msg']); _0x2b0a41[_0x4472('0x14')] = undefined; _0x4c4bb9(_0x2b0a41); } }, 0xfa0); } } function disconnectDeviceBluetooth(_0x33aa68) { deviceChannel('C3', { 'success': _0x30e18e => { _0x33aa68(toResObject(0x0, _0x4472('0x5'))); wx[_0x4472('0x41')](); wx['closeBluetoothAdapter'](); }, 'fail': _0x11bd91 => { _0x33aa68(toResObject(0x0, _0x4472('0x5'))); wx['offBLEConnectionStateChange'](); wx[_0x4472('0x29')](); } }, 0xfa0); } const codeEnum = { 'successCode': 0x3e8, 'failCode': 0xfa0, 'timeout': 0x64 }; const FUNCTION = _0x4472('0x49'); const serviceUUID = _0x4472('0x16'); const writeUUID = '0000FEC7-0000-1000-8000-00805F9B34FB'; const readUUID = '0000FEC8-0000-1000-8000-00805F9B34FB'; const UUIDCHAR1 = '0000180A-0000-1000-8000-00805F9B34FB'; const UUIDCHAR2 = _0x4472('0x36'); var hasChar1 = ![]; var hasChar2 = ![]; var version = ''; var connectDeviceId; var connectCallback; var connectTimer; var sendIndex = 0x0; function toObject(_0x293f1a, _0x1c621a, _0x3b1b67) { return { 'code': _0x293f1a, 'data': _0x1c621a, 'msg': _0x3b1b67 }; } function connectAndInit(_0x4f68dd, _0x3abbb6, _0x1a1e01) { hasChar1 = ![]; hasChar1 = ![]; version = ''; connectDeviceId = _0x4f68dd[_0x4472('0xc')]; connectCallback = _0x3abbb6; if (connectTimer != undefined) { clearTimeout(connectTimer); } connectTimer = setTimeout(() => { connectTimer = undefined; typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(0x7d2, undefined, _0x4472('0x31'))); }, _0x1a1e01); startConnectBle(); } function disconnectBleDevice(_0x206928) { const _0xe0e6d8 = String(connectDeviceId); wx[_0x4472('0xe')]({ 'deviceId': _0xe0e6d8, 'success'(_0x152ff6) { if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof _0x206928[_0x4472('0x23')] == FUNCTION && _0x206928[_0x4472('0x23')](toObject(codeEnum[ 'successCode'], _0x152ff6, _0x4472('0x2'))); }, 'fail'(_0x5c60f6) { console['log'](_0x4472('0x13'), _0x5c60f6); if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof _0x206928[_0x4472('0x40')] == FUNCTION && _0x206928['fail'](toObject(codeEnum[_0x4472( '0x3b')], _0x5c60f6, _0x4472('0x47'))); } }); } function startConnectBle() { if (connectTimer == undefined) { return; } wx[_0x4472('0x3a')]({ 'deviceId': connectDeviceId, 'success': _0x1784a1 => { startGetAndCheckService(); }, 'fail': _0x5f3701 => { console['log'](_0x4472('0x32'), _0x5f3701); if (connectTimer != undefined) { clearTimeout(connectTimer); } typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject( codeEnum[_0x4472('0x3b')], undefined, 'creatConnectionFailure')); } }); } function startGetAndCheckService() { if (connectTimer == undefined) { return; } wx['getBLEDeviceServices']({ 'deviceId': connectDeviceId, 'success': _0xb523c0 => { for (let _0x4cb2c5 = 0x0; _0x4cb2c5 < _0xb523c0['services']['length']; _0x4cb2c5++) { let _0x49cc9b = _0xb523c0[_0x4472('0x18')][_0x4cb2c5]['uuid']; if (_0x49cc9b == UUIDCHAR1) { hasChar1 = !![]; getBluetoothVersionUUID(); break; } } let _0x6e24cb = ![]; for (let _0x5411bc = 0x0; _0x5411bc < _0xb523c0[_0x4472('0x18')]['length']; _0x5411bc++) { let _0x394fd4 = _0xb523c0[_0x4472('0x18')][_0x5411bc]['uuid']; if (_0x394fd4 == serviceUUID) { _0x6e24cb = !![]; break; } } if (_0x6e24cb == !![]) { startGetAndCheckCharacterisitc(); } else { if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[ 'failCode'], undefined, _0x4472('0xf'))); } } }, 'fail': _0x3d472a => { console[_0x4472('0x9')](_0x4472('0x3c'), _0x3d472a); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback[_0x4472('0x40')]( toObject(codeEnum['failCode'], undefined, _0x3d472a['errMsg'])); } } }); } function startGetAndCheckCharacterisitc() { if (connectTimer == undefined) { return; } wx[_0x4472('0x2b')]({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'success': _0x249062 => { let _0x27ce93 = ![]; let _0x51826a = ![]; for (let _0x4f8603 = 0x0; _0x4f8603 < _0x249062[_0x4472('0x26')][_0x4472( '0x11')]; _0x4f8603++) { let _0x489709 = _0x249062[_0x4472('0x26')][_0x4f8603]['uuid']; if (_0x489709 == readUUID) { _0x27ce93 = !![]; } else if (_0x489709 == writeUUID) { _0x51826a = !![]; } if (_0x27ce93 == !![] && _0x51826a == !![]) { break; } } if (_0x27ce93 == !![] && _0x51826a == !![]) { monitorNotification(); } else { if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject( codeEnum[_0x4472('0x3b')], undefined, _0x4472('0x37'))); } } }, 'fail': _0x13f168 => { console[_0x4472('0x9')]('getBLEDeviceCharacteristics->', _0x13f168); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback['fail'](toObject( codeEnum['failCode'], undefined, _0x13f168[_0x4472('0xa')])); } } }); } function monitorNotification() { if (connectTimer == undefined) { return; } wx[_0x4472('0x4a')]({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'characteristicId': readUUID, 'state': !![], 'success': _0x588188 => { if (typeof connectTimer != undefined) { clearTimeout(connectTimer); } wx[_0x4472('0xb')](function(_0x373b44) { if (_0x373b44['deviceId'] = connectDeviceId && _0x373b44['serviceId'] == serviceUUID && _0x373b44[_0x4472('0x27')] == readUUID) { let _0x2eeb04 = arrayBuffer2hex(_0x373b44['value']); analyticData(_0x2eeb04); } }); setTimeout(() => { typeof connectCallback[_0x4472('0x23')] == FUNCTION && connectCallback['success']( toObject(codeEnum['successCode'], undefined, '连接成功,握手成功')); }, 0x3e8); }, 'fail': _0x2fcb1d => { console[_0x4472('0x9')](_0x4472('0x8'), _0x2fcb1d); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback['fail'](toObject( codeEnum['failCode'], undefined, _0x2fcb1d[_0x4472('0xa')])); } } }); } function getBluetoothVersionUUID() { wx['getBLEDeviceCharacteristics']({ 'deviceId': connectDeviceId, 'serviceId': UUIDCHAR1, 'success': _0x506f8f => { for (let _0x433573 = 0x0; _0x433573 < _0x506f8f[_0x4472('0x26')][_0x4472( '0x11')]; _0x433573++) { let _0x463df3 = _0x506f8f[_0x4472('0x26')][_0x433573][_0x4472('0x20')]; if (_0x463df3 == UUIDCHAR2) { hasChar2 = !![]; break; } } }, 'fail': _0x2a7116 => { console[_0x4472('0x9')]('getBluetoothVersionUUID->', _0x2a7116); if (connectTimer != undefined) { clearTimeout(connectTimer); typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject( codeEnum[_0x4472('0x3b')], undefined, _0x4472('0x33'))); } } }); } function readBLECharacteristicValue() { wx[_0x4472('0x44')]({ 'deviceId': connectDeviceId, 'serviceId': UUIDCHAR1, 'characteristicId': UUIDCHAR2, 'success': _0x136d49 => { console['log']('readBLECharacteristicValueSuccess->', _0x136d49); }, 'fail': _0x52b5dc => { console[_0x4472('0x9')](_0x4472('0x28'), _0x52b5dc); } }); } function onBLECharacteristicValueChange() { wx[_0x4472('0xb')](_0x482304 => { console[_0x4472('0x9')](_0x4472('0x4'), arrayBuffer2hex(_0x482304[_0x4472('0x2f')])); if (_0x482304['deviceId'] == connectDeviceId && _0x482304['serviceId'] == serviceUUID && _0x482304[ 'characteristicId'] == readUUID) { let _0xcbc651 = arrayBuffer2hex(_0x482304[_0x4472('0x2f')]); analyticData(_0xcbc651); } else if (_0x482304['deviceId'] == connectDeviceId && _0x482304[_0x4472('0x46')] == UUIDCHAR1 && _0x482304[_0x4472('0x27')] == UUIDCHAR2) { let _0x5e1112 = arrayBuffer2hex(_0x482304['value'])[_0x4472('0x7')](); if (connectTimer != undefined) { clearTimeout(connectTimer); if (_0x5e1112 != '') { typeof connectCallback[_0x4472('0x23')] == FUNCTION && connectCallback['success'](toObject( codeEnum['successCode'], _0x5e1112, '连接成功')); } else { typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[ _0x4472('0x12')], 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(_0x45b004) { if (_0x45b004['slice'](0x0, 0x2) == '50' && (_0x45b004['slice'](0x2, 0x4) == '80' || _0x45b004['slice'](0x2, 0x4) == '00') && (_0x45b004['length'] < 0x28 || _0x45b004[_0x4472('0x11')] == 0x28)) { receiveLength = parseInt(_0x45b004[_0x4472('0x2c')](0x6, 0xa), 0x10); if (_0x45b004[_0x4472('0x2c')](0x2, 0x4) == '80') { receivePacketCount = parseInt(_0x45b004['slice'](0x4, 0x6), 0x10); } } if (receiveLength != 0x0) { receiveData += _0x45b004; } console['log'](_0x4472('0x4'), receiveData); if (receiveData[_0x4472('0x2c')](0xa, receiveData[_0x4472('0x11')] - 0x2)['length'] == receiveLength * 0x2) { if (receiveData['slice'](0x0, 0x2) == '50' && receiveData['slice'](0x2, 0x4) == '80' && receiveData['slice']( 0xa, 0xc) == '97') { if (receiveData['slice'](0xa, 0xc) == '00' && receiveData[_0x4472('0x2c')](0x14, 0x16) == '00') { updateRead(!![]); } else { updateRead(![]); } receiveData = ''; } else { receivePacketData += receiveData[_0x4472('0x2c')](0xa, receiveData['length'] - 0x2); receiveData = ''; receiveLength = 0x0; receivePacketCount--; if (receivePacketCount > 0x0) { return; } let _0x8c35f3 = receivePacketData; receivePacketData = ''; receivePacketCount = ''; if (_0x8c35f3['slice'](0x0, 0x2) == '92') { cosDataRead(_0x8c35f3); } else if (_0x8c35f3[_0x4472('0x2c')](0x0, 0x2) == '91') { deviceChannelRead(_0x8c35f3); } else if (_0x8c35f3['slice'](0x0, 0x2) == '94') { authCodeRead(_0x8c35f3); } } } } function updateRead(_0x2ab7f9) { if (_0x2ab7f9) { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x4472('0x12')], null, '成功')); } else { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472('0x3b')], null, '失败')); } } function cosDataRead(_0x5ef34e) { let _0x2e87c9 = _0x5ef34e['slice'](0x4, 0x6); let _0x5e6375 = ''; if (_0x2e87c9 == '10') { _0x5e6375 = '发送ICC指令'; } else { _0x5e6375 = '发送ESAM指令'; } let _0xb98396 = parseInt(_0x5ef34e[_0x4472('0x2c')](0x6, 0xa), 0x10); if (_0x5ef34e['slice'](0xa)[_0x4472('0x11')] == _0xb98396 * 0x2) { let _0x4ca253 = new Array(); let _0x47692f = _0x5ef34e[_0x4472('0x2c')](0xa); let _0x3cfd30 = _0x47692f['slice'](0x0, 0x2); let _0x175104 = 0x0; while (_0x3cfd30 == '81') { _0x175104++; _0x3cfd30 = _0x47692f[_0x4472('0x2c')](_0x175104 * 0x2, _0x175104 * 0x2 + 0x2); } let _0x1b395b = _0x47692f[_0x4472('0x2c')](_0x175104 * 0x2 + 0x2); let _0x5c1774 = parseInt(_0x1b395b['slice'](0x2, 0x4), 0x10) * 0x2; _0x4ca253['push'](_0x1b395b['slice'](0x4, 0x4 + _0x5c1774)); let _0x3605e4 = _0x1b395b[_0x4472('0x2a')](0x4 + _0x5c1774); while (_0x3605e4 != '') { _0x5c1774 = parseInt(_0x3605e4['slice'](0x2, 0x4), 0x10) * 0x2; _0x4ca253['push'](_0x3605e4[_0x4472('0x2c')](0x4, 0x4 + _0x5c1774)); _0x3605e4 = _0x3605e4[_0x4472('0x2a')](0x4 + _0x5c1774); } if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum[_0x4472('0x12')], _0x4ca253, _0x5e6375 + '成功')); } else { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472('0x3b')], null, _0x4472('0x35'))); } } function deviceChannelRead(_0x106fb) { let _0x58c660 = _0x106fb['slice'](0x2, 0x4); if (transTimer != undefined) { clearTimeout(transTimer); } if (_0x58c660 == '00') { typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum['successCode'], _0x106fb[_0x4472('0x2c')](0xa), '操作成功')); } else { typeof mCallBack[_0x4472('0x23')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null, _0x4472('0x3d'))); } } function authCodeRead(_0x23bcd4) { let _0x556549 = _0x23bcd4[_0x4472('0x2c')](0x2, 0x4); if (transTimer != undefined) { clearTimeout(transTimer); } if (_0x556549 == '00') { typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum[_0x4472('0x12')], _0x23bcd4['slice'](0xa), _0x4472('0x1b'))); } else { typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null, '认证失败')); } } function postCommand(_0x591227, _0x3d71c3, _0x48f9da, _0x470007) { mCallBack = _0x48f9da; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, _0x4472( '0x25'))); }, _0x470007); dataArrays = new Array(); dataIndex = 0x0; let _0xc993d1 = getCosData(_0x3d71c3); let _0x5ac9a0 = '82' + _0x591227['toString'](0x10)[_0x4472('0x43')](0x2, '0') + (_0xc993d1['length'] / 0x2)[_0x4472( '0x1e')](0x10)['padStart'](0x4, '0') + _0xc993d1; let _0x211adf = 0x50 * 0x2; if (_0x5ac9a0['length'] < _0x211adf) { _0x5ac9a0 = _0x4472('0x2d') + (_0x5ac9a0['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x5ac9a0; dataArrays[0x0] = _0x5ac9a0 + CRC8(_0x5ac9a0); } else { let _0x18f9b7 = parseInt(_0x5ac9a0[_0x4472('0x11')] % _0x211adf == 0x0 ? _0x5ac9a0[_0x4472('0x11')] / _0x211adf : _0x5ac9a0['length'] / _0x211adf + 0x1); for (let _0x5a1627 = 0x0; _0x5a1627 < _0x18f9b7; _0x5a1627++) { let _0x2182c1 = _0x5a1627 + 0x1; let _0x1a409f = ''; if (_0x5a1627 == _0x18f9b7 - 0x1) { _0x1a409f = _0x5ac9a0['slice'](_0x5a1627 * _0x211adf); } else { _0x1a409f = _0x5ac9a0['slice'](_0x5a1627 * _0x211adf, _0x2182c1 * _0x211adf); } if (_0x5a1627 == 0x0) { _0x1a409f = '5080' + _0x18f9b7['toString'](0x10)['padStart'](0x2, '0') + (_0x1a409f['length'] / 0x2)[ 'toString'](0x10)['padStart'](0x4, '0') + _0x1a409f; } else { _0x1a409f = '5000' + _0x2182c1['toString'](0x10)['padStart'](0x2, '0') + (_0x1a409f['length'] / 0x2)[ 'toString'](0x10)['padStart'](0x4, '0') + _0x1a409f; } dataArrays[_0x5a1627] = _0x1a409f + CRC8(_0x1a409f); } } initReadValue(); write(dataArrays[dataIndex]); } function getCosData(_0x61028c) { let _0xff7d = ''; for (let _0x2a4c3c = 0x0; _0x2a4c3c < _0x61028c['length']; _0x2a4c3c++) { _0xff7d += (_0x2a4c3c + 0x1)['toString'](0x10)['padStart'](0x2, '0') + (_0x61028c[_0x2a4c3c]['length'] / 0x2)[ 'toString'](0x10)[_0x4472('0x1f')](0x2, '0') + _0x61028c[_0x2a4c3c]; } return '80' + (_0xff7d[_0x4472('0x11')] / 0x2)[_0x4472('0x1e')](0x10)['padStart'](0x2, '0') + _0xff7d; } function deviceChannel(_0xa4300b, _0x26620a, _0x521c3a) { mCallBack = _0x26620a; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, '操作超时')); }, _0x521c3a); dataArrays = new Array(); dataIndex = 0x0; let _0x5f8c87 = '81' + (_0xa4300b['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0xa4300b; let _0xdef1a0 = 0x50 * 0x2; if (_0x5f8c87['length'] < _0xdef1a0) { _0x5f8c87 = _0x4472('0x2d') + (_0x5f8c87[_0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x5f8c87; dataArrays[0x0] = _0x5f8c87 + CRC8(_0x5f8c87); } else { let _0x200ab2 = parseInt(_0x5f8c87['length'] % _0xdef1a0 == 0x0 ? _0x5f8c87['length'] / _0xdef1a0 : _0x5f8c87[ _0x4472('0x11')] / _0xdef1a0 + 0x1); for (let _0x285c15 = 0x0; _0x285c15 < _0x200ab2; _0x285c15++) { let _0x285b83 = _0x285c15 + 0x1; let _0x3988f8 = ''; if (_0x285c15 == _0x200ab2 - 0x1) { _0x3988f8 = _0x5f8c87[_0x4472('0x2c')](_0x285c15 * _0xdef1a0); } else { _0x3988f8 = _0x5f8c87[_0x4472('0x2c')](_0x285c15 * _0xdef1a0, _0x285b83 * _0xdef1a0); } if (_0x285c15 == 0x0) { _0x3988f8 = _0x4472('0x10') + _0x200ab2[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x2, '0') + (_0x3988f8[ _0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x3988f8; } else { _0x3988f8 = '5000' + _0x285b83['toString'](0x10)['padStart'](0x2, '0') + (_0x3988f8[_0x4472('0x11')] / 0x2)[_0x4472('0x1e')](0x10)['padStart'](0x4, '0') + _0x3988f8; } dataArrays[_0x285c15] = _0x3988f8 + CRC8(_0x3988f8); } } initReadValue(); write(dataArrays[dataIndex]); } function authObu(_0xe7b40, _0x1424a9, _0x36ce2d) { mCallBack = _0x1424a9; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, _0x4472( '0x2e'))); }, _0x36ce2d); dataArrays = new Array(); dataIndex = 0x0; let _0x2d62b8 = '84' + (_0xe7b40['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0xe7b40; let _0x3b1cb4 = 0x50 * 0x2; if (_0x2d62b8[_0x4472('0x11')] < _0x3b1cb4) { _0x2d62b8 = _0x4472('0x2d') + (_0x2d62b8['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x2d62b8; dataArrays[0x0] = _0x2d62b8 + CRC8(_0x2d62b8); } else { let _0x53a0f3 = parseInt(_0x2d62b8['length'] % _0x3b1cb4 == 0x0 ? _0x2d62b8['length'] / _0x3b1cb4 : _0x2d62b8[ 'length'] / _0x3b1cb4 + 0x1); for (let _0x4d2f44 = 0x0; _0x4d2f44 < _0x53a0f3; _0x4d2f44++) { let _0x33a578 = _0x4d2f44 + 0x1; let _0x1f3254 = ''; if (_0x4d2f44 == _0x53a0f3 - 0x1) { _0x1f3254 = _0x2d62b8[_0x4472('0x2c')](_0x4d2f44 * _0x3b1cb4); } else { _0x1f3254 = _0x2d62b8['slice'](_0x4d2f44 * _0x3b1cb4, _0x33a578 * _0x3b1cb4); } if (_0x4d2f44 == 0x0) { _0x1f3254 = _0x4472('0x10') + _0x53a0f3[_0x4472('0x1e')](0x10)['padStart'](0x2, '0') + (_0x1f3254[ _0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x1f3254; } else { _0x1f3254 = _0x4472('0x38') + _0x33a578['toString'](0x10)[_0x4472('0x1f')](0x2, '0') + (_0x1f3254[ 'length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0x1f3254; } dataArrays[_0x4d2f44] = _0x1f3254 + CRC8(_0x1f3254); } } initReadValue(); write(dataArrays[dataIndex]); } function sendUpgradeData(_0x2049ec, _0x19ec1d, _0x2ea11b) { mCallBack = _0x19ec1d; if (transTimer != undefined) { clearTimeout(transTimer); } transTimer = setTimeout(() => { transTimer = undefined; typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, '升级超时')); }, _0x2ea11b); let _0x1ed8a2 = '87' + (_0x2049ec[_0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x2049ec; let _0x48d7e9 = _0x1ed8a2[_0x4472('0x11')]; let _0x4a6a8c = 0xb8; let _0x3e8e51 = parseInt(_0x48d7e9 / _0x4a6a8c + 0x1); dataArrays = new Array(); dataIndex = 0x0; for (var _0x39f86c = 0x0; _0x39f86c < _0x3e8e51; _0x39f86c++) { let _0x4258bf = ''; if (_0x39f86c + 0x1 == _0x3e8e51) { _0x4258bf = _0x1ed8a2[_0x4472('0x2c')](_0x39f86c * _0x4a6a8c); } else { _0x4258bf = _0x1ed8a2['slice'](_0x39f86c * _0x4a6a8c, (_0x39f86c + 0x1) * _0x4a6a8c); } let _0x2af93a = ''; if (_0x39f86c == 0x0) { _0x2af93a = '80' + _0x3e8e51['toString'](0x10)[_0x4472('0x1f')](0x2, '0'); } else { _0x2af93a = '00' + (_0x39f86c + 0x1)['toString'](0x10)[_0x4472('0x1f')](0x2, '0'); } let _0x4658df = '50' + _0x2af93a + parseInt(_0x4258bf['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')]( 0x2, '0') + _0x4258bf; dataArrays['push'](_0x4658df + CRC8(_0x4658df)); } write(dataArrays[dataIndex]); } function initReadValue() { receivePacketCount = 0x0; receivePacketData = ''; receiveLength = 0x0; receiveData = ''; } function write(_0x3e2cf6) { if (dataIndex < dataArrays[_0x4472('0x11')]) { dataIndex++; sendArrays = new Array(); let _0x3b2bd3 = 0x28; let _0x3cbd19 = parseInt(_0x3e2cf6[_0x4472('0x11')] / _0x3b2bd3 + 0x1); for (var _0x1f373a = 0x0; _0x1f373a < _0x3cbd19; _0x1f373a++) { if (_0x1f373a + 0x1 == _0x3cbd19) { sendArrays[_0x4472('0x3f')](_0x3e2cf6['slice'](_0x1f373a * _0x3b2bd3)); } else { sendArrays[_0x4472('0x3f')](_0x3e2cf6[_0x4472('0x2c')](_0x1f373a * _0x3b2bd3, (_0x1f373a + 0x1) * _0x3b2bd3)); } } sendIndex = 0x0; runSendData(); } else { console[_0x4472('0x9')]('Packet\x20send\x20complete.'); } } function runSendData() { console[_0x4472('0x9')](_0x4472('0x22'), sendArrays[sendIndex]); let _0x2acb4e = hex2ArrayBuffer(sendArrays[sendIndex]); wx['writeBLECharacteristicValue']({ 'deviceId': connectDeviceId, 'serviceId': serviceUUID, 'characteristicId': writeUUID, 'value': _0x2acb4e, 'success': _0x5b7035 => { sendIndex++; if (sendIndex < sendArrays['length']) { runSendData(); } else { write(dataArrays[dataIndex]); } }, 'fail': _0x2b2b50 => { if (transTimer != undefined) { clearTimeout(transTimer); } typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472( '0x3b')], null, _0x2b2b50['errMsg'])); } }); } function CRC8(_0x1ad747) { let _0x2ba538 = new Uint8Array(hex2ArrayBuffer(_0x1ad747)); let _0xab46ff = 0x0; for (let _0x2b3b74 of _0x2ba538) { _0xab46ff ^= _0x2b3b74; } return _0xab46ff[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x2, '0')['toUpperCase'](); } function CRC16(_0x5ed917) { let _0x8b2317 = 0xffff; for (let _0x4cb4f2 of _0x5ed917) { _0x8b2317 ^= _0x4cb4f2 & 0xff; for (var _0x104edf = 0x0; _0x104edf < 0x8; _0x104edf++) { if ((_0x8b2317 & 0x1) > 0x0) { _0x8b2317 = _0x8b2317 >> 0x1; _0x8b2317 = _0x8b2317 ^ 0x8408; } else { _0x8b2317 = _0x8b2317 >> 0x1; } } } return (_0x8b2317 ^ 0xffff)[_0x4472('0x1e')](0x10); } function hex2ArrayBuffer(_0x1d7b99) { var _0x5a055c = new Uint8Array(_0x1d7b99['match'](/[\da-f]{2}/gi)['map'](function(_0x1b621a) { return parseInt(_0x1b621a, 0x10); })); return _0x5a055c['buffer']; } function arrayBuffer2hex(_0x3b0ba6) { const _0x2bf4dc = Array['prototype']['map'][_0x4472('0x1c')](new Uint8Array(_0x3b0ba6), function(_0xff9c01) { return ('00' + _0xff9c01['toString'](0x10))[_0x4472('0x2c')](-0x2); }); return _0x2bf4dc[_0x4472('0x42')](''); } function littleEndian(_0x10084d) { if (_0x10084d != '' && _0x10084d != undefined) { var _0x1f11f2 = ''; for (var _0x2b1cd6 = _0x10084d['length']; _0x2b1cd6 >= 0x0; _0x2b1cd6 = _0x2b1cd6 - 0x2) { _0x1f11f2 += _0x10084d[_0x4472('0x1')](_0x2b1cd6); _0x1f11f2 += _0x10084d[_0x4472('0x1')](_0x2b1cd6 + 0x1); } return _0x1f11f2; } else { return _0x10084d; } }