123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937 |
- const _0x221b = ['uuid', '发送ICC指令成功', 'statusCode', 'stopBluetoothDevicesDiscovery', 'prototype', 'onIsEnable',
- 'devices', 'push', '无效参数', 'writeBLECharacteristicValue', 'concat', 'onBLEConnectionStateChange', 'exports',
- 'buffer', 'getBLEDeviceServices', '发送蓝牙指令超时', 'closeBluetoothAdapter', '发送蓝牙指令返回数据异常', '开始接收:', 'substring',
- 'code', '发送数据失败', 'disconnectSuccess->', 'connected', 'data', 'success', 'slice', '已断连', 'fail',
- 'dataFrameTransboundary', 'cmdtype->', 'fe01', 'deviceList', 'padStart', 'msg', '连接成功,握手成功',
- 'noTargetServiceId', 'cmdtype->未连接设备', 'name', 'shift', 'match', '发送esam指令超时', '发送ICC指令超时', 'errMsg', '1800',
- 'createBLEConnection', '卡片复位失败', '2712', '0a0012', '发送数据失败:', '发送esam指令成功', '卡片复位返回数据异常', '包数据:', 'successCode',
- 'startBluetoothDevicesDiscovery', 'localName', '开始重发', 'offBLEConnectionStateChange', 'log', 'toString',
- '未连接设备', 'deviceId', '数据长度越界', '0000FEC8-0000-1000-8000-00805F9B34FB', 'deviceId->', '断开连接成功', 'map',
- 'characteristics', 'length'
- ];
- const _0xdbaa = function(_0x221bee, _0xdbaa49) {
- _0x221bee = _0x221bee - 0x0;
- let _0x5ce86a = _0x221b[_0x221bee];
- return _0x5ce86a;
- };
- module[_0xdbaa('0xc')] = {
- 'scanBle': scanBle,
- 'closBluetooth': closBluetooth,
- 'connectDevice': connectDevice,
- 'disconnectDevice': disconnectDevice,
- 'transCmd': transData,
- 'disconnectDeviceBluetooth': disconnectDeviceBluetooth,
- 'resetICC': sendA9Command
- };
- var deviceList = [];
- var onIsEnable = toResObject(0x0, '蓝牙状态正常');
- var scanBleTimer;
-
- function toResObject(_0x4a4039, _0x190e2d) {
- return {
- 'code': _0x4a4039,
- 'msg': _0x190e2d
- };
- }
-
- function scanBle(_0x286cc3, _0x1822a2) {
- this['deviceList'] = [];
- this['onIsEnable'] = toResObject(0x0, '蓝牙状态正常');
- scanBleTimer = setTimeout(() => {
- wx[_0xdbaa('0x3')]();
- _0x1822a2(this[_0xdbaa('0x20')], this[_0xdbaa('0x5')]);
- }, _0x286cc3);
- wx['openBluetoothAdapter']({
- 'success': _0x44cd82 => {
- wx[_0xdbaa('0x36')]({
- 'allowDuplicatesKey': !![],
- 'interval': 0x64,
- 'success': _0x53a754 => {
- wx['onBluetoothDeviceFound'](_0x23d4d3 => {
- for (let _0x491211 = 0x0; _0x491211 < _0x23d4d3[_0xdbaa('0x6')][
- 'length'
- ]; _0x491211++) {
- let _0x1bacde = ![];
- if (_0x23d4d3[_0xdbaa('0x6')][_0x491211]['localName'] ==
- undefined || _0x23d4d3[_0xdbaa('0x6')][_0x491211][
- 'localName'
- ] == '' || _0x23d4d3[_0xdbaa('0x6')][_0x491211][
- 'localName'
- ] == '<Undefined>') {
- continue;
- }
- for (let _0x41572c = 0x0; _0x41572c < this[_0xdbaa('0x20')][
- 'length'
- ]; _0x41572c++) {
- if (_0x23d4d3[_0xdbaa('0x6')][_0x491211][_0xdbaa(
- '0x3d')] == this['deviceList'][_0x41572c][
- 'deviceId'
- ]) {
- _0x1bacde = !![];
- continue;
- }
- }
- if (_0x1bacde == ![]) {
- let _0x47fc85 = {};
- _0x47fc85[_0xdbaa('0x26')] = _0x23d4d3[_0xdbaa('0x6')][
- _0x491211
- ][_0xdbaa('0x37')];
- _0x47fc85[_0xdbaa('0x3d')] = _0x23d4d3[_0xdbaa('0x6')][
- _0x491211
- ][_0xdbaa('0x3d')];
- _0x47fc85['RSSI'] = _0x23d4d3[_0xdbaa('0x6')][_0x491211]
- ['RSSI'];
- this[_0xdbaa('0x20')][_0xdbaa('0x7')](_0x47fc85);
- }
- }
- });
- },
- 'fail': _0x4008b5 => {
- this['deviceList'] = [];
- this['onIsEnable'] = toResObject(-0x1, _0x4008b5['errMsg']);
- clearTimeout(scanBleTimer);
- _0x1822a2(this[_0xdbaa('0x20')], this[_0xdbaa('0x5')]);
- }
- });
- },
- 'fail': _0x11a554 => {
- this['deviceList'] = [];
- this[_0xdbaa('0x5')] = toResObject(-0x1, _0x11a554[_0xdbaa('0x2b')]);
- clearTimeout(scanBleTimer);
- _0x1822a2(this['deviceList'], this[_0xdbaa('0x5')]);
- }
- });
- }
-
- function closBluetooth(_0xd6e914) {
- clearTimeout(scanBleTimer);
- wx['stopBluetoothDevicesDiscovery']({
- 'success': _0x1184b0 => {
- _0xd6e914(toResObject(0x0, '蓝牙搜索已停止'));
- },
- 'fail': _0x356306 => {
- _0xd6e914(toResObject(-0x1, _0x356306[_0xdbaa('0x2b')]));
- }
- });
- }
-
- function connectDevice(_0x33721e, _0x179971, _0x2860fa) {
- wx[_0xdbaa('0xb')](_0x1e1e1a => {
- if (_0x1e1e1a[_0xdbaa('0x17')]) {
- _0x2860fa(toResObject(0x0, '已连接'));
- } else {
- _0x2860fa(toResObject(-0x1, '未连接'));
- }
- });
- connectAndInit(_0x33721e, {
- 'success': _0x5afa0f => {
- if (_0x5afa0f['code'] == 0x3e8 || _0x5afa0f[_0xdbaa('0x2')] == 0x3e8) {
- _0x179971(toResObject(0x0, '连接成功'));
- }
- },
- 'fail': _0x39efbe => {
- _0x179971(toResObject(-0x1, _0x39efbe[_0xdbaa('0x22')]));
- }
- }, 0x1f40);
- }
-
- function disconnectDevice(_0x4a9821) {
- disconnectBleDevice({
- 'success': _0x51f5e4 => {
- this['connectDeviceId'] = undefined;
- _0x4a9821(toResObject(0x0, '已断连'));
- wx['offBLEConnectionStateChange']();
- wx[_0xdbaa('0x10')]();
- },
- 'fail': _0x109b28 => {
- _0x4a9821(toResObject(-0x1, _0x109b28['msg']));
- wx['offBLEConnectionStateChange']();
- wx['closeBluetoothAdapter']();
- }
- });
- }
-
- function transData(_0xf2c818, _0x30d48e, _0x40aa35) {
- if (connectDeviceId == undefined) {
- let _0x13ba14 = toResObject(-0x1, _0xdbaa('0x3c'));
- _0x13ba14[_0xdbaa('0x18')] = undefined;
- _0x40aa35(_0x13ba14);
- console['log'](_0xdbaa('0x25'), _0x30d48e);
- return;
- }
- console[_0xdbaa('0x3a')](_0xdbaa('0x1e'), _0x30d48e);
- if (_0x30d48e == '10') {
- sendAndReceive(0x0, _0xf2c818, {
- 'success': _0x56226b => {
- let _0x4634c0 = toResObject(0x0, '执行成功');
- _0x4634c0[_0xdbaa('0x18')] = _0x56226b[_0xdbaa('0x18')];
- _0x40aa35(_0x4634c0);
- },
- 'fail': _0x1c746c => {
- let _0x424cbb = toResObject(-0x1, _0x1c746c[_0xdbaa('0x22')]);
- _0x424cbb[_0xdbaa('0x18')] = undefined;
- _0x40aa35(_0x424cbb);
- }
- }, 0xfa0);
- }
- if (_0x30d48e == '20') {
- sendAndReceive(0x1, _0xf2c818, {
- 'success': _0x12b874 => {
- let _0x28926e = toResObject(0x0, '执行成功');
- _0x28926e[_0xdbaa('0x18')] = _0x12b874['data'];
- _0x40aa35(_0x28926e);
- },
- 'fail': _0x2f9951 => {
- let _0x334d91 = toResObject(-0x1, _0x2f9951['msg']);
- _0x334d91[_0xdbaa('0x18')] = undefined;
- _0x40aa35(_0x334d91);
- }
- }, 0xfa0);
- }
- }
-
- function disconnectDeviceBluetooth(_0x2c9dfb) {
- sendA5Command('C3', {
- 'success': _0x202a3a => {
- _0x2c9dfb(toResObject(0x0, _0xdbaa('0x1b')));
- wx[_0xdbaa('0x39')]();
- wx[_0xdbaa('0x10')]();
- },
- 'fail': _0x351a4b => {
- _0x2c9dfb(toResObject(0x0, _0xdbaa('0x1b')));
- wx[_0xdbaa('0x39')]();
- wx[_0xdbaa('0x10')]();
- }
- }, 0xfa0);
- }
- const codeEnum = {
- 'successCode': 0x3e8,
- 'failureCode': 0x1,
- 'stopScanFailure': 0x2,
- 'creatConnectionFailure': 0x3,
- 'getServiceFailure': 0x4,
- 'noTargetServiceId': 0x5,
- 'getCharacteristicsFailure': 0x6,
- 'noTargetCharacteristic': 0x7,
- 'monitorNotificationFailure': 0x8,
- 'authResponseFailure': 0x9,
- 'initResponseFailure': 0xa,
- 'initDeviceFailure': 0xb,
- 'dataFrameTransboundary': 0xc,
- 'notPassBccCheck': 0xd,
- 'sendDataFailure': 0xe,
- 'paraError': 0xf,
- 'timeout': 0x64
- };
- const FUNCTION = 'function';
- const serviceUUID = '0000FEE7-0000-1000-8000-00805F9B34FB';
- const writeUUID = '0000FEC7-0000-1000-8000-00805F9B34FB';
- const readUUID = _0xdbaa('0x3f');
- const connectTime = 0x14 * 0x3e8;
- const startA2Time = 0xf0;
- const waitA2ResponseTime = 0x3e8;
- var haveFoundDevice = new Array();
- var connectDeviceId;
- var connectCallback;
- var connectTimer;
- var transTimer;
- var frame = '';
- var frameLen = 0x0;
- var frames = new Array();
- var framesLen = 0x0;
- var dataHandlerCallback;
- var sendBufferArray = new Array();
- var cmds = new Array();
- var sendIndex;
- var resendCount = 0x3;
-
- function toObject(_0x2a8196, _0xcef0ec, _0x4b69d4) {
- return {
- 'code': _0x2a8196,
- 'data': _0xcef0ec,
- 'msg': _0x4b69d4
- };
- }
-
- function startConnectBle() {
- wx[_0xdbaa('0x2d')]({
- 'deviceId': connectDeviceId,
- 'success': function(_0x344335) {
- startGetAndCheckService();
- },
- 'fail': function(_0x408275) {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback[_0xdbaa('0x1c')] == FUNCTION && connectCallback[_0xdbaa('0x1c')](
- toObject(0xfa0, undefined, _0x408275[_0xdbaa('0x2b')]));
- }
- });
- }
-
- function startGetAndCheckService() {
- wx[_0xdbaa('0xe')]({
- 'deviceId': connectDeviceId,
- 'success': function(_0x5b2630) {
- let _0x1480df = ![];
- for (let _0x33eba0 = 0x0; _0x33eba0 < _0x5b2630['services']['length']; _0x33eba0++) {
- let _0x56a201 = _0x5b2630['services'][_0x33eba0][_0xdbaa('0x0')];
- if (_0x56a201 == serviceUUID) {
- _0x1480df = !![];
- break;
- }
- }
- if (_0x1480df == !![]) {
- startGetAndCheckCharacterisitc();
- } else {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback[_0xdbaa('0x1c')] == FUNCTION && connectCallback['fail'](toObject(
- codeEnum[_0xdbaa('0x24')], undefined, _0xdbaa('0x24')));
- }
- },
- 'fail': function(_0x13c868) {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback[_0xdbaa('0x1c')] == FUNCTION && connectCallback['fail'](toObject(0xfa0,
- undefined, _0x13c868[_0xdbaa('0x2b')]));
- }
- });
- }
-
- function startGetAndCheckCharacterisitc() {
- wx['getBLEDeviceCharacteristics']({
- 'deviceId': connectDeviceId,
- 'serviceId': serviceUUID,
- 'success': function(_0x470d0a) {
- let _0x1fe81f = ![];
- let _0x11e288 = ![];
- for (let _0xebad80 = 0x0; _0xebad80 < _0x470d0a['characteristics'][_0xdbaa(
- '0x44')]; _0xebad80++) {
- let _0x359431 = _0x470d0a[_0xdbaa('0x43')][_0xebad80][_0xdbaa('0x0')];
- if (_0x359431 == readUUID) {
- _0x1fe81f = !![];
- } else if (_0x359431 == writeUUID) {
- _0x11e288 = !![];
- }
- if (_0x1fe81f == !![] && _0x11e288 == !![]) {
- break;
- }
- }
- if (_0x1fe81f == !![] && _0x11e288 == !![]) {
- monitorNotification();
- } else {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback['fail'] == FUNCTION && connectCallback[_0xdbaa('0x1c')](toObject(
- 0xfa0, undefined, 'noTargetCharacteristic'));
- }
- },
- 'fail': function(_0x58e8ac) {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback[_0xdbaa('0x1c')] == FUNCTION && connectCallback['fail'](toObject(0xfa0,
- undefined, _0x58e8ac[_0xdbaa('0x2b')]));
- }
- });
- }
-
- function monitorNotification() {
- wx['notifyBLECharacteristicValueChange']({
- 'deviceId': connectDeviceId,
- 'serviceId': serviceUUID,
- 'characteristicId': readUUID,
- 'state': !![],
- 'success': function(_0x8fb946) {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- setTimeout(() => {
- typeof connectCallback['success'] == FUNCTION && connectCallback['success'](
- toObject(codeEnum['successCode'], undefined, _0xdbaa('0x23')));
- }, 0x3e8);
- },
- 'fail': function() {
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(0xfa0, undefined,
- 'monitorNotificationFailure'));
- }
- });
- wx['onBLECharacteristicValueChange'](function(_0x28c56f) {
- if (_0x28c56f['deviceId'] = connectDeviceId && _0x28c56f['serviceId'] == serviceUUID && _0x28c56f[
- 'characteristicId'] == readUUID) {
- analyticData(_0x28c56f['value']);
- }
- });
- }
- var sendDataCount = 0x1;
-
- function analyticData(_0x81bc09) {
- let _0x33a038 = bufferArrayToHexString(_0x81bc09);
- if (_0x33a038[_0xdbaa('0x44')] == 0x28 && _0x33a038[_0xdbaa('0x1a')](0x0, 0x4) == _0xdbaa('0x1f')) {
- console[_0xdbaa('0x3a')](_0xdbaa('0x12'));
- sendDataCount = 0x0;
- }
- sendDataCount++;
- console[_0xdbaa('0x3a')]('第', sendDataCount, _0xdbaa('0x34'), _0x33a038);
- if (frame['length'] == 0x0) {
- frameLen = parseInt(_0x33a038[_0xdbaa('0x1a')](0x4, 0x8), 0x10) * 0x2;
- }
- frame += _0x33a038;
- if (frame['slice'](0x0, 0x4) != _0xdbaa('0x1f')) {
- frame = '';
- frameLen = 0x0;
- } else if (frame[_0xdbaa('0x44')] > frameLen) {
- frame = '';
- frameLen = 0x0;
- typeof dataHandlerCallback == FUNCTION && dataHandlerCallback(toObject(codeEnum[_0xdbaa('0x1d')], '', _0xdbaa(
- '0x3e')));
- } else if (frame[_0xdbaa('0x44')] == frameLen) {
- let _0x27b94d = frame[_0xdbaa('0x1a')](0x8, 0xc);
- if (_0x27b94d === _0xdbaa('0x2f')) {
- let _0x4d0d94 = frame[_0xdbaa('0x1a')](0x10);
- let _0x560f44 = _0x4d0d94[_0xdbaa('0x1a')](0x8, -0x6);
- frame = '';
- frameLen = 0x0;
- if (frames['length'] == 0x0) {
- let _0x189057 = parseInt(_0x560f44[_0xdbaa('0x1a')](0x4, 0x6), 0x10);
- framesLen = _0x189057 - 0x80 + 0x1;
- }
- frames['push'](_0x560f44);
- if (frames['length'] == framesLen) {
- let _0x563253 = !![];
- for (let _0x256751 = 0x0; _0x256751 < frames[_0xdbaa('0x44')]; _0x256751++) {
- let _0x2e116f = frames[_0x256751];
- let _0x1837ea = 0x0;
- for (let _0x37b89e = 0x1; _0x37b89e < parseInt(_0x2e116f['length'] / 0x2) - 0x1; _0x37b89e++) {
- let _0x72566f = parseInt(_0x2e116f[_0xdbaa('0x1a')](_0x37b89e * 0x2, (_0x37b89e + 0x1) * 0x2),
- 0x10);
- _0x1837ea ^= _0x72566f;
- }
- if (_0x1837ea != parseInt(_0x2e116f[_0xdbaa('0x1a')](-0x2), 0x10)) {
- _0x563253 = ![];
- break;
- }
- }
- if (_0x563253 == ![]) {
- frames = new Array();
- framesLen = 0x0;
- typeof dataHandlerCallback == FUNCTION && dataHandlerCallback(toObject(codeEnum['notPassBccCheck'],
- '', 'bcc校验不通过'));
- } else {
- let _0x52c7b9 = '';
- for (let _0x7bedb = 0x0; _0x7bedb < frames[_0xdbaa('0x44')]; _0x7bedb++) {
- let _0x58d038 = frames[_0x7bedb];
- _0x52c7b9 += _0x58d038[_0xdbaa('0x1a')](0x8, -0x2);
- }
- frames = new Array();
- framesLen = 0x0;
- typeof dataHandlerCallback == FUNCTION && dataHandlerCallback(toObject(codeEnum['successCode'],
- _0x52c7b9, '成功'));
- }
- }
- } else {
- console[_0xdbaa('0x3a')]('提示数据');
- frame = '';
- frameLen = 0x0;
- }
- }
- }
-
- function connectAndInit(_0x5c5db4, _0x38a451, _0x50526d) {
- connectDeviceId = _0x5c5db4[_0xdbaa('0x3d')];
- const _0x6cb3dd = connectDeviceId;
- console['log'](_0xdbaa('0x40'), _0x6cb3dd);
- if (_0x6cb3dd != 'undefined' && _0x6cb3dd != '') {
- wx['closeBLEConnection']({
- 'deviceId': _0x6cb3dd,
- 'success'(_0x1eca68) {
- console['log'](_0xdbaa('0x16'), _0x1eca68);
- },
- 'fail'(_0x2a8299) {
- console[_0xdbaa('0x3a')]('disconnectFail->', _0x2a8299);
- }
- });
- }
- connectDeviceId = _0x5c5db4[_0xdbaa('0x3d')];
- connectCallback = _0x38a451;
- if (typeof connectTimer != undefined) {
- clearTimeout(connectTimer);
- }
- connectTimer = setTimeout(() => {
- typeof connectCallback[_0xdbaa('0x1c')] == FUNCTION && connectCallback['fail'](toObject(0x7d2,
- undefined, '连接超时'));
- }, _0x50526d);
- startConnectBle();
- }
-
- function disconnectBleDevice(_0x17d8ce) {
- const _0x1e4bc6 = String(connectDeviceId);
- wx['closeBLEConnection']({
- 'deviceId': _0x1e4bc6,
- 'success'(_0x294a83) {
- typeof _0x17d8ce['success'] == FUNCTION && _0x17d8ce['success'](toObject(codeEnum[_0xdbaa('0x35')],
- _0x294a83, _0xdbaa('0x41')));
- },
- 'fail'(_0x1742ab) {
- typeof _0x17d8ce['fail'] == FUNCTION && _0x17d8ce[_0xdbaa('0x1c')](toObject(0xfa0, _0x1742ab,
- '断开连接失败'));
- }
- });
- }
-
- function sendAndReceive(_0x110528, _0x5e89f4, _0x1e49be, _0x4908cb) {
- let _0x1f8566 = ![];
- let _0x427250 = setTimeout(() => {
- typeof _0x1e49be[_0xdbaa('0x1c')] == FUNCTION && _0x1e49be[_0xdbaa('0x1c')](toObject(0x7d2, undefined,
- _0x110528 == 0x0 ? '发送ICC指令超时' : _0xdbaa('0x29')));
- }, _0x4908cb);
- transCmd(_0x110528, _0x5e89f4, {
- 'success': _0x3cc671 => {
- clearTimeout(_0x427250);
- typeof _0x1e49be['success'] == FUNCTION && _0x1e49be[_0xdbaa('0x19')](_0x3cc671);
- },
- 'fail': _0x4b7ca2 => {
- if (_0x4b7ca2['code'] == 0x7d0 && _0x1f8566 == ![]) {
- console['log'](_0xdbaa('0x38'));
- _0x1f8566 = !![];
- transCmd(_0x110528, _0x5e89f4, {
- 'success': _0x5707f6 => {
- clearTimeout(_0x427250);
- typeof _0x1e49be['success'] == FUNCTION && _0x1e49be['success'](
- _0x5707f6);
- },
- 'fail': _0x7ea0e2 => {
- clearTimeout(_0x427250);
- typeof _0x1e49be[_0xdbaa('0x1c')] == FUNCTION && _0x1e49be[_0xdbaa(
- '0x1c')](_0x7ea0e2);
- }
- }, 0x7d0);
- } else {
- clearTimeout(_0x427250);
- typeof _0x1e49be[_0xdbaa('0x1c')] == FUNCTION && _0x1e49be[_0xdbaa('0x1c')](_0x4b7ca2);
- }
- }
- }, 0x7d0);
- }
-
- function transCmd(_0x5a39f8, _0x3e8f43, _0x555f5d, _0x458940) {
- if (_0x5a39f8 != 0x0 && _0x5a39f8 != 0x1 && _0x5a39f8 != 0x2) {
- typeof _0x555f5d[_0xdbaa('0x1c')] == FUNCTION && _0x555f5d['fail'](toObject(0xfa0, undefined, 'type\x20错误'));
- return;
- }
- if (typeof transTimer != undefined) {
- clearTimeout(transTimer);
- }
- transTimer = setTimeout(() => {
- typeof _0x555f5d[_0xdbaa('0x1c')] == FUNCTION && _0x555f5d['fail'](toObject(0x7d2, undefined,
- _0x5a39f8 == 0x0 ? '发送ICC指令超时' : _0xdbaa('0x29')));
- }, _0x458940);
- cmds = _0x3e8f43['slice']();
- var _0x181c19 = new Array();
- var _0x47708a;
- var _0x4a4158;
- for (var _0x562067 = 0x0; _0x562067 < _0x3e8f43['length']; _0x562067++) {
- if (_0x562067 == 0x0) {
- _0x47708a = cmds[_0xdbaa('0x27')]();
- _0x4a4158 = promise(_0x47708a, _0x5a39f8);
- }
- _0x4a4158 = _0x4a4158['then'](_0x5b30d4 => {
- if (typeof transTimer != undefined) {
- clearTimeout(transTimer);
- }
- if (_0x5b30d4 === undefined) {
- return;
- }
- _0x181c19['push'](_0x5b30d4);
- if (cmds['length'] > 0x0) {
- transTimer = setTimeout(() => {
- typeof _0x555f5d[_0xdbaa('0x1c')] == FUNCTION && _0x555f5d['fail'](toObject(0x7d2,
- undefined, _0x5a39f8 == 0x0 ? _0xdbaa('0x2a') : '发送esam指令超时'));
- }, _0x458940);
- _0x47708a = cmds[_0xdbaa('0x27')]();
- return promise(_0x47708a, _0x5a39f8);
- }
- typeof _0x555f5d['success'] == FUNCTION && _0x555f5d['success'](toObject(codeEnum[_0xdbaa('0x35')],
- _0x181c19, _0x5a39f8 == 0x0 ? _0xdbaa('0x1') : _0xdbaa('0x32')));
- }, (_0x50f5ee, _0x791fff) => {
- if (_0x50f5ee != undefined) {
- if (typeof transTimer != undefined) {
- clearTimeout(transTimer);
- }
- typeof _0x555f5d['fail'] == FUNCTION && _0x555f5d[_0xdbaa('0x1c')](toObject(0xfa0, _0x181c19,
- _0x47708a + _0x50f5ee));
- }
- });
- }
- }
-
- function promise(_0x24ae76, _0x84d67c) {
- return new Promise((_0xbfca21, _0x37740f) => {
- if (_0x84d67c === 0x0) {
- var _0x50d360 = makeA3SendData('00', makeTLV([_0x24ae76]));
- } else {
- var _0x50d360 = makeACSendData('00', makeTLV([_0x24ae76]));
- }
- sendDataToDevice(_0x50d360, _0x307c84 => {
- if (_0x307c84[_0xdbaa('0x14')] === codeEnum[_0xdbaa('0x35')]) {
- if (_0x307c84['data']['slice'](0x2, 0x4) === '00' || _0x307c84['data']['slice'](0x2,
- 0x4) === 'cf') {
- let _0x2aa53b = _0x307c84[_0xdbaa('0x18')][_0xdbaa('0x1a')](0xa);
- let _0xc33b5 = resolveTLV(_0x307c84['data']['slice'](0xa));
- if (_0xc33b5[_0xdbaa('0x44')] == 0x1) {
- _0xbfca21(_0xc33b5[0x0]);
- } else {
- _0x37740f('数据返回错误');
- }
- } else {
- let _0x294462 = _0x307c84['data'][_0xdbaa('0x1a')](0xa);
- let _0x100afb = resolveTLV(_0x307c84[_0xdbaa('0x18')]['slice'](0xa));
- _0x37740f('错误码:' + _0x100afb[_0x100afb['length'] - 0x1]['slice'](-0x4));
- }
- } else {
- _0x37740f(_0x307c84[_0xdbaa('0x22')]);
- }
- });
- });
- }
-
- function sendDataToDevice(_0x4d4da7, _0x262979) {
- dataHandlerCallback = _0x262979;
- sendBufferArray = new Array()[_0xdbaa('0xa')](_0x4d4da7);
- sendIndex = 0x0;
- frame = '';
- frameLen = 0x0;
- frames = new Array();
- framesLen = 0x0;
- console['log']('开始发送:');
- runningSendData();
- }
-
- function runningSendData() {
- let _0x29f9c6 = sendBufferArray[sendIndex];
- let _0x560439 = bufferArrayToHexString(_0x29f9c6);
- console['log']('第', sendIndex + 0x1, _0xdbaa('0x34'), _0x560439);
- wx[_0xdbaa('0x9')]({
- 'deviceId': connectDeviceId,
- 'serviceId': serviceUUID,
- 'characteristicId': writeUUID,
- 'value': _0x29f9c6,
- 'success': function(_0x2f1c3c) {
- sendIndex++;
- resendCount = 0x3;
- if (sendIndex < sendBufferArray['length']) {
- runningSendData();
- }
- },
- 'fail': function(_0x177d36) {
- if (resendCount > 0x0) {
- resendCount--;
- setTimeout(() => {
- console['log']('第' + (0x3 - resendCount) + '次重发');
- runningSendData();
- }, 0xc8);
- } else {
- typeof dataHandlerCallback == FUNCTION && dataHandlerCallback(toObject(codeEnum[
- 'sendDataFailure'], '', _0xdbaa('0x31') + _0x177d36['errMsg']));
- }
- }
- });
- }
-
- function sendA5Command(_0x2af7a9, _0x1d6ff7, _0x3a565b) {
- var _0x5e3a62 = setTimeout(() => {
- typeof _0x1d6ff7[_0xdbaa('0x1c')] == FUNCTION && _0x1d6ff7[_0xdbaa('0x1c')](toObject(0x7d2, undefined,
- _0xdbaa('0xf')));
- }, _0x3a565b);
- var _0x46493e = makeA5SendData(_0x2af7a9);
- sendDataToDevice(_0x46493e, _0x5c480e => {
- if (_0x5e3a62 != undefined) {
- clearTimeout(_0x5e3a62);
- }
- if (_0x5c480e[_0xdbaa('0x14')] === codeEnum[_0xdbaa('0x35')]) {
- if (_0x5c480e[_0xdbaa('0x18')]['slice'](0x0, 0x2) == 'b5' && _0x5c480e['data'][_0xdbaa('0x1a')](0x2,
- 0x4) == '00') {
- let _0x2ab972 = parseInt(_0x5c480e['data'][_0xdbaa('0x1a')](0x4, 0x6), 0x10);
- typeof _0x1d6ff7['success'] == FUNCTION && _0x1d6ff7['success'](toObject(codeEnum[_0xdbaa(
- '0x35')], _0x5c480e['data']['slice'](0x6, 0x6 + _0x2ab972 * 0x2), '成功'));
- } else {
- typeof _0x1d6ff7['fail'] == FUNCTION && _0x1d6ff7[_0xdbaa('0x1c')](toObject(0xfa0, _0x5c480e[
- 'data'], _0xdbaa('0x11')));
- }
- } else {
- typeof _0x1d6ff7[_0xdbaa('0x1c')] == FUNCTION && _0x1d6ff7[_0xdbaa('0x1c')](toObject(0xfa0,
- undefined, _0xdbaa('0x15')));
- }
- });
- }
-
- function openOrCloseAerial(_0x40f5d6, _0x37f2d4, _0x451391, _0x4c2faa) {
- if (_0x40f5d6 != 0x1 && _0x40f5d6 != 0x2 && _0x40f5d6 != 0x3 && _0x40f5d6 != 0x4) {
- typeof _0x451391['fail'] == FUNCTION && _0x451391[_0xdbaa('0x1c')](toObject(0xfa0, undefined, _0xdbaa('0x8')));
- } else {
- var _0x564530 = setTimeout(() => {
- typeof _0x451391[_0xdbaa('0x1c')] == FUNCTION && _0x451391['fail'](toObject(0x7d2, undefined,
- '打开/关闭5.8G指令超时'));
- }, _0x4c2faa);
- let _0x472d65 = _0x37f2d4;
- if (_0x37f2d4 < 0x0) {
- _0x472d65 = 0x0;
- }
- if (_0x37f2d4 > 0x12c) {
- _0x472d65 = 0x12c;
- }
- let _0x297ab6 = 'C7' + parseInt(_0x40f5d6)['toString'](0x10)[_0xdbaa('0x21')](0x2, '0');
- if (_0x40f5d6 == 0x2) {
- _0x297ab6 += parseInt(_0x472d65)[_0xdbaa('0x3b')](0x10)['padStart'](0x4, '0');
- }
- var _0x4c7439 = makeA5SendData(_0x297ab6);
- sendDataToDevice(_0x4c7439, _0x3d8cdb => {
- if (_0x564530 != undefined) {
- clearTimeout(_0x564530);
- }
- if (_0x3d8cdb['code'] === codeEnum[_0xdbaa('0x35')]) {
- if (_0x3d8cdb['data'][_0xdbaa('0x1a')](0x0, 0x2) == 'b5' && _0x3d8cdb[_0xdbaa('0x18')]['slice'](
- 0x2, 0x4) == '00') {
- let _0x28bf0e = parseInt(_0x3d8cdb['data'][_0xdbaa('0x1a')](0x4, 0x6), 0x10);
- typeof _0x451391['success'] == FUNCTION && _0x451391['success'](toObject(codeEnum[_0xdbaa(
- '0x35')], _0x3d8cdb[_0xdbaa('0x18')][_0xdbaa('0x1a')](0x6, 0x6 + _0x28bf0e *
- 0x2), '成功'));
- } else {
- typeof _0x451391['fail'] == FUNCTION && _0x451391['fail'](toObject(0xfa0, _0x3d8cdb[_0xdbaa(
- '0x18')], _0xdbaa('0x11')));
- }
- } else {
- typeof _0x451391[_0xdbaa('0x1c')] == FUNCTION && _0x451391['fail'](toObject(0xfa0, undefined,
- '打开/关闭5.8G失败'));
- }
- });
- }
- }
-
- function sendA9Command(_0x365ba9, _0x40c12c) {
- var _0x587b3c = setTimeout(() => {
- typeof _0x365ba9[_0xdbaa('0x1c')] == FUNCTION && _0x365ba9[_0xdbaa('0x1c')](toObject(0x7d2, undefined,
- '卡片复位超时'));
- }, _0x40c12c);
- var _0x5134c0 = makeA9SendData('00');
- sendDataToDevice(_0x5134c0, _0xa8dfb9 => {
- if (_0x587b3c != undefined) {
- clearTimeout(_0x587b3c);
- }
- if (_0xa8dfb9[_0xdbaa('0x14')] === codeEnum['successCode']) {
- if (_0xa8dfb9['data']['slice'](0x0, 0x2) == 'b9' && _0xa8dfb9[_0xdbaa('0x18')][_0xdbaa('0x1a')](0x2,
- 0x4) == '00') {
- let _0x236cf6 = parseInt(_0xa8dfb9[_0xdbaa('0x18')]['slice'](0x4, 0x6), 0x10);
- typeof _0x365ba9[_0xdbaa('0x19')] == FUNCTION && _0x365ba9['success'](toObject(codeEnum[
- 'successCode'], _0xa8dfb9[_0xdbaa('0x18')]['slice'](0x6, 0x6 + _0x236cf6 * 0x2),
- '成功'));
- } else {
- typeof _0x365ba9[_0xdbaa('0x1c')] == FUNCTION && _0x365ba9[_0xdbaa('0x1c')](toObject(0xfa0,
- _0xa8dfb9['data'], _0xdbaa('0x33')));
- }
- } else {
- typeof _0x365ba9['fail'] == FUNCTION && _0x365ba9['fail'](toObject(0xfa0, undefined, _0xdbaa(
- '0x2e')));
- }
- });
- }
- const frame_Len = 0x32 * 0x2;
- const send_Len = 0x14 * 0x2;
- const ST = '33';
- const pre_Proto = _0xdbaa('0x30');
- const end_Proto = _0xdbaa('0x2c');
- const bMagic = 'fe';
- const bVer = '01';
- const bCmdId = '7531';
- var SEQ = 0x3;
-
- function makeFrame(_0x2a2c7b) {
- let _0x2964c8 = parseInt(_0x2a2c7b[_0xdbaa('0x44')] / frame_Len);
- let _0xe34cea = _0x2a2c7b[_0xdbaa('0x44')] % frame_Len;
- let _0x1af1e4 = new Array();
- for (let _0x229e92 = 0x0; _0x229e92 < _0x2964c8; _0x229e92++) {
- _0x1af1e4[_0xdbaa('0x7')](_0x2a2c7b[_0xdbaa('0x1a')](_0x229e92 * frame_Len, (_0x229e92 + 0x1) * frame_Len));
- }
- if (_0xe34cea > 0x0) {
- _0x1af1e4[_0xdbaa('0x7')](_0x2a2c7b['slice'](-_0xe34cea));
- }
- let _0x5d2a25 = new Array();
- for (let _0x13860c = 0x0; _0x13860c < _0x1af1e4['length']; _0x13860c++) {
- let _0x1ff86c = _0x1af1e4[_0x13860c];
- let _0x430530 = numberToHexString(_0x13860c + 0x1, 0x1, !![]);
- let _0x27a37e = '';
- if (_0x13860c == 0x0) {
- _0x27a37e = numberToHexString(0x80 + _0x1af1e4[_0xdbaa('0x44')] - 0x1, 0x1, !![]);
- } else {
- _0x27a37e = numberToHexString(_0x1af1e4[_0xdbaa('0x44')] - _0x13860c - 0x1, 0x1, !![]);
- }
- let _0x391d6c = numberToHexString(parseInt(_0x1ff86c[_0xdbaa('0x44')] / 0x2), 0x1, !![]);
- let _0x40aa72 = ST + _0x430530 + _0x27a37e + _0x391d6c + _0x1ff86c;
- let _0x53fcd9 = 0x0;
- for (let _0x395d1a = 0x1; _0x395d1a < parseInt(_0x40aa72['length'] / 0x2); _0x395d1a++) {
- let _0x3ea4c0 = parseInt(_0x40aa72['slice'](_0x395d1a * 0x2, (_0x395d1a + 0x1) * 0x2), 0x10);
- _0x53fcd9 = _0x53fcd9 ^ _0x3ea4c0;
- }
- _0x40aa72 += numberToHexString(_0x53fcd9, 0x1, !![]);
- _0x5d2a25[_0xdbaa('0x7')](_0x40aa72);
- }
- let _0x40387a = new Array();
- for (let _0x25293d = 0x0; _0x25293d < _0x5d2a25[_0xdbaa('0x44')]; _0x25293d++) {
- let _0x2a26d4 = _0x5d2a25[_0x25293d];
- let _0x402715 = numberToHexString(parseInt(_0x2a26d4['length'] / 0x2), 0x1, !![]);
- let _0x80b5a1 = pre_Proto + _0x402715 + _0x2a26d4 + end_Proto;
- _0x40387a[_0xdbaa('0x7')](_0x80b5a1);
- }
- let _0x5143d4 = new Array();
- for (let _0x264a59 = 0x0; _0x264a59 < _0x40387a[_0xdbaa('0x44')]; _0x264a59++) {
- let _0xbc2ce5 = _0x40387a[_0x264a59];
- let _0x3c40cf = numberToHexString(parseInt(_0xbc2ce5['length'] / 0x2) + 0x8, 0x2, !![]);
- let _0x1b89ff = numberToHexString(SEQ, 0x2, !![]);
- let _0x2ad2c8 = bMagic + bVer + _0x3c40cf + bCmdId + _0x1b89ff + _0xbc2ce5;
- _0x5143d4[_0xdbaa('0x7')](_0x2ad2c8);
- }
- SEQ++;
- if (SEQ > 0xf) {
- SEQ = 0x1;
- }
- let _0x461a7b = new Array();
- for (let _0xe28229 = 0x0; _0xe28229 < _0x5143d4['length']; _0xe28229++) {
- let _0x44ffca = _0x5143d4[_0xe28229];
- let _0x20750e = parseInt(_0x44ffca['length'] / send_Len);
- let _0x27c4e6 = _0x44ffca['length'] % send_Len;
- for (let _0x22183c = 0x0; _0x22183c < _0x20750e; _0x22183c++) {
- let _0x451f31 = _0x44ffca['slice'](_0x22183c * send_Len, (_0x22183c + 0x1) * send_Len);
- _0x461a7b['push'](hexStringToBufferArray(_0x451f31));
- }
- if (_0x27c4e6 > 0x0) {
- let _0x27cd63 = _0x44ffca['slice'](-_0x27c4e6);
- _0x461a7b['push'](hexStringToBufferArray(_0x27cd63));
- }
- }
- return _0x461a7b;
- }
-
- function makeA3SendData(_0xc88ab7, _0x5bd73d) {
- let _0x3f0364 = 'a3' + _0xc88ab7;
- let _0x42c12f = numberToHexString(parseInt(_0x5bd73d['length'] / 0x2), 0x2, ![]);
- _0x3f0364 += _0x42c12f;
- _0x3f0364 += _0x5bd73d;
- return makeFrame(_0x3f0364);
- }
-
- function makeA7SendData(_0xc5fc95, _0x224e5b) {
- let _0x3e99ed = 'a7' + _0xc5fc95;
- let _0x549e70 = numberToHexString(parseInt(_0x224e5b['length'] / 0x2), 0x2, ![]);
- _0x3e99ed += _0x549e70;
- _0x3e99ed += _0x224e5b;
- return makeFrame(_0x3e99ed);
- }
-
- function makeACSendData(_0x4a0b65, _0x24aee) {
- let _0x23e0ab = 'ac' + _0x4a0b65;
- let _0x4d2e97 = numberToHexString(parseInt(_0x24aee[_0xdbaa('0x44')] / 0x2), 0x2, ![]);
- _0x23e0ab += _0x4d2e97;
- _0x23e0ab += _0x24aee;
- return makeFrame(_0x23e0ab);
- }
-
- function numberToHexString(_0x1ca28c, _0x49cb0b, _0x1befcb) {
- let _0x594c49 = _0x1ca28c[_0xdbaa('0x3b')](0x10);
- for (let _0x20d709 = _0x594c49['length']; _0x20d709 < _0x49cb0b * 0x2; _0x20d709++) {
- _0x594c49 = '0' + _0x594c49;
- }
- if (_0x594c49[_0xdbaa('0x44')] > _0x49cb0b * 0x2) {
- _0x594c49 = _0x594c49['substring'](_0x594c49['length'] - _0x49cb0b * 0x2);
- }
- if (_0x1befcb == ![]) {
- let _0x3cc91b = '';
- for (let _0x270ccf = _0x594c49[_0xdbaa('0x44')] - 0x2; _0x270ccf >= 0x0; _0x270ccf -= 0x2) {
- _0x3cc91b = _0x3cc91b + _0x594c49[_0xdbaa('0x13')](_0x270ccf, _0x270ccf + 0x2);
- }
- _0x594c49 = _0x3cc91b;
- }
- return _0x594c49;
- }
-
- function hexStringToBufferArray(_0x48d905) {
- let _0x43c9d9 = new Uint8Array(_0x48d905[_0xdbaa('0x28')](/[0-9a-f]{2}/gi)[_0xdbaa('0x42')](function(_0x474769) {
- return parseInt(_0x474769, 0x10);
- }));
- return _0x43c9d9[_0xdbaa('0xd')];
- }
-
- function bufferArrayToHexString(_0x25e6b9) {
- let _0x2acc66 = Array[_0xdbaa('0x4')]['map']['call'](new Uint8Array(_0x25e6b9), _0x5bee07 => ('00' + _0x5bee07[
- 'toString'](0x10))[_0xdbaa('0x1a')](-0x2))['join']('');
- return _0x2acc66;
- }
-
- function makeTLVBak(_0x591774) {
- let _0x2eec7f = '';
- for (let _0x19568d = 0x0; _0x19568d < _0x591774[_0xdbaa('0x44')]; _0x19568d++) {
- _0x2eec7f += (_0x19568d + 0x1)[_0xdbaa('0x3b')](0x10)['padStart'](0x2, '0') + (_0x591774[_0x19568d]['length'] /
- 0x2)[_0xdbaa('0x3b')](0x10)[_0xdbaa('0x21')](0x2, '0') + _0x591774[_0x19568d];
- }
- return '80' + (_0x2eec7f[_0xdbaa('0x44')] / 0x2)['toString'](0x10)[_0xdbaa('0x21')](0x2, '0') + _0x2eec7f;
- }
-
- function makeTLV(_0x192f4e) {
- let _0xbbf774 = '';
- for (let _0x5d5862 = 0x0; _0x5d5862 < _0x192f4e['length']; _0x5d5862++) {
- let _0x541ee8 = '' + _0x192f4e[_0x5d5862];
- _0xbbf774 = _0xbbf774 + numberToHexString(_0x5d5862 + 0x1, 0x1, !![]) + numberToHexString(parseInt(_0x541ee8[
- 'length'] / 0x2), 0x1, !![]) + _0x541ee8;
- }
- let _0x365434 = _0xbbf774[_0xdbaa('0x44')] / 0x2;
- let _0x5431e7 = _0x365434['toString'](0x10);
- if (_0x5431e7['length'] % 0x2 != 0x0) {
- _0x5431e7 = '0' + _0x5431e7;
- }
- if (_0x365434 > 0x80) {
- _0x5431e7 = (0x80 + parseInt(_0x5431e7[_0xdbaa('0x44')] / 0x2))[_0xdbaa('0x3b')](0x10) + _0x5431e7;
- }
- return '80' + _0x5431e7 + _0xbbf774;
- }
-
- function resolveTLV(_0x3dfd3c) {
- let _0x130972 = new Array();
- let _0x31ce63 = parseInt(_0x3dfd3c['substring'](0x2, 0x4), 0x10);
- let _0x86449f = 0x4;
- if (_0x31ce63 > 0x80) {
- _0x86449f = _0x86449f + (_0x31ce63 - 0x80) * 0x2;
- }
- let _0x1d7f5 = 0x1;
- while (_0x86449f < _0x3dfd3c[_0xdbaa('0x44')]) {
- let _0x2b1a7c = parseInt(_0x3dfd3c[_0xdbaa('0x13')](_0x86449f, _0x86449f + 0x2), 0x10);
- _0x86449f += 0x2;
- let _0x47215f = parseInt(_0x3dfd3c['substring'](_0x86449f, _0x86449f + 0x2), 0x10);
- _0x86449f += 0x2;
- let _0x55279b = _0x3dfd3c[_0xdbaa('0x13')](_0x86449f, _0x86449f + _0x47215f * 0x2);
- _0x130972[_0xdbaa('0x7')](_0x55279b);
- _0x86449f += _0x47215f * 0x2;
- }
- return _0x130972;
- }
-
- function makeA5SendData(_0x563955) {
- let _0x3e7ee7 = 'a5';
- let _0x3a3e5c = Number(parseInt(_0x563955[_0xdbaa('0x44')] / 0x2))[_0xdbaa('0x3b')](0x10)['padStart'](0x2, '0');
- _0x3e7ee7 += _0x3a3e5c;
- _0x3e7ee7 += _0x563955;
- return makeFrame(_0x3e7ee7);
- }
-
- function makeA9SendData(_0x221624) {
- let _0x4dc3d7 = 'a9';
- let _0x1f7102 = Number(parseInt(_0x221624['length'] / 0x2))[_0xdbaa('0x3b')](0x10)[_0xdbaa('0x21')](0x2, '0');
- _0x4dc3d7 += _0x1f7102;
- _0x4dc3d7 += _0x221624;
- return makeFrame(_0x4dc3d7);
- }
|