您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MCObuSDK.js 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. const _0x2260 = ['508001', 'openBluetoothAdapter', 'characteristics', 'failCode', 'readBLECharacteristicValue',
  2. '数据解析失败', 'call', 'RSSI', '断开连接成功', 'offBLEConnectionStateChange', 'successCode', 'deviceId', 'substring',
  3. 'success', 'serviceId', 'startConnectBle->', 'toString', '00002A28-0000-1000-8000-00805F9B34FB', '操作失败', 'code',
  4. 'log', 'getBLEDeviceCharacteristics->', '已连接', 'slice', 'characteristicId',
  5. '0000180A-0000-1000-8000-00805F9B34FB', 'charAt', '执行成功', '发送ICC指令', 'errMsg', 'deviceList', 'fail', '蓝牙搜索已停止',
  6. '获取蓝牙版本号失败', 'localName', '认证成功', 'devices', 'closeBluetoothAdapter', 'noTargetCharacteristic', 'length',
  7. 'padStart', '0000FF03-0000-1000-8000-00805F9B34FB', 'msg', 'createBLEConnection',
  8. 'notifyBLECharacteristicValueChange', '认证失败', '发送ESAM指令', 'receiveData->', 'data', 'services', 'onIsEnable',
  9. '5080', 'writeBLECharacteristicValue', 'name', 'function', '断开连接失败', 'uuid', 'onBLECharacteristicValueChange',
  10. 'push', '未连接', '5000', 'value', 'stopBluetoothDevicesDiscovery', 'sendData->', 'padEnd', 'join',
  11. 'getBluetoothVersionUUID->', 'buffer', '蓝牙状态正常'
  12. ];
  13. const _0x5b64 = function(_0x2260b7, _0x5b649a) {
  14. _0x2260b7 = _0x2260b7 - 0x0;
  15. let _0x4ba33a = _0x2260[_0x2260b7];
  16. return _0x4ba33a;
  17. };
  18. module['exports'] = {
  19. 'scanBle': scanBle,
  20. 'closBluetooth': closBluetooth,
  21. 'connectDevice': connectDevice,
  22. 'disconnectDevice': disconnectDevice,
  23. 'transCmd': transCmd,
  24. 'disconnectDeviceBluetooth': disconnectDeviceBluetooth
  25. };
  26. var deviceList = [];
  27. var onIsEnable = toResObject(0x0, _0x5b64('0x44'));
  28. var scanBleTimer;
  29. function toResObject(_0x30005a, _0x54b515) {
  30. return {
  31. 'code': _0x30005a,
  32. 'msg': _0x54b515
  33. };
  34. }
  35. function scanBle(_0x7fe242, _0x1d0507) {
  36. this[_0x5b64('0x1e')] = [];
  37. this['onIsEnable'] = toResObject(0x0, _0x5b64('0x44'));
  38. scanBleTimer = setTimeout(() => {
  39. wx['stopBluetoothDevicesDiscovery']();
  40. _0x1d0507(this[_0x5b64('0x1e')], this[_0x5b64('0x32')]);
  41. }, _0x7fe242);
  42. wx[_0x5b64('0x1')]({
  43. 'success': _0x572619 => {
  44. wx['startBluetoothDevicesDiscovery']({
  45. 'allowDuplicatesKey': !![],
  46. 'interval': 0x64,
  47. 'success': _0x10b54e => {
  48. wx['onBluetoothDeviceFound'](_0x4a78d0 => {
  49. for (let _0x44b154 = 0x0; _0x44b154 < _0x4a78d0['devices'][
  50. _0x5b64('0x27')
  51. ]; _0x44b154++) {
  52. let _0x57d361 = ![];
  53. if (_0x4a78d0['devices'][_0x44b154][_0x5b64('0x22')] ==
  54. undefined || _0x4a78d0['devices'][_0x44b154][
  55. 'localName'] == '' || _0x4a78d0[_0x5b64('0x24')][
  56. _0x44b154
  57. ][_0x5b64('0x22')] == '<Undefined>') {
  58. break;
  59. }
  60. for (let _0x3b119a = 0x0; _0x3b119a < this[_0x5b64('0x1e')][
  61. 'length'
  62. ]; _0x3b119a++) {
  63. if (_0x4a78d0['devices'][_0x44b154]['deviceId'] == this[
  64. _0x5b64('0x1e')][_0x3b119a][_0x5b64('0xb')]) {
  65. _0x57d361 = !![];
  66. break;
  67. }
  68. }
  69. if (_0x57d361 == ![]) {
  70. let _0x9edd5e = {};
  71. _0x9edd5e[_0x5b64('0x35')] = _0x4a78d0[_0x5b64('0x24')][
  72. _0x44b154
  73. ]['localName'];
  74. _0x9edd5e['deviceId'] = _0x4a78d0['devices'][_0x44b154][
  75. 'deviceId'
  76. ];
  77. _0x9edd5e['RSSI'] = _0x4a78d0['devices'][_0x44b154][
  78. _0x5b64('0x7')
  79. ];
  80. this['deviceList'][_0x5b64('0x3a')](_0x9edd5e);
  81. }
  82. }
  83. });
  84. },
  85. 'fail': _0x2301b8 => {
  86. this[_0x5b64('0x1e')] = [];
  87. this['onIsEnable'] = toResObject(-0x1, _0x2301b8['errMsg']);
  88. clearTimeout(scanBleTimer);
  89. _0x1d0507(this[_0x5b64('0x1e')], this[_0x5b64('0x32')]);
  90. }
  91. });
  92. },
  93. 'fail': _0x1ffde9 => {
  94. this['deviceList'] = [];
  95. this[_0x5b64('0x32')] = toResObject(-0x1, _0x1ffde9[_0x5b64('0x1d')]);
  96. clearTimeout(scanBleTimer);
  97. _0x1d0507(this[_0x5b64('0x1e')], this['onIsEnable']);
  98. }
  99. });
  100. }
  101. function closBluetooth(_0x3b3fd8) {
  102. clearTimeout(scanBleTimer);
  103. wx[_0x5b64('0x3e')]({
  104. 'success': _0xbfa7ce => {
  105. _0x3b3fd8(toResObject(0x0, _0x5b64('0x20')));
  106. },
  107. 'fail': _0x30c2dd => {
  108. _0x3b3fd8(toResObject(-0x1, _0x30c2dd['errMsg']));
  109. }
  110. });
  111. }
  112. function connectDevice(_0x41e7c0, _0x47415a, _0x29a97e) {
  113. wx['onBLEConnectionStateChange'](_0x504a3b => {
  114. if (_0x504a3b['connected']) {
  115. _0x29a97e(toResObject(0x0, _0x5b64('0x16')));
  116. } else {
  117. _0x29a97e(toResObject(-0x1, _0x5b64('0x3b')));
  118. }
  119. });
  120. connectAndInit(_0x41e7c0, {
  121. 'success': _0x279aa9 => {
  122. if (_0x279aa9[_0x5b64('0x13')] == 0x3e8 || _0x279aa9['statusCode'] == 0x3e8) {
  123. _0x47415a(toResObject(0x0, '连接成功'));
  124. }
  125. },
  126. 'fail': _0x5eadb0 => {
  127. _0x47415a(toResObject(-0x1, _0x5eadb0[_0x5b64('0x2a')]));
  128. }
  129. }, 0x1f40);
  130. }
  131. function disconnectDevice(_0x1061b0) {
  132. disconnectBleDevice({
  133. 'success': _0xff64d4 => {
  134. this['connectDeviceId'] = undefined;
  135. _0x1061b0(toResObject(0x0, '已断连'));
  136. wx[_0x5b64('0x9')]();
  137. wx[_0x5b64('0x25')]();
  138. },
  139. 'fail': _0x340760 => {
  140. _0x1061b0(toResObject(-0x1, _0x340760[_0x5b64('0x2a')]));
  141. wx['offBLEConnectionStateChange']();
  142. wx[_0x5b64('0x25')]();
  143. }
  144. });
  145. }
  146. function transCmd(_0x5ac97d, _0x5740ad, _0x9016d) {
  147. if (connectDeviceId == undefined) {
  148. let _0x11c43d = toResObject(-0x1, '未连接设备');
  149. _0x11c43d[_0x5b64('0x30')] = undefined;
  150. _0x9016d(_0x11c43d);
  151. return;
  152. }
  153. if (_0x5740ad == '10') {
  154. postCommand(0x1, _0x5ac97d, {
  155. 'success': _0x5200ce => {
  156. let _0x7cf1e4 = toResObject(0x0, _0x5b64('0x1b'));
  157. _0x7cf1e4['data'] = _0x5200ce['data'];
  158. _0x9016d(_0x7cf1e4);
  159. },
  160. 'fail': _0x38dd09 => {
  161. let _0x54734e = toResObject(-0x1, _0x38dd09[_0x5b64('0x2a')]);
  162. _0x54734e['data'] = undefined;
  163. _0x9016d(_0x54734e);
  164. }
  165. }, 0xfa0);
  166. }
  167. if (_0x5740ad == '20') {
  168. postCommand(0x2, _0x5ac97d, {
  169. 'success': _0x20023e => {
  170. let _0x2a29f3 = toResObject(0x0, _0x5b64('0x1b'));
  171. _0x2a29f3['data'] = _0x20023e[_0x5b64('0x30')];
  172. _0x9016d(_0x2a29f3);
  173. },
  174. 'fail': _0x1cb7d7 => {
  175. let _0x281084 = toResObject(-0x1, _0x1cb7d7['msg']);
  176. _0x281084['data'] = undefined;
  177. _0x9016d(_0x281084);
  178. }
  179. }, 0xfa0);
  180. }
  181. }
  182. function disconnectDeviceBluetooth(_0x4af6f2) {
  183. deviceChannel('C3', {
  184. 'success': _0x358f1c => {
  185. _0x4af6f2(toResObject(0x0, '已断连'));
  186. wx['offBLEConnectionStateChange']();
  187. wx[_0x5b64('0x25')]();
  188. },
  189. 'fail': _0x52e776 => {
  190. _0x4af6f2(toResObject(0x0, '已断连'));
  191. wx['offBLEConnectionStateChange']();
  192. wx[_0x5b64('0x25')]();
  193. }
  194. }, 0xfa0);
  195. }
  196. const codeEnum = {
  197. 'successCode': 0x3e8,
  198. 'failCode': 0xfa0,
  199. 'timeout': 0x64
  200. };
  201. const FUNCTION = _0x5b64('0x36');
  202. const serviceUUID = '0000FF17-0000-1000-8000-00805F9B34FB';
  203. const writeUUID = '0000FF02-0000-1000-8000-00805F9B34FB';
  204. const readUUID = _0x5b64('0x29');
  205. const UUIDCHAR1 = _0x5b64('0x19');
  206. const UUIDCHAR2 = _0x5b64('0x11');
  207. var hasChar1 = ![];
  208. var hasChar2 = ![];
  209. var version = '';
  210. var connectDeviceId;
  211. var connectCallback;
  212. var connectTimer;
  213. var sendIndex = 0x0;
  214. function toObject(_0x393655, _0x3e1476, _0x497697) {
  215. return {
  216. 'code': _0x393655,
  217. 'data': _0x3e1476,
  218. 'msg': _0x497697
  219. };
  220. }
  221. function connectAndInit(_0x37ca85, _0xb9650d, _0x18988f) {
  222. hasChar1 = ![];
  223. hasChar1 = ![];
  224. version = '';
  225. connectDeviceId = _0x37ca85[_0x5b64('0xb')];
  226. connectCallback = _0xb9650d;
  227. if (connectTimer != undefined) {
  228. clearTimeout(connectTimer);
  229. }
  230. connectTimer = setTimeout(() => {
  231. connectTimer = undefined;
  232. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(0x7d2, undefined,
  233. '连接超时'));
  234. }, _0x18988f);
  235. startConnectBle();
  236. }
  237. function disconnectBleDevice(_0xfa48b3) {
  238. const _0x20ed38 = String(connectDeviceId);
  239. wx['closeBLEConnection']({
  240. 'deviceId': _0x20ed38,
  241. 'success'(_0x1af5b5) {
  242. if (connectTimer != undefined) {
  243. clearTimeout(connectTimer);
  244. }
  245. typeof _0xfa48b3[_0x5b64('0xd')] == FUNCTION && _0xfa48b3[_0x5b64('0xd')](toObject(codeEnum[
  246. 'successCode'], _0x1af5b5, _0x5b64('0x8')));
  247. },
  248. 'fail'(_0x5446d8) {
  249. console[_0x5b64('0x14')]('disconnectDevice->', _0x5446d8);
  250. if (connectTimer != undefined) {
  251. clearTimeout(connectTimer);
  252. }
  253. typeof _0xfa48b3[_0x5b64('0x1f')] == FUNCTION && _0xfa48b3[_0x5b64('0x1f')](toObject(codeEnum[
  254. 'failCode'], _0x5446d8, _0x5b64('0x37')));
  255. }
  256. });
  257. }
  258. function startConnectBle() {
  259. if (connectTimer == undefined) {
  260. return;
  261. }
  262. wx[_0x5b64('0x2b')]({
  263. 'deviceId': connectDeviceId,
  264. 'success': _0x1926c5 => {
  265. startGetAndCheckService();
  266. },
  267. 'fail': _0x4bee2a => {
  268. console['log'](_0x5b64('0xf'), _0x4bee2a);
  269. if (connectTimer != undefined) {
  270. clearTimeout(connectTimer);
  271. }
  272. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[_0x5b64(
  273. '0x3')], undefined, 'creatConnectionFailure'));
  274. }
  275. });
  276. }
  277. function startGetAndCheckService() {
  278. if (connectTimer == undefined) {
  279. return;
  280. }
  281. wx['getBLEDeviceServices']({
  282. 'deviceId': connectDeviceId,
  283. 'success': _0x160c13 => {
  284. for (let _0x173858 = 0x0; _0x173858 < _0x160c13[_0x5b64('0x31')][_0x5b64(
  285. '0x27')]; _0x173858++) {
  286. let _0x2bf2c9 = _0x160c13[_0x5b64('0x31')][_0x173858][_0x5b64('0x38')];
  287. if (_0x2bf2c9 == UUIDCHAR1) {
  288. hasChar1 = !![];
  289. getBluetoothVersionUUID();
  290. break;
  291. }
  292. }
  293. let _0x2bffe9 = ![];
  294. for (let _0x3f6092 = 0x0; _0x3f6092 < _0x160c13['services'][_0x5b64('0x27')]; _0x3f6092++) {
  295. let _0x43d377 = _0x160c13[_0x5b64('0x31')][_0x3f6092][_0x5b64('0x38')];
  296. if (_0x43d377 == serviceUUID) {
  297. _0x2bffe9 = !![];
  298. break;
  299. }
  300. }
  301. if (_0x2bffe9 == !![]) {
  302. startGetAndCheckCharacterisitc();
  303. } else {
  304. if (connectTimer != undefined) {
  305. clearTimeout(connectTimer);
  306. typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback['fail'](toObject(
  307. codeEnum['failCode'], undefined, 'noTargetServiceId'));
  308. }
  309. }
  310. },
  311. 'fail': _0x28f606 => {
  312. console['log']('getBLEDeviceServices->', _0x28f606);
  313. if (connectTimer != undefined) {
  314. clearTimeout(connectTimer);
  315. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[
  316. _0x5b64('0x3')], undefined, _0x28f606[_0x5b64('0x1d')]));
  317. }
  318. }
  319. });
  320. }
  321. function startGetAndCheckCharacterisitc() {
  322. if (connectTimer == undefined) {
  323. return;
  324. }
  325. wx['getBLEDeviceCharacteristics']({
  326. 'deviceId': connectDeviceId,
  327. 'serviceId': serviceUUID,
  328. 'success': _0x330c9f => {
  329. let _0x452b54 = ![];
  330. let _0x147f84 = ![];
  331. for (let _0x56dcdf = 0x0; _0x56dcdf < _0x330c9f[_0x5b64('0x2')]['length']; _0x56dcdf++) {
  332. let _0xab10a6 = _0x330c9f['characteristics'][_0x56dcdf]['uuid'];
  333. if (_0xab10a6 == readUUID) {
  334. _0x452b54 = !![];
  335. } else if (_0xab10a6 == writeUUID) {
  336. _0x147f84 = !![];
  337. }
  338. if (_0x452b54 == !![] && _0x147f84 == !![]) {
  339. break;
  340. }
  341. }
  342. if (_0x452b54 == !![] && _0x147f84 == !![]) {
  343. monitorNotification();
  344. } else {
  345. if (connectTimer != undefined) {
  346. clearTimeout(connectTimer);
  347. typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback[_0x5b64('0x1f')](
  348. toObject(codeEnum['failCode'], undefined, _0x5b64('0x26')));
  349. }
  350. }
  351. },
  352. 'fail': _0x27e5f3 => {
  353. console['log'](_0x5b64('0x15'), _0x27e5f3);
  354. if (connectTimer != undefined) {
  355. clearTimeout(connectTimer);
  356. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[
  357. 'failCode'], undefined, _0x27e5f3[_0x5b64('0x1d')]));
  358. }
  359. }
  360. });
  361. }
  362. function monitorNotification() {
  363. if (connectTimer == undefined) {
  364. return;
  365. }
  366. wx[_0x5b64('0x2c')]({
  367. 'deviceId': connectDeviceId,
  368. 'serviceId': serviceUUID,
  369. 'characteristicId': readUUID,
  370. 'state': !![],
  371. 'success': _0x397f51 => {
  372. if (typeof connectTimer != undefined) {
  373. clearTimeout(connectTimer);
  374. }
  375. wx[_0x5b64('0x39')](function(_0xa1119e) {
  376. if (_0xa1119e['deviceId'] = connectDeviceId && _0xa1119e['serviceId'] ==
  377. serviceUUID && _0xa1119e[_0x5b64('0x18')] == readUUID) {
  378. let _0x102714 = arrayBuffer2hex(_0xa1119e[_0x5b64('0x3d')]);
  379. analyticData(_0x102714);
  380. }
  381. });
  382. setTimeout(() => {
  383. typeof connectCallback[_0x5b64('0xd')] == FUNCTION && connectCallback[_0x5b64(
  384. '0xd')](toObject(codeEnum['successCode'], undefined, '连接成功,握手成功'));
  385. }, 0x3e8);
  386. },
  387. 'fail': _0x3ad67f => {
  388. console[_0x5b64('0x14')]('notifyBLECharacteristicValueChange->', _0x3ad67f);
  389. if (connectTimer != undefined) {
  390. clearTimeout(connectTimer);
  391. typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x5b64('0x1f')](toObject(
  392. codeEnum['failCode'], undefined, _0x3ad67f[_0x5b64('0x1d')]));
  393. }
  394. }
  395. });
  396. }
  397. function getBluetoothVersionUUID() {
  398. wx['getBLEDeviceCharacteristics']({
  399. 'deviceId': connectDeviceId,
  400. 'serviceId': UUIDCHAR1,
  401. 'success': _0x5722c6 => {
  402. for (let _0x32d58e = 0x0; _0x32d58e < _0x5722c6['characteristics']['length']; _0x32d58e++) {
  403. let _0x3bce97 = _0x5722c6['characteristics'][_0x32d58e]['uuid'];
  404. if (_0x3bce97 == UUIDCHAR2) {
  405. hasChar2 = !![];
  406. break;
  407. }
  408. }
  409. },
  410. 'fail': _0x1498ae => {
  411. console['log'](_0x5b64('0x42'), _0x1498ae);
  412. if (connectTimer != undefined) {
  413. clearTimeout(connectTimer);
  414. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[
  415. 'failCode'], undefined, _0x5b64('0x21')));
  416. }
  417. }
  418. });
  419. }
  420. function readBLECharacteristicValue() {
  421. wx[_0x5b64('0x4')]({
  422. 'deviceId': connectDeviceId,
  423. 'serviceId': UUIDCHAR1,
  424. 'characteristicId': UUIDCHAR2,
  425. 'success': _0x313e20 => {
  426. console[_0x5b64('0x14')]('readBLECharacteristicValueSuccess->', _0x313e20);
  427. },
  428. 'fail': _0x5b0ea9 => {
  429. console['log']('readBLECharacteristicValueFail->', _0x5b0ea9);
  430. }
  431. });
  432. }
  433. function onBLECharacteristicValueChange() {
  434. wx['onBLECharacteristicValueChange'](_0x26a854 => {
  435. console['log']('receiveData->', arrayBuffer2hex(_0x26a854[_0x5b64('0x3d')]));
  436. if (_0x26a854['deviceId'] == connectDeviceId && _0x26a854[_0x5b64('0xe')] == serviceUUID && _0x26a854[
  437. _0x5b64('0x18')] == readUUID) {
  438. let _0x50e6b5 = arrayBuffer2hex(_0x26a854[_0x5b64('0x3d')]);
  439. analyticData(_0x50e6b5);
  440. } else if (_0x26a854[_0x5b64('0xb')] == connectDeviceId && _0x26a854['serviceId'] == UUIDCHAR1 &&
  441. _0x26a854[_0x5b64('0x18')] == UUIDCHAR2) {
  442. let _0x364d00 = arrayBuffer2hex(_0x26a854['value'])['toUpperCase']();
  443. if (connectTimer != undefined) {
  444. clearTimeout(connectTimer);
  445. if (_0x364d00 != '') {
  446. typeof connectCallback['success'] == FUNCTION && connectCallback[_0x5b64('0xd')](toObject(
  447. codeEnum[_0x5b64('0xa')], _0x364d00, '连接成功'));
  448. } else {
  449. typeof connectCallback[_0x5b64('0x1f')] == FUNCTION && connectCallback[_0x5b64('0x1f')](
  450. toObject(codeEnum['successCode'], undefined, '连接失败'));
  451. }
  452. }
  453. }
  454. });
  455. }
  456. var dataArrays;
  457. var dataIndex = 0x0;
  458. var sendArrays = 0x0;
  459. var mCallBack;
  460. var transTimer;
  461. var receivePacketCount = 0x0;
  462. var receivePacketData = '';
  463. var receiveLength = 0x0;
  464. var receiveData = '';
  465. function analyticData(_0x2b3ef4) {
  466. if (_0x2b3ef4[_0x5b64('0x17')](0x0, 0x2) == '50' && (_0x2b3ef4[_0x5b64('0x17')](0x2, 0x4) == '80' || _0x2b3ef4[
  467. _0x5b64('0x17')](0x2, 0x4) == '00') && (_0x2b3ef4['length'] < 0x28 || _0x2b3ef4['length'] == 0x28)) {
  468. receiveLength = parseInt(_0x2b3ef4['slice'](0x6, 0xa), 0x10);
  469. if (_0x2b3ef4[_0x5b64('0x17')](0x2, 0x4) == '80') {
  470. receivePacketCount = parseInt(_0x2b3ef4[_0x5b64('0x17')](0x4, 0x6), 0x10);
  471. }
  472. }
  473. if (receiveLength != 0x0) {
  474. receiveData += _0x2b3ef4;
  475. }
  476. console[_0x5b64('0x14')](_0x5b64('0x2f'), receiveData);
  477. if (receiveData[_0x5b64('0x17')](0xa, receiveData['length'] - 0x2)['length'] == receiveLength * 0x2) {
  478. if (receiveData[_0x5b64('0x17')](0x0, 0x2) == '50' && receiveData[_0x5b64('0x17')](0x2, 0x4) == '80' &&
  479. receiveData[_0x5b64('0x17')](0xa, 0xc) == '97') {
  480. if (receiveData[_0x5b64('0x17')](0xa, 0xc) == '00' && receiveData[_0x5b64('0x17')](0x14, 0x16) == '00') {
  481. updateRead(!![]);
  482. } else {
  483. updateRead(![]);
  484. }
  485. receiveData = '';
  486. } else {
  487. receivePacketData += receiveData['slice'](0xa, receiveData['length'] - 0x2);
  488. receiveData = '';
  489. receiveLength = 0x0;
  490. receivePacketCount--;
  491. if (receivePacketCount > 0x0) {
  492. return;
  493. }
  494. let _0xbc3109 = receivePacketData;
  495. receivePacketData = '';
  496. receivePacketCount = '';
  497. if (_0xbc3109['slice'](0x0, 0x2) == '92') {
  498. cosDataRead(_0xbc3109);
  499. } else if (_0xbc3109['slice'](0x0, 0x2) == '91') {
  500. deviceChannelRead(_0xbc3109);
  501. } else if (_0xbc3109['slice'](0x0, 0x2) == '94') {
  502. authCodeRead(_0xbc3109);
  503. }
  504. }
  505. }
  506. }
  507. function updateRead(_0x5bdeed) {
  508. if (_0x5bdeed) {
  509. if (transTimer != undefined) {
  510. clearTimeout(transTimer);
  511. }
  512. typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x5b64('0xa')], null, '成功'));
  513. } else {
  514. if (transTimer != undefined) {
  515. clearTimeout(transTimer);
  516. }
  517. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(codeEnum[_0x5b64('0x3')], null,
  518. '失败'));
  519. }
  520. }
  521. function cosDataRead(_0x44b0d9) {
  522. let _0x4aad28 = _0x44b0d9[_0x5b64('0x17')](0x4, 0x6);
  523. let _0x25c75b = '';
  524. if (_0x4aad28 == '10') {
  525. _0x25c75b = _0x5b64('0x1c');
  526. } else {
  527. _0x25c75b = _0x5b64('0x2e');
  528. }
  529. let _0x57001e = parseInt(_0x44b0d9['slice'](0x6, 0xa), 0x10);
  530. if (_0x44b0d9['slice'](0xa)[_0x5b64('0x27')] == _0x57001e * 0x2) {
  531. let _0x2f7894 = new Array();
  532. let _0x4c82b7 = _0x44b0d9[_0x5b64('0x17')](0xa);
  533. let _0x10a3f3 = _0x4c82b7[_0x5b64('0x17')](0x0, 0x2);
  534. let _0x5ee3c2 = 0x0;
  535. while (_0x10a3f3 == '81') {
  536. _0x5ee3c2++;
  537. _0x10a3f3 = _0x4c82b7[_0x5b64('0x17')](_0x5ee3c2 * 0x2, _0x5ee3c2 * 0x2 + 0x2);
  538. }
  539. let _0x4668d0 = _0x4c82b7['slice'](_0x5ee3c2 * 0x2 + 0x2);
  540. let _0x408d1d = parseInt(_0x4668d0['slice'](0x2, 0x4), 0x10) * 0x2;
  541. _0x2f7894['push'](_0x4668d0[_0x5b64('0x17')](0x4, 0x4 + _0x408d1d));
  542. let _0x5187a9 = _0x4668d0[_0x5b64('0xc')](0x4 + _0x408d1d);
  543. while (_0x5187a9 != '') {
  544. _0x408d1d = parseInt(_0x5187a9[_0x5b64('0x17')](0x2, 0x4), 0x10) * 0x2;
  545. _0x2f7894[_0x5b64('0x3a')](_0x5187a9['slice'](0x4, 0x4 + _0x408d1d));
  546. _0x5187a9 = _0x5187a9['substring'](0x4 + _0x408d1d);
  547. }
  548. if (transTimer != undefined) {
  549. clearTimeout(transTimer);
  550. }
  551. typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'],
  552. _0x2f7894, _0x25c75b + '成功'));
  553. } else {
  554. if (transTimer != undefined) {
  555. clearTimeout(transTimer);
  556. }
  557. typeof mCallBack['fail'] == FUNCTION && mCallBack['fail'](toObject(codeEnum[_0x5b64('0x3')], null, _0x5b64(
  558. '0x5')));
  559. }
  560. }
  561. function deviceChannelRead(_0x58f05f) {
  562. let _0x58a563 = _0x58f05f['slice'](0x2, 0x4);
  563. if (transTimer != undefined) {
  564. clearTimeout(transTimer);
  565. }
  566. if (_0x58a563 == '00') {
  567. typeof mCallBack['success'] == FUNCTION && mCallBack[_0x5b64('0xd')](toObject(codeEnum['successCode'],
  568. _0x58f05f['slice'](0xa), '操作成功'));
  569. } else {
  570. typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null,
  571. _0x5b64('0x12')));
  572. }
  573. }
  574. function authCodeRead(_0x42a6be) {
  575. let _0x274035 = _0x42a6be[_0x5b64('0x17')](0x2, 0x4);
  576. if (transTimer != undefined) {
  577. clearTimeout(transTimer);
  578. }
  579. if (_0x274035 == '00') {
  580. typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack[_0x5b64('0xd')](toObject(codeEnum['successCode'],
  581. _0x42a6be['slice'](0xa), _0x5b64('0x23')));
  582. } else {
  583. typeof mCallBack[_0x5b64('0xd')] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x5b64('0xa')], null,
  584. _0x5b64('0x2d')));
  585. }
  586. }
  587. function postCommand(_0x11f84c, _0x18df9d, _0x6519e2, _0x423e32) {
  588. mCallBack = _0x6519e2;
  589. if (transTimer != undefined) {
  590. clearTimeout(transTimer);
  591. }
  592. transTimer = setTimeout(() => {
  593. transTimer = undefined;
  594. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined,
  595. '发送指令超时'));
  596. }, _0x423e32);
  597. dataArrays = new Array();
  598. dataIndex = 0x0;
  599. let _0x3348d9 = getCosData(_0x18df9d);
  600. let _0x1bb0bc = '82' + _0x11f84c[_0x5b64('0x10')](0x10)[_0x5b64('0x40')](0x2, '0') + (_0x3348d9['length'] / 0x2)[
  601. _0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x3348d9;
  602. let _0x122d26 = 0x50 * 0x2;
  603. if (_0x1bb0bc['length'] < _0x122d26) {
  604. _0x1bb0bc = _0x5b64('0x0') + (_0x1bb0bc[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') +
  605. _0x1bb0bc;
  606. dataArrays[0x0] = _0x1bb0bc + CRC8(_0x1bb0bc);
  607. } else {
  608. let _0x1713bd = parseInt(_0x1bb0bc['length'] % _0x122d26 == 0x0 ? _0x1bb0bc['length'] / _0x122d26 : _0x1bb0bc[
  609. _0x5b64('0x27')] / _0x122d26 + 0x1);
  610. for (let _0x3b09d6 = 0x0; _0x3b09d6 < _0x1713bd; _0x3b09d6++) {
  611. let _0x2692f8 = _0x3b09d6 + 0x1;
  612. let _0x429c3a = '';
  613. if (_0x3b09d6 == _0x1713bd - 0x1) {
  614. _0x429c3a = _0x1bb0bc['slice'](_0x3b09d6 * _0x122d26);
  615. } else {
  616. _0x429c3a = _0x1bb0bc[_0x5b64('0x17')](_0x3b09d6 * _0x122d26, _0x2692f8 * _0x122d26);
  617. }
  618. if (_0x3b09d6 == 0x0) {
  619. _0x429c3a = '5080' + _0x1713bd['toString'](0x10)[_0x5b64('0x28')](0x2, '0') + (_0x429c3a[_0x5b64(
  620. '0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x429c3a;
  621. } else {
  622. _0x429c3a = _0x5b64('0x3c') + _0x2692f8[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x429c3a[
  623. _0x5b64('0x27')] / 0x2)['toString'](0x10)[_0x5b64('0x28')](0x4, '0') + _0x429c3a;
  624. }
  625. dataArrays[_0x3b09d6] = _0x429c3a + CRC8(_0x429c3a);
  626. }
  627. }
  628. initReadValue();
  629. write(dataArrays[dataIndex]);
  630. }
  631. function getCosData(_0x2a3a45) {
  632. let _0x31c510 = '';
  633. for (let _0x4c0e88 = 0x0; _0x4c0e88 < _0x2a3a45[_0x5b64('0x27')]; _0x4c0e88++) {
  634. _0x31c510 += (_0x4c0e88 + 0x1)[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x2a3a45[_0x4c0e88]['length'] /
  635. 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x2, '0') + _0x2a3a45[_0x4c0e88];
  636. }
  637. return '80' + (_0x31c510[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + _0x31c510;
  638. }
  639. function deviceChannel(_0x337446, _0x18f599, _0x24f468) {
  640. mCallBack = _0x18f599;
  641. if (transTimer != undefined) {
  642. clearTimeout(transTimer);
  643. }
  644. transTimer = setTimeout(() => {
  645. transTimer = undefined;
  646. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined, '操作超时'));
  647. }, _0x24f468);
  648. dataArrays = new Array();
  649. dataIndex = 0x0;
  650. let _0x46bbdf = '81' + (_0x337446['length'] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x337446;
  651. let _0x2394ed = 0x50 * 0x2;
  652. if (_0x46bbdf[_0x5b64('0x27')] < _0x2394ed) {
  653. _0x46bbdf = '508001' + (_0x46bbdf['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x46bbdf;
  654. dataArrays[0x0] = _0x46bbdf + CRC8(_0x46bbdf);
  655. } else {
  656. let _0x46eab8 = parseInt(_0x46bbdf['length'] % _0x2394ed == 0x0 ? _0x46bbdf['length'] / _0x2394ed : _0x46bbdf[
  657. _0x5b64('0x27')] / _0x2394ed + 0x1);
  658. for (let _0xb02dd0 = 0x0; _0xb02dd0 < _0x46eab8; _0xb02dd0++) {
  659. let _0x4d5564 = _0xb02dd0 + 0x1;
  660. let _0x15f379 = '';
  661. if (_0xb02dd0 == _0x46eab8 - 0x1) {
  662. _0x15f379 = _0x46bbdf['slice'](_0xb02dd0 * _0x2394ed);
  663. } else {
  664. _0x15f379 = _0x46bbdf[_0x5b64('0x17')](_0xb02dd0 * _0x2394ed, _0x4d5564 * _0x2394ed);
  665. }
  666. if (_0xb02dd0 == 0x0) {
  667. _0x15f379 = '5080' + _0x46eab8[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x15f379['length'] /
  668. 0x2)['toString'](0x10)[_0x5b64('0x28')](0x4, '0') + _0x15f379;
  669. } else {
  670. _0x15f379 = '5000' + _0x4d5564[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x15f379['length'] /
  671. 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x15f379;
  672. }
  673. dataArrays[_0xb02dd0] = _0x15f379 + CRC8(_0x15f379);
  674. }
  675. }
  676. initReadValue();
  677. write(dataArrays[dataIndex]);
  678. }
  679. function authObu(_0x1f28e7, _0x35d7c0, _0x11bbc2) {
  680. mCallBack = _0x35d7c0;
  681. if (transTimer != undefined) {
  682. clearTimeout(transTimer);
  683. }
  684. transTimer = setTimeout(() => {
  685. transTimer = undefined;
  686. typeof mCallBack[_0x5b64('0x1f')] == FUNCTION && mCallBack['fail'](toObject(0x7d0, undefined, '认证超时'));
  687. }, _0x11bbc2);
  688. dataArrays = new Array();
  689. dataIndex = 0x0;
  690. let _0xe07a30 = '84' + (_0x1f28e7['length'] / 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x4, '0') + _0x1f28e7;
  691. let _0x40835c = 0x50 * 0x2;
  692. if (_0xe07a30['length'] < _0x40835c) {
  693. _0xe07a30 = _0x5b64('0x0') + (_0xe07a30[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x4,
  694. '0') + _0xe07a30;
  695. dataArrays[0x0] = _0xe07a30 + CRC8(_0xe07a30);
  696. } else {
  697. let _0x1e9df4 = parseInt(_0xe07a30[_0x5b64('0x27')] % _0x40835c == 0x0 ? _0xe07a30['length'] / _0x40835c :
  698. _0xe07a30[_0x5b64('0x27')] / _0x40835c + 0x1);
  699. for (let _0xe2e9d7 = 0x0; _0xe2e9d7 < _0x1e9df4; _0xe2e9d7++) {
  700. let _0x15129c = _0xe2e9d7 + 0x1;
  701. let _0x16c078 = '';
  702. if (_0xe2e9d7 == _0x1e9df4 - 0x1) {
  703. _0x16c078 = _0xe07a30['slice'](_0xe2e9d7 * _0x40835c);
  704. } else {
  705. _0x16c078 = _0xe07a30[_0x5b64('0x17')](_0xe2e9d7 * _0x40835c, _0x15129c * _0x40835c);
  706. }
  707. if (_0xe2e9d7 == 0x0) {
  708. _0x16c078 = _0x5b64('0x33') + _0x1e9df4['toString'](0x10)[_0x5b64('0x28')](0x2, '0') + (_0x16c078[
  709. 'length'] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x16c078;
  710. } else {
  711. _0x16c078 = _0x5b64('0x3c') + _0x15129c[_0x5b64('0x10')](0x10)['padStart'](0x2, '0') + (_0x16c078[
  712. _0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x16c078;
  713. }
  714. dataArrays[_0xe2e9d7] = _0x16c078 + CRC8(_0x16c078);
  715. }
  716. }
  717. initReadValue();
  718. write(dataArrays[dataIndex]);
  719. }
  720. function sendUpgradeData(_0x4617fc, _0x12dfd4, _0xc38619) {
  721. mCallBack = _0x12dfd4;
  722. if (transTimer != undefined) {
  723. clearTimeout(transTimer);
  724. }
  725. transTimer = setTimeout(() => {
  726. transTimer = undefined;
  727. typeof mCallBack[_0x5b64('0x1f')] == FUNCTION && mCallBack[_0x5b64('0x1f')](toObject(0x7d0, undefined,
  728. '升级超时'));
  729. }, _0xc38619);
  730. let _0x132fa1 = '87' + (_0x4617fc[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart'](0x4, '0') + _0x4617fc;
  731. let _0x4b195e = _0x132fa1[_0x5b64('0x27')];
  732. let _0x2c1d58 = 0xb8;
  733. let _0x28a861 = parseInt(_0x4b195e / _0x2c1d58 + 0x1);
  734. dataArrays = new Array();
  735. dataIndex = 0x0;
  736. for (var _0x4f8d46 = 0x0; _0x4f8d46 < _0x28a861; _0x4f8d46++) {
  737. let _0x3a862f = '';
  738. if (_0x4f8d46 + 0x1 == _0x28a861) {
  739. _0x3a862f = _0x132fa1[_0x5b64('0x17')](_0x4f8d46 * _0x2c1d58);
  740. } else {
  741. _0x3a862f = _0x132fa1[_0x5b64('0x17')](_0x4f8d46 * _0x2c1d58, (_0x4f8d46 + 0x1) * _0x2c1d58);
  742. }
  743. let _0x4fce2c = '';
  744. if (_0x4f8d46 == 0x0) {
  745. _0x4fce2c = '80' + _0x28a861['toString'](0x10)['padStart'](0x2, '0');
  746. } else {
  747. _0x4fce2c = '00' + (_0x4f8d46 + 0x1)[_0x5b64('0x10')](0x10)[_0x5b64('0x28')](0x2, '0');
  748. }
  749. let _0x49072f = '50' + _0x4fce2c + parseInt(_0x3a862f[_0x5b64('0x27')] / 0x2)[_0x5b64('0x10')](0x10)['padStart']
  750. (0x2, '0') + _0x3a862f;
  751. dataArrays[_0x5b64('0x3a')](_0x49072f + CRC8(_0x49072f));
  752. }
  753. write(dataArrays[dataIndex]);
  754. }
  755. function initReadValue() {
  756. receivePacketCount = 0x0;
  757. receivePacketData = '';
  758. receiveLength = 0x0;
  759. receiveData = '';
  760. }
  761. function write(_0x55036b) {
  762. if (dataIndex < dataArrays[_0x5b64('0x27')]) {
  763. dataIndex++;
  764. sendArrays = new Array();
  765. let _0x450b62 = 0x28;
  766. let _0x4908a8 = parseInt(_0x55036b[_0x5b64('0x27')] / _0x450b62 + 0x1);
  767. for (var _0x3a3653 = 0x0; _0x3a3653 < _0x4908a8; _0x3a3653++) {
  768. if (_0x3a3653 + 0x1 == _0x4908a8) {
  769. sendArrays[_0x5b64('0x3a')](_0x55036b[_0x5b64('0x17')](_0x3a3653 * _0x450b62));
  770. } else {
  771. sendArrays['push'](_0x55036b['slice'](_0x3a3653 * _0x450b62, (_0x3a3653 + 0x1) * _0x450b62));
  772. }
  773. }
  774. sendIndex = 0x0;
  775. runSendData();
  776. } else {
  777. console['log']('Packet\x20send\x20complete.');
  778. }
  779. }
  780. function runSendData() {
  781. console[_0x5b64('0x14')](_0x5b64('0x3f'), sendArrays[sendIndex]);
  782. let _0x54f524 = hex2ArrayBuffer(sendArrays[sendIndex]);
  783. wx[_0x5b64('0x34')]({
  784. 'deviceId': connectDeviceId,
  785. 'serviceId': serviceUUID,
  786. 'characteristicId': writeUUID,
  787. 'value': _0x54f524,
  788. 'success': _0x420952 => {
  789. sendIndex++;
  790. if (sendIndex < sendArrays[_0x5b64('0x27')]) {
  791. runSendData();
  792. } else {
  793. write(dataArrays[dataIndex]);
  794. }
  795. },
  796. 'fail': _0x12d4eb => {
  797. if (transTimer != undefined) {
  798. clearTimeout(transTimer);
  799. }
  800. typeof mCallBack['fail'] == FUNCTION && mCallBack['fail'](toObject(codeEnum['failCode'], null,
  801. _0x12d4eb[_0x5b64('0x1d')]));
  802. }
  803. });
  804. }
  805. function CRC8(_0x1b496e) {
  806. let _0x479cf7 = new Uint8Array(hex2ArrayBuffer(_0x1b496e));
  807. let _0x4ff77a = 0x0;
  808. for (let _0x2c0921 of _0x479cf7) {
  809. _0x4ff77a ^= _0x2c0921;
  810. }
  811. return _0x4ff77a[_0x5b64('0x10')](0x10)['padStart'](0x2, '0')['toUpperCase']();
  812. }
  813. function CRC16(_0x3bed35) {
  814. let _0x17d0e0 = 0xffff;
  815. for (let _0x52f618 of _0x3bed35) {
  816. _0x17d0e0 ^= _0x52f618 & 0xff;
  817. for (var _0x44b8fb = 0x0; _0x44b8fb < 0x8; _0x44b8fb++) {
  818. if ((_0x17d0e0 & 0x1) > 0x0) {
  819. _0x17d0e0 = _0x17d0e0 >> 0x1;
  820. _0x17d0e0 = _0x17d0e0 ^ 0x8408;
  821. } else {
  822. _0x17d0e0 = _0x17d0e0 >> 0x1;
  823. }
  824. }
  825. }
  826. return (_0x17d0e0 ^ 0xffff)[_0x5b64('0x10')](0x10);
  827. }
  828. function hex2ArrayBuffer(_0x302f62) {
  829. var _0x3c036b = new Uint8Array(_0x302f62['match'](/[\da-f]{2}/gi)['map'](function(_0x5df096) {
  830. return parseInt(_0x5df096, 0x10);
  831. }));
  832. return _0x3c036b[_0x5b64('0x43')];
  833. }
  834. function arrayBuffer2hex(_0x13cb49) {
  835. const _0x51a173 = Array['prototype']['map'][_0x5b64('0x6')](new Uint8Array(_0x13cb49), function(_0x48413b) {
  836. return ('00' + _0x48413b['toString'](0x10))[_0x5b64('0x17')](-0x2);
  837. });
  838. return _0x51a173[_0x5b64('0x41')]('');
  839. }
  840. function littleEndian(_0x3af579) {
  841. if (_0x3af579 != '' && _0x3af579 != undefined) {
  842. var _0x3dc2bd = '';
  843. for (var _0x197e01 = _0x3af579[_0x5b64('0x27')]; _0x197e01 >= 0x0; _0x197e01 = _0x197e01 - 0x2) {
  844. _0x3dc2bd += _0x3af579['charAt'](_0x197e01);
  845. _0x3dc2bd += _0x3af579[_0x5b64('0x1a')](_0x197e01 + 0x1);
  846. }
  847. return _0x3dc2bd;
  848. } else {
  849. return _0x3af579;
  850. }
  851. }