You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. const _0x4a4b = ['name', 'charAt', '断开连接成功', '蓝牙搜索已停止', 'receiveData->', '已断连', 'RSSI', 'toUpperCase',
  2. 'notifyBLECharacteristicValueChange->', 'log', 'errMsg', 'onBLECharacteristicValueChange', 'deviceId', '未连接',
  3. 'closeBLEConnection', 'noTargetServiceId', '5080', 'length', 'successCode', 'disconnectDevice->', 'data',
  4. 'localName', '0000FEE7-0000-1000-8000-00805F9B34FB', '蓝牙状态正常', 'services', 'statusCode', '执行成功', '认证成功', 'call',
  5. 'connected', 'toString', 'padStart', 'uuid', 'deviceList', 'sendData->', 'success', 'onBluetoothDeviceFound',
  6. '发送指令超时', 'characteristics', 'characteristicId', 'readBLECharacteristicValueFail->', 'closeBluetoothAdapter',
  7. 'substring', 'getBLEDeviceCharacteristics', 'slice', '508001', '认证超时', 'value', 'msg', '连接超时',
  8. 'startConnectBle->', '获取蓝牙版本号失败', 'exports', '数据解析失败', '00002A28-0000-1000-8000-00805F9B34FB',
  9. 'noTargetCharacteristic', '5000', 'devices', 'createBLEConnection', 'failCode', 'getBLEDeviceServices->',
  10. '操作失败', 'code', 'push', 'fail', 'offBLEConnectionStateChange', 'join', 'padEnd', 'readBLECharacteristicValue',
  11. 'stopBluetoothDevicesDiscovery', 'serviceId', '断开连接失败', 'onIsEnable', 'function',
  12. 'notifyBLECharacteristicValueChange'
  13. ];
  14. const _0x4472 = function(_0x4a4b21, _0x447294) {
  15. _0x4a4b21 = _0x4a4b21 - 0x0;
  16. let _0x186588 = _0x4a4b[_0x4a4b21];
  17. return _0x186588;
  18. };
  19. module[_0x4472('0x34')] = {
  20. 'scanBle': scanBle,
  21. 'closBluetooth': closBluetooth,
  22. 'connectDevice': connectDevice,
  23. 'disconnectDevice': disconnectDevice,
  24. 'transCmd': transCmd,
  25. 'disconnectDeviceBluetooth': disconnectDeviceBluetooth
  26. };
  27. var deviceList = [];
  28. var onIsEnable = toResObject(0x0, '蓝牙状态正常');
  29. var scanBleTimer;
  30. function toResObject(_0x1d50f8, _0x18421d) {
  31. return {
  32. 'code': _0x1d50f8,
  33. 'msg': _0x18421d
  34. };
  35. }
  36. function scanBle(_0x4b76df, _0x185be1) {
  37. this[_0x4472('0x21')] = [];
  38. this[_0x4472('0x48')] = toResObject(0x0, _0x4472('0x17'));
  39. scanBleTimer = setTimeout(() => {
  40. wx[_0x4472('0x45')]();
  41. _0x185be1(this['deviceList'], this['onIsEnable']);
  42. }, _0x4b76df);
  43. wx['openBluetoothAdapter']({
  44. 'success': _0x4dcb5e => {
  45. wx['startBluetoothDevicesDiscovery']({
  46. 'allowDuplicatesKey': !![],
  47. 'interval': 0x64,
  48. 'success': _0x346f55 => {
  49. wx[_0x4472('0x24')](_0x1b44eb => {
  50. for (let _0x43f7b0 = 0x0; _0x43f7b0 < _0x1b44eb['devices'][
  51. _0x4472('0x11')
  52. ]; _0x43f7b0++) {
  53. let _0xb249a1 = ![];
  54. if (_0x1b44eb[_0x4472('0x39')][_0x43f7b0][_0x4472(
  55. '0x15')] == undefined || _0x1b44eb[_0x4472('0x39')][
  56. _0x43f7b0
  57. ][_0x4472('0x15')] == '' || _0x1b44eb['devices'][
  58. _0x43f7b0
  59. ]['localName'] == '<Undefined>') {
  60. continue;
  61. }
  62. for (let _0xc00c8c = 0x0; _0xc00c8c < this['deviceList'][
  63. 'length'
  64. ]; _0xc00c8c++) {
  65. if (_0x1b44eb[_0x4472('0x39')][_0x43f7b0][_0x4472(
  66. '0xc')] == this[_0x4472('0x21')][_0xc00c8c][
  67. 'deviceId'
  68. ]) {
  69. _0xb249a1 = !![];
  70. continue;
  71. }
  72. }
  73. if (_0xb249a1 == ![]) {
  74. let _0x37639f = {};
  75. _0x37639f[_0x4472('0x0')] = _0x1b44eb['devices'][
  76. _0x43f7b0
  77. ]['localName'];
  78. _0x37639f['deviceId'] = _0x1b44eb['devices'][_0x43f7b0][
  79. 'deviceId'
  80. ];
  81. _0x37639f[_0x4472('0x6')] = _0x1b44eb['devices'][
  82. _0x43f7b0
  83. ][_0x4472('0x6')];
  84. this['deviceList'][_0x4472('0x3f')](_0x37639f);
  85. }
  86. }
  87. });
  88. },
  89. 'fail': _0x28beb4 => {
  90. this[_0x4472('0x21')] = [];
  91. this['onIsEnable'] = toResObject(-0x1, _0x28beb4['errMsg']);
  92. clearTimeout(scanBleTimer);
  93. _0x185be1(this[_0x4472('0x21')], this[_0x4472('0x48')]);
  94. }
  95. });
  96. },
  97. 'fail': _0x1e7ba6 => {
  98. this['deviceList'] = [];
  99. this[_0x4472('0x48')] = toResObject(-0x1, _0x1e7ba6[_0x4472('0xa')]);
  100. clearTimeout(scanBleTimer);
  101. _0x185be1(this[_0x4472('0x21')], this['onIsEnable']);
  102. }
  103. });
  104. }
  105. function closBluetooth(_0x27c990) {
  106. clearTimeout(scanBleTimer);
  107. wx['stopBluetoothDevicesDiscovery']({
  108. 'success': _0x3139be => {
  109. _0x27c990(toResObject(0x0, _0x4472('0x3')));
  110. },
  111. 'fail': _0x36e2e0 => {
  112. _0x27c990(toResObject(-0x1, _0x36e2e0[_0x4472('0xa')]));
  113. }
  114. });
  115. }
  116. function connectDevice(_0x2d6013, _0x936e65, _0x589d51) {
  117. wx['onBLEConnectionStateChange'](_0x1202cc => {
  118. if (_0x1202cc[_0x4472('0x1d')]) {
  119. _0x589d51(toResObject(0x0, '已连接'));
  120. } else {
  121. _0x589d51(toResObject(-0x1, _0x4472('0xd')));
  122. }
  123. });
  124. connectAndInit(_0x2d6013, {
  125. 'success': _0x4deb5e => {
  126. if (_0x4deb5e[_0x4472('0x3e')] == 0x3e8 || _0x4deb5e[_0x4472('0x19')] == 0x3e8) {
  127. _0x936e65(toResObject(0x0, '连接成功'));
  128. }
  129. },
  130. 'fail': _0xd633fb => {
  131. _0x936e65(toResObject(-0x1, _0xd633fb['msg']));
  132. }
  133. }, 0x1f40);
  134. }
  135. function disconnectDevice(_0x2ea989) {
  136. disconnectBleDevice({
  137. 'success': _0x33240a => {
  138. this['connectDeviceId'] = undefined;
  139. _0x2ea989(toResObject(0x0, _0x4472('0x5')));
  140. wx['offBLEConnectionStateChange']();
  141. wx['closeBluetoothAdapter']();
  142. },
  143. 'fail': _0x5694aa => {
  144. _0x2ea989(toResObject(-0x1, _0x5694aa['msg']));
  145. wx[_0x4472('0x41')]();
  146. wx[_0x4472('0x29')]();
  147. }
  148. });
  149. }
  150. function transCmd(_0x5a4809, _0x259a28, _0x4c4bb9) {
  151. if (connectDeviceId == undefined) {
  152. let _0x47e0ad = toResObject(-0x1, '未连接设备');
  153. _0x47e0ad['data'] = undefined;
  154. _0x4c4bb9(_0x47e0ad);
  155. return;
  156. }
  157. if (_0x259a28 == '10') {
  158. postCommand(0x1, _0x5a4809, {
  159. 'success': _0x15e935 => {
  160. let _0x3a739e = toResObject(0x0, _0x4472('0x1a'));
  161. _0x3a739e[_0x4472('0x14')] = _0x15e935['data'];
  162. _0x4c4bb9(_0x3a739e);
  163. },
  164. 'fail': _0x3fb131 => {
  165. let _0x5b4e9b = toResObject(-0x1, _0x3fb131[_0x4472('0x30')]);
  166. _0x5b4e9b[_0x4472('0x14')] = undefined;
  167. _0x4c4bb9(_0x5b4e9b);
  168. }
  169. }, 0xfa0);
  170. }
  171. if (_0x259a28 == '20') {
  172. postCommand(0x2, _0x5a4809, {
  173. 'success': _0x2a1d8c => {
  174. let _0x1946b1 = toResObject(0x0, _0x4472('0x1a'));
  175. _0x1946b1[_0x4472('0x14')] = _0x2a1d8c['data'];
  176. _0x4c4bb9(_0x1946b1);
  177. },
  178. 'fail': _0x40ec18 => {
  179. let _0x2b0a41 = toResObject(-0x1, _0x40ec18['msg']);
  180. _0x2b0a41[_0x4472('0x14')] = undefined;
  181. _0x4c4bb9(_0x2b0a41);
  182. }
  183. }, 0xfa0);
  184. }
  185. }
  186. function disconnectDeviceBluetooth(_0x33aa68) {
  187. deviceChannel('C3', {
  188. 'success': _0x30e18e => {
  189. _0x33aa68(toResObject(0x0, _0x4472('0x5')));
  190. wx[_0x4472('0x41')]();
  191. wx['closeBluetoothAdapter']();
  192. },
  193. 'fail': _0x11bd91 => {
  194. _0x33aa68(toResObject(0x0, _0x4472('0x5')));
  195. wx['offBLEConnectionStateChange']();
  196. wx[_0x4472('0x29')]();
  197. }
  198. }, 0xfa0);
  199. }
  200. const codeEnum = {
  201. 'successCode': 0x3e8,
  202. 'failCode': 0xfa0,
  203. 'timeout': 0x64
  204. };
  205. const FUNCTION = _0x4472('0x49');
  206. const serviceUUID = _0x4472('0x16');
  207. const writeUUID = '0000FEC7-0000-1000-8000-00805F9B34FB';
  208. const readUUID = '0000FEC8-0000-1000-8000-00805F9B34FB';
  209. const UUIDCHAR1 = '0000180A-0000-1000-8000-00805F9B34FB';
  210. const UUIDCHAR2 = _0x4472('0x36');
  211. var hasChar1 = ![];
  212. var hasChar2 = ![];
  213. var version = '';
  214. var connectDeviceId;
  215. var connectCallback;
  216. var connectTimer;
  217. var sendIndex = 0x0;
  218. function toObject(_0x293f1a, _0x1c621a, _0x3b1b67) {
  219. return {
  220. 'code': _0x293f1a,
  221. 'data': _0x1c621a,
  222. 'msg': _0x3b1b67
  223. };
  224. }
  225. function connectAndInit(_0x4f68dd, _0x3abbb6, _0x1a1e01) {
  226. hasChar1 = ![];
  227. hasChar1 = ![];
  228. version = '';
  229. connectDeviceId = _0x4f68dd[_0x4472('0xc')];
  230. connectCallback = _0x3abbb6;
  231. if (connectTimer != undefined) {
  232. clearTimeout(connectTimer);
  233. }
  234. connectTimer = setTimeout(() => {
  235. connectTimer = undefined;
  236. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(0x7d2, undefined,
  237. _0x4472('0x31')));
  238. }, _0x1a1e01);
  239. startConnectBle();
  240. }
  241. function disconnectBleDevice(_0x206928) {
  242. const _0xe0e6d8 = String(connectDeviceId);
  243. wx[_0x4472('0xe')]({
  244. 'deviceId': _0xe0e6d8,
  245. 'success'(_0x152ff6) {
  246. if (connectTimer != undefined) {
  247. clearTimeout(connectTimer);
  248. }
  249. typeof _0x206928[_0x4472('0x23')] == FUNCTION && _0x206928[_0x4472('0x23')](toObject(codeEnum[
  250. 'successCode'], _0x152ff6, _0x4472('0x2')));
  251. },
  252. 'fail'(_0x5c60f6) {
  253. console['log'](_0x4472('0x13'), _0x5c60f6);
  254. if (connectTimer != undefined) {
  255. clearTimeout(connectTimer);
  256. }
  257. typeof _0x206928[_0x4472('0x40')] == FUNCTION && _0x206928['fail'](toObject(codeEnum[_0x4472(
  258. '0x3b')], _0x5c60f6, _0x4472('0x47')));
  259. }
  260. });
  261. }
  262. function startConnectBle() {
  263. if (connectTimer == undefined) {
  264. return;
  265. }
  266. wx[_0x4472('0x3a')]({
  267. 'deviceId': connectDeviceId,
  268. 'success': _0x1784a1 => {
  269. startGetAndCheckService();
  270. },
  271. 'fail': _0x5f3701 => {
  272. console['log'](_0x4472('0x32'), _0x5f3701);
  273. if (connectTimer != undefined) {
  274. clearTimeout(connectTimer);
  275. }
  276. typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject(
  277. codeEnum[_0x4472('0x3b')], undefined, 'creatConnectionFailure'));
  278. }
  279. });
  280. }
  281. function startGetAndCheckService() {
  282. if (connectTimer == undefined) {
  283. return;
  284. }
  285. wx['getBLEDeviceServices']({
  286. 'deviceId': connectDeviceId,
  287. 'success': _0xb523c0 => {
  288. for (let _0x4cb2c5 = 0x0; _0x4cb2c5 < _0xb523c0['services']['length']; _0x4cb2c5++) {
  289. let _0x49cc9b = _0xb523c0[_0x4472('0x18')][_0x4cb2c5]['uuid'];
  290. if (_0x49cc9b == UUIDCHAR1) {
  291. hasChar1 = !![];
  292. getBluetoothVersionUUID();
  293. break;
  294. }
  295. }
  296. let _0x6e24cb = ![];
  297. for (let _0x5411bc = 0x0; _0x5411bc < _0xb523c0[_0x4472('0x18')]['length']; _0x5411bc++) {
  298. let _0x394fd4 = _0xb523c0[_0x4472('0x18')][_0x5411bc]['uuid'];
  299. if (_0x394fd4 == serviceUUID) {
  300. _0x6e24cb = !![];
  301. break;
  302. }
  303. }
  304. if (_0x6e24cb == !![]) {
  305. startGetAndCheckCharacterisitc();
  306. } else {
  307. if (connectTimer != undefined) {
  308. clearTimeout(connectTimer);
  309. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[
  310. 'failCode'], undefined, _0x4472('0xf')));
  311. }
  312. }
  313. },
  314. 'fail': _0x3d472a => {
  315. console[_0x4472('0x9')](_0x4472('0x3c'), _0x3d472a);
  316. if (connectTimer != undefined) {
  317. clearTimeout(connectTimer);
  318. typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback[_0x4472('0x40')](
  319. toObject(codeEnum['failCode'], undefined, _0x3d472a['errMsg']));
  320. }
  321. }
  322. });
  323. }
  324. function startGetAndCheckCharacterisitc() {
  325. if (connectTimer == undefined) {
  326. return;
  327. }
  328. wx[_0x4472('0x2b')]({
  329. 'deviceId': connectDeviceId,
  330. 'serviceId': serviceUUID,
  331. 'success': _0x249062 => {
  332. let _0x27ce93 = ![];
  333. let _0x51826a = ![];
  334. for (let _0x4f8603 = 0x0; _0x4f8603 < _0x249062[_0x4472('0x26')][_0x4472(
  335. '0x11')]; _0x4f8603++) {
  336. let _0x489709 = _0x249062[_0x4472('0x26')][_0x4f8603]['uuid'];
  337. if (_0x489709 == readUUID) {
  338. _0x27ce93 = !![];
  339. } else if (_0x489709 == writeUUID) {
  340. _0x51826a = !![];
  341. }
  342. if (_0x27ce93 == !![] && _0x51826a == !![]) {
  343. break;
  344. }
  345. }
  346. if (_0x27ce93 == !![] && _0x51826a == !![]) {
  347. monitorNotification();
  348. } else {
  349. if (connectTimer != undefined) {
  350. clearTimeout(connectTimer);
  351. typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject(
  352. codeEnum[_0x4472('0x3b')], undefined, _0x4472('0x37')));
  353. }
  354. }
  355. },
  356. 'fail': _0x13f168 => {
  357. console[_0x4472('0x9')]('getBLEDeviceCharacteristics->', _0x13f168);
  358. if (connectTimer != undefined) {
  359. clearTimeout(connectTimer);
  360. typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback['fail'](toObject(
  361. codeEnum['failCode'], undefined, _0x13f168[_0x4472('0xa')]));
  362. }
  363. }
  364. });
  365. }
  366. function monitorNotification() {
  367. if (connectTimer == undefined) {
  368. return;
  369. }
  370. wx[_0x4472('0x4a')]({
  371. 'deviceId': connectDeviceId,
  372. 'serviceId': serviceUUID,
  373. 'characteristicId': readUUID,
  374. 'state': !![],
  375. 'success': _0x588188 => {
  376. if (typeof connectTimer != undefined) {
  377. clearTimeout(connectTimer);
  378. }
  379. wx[_0x4472('0xb')](function(_0x373b44) {
  380. if (_0x373b44['deviceId'] = connectDeviceId && _0x373b44['serviceId'] ==
  381. serviceUUID && _0x373b44[_0x4472('0x27')] == readUUID) {
  382. let _0x2eeb04 = arrayBuffer2hex(_0x373b44['value']);
  383. analyticData(_0x2eeb04);
  384. }
  385. });
  386. setTimeout(() => {
  387. typeof connectCallback[_0x4472('0x23')] == FUNCTION && connectCallback['success'](
  388. toObject(codeEnum['successCode'], undefined, '连接成功,握手成功'));
  389. }, 0x3e8);
  390. },
  391. 'fail': _0x2fcb1d => {
  392. console[_0x4472('0x9')](_0x4472('0x8'), _0x2fcb1d);
  393. if (connectTimer != undefined) {
  394. clearTimeout(connectTimer);
  395. typeof connectCallback[_0x4472('0x40')] == FUNCTION && connectCallback['fail'](toObject(
  396. codeEnum['failCode'], undefined, _0x2fcb1d[_0x4472('0xa')]));
  397. }
  398. }
  399. });
  400. }
  401. function getBluetoothVersionUUID() {
  402. wx['getBLEDeviceCharacteristics']({
  403. 'deviceId': connectDeviceId,
  404. 'serviceId': UUIDCHAR1,
  405. 'success': _0x506f8f => {
  406. for (let _0x433573 = 0x0; _0x433573 < _0x506f8f[_0x4472('0x26')][_0x4472(
  407. '0x11')]; _0x433573++) {
  408. let _0x463df3 = _0x506f8f[_0x4472('0x26')][_0x433573][_0x4472('0x20')];
  409. if (_0x463df3 == UUIDCHAR2) {
  410. hasChar2 = !![];
  411. break;
  412. }
  413. }
  414. },
  415. 'fail': _0x2a7116 => {
  416. console[_0x4472('0x9')]('getBluetoothVersionUUID->', _0x2a7116);
  417. if (connectTimer != undefined) {
  418. clearTimeout(connectTimer);
  419. typeof connectCallback['fail'] == FUNCTION && connectCallback[_0x4472('0x40')](toObject(
  420. codeEnum[_0x4472('0x3b')], undefined, _0x4472('0x33')));
  421. }
  422. }
  423. });
  424. }
  425. function readBLECharacteristicValue() {
  426. wx[_0x4472('0x44')]({
  427. 'deviceId': connectDeviceId,
  428. 'serviceId': UUIDCHAR1,
  429. 'characteristicId': UUIDCHAR2,
  430. 'success': _0x136d49 => {
  431. console['log']('readBLECharacteristicValueSuccess->', _0x136d49);
  432. },
  433. 'fail': _0x52b5dc => {
  434. console[_0x4472('0x9')](_0x4472('0x28'), _0x52b5dc);
  435. }
  436. });
  437. }
  438. function onBLECharacteristicValueChange() {
  439. wx[_0x4472('0xb')](_0x482304 => {
  440. console[_0x4472('0x9')](_0x4472('0x4'), arrayBuffer2hex(_0x482304[_0x4472('0x2f')]));
  441. if (_0x482304['deviceId'] == connectDeviceId && _0x482304['serviceId'] == serviceUUID && _0x482304[
  442. 'characteristicId'] == readUUID) {
  443. let _0xcbc651 = arrayBuffer2hex(_0x482304[_0x4472('0x2f')]);
  444. analyticData(_0xcbc651);
  445. } else if (_0x482304['deviceId'] == connectDeviceId && _0x482304[_0x4472('0x46')] == UUIDCHAR1 &&
  446. _0x482304[_0x4472('0x27')] == UUIDCHAR2) {
  447. let _0x5e1112 = arrayBuffer2hex(_0x482304['value'])[_0x4472('0x7')]();
  448. if (connectTimer != undefined) {
  449. clearTimeout(connectTimer);
  450. if (_0x5e1112 != '') {
  451. typeof connectCallback[_0x4472('0x23')] == FUNCTION && connectCallback['success'](toObject(
  452. codeEnum['successCode'], _0x5e1112, '连接成功'));
  453. } else {
  454. typeof connectCallback['fail'] == FUNCTION && connectCallback['fail'](toObject(codeEnum[
  455. _0x4472('0x12')], undefined, '连接失败'));
  456. }
  457. }
  458. }
  459. });
  460. }
  461. var dataArrays;
  462. var dataIndex = 0x0;
  463. var sendArrays = 0x0;
  464. var mCallBack;
  465. var transTimer;
  466. var receivePacketCount = 0x0;
  467. var receivePacketData = '';
  468. var receiveLength = 0x0;
  469. var receiveData = '';
  470. function analyticData(_0x45b004) {
  471. if (_0x45b004['slice'](0x0, 0x2) == '50' && (_0x45b004['slice'](0x2, 0x4) == '80' || _0x45b004['slice'](0x2, 0x4) ==
  472. '00') && (_0x45b004['length'] < 0x28 || _0x45b004[_0x4472('0x11')] == 0x28)) {
  473. receiveLength = parseInt(_0x45b004[_0x4472('0x2c')](0x6, 0xa), 0x10);
  474. if (_0x45b004[_0x4472('0x2c')](0x2, 0x4) == '80') {
  475. receivePacketCount = parseInt(_0x45b004['slice'](0x4, 0x6), 0x10);
  476. }
  477. }
  478. if (receiveLength != 0x0) {
  479. receiveData += _0x45b004;
  480. }
  481. console['log'](_0x4472('0x4'), receiveData);
  482. if (receiveData[_0x4472('0x2c')](0xa, receiveData[_0x4472('0x11')] - 0x2)['length'] == receiveLength * 0x2) {
  483. if (receiveData['slice'](0x0, 0x2) == '50' && receiveData['slice'](0x2, 0x4) == '80' && receiveData['slice'](
  484. 0xa, 0xc) == '97') {
  485. if (receiveData['slice'](0xa, 0xc) == '00' && receiveData[_0x4472('0x2c')](0x14, 0x16) == '00') {
  486. updateRead(!![]);
  487. } else {
  488. updateRead(![]);
  489. }
  490. receiveData = '';
  491. } else {
  492. receivePacketData += receiveData[_0x4472('0x2c')](0xa, receiveData['length'] - 0x2);
  493. receiveData = '';
  494. receiveLength = 0x0;
  495. receivePacketCount--;
  496. if (receivePacketCount > 0x0) {
  497. return;
  498. }
  499. let _0x8c35f3 = receivePacketData;
  500. receivePacketData = '';
  501. receivePacketCount = '';
  502. if (_0x8c35f3['slice'](0x0, 0x2) == '92') {
  503. cosDataRead(_0x8c35f3);
  504. } else if (_0x8c35f3[_0x4472('0x2c')](0x0, 0x2) == '91') {
  505. deviceChannelRead(_0x8c35f3);
  506. } else if (_0x8c35f3['slice'](0x0, 0x2) == '94') {
  507. authCodeRead(_0x8c35f3);
  508. }
  509. }
  510. }
  511. }
  512. function updateRead(_0x2ab7f9) {
  513. if (_0x2ab7f9) {
  514. if (transTimer != undefined) {
  515. clearTimeout(transTimer);
  516. }
  517. typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum[_0x4472('0x12')], null,
  518. '成功'));
  519. } else {
  520. if (transTimer != undefined) {
  521. clearTimeout(transTimer);
  522. }
  523. typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472('0x3b')],
  524. null, '失败'));
  525. }
  526. }
  527. function cosDataRead(_0x5ef34e) {
  528. let _0x2e87c9 = _0x5ef34e['slice'](0x4, 0x6);
  529. let _0x5e6375 = '';
  530. if (_0x2e87c9 == '10') {
  531. _0x5e6375 = '发送ICC指令';
  532. } else {
  533. _0x5e6375 = '发送ESAM指令';
  534. }
  535. let _0xb98396 = parseInt(_0x5ef34e[_0x4472('0x2c')](0x6, 0xa), 0x10);
  536. if (_0x5ef34e['slice'](0xa)[_0x4472('0x11')] == _0xb98396 * 0x2) {
  537. let _0x4ca253 = new Array();
  538. let _0x47692f = _0x5ef34e[_0x4472('0x2c')](0xa);
  539. let _0x3cfd30 = _0x47692f['slice'](0x0, 0x2);
  540. let _0x175104 = 0x0;
  541. while (_0x3cfd30 == '81') {
  542. _0x175104++;
  543. _0x3cfd30 = _0x47692f[_0x4472('0x2c')](_0x175104 * 0x2, _0x175104 * 0x2 + 0x2);
  544. }
  545. let _0x1b395b = _0x47692f[_0x4472('0x2c')](_0x175104 * 0x2 + 0x2);
  546. let _0x5c1774 = parseInt(_0x1b395b['slice'](0x2, 0x4), 0x10) * 0x2;
  547. _0x4ca253['push'](_0x1b395b['slice'](0x4, 0x4 + _0x5c1774));
  548. let _0x3605e4 = _0x1b395b[_0x4472('0x2a')](0x4 + _0x5c1774);
  549. while (_0x3605e4 != '') {
  550. _0x5c1774 = parseInt(_0x3605e4['slice'](0x2, 0x4), 0x10) * 0x2;
  551. _0x4ca253['push'](_0x3605e4[_0x4472('0x2c')](0x4, 0x4 + _0x5c1774));
  552. _0x3605e4 = _0x3605e4[_0x4472('0x2a')](0x4 + _0x5c1774);
  553. }
  554. if (transTimer != undefined) {
  555. clearTimeout(transTimer);
  556. }
  557. typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum[_0x4472('0x12')],
  558. _0x4ca253, _0x5e6375 + '成功'));
  559. } else {
  560. if (transTimer != undefined) {
  561. clearTimeout(transTimer);
  562. }
  563. typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472('0x3b')],
  564. null, _0x4472('0x35')));
  565. }
  566. }
  567. function deviceChannelRead(_0x106fb) {
  568. let _0x58c660 = _0x106fb['slice'](0x2, 0x4);
  569. if (transTimer != undefined) {
  570. clearTimeout(transTimer);
  571. }
  572. if (_0x58c660 == '00') {
  573. typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum['successCode'],
  574. _0x106fb[_0x4472('0x2c')](0xa), '操作成功'));
  575. } else {
  576. typeof mCallBack[_0x4472('0x23')] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null,
  577. _0x4472('0x3d')));
  578. }
  579. }
  580. function authCodeRead(_0x23bcd4) {
  581. let _0x556549 = _0x23bcd4[_0x4472('0x2c')](0x2, 0x4);
  582. if (transTimer != undefined) {
  583. clearTimeout(transTimer);
  584. }
  585. if (_0x556549 == '00') {
  586. typeof mCallBack['success'] == FUNCTION && mCallBack[_0x4472('0x23')](toObject(codeEnum[_0x4472('0x12')],
  587. _0x23bcd4['slice'](0xa), _0x4472('0x1b')));
  588. } else {
  589. typeof mCallBack['success'] == FUNCTION && mCallBack['success'](toObject(codeEnum['successCode'], null,
  590. '认证失败'));
  591. }
  592. }
  593. function postCommand(_0x591227, _0x3d71c3, _0x48f9da, _0x470007) {
  594. mCallBack = _0x48f9da;
  595. if (transTimer != undefined) {
  596. clearTimeout(transTimer);
  597. }
  598. transTimer = setTimeout(() => {
  599. transTimer = undefined;
  600. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, _0x4472(
  601. '0x25')));
  602. }, _0x470007);
  603. dataArrays = new Array();
  604. dataIndex = 0x0;
  605. let _0xc993d1 = getCosData(_0x3d71c3);
  606. let _0x5ac9a0 = '82' + _0x591227['toString'](0x10)[_0x4472('0x43')](0x2, '0') + (_0xc993d1['length'] / 0x2)[_0x4472(
  607. '0x1e')](0x10)['padStart'](0x4, '0') + _0xc993d1;
  608. let _0x211adf = 0x50 * 0x2;
  609. if (_0x5ac9a0['length'] < _0x211adf) {
  610. _0x5ac9a0 = _0x4472('0x2d') + (_0x5ac9a0['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x5ac9a0;
  611. dataArrays[0x0] = _0x5ac9a0 + CRC8(_0x5ac9a0);
  612. } else {
  613. let _0x18f9b7 = parseInt(_0x5ac9a0[_0x4472('0x11')] % _0x211adf == 0x0 ? _0x5ac9a0[_0x4472('0x11')] /
  614. _0x211adf : _0x5ac9a0['length'] / _0x211adf + 0x1);
  615. for (let _0x5a1627 = 0x0; _0x5a1627 < _0x18f9b7; _0x5a1627++) {
  616. let _0x2182c1 = _0x5a1627 + 0x1;
  617. let _0x1a409f = '';
  618. if (_0x5a1627 == _0x18f9b7 - 0x1) {
  619. _0x1a409f = _0x5ac9a0['slice'](_0x5a1627 * _0x211adf);
  620. } else {
  621. _0x1a409f = _0x5ac9a0['slice'](_0x5a1627 * _0x211adf, _0x2182c1 * _0x211adf);
  622. }
  623. if (_0x5a1627 == 0x0) {
  624. _0x1a409f = '5080' + _0x18f9b7['toString'](0x10)['padStart'](0x2, '0') + (_0x1a409f['length'] / 0x2)[
  625. 'toString'](0x10)['padStart'](0x4, '0') + _0x1a409f;
  626. } else {
  627. _0x1a409f = '5000' + _0x2182c1['toString'](0x10)['padStart'](0x2, '0') + (_0x1a409f['length'] / 0x2)[
  628. 'toString'](0x10)['padStart'](0x4, '0') + _0x1a409f;
  629. }
  630. dataArrays[_0x5a1627] = _0x1a409f + CRC8(_0x1a409f);
  631. }
  632. }
  633. initReadValue();
  634. write(dataArrays[dataIndex]);
  635. }
  636. function getCosData(_0x61028c) {
  637. let _0xff7d = '';
  638. for (let _0x2a4c3c = 0x0; _0x2a4c3c < _0x61028c['length']; _0x2a4c3c++) {
  639. _0xff7d += (_0x2a4c3c + 0x1)['toString'](0x10)['padStart'](0x2, '0') + (_0x61028c[_0x2a4c3c]['length'] / 0x2)[
  640. 'toString'](0x10)[_0x4472('0x1f')](0x2, '0') + _0x61028c[_0x2a4c3c];
  641. }
  642. return '80' + (_0xff7d[_0x4472('0x11')] / 0x2)[_0x4472('0x1e')](0x10)['padStart'](0x2, '0') + _0xff7d;
  643. }
  644. function deviceChannel(_0xa4300b, _0x26620a, _0x521c3a) {
  645. mCallBack = _0x26620a;
  646. if (transTimer != undefined) {
  647. clearTimeout(transTimer);
  648. }
  649. transTimer = setTimeout(() => {
  650. transTimer = undefined;
  651. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, '操作超时'));
  652. }, _0x521c3a);
  653. dataArrays = new Array();
  654. dataIndex = 0x0;
  655. let _0x5f8c87 = '81' + (_0xa4300b['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0xa4300b;
  656. let _0xdef1a0 = 0x50 * 0x2;
  657. if (_0x5f8c87['length'] < _0xdef1a0) {
  658. _0x5f8c87 = _0x4472('0x2d') + (_0x5f8c87[_0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') +
  659. _0x5f8c87;
  660. dataArrays[0x0] = _0x5f8c87 + CRC8(_0x5f8c87);
  661. } else {
  662. let _0x200ab2 = parseInt(_0x5f8c87['length'] % _0xdef1a0 == 0x0 ? _0x5f8c87['length'] / _0xdef1a0 : _0x5f8c87[
  663. _0x4472('0x11')] / _0xdef1a0 + 0x1);
  664. for (let _0x285c15 = 0x0; _0x285c15 < _0x200ab2; _0x285c15++) {
  665. let _0x285b83 = _0x285c15 + 0x1;
  666. let _0x3988f8 = '';
  667. if (_0x285c15 == _0x200ab2 - 0x1) {
  668. _0x3988f8 = _0x5f8c87[_0x4472('0x2c')](_0x285c15 * _0xdef1a0);
  669. } else {
  670. _0x3988f8 = _0x5f8c87[_0x4472('0x2c')](_0x285c15 * _0xdef1a0, _0x285b83 * _0xdef1a0);
  671. }
  672. if (_0x285c15 == 0x0) {
  673. _0x3988f8 = _0x4472('0x10') + _0x200ab2[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x2, '0') + (_0x3988f8[
  674. _0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x3988f8;
  675. } else {
  676. _0x3988f8 = '5000' + _0x285b83['toString'](0x10)['padStart'](0x2, '0') + (_0x3988f8[_0x4472('0x11')] /
  677. 0x2)[_0x4472('0x1e')](0x10)['padStart'](0x4, '0') + _0x3988f8;
  678. }
  679. dataArrays[_0x285c15] = _0x3988f8 + CRC8(_0x3988f8);
  680. }
  681. }
  682. initReadValue();
  683. write(dataArrays[dataIndex]);
  684. }
  685. function authObu(_0xe7b40, _0x1424a9, _0x36ce2d) {
  686. mCallBack = _0x1424a9;
  687. if (transTimer != undefined) {
  688. clearTimeout(transTimer);
  689. }
  690. transTimer = setTimeout(() => {
  691. transTimer = undefined;
  692. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined, _0x4472(
  693. '0x2e')));
  694. }, _0x36ce2d);
  695. dataArrays = new Array();
  696. dataIndex = 0x0;
  697. let _0x2d62b8 = '84' + (_0xe7b40['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0xe7b40;
  698. let _0x3b1cb4 = 0x50 * 0x2;
  699. if (_0x2d62b8[_0x4472('0x11')] < _0x3b1cb4) {
  700. _0x2d62b8 = _0x4472('0x2d') + (_0x2d62b8['length'] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x2d62b8;
  701. dataArrays[0x0] = _0x2d62b8 + CRC8(_0x2d62b8);
  702. } else {
  703. let _0x53a0f3 = parseInt(_0x2d62b8['length'] % _0x3b1cb4 == 0x0 ? _0x2d62b8['length'] / _0x3b1cb4 : _0x2d62b8[
  704. 'length'] / _0x3b1cb4 + 0x1);
  705. for (let _0x4d2f44 = 0x0; _0x4d2f44 < _0x53a0f3; _0x4d2f44++) {
  706. let _0x33a578 = _0x4d2f44 + 0x1;
  707. let _0x1f3254 = '';
  708. if (_0x4d2f44 == _0x53a0f3 - 0x1) {
  709. _0x1f3254 = _0x2d62b8[_0x4472('0x2c')](_0x4d2f44 * _0x3b1cb4);
  710. } else {
  711. _0x1f3254 = _0x2d62b8['slice'](_0x4d2f44 * _0x3b1cb4, _0x33a578 * _0x3b1cb4);
  712. }
  713. if (_0x4d2f44 == 0x0) {
  714. _0x1f3254 = _0x4472('0x10') + _0x53a0f3[_0x4472('0x1e')](0x10)['padStart'](0x2, '0') + (_0x1f3254[
  715. _0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x1f3254;
  716. } else {
  717. _0x1f3254 = _0x4472('0x38') + _0x33a578['toString'](0x10)[_0x4472('0x1f')](0x2, '0') + (_0x1f3254[
  718. 'length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x4, '0') + _0x1f3254;
  719. }
  720. dataArrays[_0x4d2f44] = _0x1f3254 + CRC8(_0x1f3254);
  721. }
  722. }
  723. initReadValue();
  724. write(dataArrays[dataIndex]);
  725. }
  726. function sendUpgradeData(_0x2049ec, _0x19ec1d, _0x2ea11b) {
  727. mCallBack = _0x19ec1d;
  728. if (transTimer != undefined) {
  729. clearTimeout(transTimer);
  730. }
  731. transTimer = setTimeout(() => {
  732. transTimer = undefined;
  733. typeof mCallBack[_0x4472('0x40')] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(0x7d0, undefined,
  734. '升级超时'));
  735. }, _0x2ea11b);
  736. let _0x1ed8a2 = '87' + (_0x2049ec[_0x4472('0x11')] / 0x2)['toString'](0x10)['padStart'](0x4, '0') + _0x2049ec;
  737. let _0x48d7e9 = _0x1ed8a2[_0x4472('0x11')];
  738. let _0x4a6a8c = 0xb8;
  739. let _0x3e8e51 = parseInt(_0x48d7e9 / _0x4a6a8c + 0x1);
  740. dataArrays = new Array();
  741. dataIndex = 0x0;
  742. for (var _0x39f86c = 0x0; _0x39f86c < _0x3e8e51; _0x39f86c++) {
  743. let _0x4258bf = '';
  744. if (_0x39f86c + 0x1 == _0x3e8e51) {
  745. _0x4258bf = _0x1ed8a2[_0x4472('0x2c')](_0x39f86c * _0x4a6a8c);
  746. } else {
  747. _0x4258bf = _0x1ed8a2['slice'](_0x39f86c * _0x4a6a8c, (_0x39f86c + 0x1) * _0x4a6a8c);
  748. }
  749. let _0x2af93a = '';
  750. if (_0x39f86c == 0x0) {
  751. _0x2af93a = '80' + _0x3e8e51['toString'](0x10)[_0x4472('0x1f')](0x2, '0');
  752. } else {
  753. _0x2af93a = '00' + (_0x39f86c + 0x1)['toString'](0x10)[_0x4472('0x1f')](0x2, '0');
  754. }
  755. let _0x4658df = '50' + _0x2af93a + parseInt(_0x4258bf['length'] / 0x2)[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](
  756. 0x2, '0') + _0x4258bf;
  757. dataArrays['push'](_0x4658df + CRC8(_0x4658df));
  758. }
  759. write(dataArrays[dataIndex]);
  760. }
  761. function initReadValue() {
  762. receivePacketCount = 0x0;
  763. receivePacketData = '';
  764. receiveLength = 0x0;
  765. receiveData = '';
  766. }
  767. function write(_0x3e2cf6) {
  768. if (dataIndex < dataArrays[_0x4472('0x11')]) {
  769. dataIndex++;
  770. sendArrays = new Array();
  771. let _0x3b2bd3 = 0x28;
  772. let _0x3cbd19 = parseInt(_0x3e2cf6[_0x4472('0x11')] / _0x3b2bd3 + 0x1);
  773. for (var _0x1f373a = 0x0; _0x1f373a < _0x3cbd19; _0x1f373a++) {
  774. if (_0x1f373a + 0x1 == _0x3cbd19) {
  775. sendArrays[_0x4472('0x3f')](_0x3e2cf6['slice'](_0x1f373a * _0x3b2bd3));
  776. } else {
  777. sendArrays[_0x4472('0x3f')](_0x3e2cf6[_0x4472('0x2c')](_0x1f373a * _0x3b2bd3, (_0x1f373a + 0x1) *
  778. _0x3b2bd3));
  779. }
  780. }
  781. sendIndex = 0x0;
  782. runSendData();
  783. } else {
  784. console[_0x4472('0x9')]('Packet\x20send\x20complete.');
  785. }
  786. }
  787. function runSendData() {
  788. console[_0x4472('0x9')](_0x4472('0x22'), sendArrays[sendIndex]);
  789. let _0x2acb4e = hex2ArrayBuffer(sendArrays[sendIndex]);
  790. wx['writeBLECharacteristicValue']({
  791. 'deviceId': connectDeviceId,
  792. 'serviceId': serviceUUID,
  793. 'characteristicId': writeUUID,
  794. 'value': _0x2acb4e,
  795. 'success': _0x5b7035 => {
  796. sendIndex++;
  797. if (sendIndex < sendArrays['length']) {
  798. runSendData();
  799. } else {
  800. write(dataArrays[dataIndex]);
  801. }
  802. },
  803. 'fail': _0x2b2b50 => {
  804. if (transTimer != undefined) {
  805. clearTimeout(transTimer);
  806. }
  807. typeof mCallBack['fail'] == FUNCTION && mCallBack[_0x4472('0x40')](toObject(codeEnum[_0x4472(
  808. '0x3b')], null, _0x2b2b50['errMsg']));
  809. }
  810. });
  811. }
  812. function CRC8(_0x1ad747) {
  813. let _0x2ba538 = new Uint8Array(hex2ArrayBuffer(_0x1ad747));
  814. let _0xab46ff = 0x0;
  815. for (let _0x2b3b74 of _0x2ba538) {
  816. _0xab46ff ^= _0x2b3b74;
  817. }
  818. return _0xab46ff[_0x4472('0x1e')](0x10)[_0x4472('0x1f')](0x2, '0')['toUpperCase']();
  819. }
  820. function CRC16(_0x5ed917) {
  821. let _0x8b2317 = 0xffff;
  822. for (let _0x4cb4f2 of _0x5ed917) {
  823. _0x8b2317 ^= _0x4cb4f2 & 0xff;
  824. for (var _0x104edf = 0x0; _0x104edf < 0x8; _0x104edf++) {
  825. if ((_0x8b2317 & 0x1) > 0x0) {
  826. _0x8b2317 = _0x8b2317 >> 0x1;
  827. _0x8b2317 = _0x8b2317 ^ 0x8408;
  828. } else {
  829. _0x8b2317 = _0x8b2317 >> 0x1;
  830. }
  831. }
  832. }
  833. return (_0x8b2317 ^ 0xffff)[_0x4472('0x1e')](0x10);
  834. }
  835. function hex2ArrayBuffer(_0x1d7b99) {
  836. var _0x5a055c = new Uint8Array(_0x1d7b99['match'](/[\da-f]{2}/gi)['map'](function(_0x1b621a) {
  837. return parseInt(_0x1b621a, 0x10);
  838. }));
  839. return _0x5a055c['buffer'];
  840. }
  841. function arrayBuffer2hex(_0x3b0ba6) {
  842. const _0x2bf4dc = Array['prototype']['map'][_0x4472('0x1c')](new Uint8Array(_0x3b0ba6), function(_0xff9c01) {
  843. return ('00' + _0xff9c01['toString'](0x10))[_0x4472('0x2c')](-0x2);
  844. });
  845. return _0x2bf4dc[_0x4472('0x42')]('');
  846. }
  847. function littleEndian(_0x10084d) {
  848. if (_0x10084d != '' && _0x10084d != undefined) {
  849. var _0x1f11f2 = '';
  850. for (var _0x2b1cd6 = _0x10084d['length']; _0x2b1cd6 >= 0x0; _0x2b1cd6 = _0x2b1cd6 - 0x2) {
  851. _0x1f11f2 += _0x10084d[_0x4472('0x1')](_0x2b1cd6);
  852. _0x1f11f2 += _0x10084d[_0x4472('0x1')](_0x2b1cd6 + 0x1);
  853. }
  854. return _0x1f11f2;
  855. } else {
  856. return _0x10084d;
  857. }
  858. }