hhdlinkble 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -12,4 +12,4 @@ function(){var t=U,e=t.lib,r=e.WordArray,n=e.Hasher,i=t.algo,a=r.create([0,1,2,3
|
|
|
12
12
|
* derived from CryptoJS.mode.CTR
|
|
13
13
|
* Jan Hruby jhruby.web@gmail.com
|
|
14
14
|
*/
|
|
15
|
-
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),t=C.recoverRecv(t),console.log("反转报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);switch(console.log("解密后:",C.ab2hex(c)),c=c.slice(8,i),console.log("解密后:",C.ab2hex(c)),console.log("解密后:",i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)})),console.log("11111");var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];console.log("22323");var f=C.Encrypt(C.ab2hex(c.buffer),n);console.log("22323"),console.log("abx",C.ab2hex(f));for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,console.log("abx",C.ab2hex(C.ShiftSend(i.slice(0,14+f.byteLength+1)))),C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),console.log("原始报文",t),console.log("原始报文",C.ab2hex(S)),R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();module.exports=V;
|
|
15
|
+
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),t=C.recoverRecv(t),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2),c=C.Decrypt(C.ab2hex(s),e,o);switch(c=c.slice(8,i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];var f=C.Encrypt(C.ab2hex(c.buffer),n);for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();module.exports=V;
|
package/dist/index.esm.js
CHANGED
|
@@ -12,4 +12,4 @@ function(){var t=U,e=t.lib,r=e.WordArray,n=e.Hasher,i=t.algo,a=r.create([0,1,2,3
|
|
|
12
12
|
* derived from CryptoJS.mode.CTR
|
|
13
13
|
* Jan Hruby jhruby.web@gmail.com
|
|
14
14
|
*/
|
|
15
|
-
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),t=C.recoverRecv(t),console.log("反转报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);switch(console.log("解密后:",C.ab2hex(c)),c=c.slice(8,i),console.log("解密后:",C.ab2hex(c)),console.log("解密后:",i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)})),console.log("11111");var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];console.log("22323");var f=C.Encrypt(C.ab2hex(c.buffer),n);console.log("22323"),console.log("abx",C.ab2hex(f));for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,console.log("abx",C.ab2hex(C.ShiftSend(i.slice(0,14+f.byteLength+1)))),C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),console.log("原始报文",t),console.log("原始报文",C.ab2hex(S)),R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();export{V as default};
|
|
15
|
+
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),t=C.recoverRecv(t),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2),c=C.Decrypt(C.ab2hex(s),e,o);switch(c=c.slice(8,i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];var f=C.Encrypt(C.ab2hex(c.buffer),n);for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();export{V as default};
|
package/dist/index.iife.js
CHANGED
|
@@ -12,4 +12,4 @@ function(){var t=U,e=t.lib,r=e.WordArray,n=e.Hasher,i=t.algo,a=r.create([0,1,2,3
|
|
|
12
12
|
* derived from CryptoJS.mode.CTR
|
|
13
13
|
* Jan Hruby jhruby.web@gmail.com
|
|
14
14
|
*/
|
|
15
|
-
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),t=C.recoverRecv(t),console.log("反转报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);switch(console.log("解密后:",C.ab2hex(c)),c=c.slice(8,i),console.log("解密后:",C.ab2hex(c)),console.log("解密后:",i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)})),console.log("11111");var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];console.log("22323");var f=C.Encrypt(C.ab2hex(c.buffer),n);console.log("22323"),console.log("abx",C.ab2hex(f));for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,console.log("abx",C.ab2hex(C.ShiftSend(i.slice(0,14+f.byteLength+1)))),C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),console.log("原始报文",t),console.log("原始报文",C.ab2hex(S)),R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=parseInt(i,16),o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();return V}();
|
|
15
|
+
U.mode.CTRGladman=function(){var t=U.lib.BlockCipherMode.extend();function e(t){if(255&~(t>>24))t+=1<<24;else{var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}return t}function r(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var n=t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),r(o);var s=o.slice(0);n.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}});return t.Decryptor=n,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.Rabbit=e.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,r=0;r<4;r++)s.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(i[0]^=l,i[1]^=f,i[2]^=u,i[3]^=h,i[4]^=l,i[5]^=f,i[6]^=u,i[7]^=h,r=0;r<4;r++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.Rabbit=e._createHelper(o)}(),U.mode.CTR=function(){var t=U.lib.BlockCipherMode.extend(),e=t.Encryptor=t.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0);var o=a.slice(0);r.encryptBlock(o,0),a[n-1]=a[n-1]+1|0;for(var s=0;s<n;s++)t[e+s]^=o[s]}});return t.Decryptor=e,t}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,n=[],i=[],a=[],o=r.RabbitLegacy=e.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)s.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var a=e.words,o=a[0],c=a[1],l=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),f=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=f,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=f,n[6]^=u,n[7]^=h,i=0;i<4;i++)s.call(this)}},_doProcessBlock:function(t,e){var r=this._X;s.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function s(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<i[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<i[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<i[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<i[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<i[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<i[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<i[6]>>>0?1:0)|0,this._b=e[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=t[r]+e[r],o=65535&n,s=n>>>16,c=((o*o>>>17)+o*s>>>15)+s*s,l=((4294901760&n)*n|0)+((65535&n)*n|0);a[r]=c^l}t[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,t[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,t[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,t[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,t[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,t[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,t[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,t[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}t.RabbitLegacy=e._createHelper(o)}(),U.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},U),new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);var C={formatTime:w,inArray:function(t,e,r){for(var n=0;n<t.length;n++)if(t[n][e]===r)return n;return-1},ab2hex:b,mergeArrayBuffer:function(){for(var t=0,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var i=0;i<r.length;i++)r[i]=new Uint8Array(r[i]),t+=r[i].length;for(var a=new Uint8Array(t),o=0,s=0,c=r;s<c.length;s++){var l=c[s];a.set(l,o),o+=l.length}return a.buffer},Encrypt:B,Decrypt:function(t,e,r){var n=b(B(b(new Uint8Array(16).buffer),e)),i=m.exports;t=A(t);var a=new Uint8Array([]);e=b(e);for(var o=i.enc.Hex.parse(e),c=i.enc.Hex.parse(""),l=0;l<t.length;l+=16){var u=t.slice(l,l+16);if(b(u)!=n){var f=i.enc.Hex.parse(b(u)),h=i.enc.Base64.stringify(f),g=i.AES.decrypt(h,o,{iv:c,mode:i.mode.CBC,padding:i.pad.NoPadding});a=new Uint8Array([].concat(s(a),s(A(i.enc.Hex.stringify(g)))))}}return a},Crc16_Ccitt:S,SunCheck:function(t,e){var r,n=0;for(r=0;r<e;r++)n=n+(255&t[r])&255;return n=1+~n,(n&=255)>240&&(n-=16),n},stringToUint8Array:function(t){for(var e=[],r=0,n=t.length;r<n;++r)e.push(t.charCodeAt(r));return new Uint8Array(e)},sleep:function(t){for(var e=new Date,r=e.getTime()+t;;)if((e=new Date).getTime()>r)return},Uint8ArrayToHex:function(t,e){if(null==t)return"";for(var r,n=[],i=0;i<t.length;i++)1==(r=t[i].toString(16)).length&&(r="0"+r),n.push(r);return e?n.join(""):n.join(" ")},Uint8ArrayToString:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},getTimeArr:function(t){var e=w(new Date);return t&&(e=w(new Date(t))),A(e)},HexToUint8Array:A,DelayExecFunc:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;null==t||t.length<1||null==e||r<1||function n(){null==t||t.length<1||(e(t.shift()),setTimeout(n,r))}()},SplitArray:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==t||t.length<1||e<1)return[];for(var n=[],i=0;i<t.length;)n.push(t.slice(i,i+e)),i+=e;return null==r||n.forEach((function(t,e,n){r(t)})),n},clone:function(t){var e=null;if(t instanceof Array)e=t.concat();else if(t instanceof Function)e=t;else for(var r in e=new Object,t){var n=t[r];e[r]=n instanceof Object?this.clone(n):n}return e},GetPowerPercent:function(t){if(t<=3)return 0;if(t>4.22)return 102;if(t>=4.2)return 100;var e=0,r=0,n=0,i=10;return t<4.2&&t>=4.06?(e=90,r=4.2,n=4.06):t<4.06&&t>=3.98?(e=80,r=4.06,n=3.98):t<3.98&&t>=3.92?(e=70,r=3.98,n=3.92):t<3.92&&t>=3.87?(e=60,r=3.92,n=3.87):t<3.87&&t>=3.82?(e=50,r=3.87,n=3.82):t<3.82&&t>=3.79?(e=40,r=3.82,n=3.79):t<3.79&&t>=3.77?(e=30,r=3.79,n=3.77):t<3.77&&t>=3.74?(e=20,r=3.77,n=3.74):t<3.74&&t>=3.68?(e=10,r=3.74,n=3.68):t<3.68&&t>=3.45?(e=5,r=3.68,n=3.45,i=5):t<3.45&&t>=3&&(e=0,r=3.45,n=3,i=5),parseInt(e+i*(t-n)/(r-n))},GetPower:function(t){return t<3?5:t>=3?100:parseInt(t)},GetPowertow:function(t){var e=0;return t<1.4?0:t>=3?100:(t<3&&t>=2.5?e=(e=parseInt(392.16*t-488.24))>=100?100:e:t<2.016&&t>=1.4?e=parseInt(44.286*t*t-10.706*t-14.206):t<2.628&&t>=2.016?e=parseInt(13141*t*t-3752.7*t*t*t-15022*t+5653.6):t<3&&t>=2.628&&(e=(e=parseInt(53.763*t+19.36))>=100?100:e),e)},GetXorCheck:function(t,e){if(null==t||e<1)return 0;for(var r=0,n=0;n<e;n++)r^=t[n],r&=255;return r},ShiftSend:function(t){for(var e=new ArrayBuffer(2*t.length+2),r=new DataView(e,0),n=1,i=1;i<t.length-1;i++)126==t[i]?(r.setUint8(n,125),r.setUint8(n+1,2),n++):125==t[i]?(r.setUint8(n,125),r.setUint8(n+1,1),n++):r.setUint8(n,t[i]),n++;r.setUint8(0,126),r.setUint8(n,126),n++;try{return new Uint8Array(e.slice(0,n))}catch(t){return!1}},recoverRecv:function(t){for(var e=new Uint8Array(t.length),r=0,n=0;n<t.length;n++)125==t[n]?2==t[n+1]?(e[r]=126,n++):1==t[n+1]?(e[r]=125,n++):e[r]=t[n]:e[r]=t[n],r++;return e=e.slice(0,r)},bufferToHex:function(t){if(null==t)return"";for(var e,r=[],n=0;n<t.length;n++)1==(e=t[n].toString(16)).length&&(e="0"+e),r.push(e);return r.join(" ")},stringToUint8Arraytwo:function(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?(e.push(192|n>>6),e.push(128|63&n)):n<65536?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|63&n)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|63&n))}return new Uint8Array(e)},checkCrc:function(t,e){var r=new ArrayBuffer(2),n=new DataView(r);n.setUint8(0,t[0]),n.setUint8(1,t[1]);var i=t.slice(12,e),a=S(i,i.length);return a&=65535,n.getUint16(0)==a}};var k={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"2401":return r=a(a({},r),function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint16(3),n={};1==(r>>15&1)?n.Power=((32767&r)/100).toFixed(2):n.Voltage=(r/1e3).toFixed(2);return n.sealNum=e.getUint32(5),n.unsealNum=e.getUint32(9),n.Time=C.Uint8ArrayToHex(t.slice(13,20),!0),n}(c));case"2403":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={CardList:[]},n=(t.length-1)/4,i=0;i<n;i++){var a=t.slice(e,e+4);r.CardList.push(C.ab2hex(a)),e+=4}return r.CardList=r.CardList,r}(c));case"2406":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=1,r={sealLogList:[]},n=(t.length-1)/11,i=0;i<n;i++){var a={};a.eventID=t[e];var o=t.slice(e+1,e+1+4);a.UserId=C.ab2hex(o),o=t.slice(e+5,e+5+6),a.Time=C.ab2hex(o),r.sealLogList.push(a),e+=11}return r}(c));case"2407":return r=a(a({},r),function(t){if(1!=t[0])return;for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=1,n={alarmLogList:[]},i=(t.length-1)/10,a=0;a<i;a++){var o={};o.eventID=e.getUint8(r),o.sealStatus=e.getUint8(r+1),o.Voltage=e.getUint16(r+2)/1e3;var s=t.slice(r+4,r+4+6);o.Time=C.ab2hex(s),n.alarmLogList.push(o),r+=10}return n}(c));case"2409":return r=a(a({},r),function(t){if(1!=t[0])return;var e=1,r={Content:""},n=t.slice(e,e+512);return r.Content=C.Uint8ArrayToString(n),r}(c));case"240D":return r.Data=function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(1),n=1,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o){var c=0;2==s&&(c=e.getUint16(n+3)),i[""+o]=c}else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x04"==o||"0x07"==o||"0x06"==o||"0x10"==o||"0x12"==o||"0xFC"==o){c="";c=C.Uint8ArrayToHex(t.slice(n+3,n+3+s),!0),i[""+o]=c}else if("0x11"==o||"0x0E"==o||"0x08"==o||"0x09"==o||"0x0A"==o){var l=t.slice(n+3,n+3+s);if(parseInt(l[0])>=49)i[""+o]=C.Uint8ArrayToString(l);else{for(var u="",f=0;f<l.length;f++)u+=l[f];i[""+o]=u}}else{l=t.slice(n+3,n+3+s);i[""+o]=l.toString()}n+=2+s}return i}(c),r;case"2402":case"2408":case"240A":case"240B":case"240C":return r}}catch(t){return console.log("==--",t),r}}};function T(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var I={setCommand:function(t,e){switch(t){case"HHD_BLE_2401":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=1;for(var r=new Uint8Array(20),n=C.stringToUint8Arraytwo(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];r[8]=parseInt(t.setData.cmd);var a=C.getTimeArr();return r[9]=a[0],r[10]=a[1],r[11]=a[2],r[12]=a[3],r[13]=a[4],r[14]=a[5],r[15]=a[6],r[16]=0,r[17]=0,r[18]=0,r[19]=0,T(e,r,t)}(e);case"HHD_BLE_2402":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=2;for(var r=t.setData,n=new Uint8Array(8+4*r.length),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];var o=0;for(a=0;a<r.length;a++){for(var s=C.HexToUint8Array(r[a]),c=0;c<4;c++)n[8+o+c]=s[c];o+=4}return T(e,n,t)}(e);case"HHD_BLE_2403":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=3;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2406":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=6;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2407":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=7;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e);case"HHD_BLE_2408":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=8;for(var r=C.stringToUint8Arraytwo(t.setData.content),n=new Uint8Array(8+r.length+1),i=C.stringToUint8Array(t.blePassword),a=0;a<i.byteLength;a++)n[a]=i[a];n[8]=parseInt(t.setData.address);for(a=0;a<r.length;a++)n[9+a]=r[a];return T(e,n,t)}(e);case"HHD_BLE_2409":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=9;for(var r=new Uint8Array(9),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return r[8]=t.setData.address,T(e,r,t)}(e);case"HHD_BLE_240A":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=10;for(var r=new Uint8Array(16),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.password);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240B":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=11;for(var r=new Uint8Array(24),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];var a=C.stringToUint8Array(t.setData.aespassword);for(i=0;i<a.byteLength;i++)r[8+i]=a[i];return T(e,r,t)}(e);case"HHD_BLE_240C":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(a.setUint8(r+1,parseInt(o)),"0x03"==o||"0x0B"==o||"0x0C"==o||"0x0D"==o||"0x13"==o)a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x01"==o||"0x02"==o||"0x09"==o||"0x0F"==o||"0xFE"==o||"0x14"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x04"==o){a.setUint8(r+2,7);var c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),a.setUint8(r+9,c[6]),r+=9}else if("0x07"==o){a.setUint8(r+2,6);c=C.HexToUint8Array(s);a.setUint8(r+3,c[0]),a.setUint8(r+4,c[1]),a.setUint8(r+5,c[2]),a.setUint8(r+6,c[3]),a.setUint8(r+7,c[4]),a.setUint8(r+8,c[5]),r+=8}else if("0xFC"==o){var l=C.HexToUint8Array(s);a.setUint8(r+2,l.length);for(var u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);r+=l.length+2}else{for(l=C.stringToUint8Arraytwo(s),u=0;u<l.length;u++)a.setUint8(r+3+u,l[u]);a.setUint8(r+2,l.length),r+=2+l.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var f=new Uint8Array(2);f[0]=36,f[1]=12;var h=new Uint8Array(8+r+1),g=C.stringToUint8Array(t.blePassword);for(u=0;u<g.byteLength;u++)h[u]=g[u];for(u=0;u<r+1;u++)h[8+u]=a.getUint8(u);return T(f,h,t)}return!1}(e);case"HHD_BLE_240D":return function(t){var e=new Uint8Array(2);e[0]=36,e[1]=13;for(var r=new Uint8Array(8),n=C.stringToUint8Array(t.blePassword),i=0;i<n.byteLength;i++)r[i]=n[i];return T(e,r,t)}(e)}}},H=a(a({},k),I),L=Object.freeze({__proto__:null,default:H});var D={parseResponse:function(t,e){t=new Uint8Array(t),t=C.recoverRecv(t),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(3,5);i=2047&new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+15!=n)return r;var s=t.slice(13,n-2),c=C.Decrypt(C.ab2hex(s),e,o);switch(c=c.slice(8,i),r.Code=c[0],C.ab2hex(t.slice(1,3)).toUpperCase()){case"0311":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0313":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2)}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0215":return r;case"0217":return r=a(a({},r),function(t){var e=0,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function R(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=126,i[1]=t[0],i[2]=t[1];var a=e.length+6|32768;i[3]=a>>8,i[4]=a;var o="00000000000000"+r.lockId;o=o.substr(-12),i[5]=parseInt(o.substr(0,2),16),i[6]=parseInt(o.substr(2,2),16),i[7]=parseInt(o.substr(4,2),16),i[8]=parseInt(o.substr(6,2),16),i[9]=parseInt(o.substr(8,2),16),i[10]=parseInt(o.substr(10,2),16),i[11]=0,i[12]=0;var s=parseInt(16*Math.ceil((6+e.length)/16)),c=new Uint8Array(s),l=C.getTimeArr();c[0]=l[1],c[1]=l[2],c[2]=l[3],c[3]=l[4],c[4]=l[5],c[5]=l[6];for(var u=0;u<e.length;u++)c[6+u]=e[u];var f=C.Encrypt(C.ab2hex(c.buffer),n);for(u=0;u<f.byteLength;u++)i[13+u]=f[u];return i[13+f.byteLength]=C.GetXorCheck(i.slice(1,f.byteLength+13),f.byteLength+13),i[14+f.byteLength]=126,C.ShiftSend(i.slice(0,14+f.byteLength+1))}var E={setCommand:function(t,e){switch(t){case"HHD_JT_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return R(S,B,t)}return!1}(e);case"HHD_JT_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return R(r,a,t)}(e);case"HHD_JT_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),R(r,i,t)}(e);case"HHD_JT_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,R(r,n,t)}(e)}}},P=a(a({},D),E),M=Object.freeze({__proto__:null,default:P});var O={parseResponse:function(t,e){t=new Uint8Array(t),console.log("响应报文",C.ab2hex(t)),e=e.split("").map((function(t){return t.charCodeAt(0)}));var r={Code:6};try{var n=t.byteLength,i=t.slice(6,8);i=new DataView(C.mergeArrayBuffer([],i)).getUint16();var o=16*Math.ceil(i/16);if(o+11!=n)return r;if(C.SunCheck(t.slice(2,n-3),n-5)!=t[n-3])return r;var s=t.slice(8,n-3);console.log("解密前:",C.ab2hex(s));var c=C.Decrypt(C.ab2hex(s),e,o);if(console.log("解密后:",C.ab2hex(c)),!C.checkCrc(c,i))return r.Code=5,r;switch(c=c.slice(12,i),r.Code=c[0],C.ab2hex(t.slice(4,6)).toUpperCase()){case"0310":return r=a({},function(t){for(var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0),n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase()}catch(t){break}i[o]=e.getUint8(n+2),n+=2}return i}(c));case"0312":return r=a({},function(t){var e=new DataView(C.mergeArrayBuffer([],t),0),r=e.getUint8(0);console.log("ID总数:",r);for(var n=0,i={},a=0;a<r;a++){try{var o="0x"+C.Uint8ArrayToHex([e.getUint8(n+1)]).toUpperCase(),s=e.getUint8(n+2);console.log(o,"================")}catch(t){break}if("0x06"==o||"0x2A"==o||"0x42"==o){var c=0;c=e.getUint32(n+3),i[""+o]=c}else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x94"==o||"0x02"==o||"0x88"==o||"0x89"==o||"0x8A"==o||"0x8B"==o||"0x34"==o||"0x3E"==o||"0x82"==o){c=0;2==s&&(c=e.getUint16(n+3)),"0x8B"==o&&(c>0?c/=100:c=0),i[""+o]=c+""}else if("0x43"==o){var l={TimeforConsecIncorrPwdEntries:e.getUint8(n+3),NumberofConsecIncorrPwdEntries:e.getUint8(n+4)};i[""+o]=l}else if("0x40"==o){l={DurationOfInactivity:e.getUint16(n+3),ShortConnTransInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x90"==o){l={LowVoltageValue:e.getUint16(n+3),TransmissionInterval:e.getUint16(n+5)};i[""+o]=l}else if("0x24"==o||"0x0F"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4F"==o||"0x23"==o||"0x5D"==o||"0x5E"==o||"0x5F"==o||"0x5C"==o||"0x3B"==o||"0x4E"==o||"0x44"==o||"0x72"==o||"0x98"==o||"0x30"==o||"0x2B"==o||"0x1A"==o||"0x2E"==o||"0x31"==o||"0x4D"==o||"0x99"==o||"0xA3"==o||"0xB1"==o||"0xB2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x2C"==o||"0xC2"==o||"0xC3"==o||"0xC4"==o||"0xC6"==o||"0xFE"==o||"0x75"==o){c=0;1==s&&(c=e.getUint8(n+3)),i[""+o]=c+""}else if("0x41"==o||"0x4B"==o){for(var u=[],f=s/7,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+7*h+3,n+7*h+10)));i[""+o]=u}else if("0x45"==o){for(u=[],f=s/6,h=0;h<f;h++)u.push(C.ab2hex(t.slice(n+6*h+3,n+6*h+9)));i[""+o]=u}else if("0xFC"==o)i[""+o]=C.ab2hex(t.slice(n+3,n+9));else if("0x28"==o||"0xC7"==o||"0xC8"==o){c=t.slice(n+3,n+3+s);c=C.ab2hex(c),i[""+o]=c}else if("0x15"==o||"0x9A"==o){c=t.slice(n+3,n+3+s);parseInt(c[0])>=49?i[""+o]=C.Uint8ArrayToString(c):(c=C.ab2hex(c),i[""+o]=c)}else if("0x3F"==o){for(u=[],h=0;h<s;h+=18){var g={};c=t.slice(n+3+h,n+3+h+6);try{g.LoraTHSensor=C.Uint8ArrayToString(c)}catch(t){g.LoraTHSensor=C.ab2hex(c)}g.THSensorName=e.getUint16(n+3+h+6),g.TempUpperLimit=e.getUint16(n+3+h+8),g.TempLowerLimit=e.getUint16(n+3+h+10),g.ContOverHeatTIME=e.getUint8(n+3+h+12),g.HumUpperLimit=e.getUint8(n+3+h+13),g.HumLowerLimit=e.getUint16(n+3+h+14),g.ContSuperWetTIME=e.getUint16(n+3+h+16),u.push(g)}i[""+o]=u}else if("0x70"==o){(u={}).ConnectionStatus=e.getUint8(n+3),u.BaseStationCSQValue=e.getUint8(n+4),u.LastOnlineDuration=e.getUint32(n+5),u.ExternalStorageStatus=e.getUint8(n+9),u.RemTrackBlindSpots=32767&e.getUint16(n+10),u.RemEventBlindSpots=32767&e.getUint16(n+12),u.TrackBlindSpotD=e.getUint16(n+10)>>15&1?1:0,u.EventBlindSpotD=e.getUint16(n+12)>>15&1?1:0,i[""+o]=u}else if("0x71"==o){(u={}).RealTimeSensorStatus=e.getUint8(n+3),u.RealTimeLocationStatus=e.getUint8(n+4),u.RealTimeLocAntennaStatus=e.getUint8(n+5),u.RealTimePDOP=e.getUint16(n+6)/10,u.RealTimeLongitude=e.getUint32(n+8)/1e6,u.RealTimeLatitude=e.getUint32(n+12)/1e6,u.TotalNumberOfSatellites=e.getUint8(n+16),u.NumberOfBDSSatellites=e.getUint8(n+17),u.NumberOfGPSSatellites=e.getUint8(n+18),u.CNValuesOfTheTop10Strongest=e.getUint8(n+19)+","+e.getUint8(n+20)+","+e.getUint8(n+21)+","+e.getUint8(n+22)+","+e.getUint8(n+23)+","+e.getUint8(n+24)+","+e.getUint8(n+25)+","+e.getUint8(n+26)+","+e.getUint8(n+27)+","+e.getUint8(n+28),i[""+o]=u}else if("0x72"==o){c=[];u.push(e.getUint8(n+3)),i[""+o]=c.join(";")}else if("0x76"==o){(u={}).CardStatus=e.getUint8(n+3)+"",u.CardTotalCapacity=e.getUint32(n+4),u.CardUsedCapacit=e.getUint32(n+8),u.AvailableCapacity=e.getUint32(n+12),i[""+o]=u}else if("0x9C"==o){for(u=[],f=s/10,h=0;h<f;h++){var p={};p.StartMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+3,n+10*h+6)),p.EndMinuteSecondBCD=C.ab2hex(t.slice(n+10*h+6,n+10*h+9)),p.DeviceReturnInterval=e.getUint32(n+10*h+9),u.push(p)}i[""+o]=u}else if("0x91"==o){for(u=[],f=s/22,h=0;h<f;h++){var d={};d.StartDate=C.ab2hex(t.slice(n+22*h+3,n+22*h+10)),d.EndDate=C.ab2hex(t.slice(n+22*h+10,n+22*h+17)),d.ReturnInterval=e.getUint32(n+22*h+17),d.StaticTimingThreshold=e.getUint16(n+22*h+21),d.StaticReturnInterva=e.getUint16(n+22*h+23),u.push(d)}i[""+o]=u}else if("0x95"==o){var v=e.getUint32(n+3);u={RedLockRodDestroyAlarm:1&v?1:"0",RedShellDamageAlarm:v>>1&1?1:"0",RedLowBatteryAlarm:v>>2&1?1:"0",RedMcuAbnormalAlarm:v>>3&1?1:"0",RedCutLockRodAlarm:v>>4&1?1:"0",RedOpenCircuitAlarm:v>>5&1?1:"0",RedShortCircuitAlarm:v>>6&1?1:"0",RedSealStickAlarm:v>>7&1?1:"0",RedUnsealStickAlarm:v>>8&1?1:"0",RedOverspeedAlarm:v>>9&1?1:"0",RedTimeoutAlarm:v>>10&1?1:"0",RedGnssDownAlarm:v>>11&1?1:"0",RedPowerDownAlarm:v>>12&1?1:"0"};i[""+o]=u}else if("0x96"==o){var x=e.getUint32(n+3);u={RedAccStatus:(1&x)+"",RedGPSPositionStatus:(x>>1&1)+"",RedLatitudePosition:(x>>2&1)+"",RedLongitudePosition:(x>>3&1)+"",RedLinkMode:(x>>4&1)+"",RedLocationModuleStatus:(x>>5&1)+"",RedMotionSensorStatus:(x>>6&1)+"",RedDeviceSwitchState:(x>>14&1)+"",RedLockRodStatus:(x>>15&1)+"",RedChargeStatus:(x>>17&1)+""+(x>>16&1),RedNetworkMode:(x>>19&1)+""+(x>>18&1),RedSimMode:(x>>21&1)+""+(x>>20&1)};i[""+o]=u}else if("0x97"==o){(u={}).RedLatitude=e.getUint32(n+3)/1e6,u.RedLongitude=e.getUint32(n+7)/1e6,u.RedElevation=e.getUint16(n+11),u.RedSpeed=e.getUint16(n+13),u.RedDirection=e.getUint16(n+15),i[""+o]=u}else if("0x26"==o||"0x39"==o||"0x48"==o||"0x93"==o||"0x92"==o){var y=t.slice(n+3,n+3+s);if(parseInt(y[0])>=49)i[""+o]=C.Uint8ArrayToString(y);else{for(var U="",m=0;m<y.length;m++)U+=y[m];i[""+o]=U}}else if("0xA4"==o){(u={}).FaultBoxID=e.getUint8(n+3),u.DisableBoxID=e.getUint16(n+4),i[""+o]=u}else if("0xA5"==o){(u={}).IlluminationStartTime=C.ab2hex(t.slice(n+3,n+5)),u.IlluminationEndTime=C.ab2hex(t.slice(n+5,n+7)),i[""+o]=u}else if("0xA6"==o){u=[];for(var w=0;w<parseInt(s/2);w++)u.push(e.getUint16(n+3+2*w));i[""+o]=u}else if("0xB0"==o){(u={}).TempSensorEnableFlag=e.getUint8(n+3),u.TempAlarmThreshold=e.getUint16(n+4),i[""+o]=u}else if("0x22"==o){(u={}).TrackBlindSpotData=e.getUint8(n+3),u.EventBlindSpotData=e.getUint16(n+4),i[""+o]=u}else if("0x62"==o){(u={}).RemoteShootChannelNo=e.getUint8(n+3),u.ShootingDuration=e.getUint8(n+3),i[""+o]=u}else if("0x32"==o){(u={}).TempMinLimit=e.getInt16(n+3)/10,u.TempMaxLimit=e.getInt16(n+5)/10,i[""+o]=u}else if("0x33"==o){(u={}).HumMinLimit=e.getUint16(n+3)/10,u.HumMaxLimit=e.getUint16(n+5)/10,i[""+o]=u}else if("0x6A"==o){(u={}).RecordingActivationMode=e.getUint8(n+3)+"",u.FrameRate=e.getUint8(n+3),u.VideoQuality=e.getUint8(n+3)+"",i[""+o]=u}else if("0x77"==o){y=t.slice(n+3,n+3+s);var _=C.Uint8ArrayToString(y);u={};_&&(_=_.split(","),u.simId=_[0],u.apnName=_[1],u.apnUserName=_[2],u.apnPassword=_[3],u.apnAuth=_[4],u.regisNetStatus=_[5]),i[""+o]=u}else{y=t.slice(n+3,n+3+s);i[""+o]=C.Uint8ArrayToString(y)}n+=2+s}return i}(c)),r;case"0214":return r;case"0216":return r=a(a({},r),function(t){var e=1,r=new DataView(C.mergeArrayBuffer([],t),0);r.getUint8(e),e+=1;var n=r.getUint16(e);e+=2,r.getUint16(e),e+=2;for(var i=[],a=0;a<n;a++){var o=t.slice(e+2,e+2+4);i.push(C.Uint8ArrayToHex(o).replace(/\s*/g,"")),e+=6}return{CardList:i}}(c))}}catch(t){return console.log("==--",t),r}}};function N(t,e,r){var n;n=r.aesPassword.split("").map((function(t){return t.charCodeAt(0)}));var i=new Uint8Array(2e3);i[0]=241,i[1]=31,i[2]=255,i[3]=238,i[4]=t[0],i[5]=t[1],i[6]=e.length>>8,i[7]=e.length;for(var a=0;a<e.length;a++)i[8+a]=e[a];var o=parseInt(16*Math.ceil((12+e.length)/16)),s=new Uint8Array(o),c=C.Crc16_Ccitt(i.slice(8,8+e.length),e.length);s[0]=c>>8,s[1]=c;var l=C.getTimeArr();s[2]=l[1],s[3]=l[2],s[4]=l[3],s[5]=l[4],s[6]=l[5],s[7]=l[6],s[8]=49,s[9]=50,s[10]=51,s[11]=52;for(a=0;a<e.length;a++)s[12+a]=e[a];var u=C.Encrypt(C.ab2hex(s.buffer),n);for(a=0;a<u.byteLength;a++)i[8+a]=u[a];return i[6]=e.length+12>>8,i[7]=e.length+12,i[u.byteLength+8]=C.SunCheck(i.slice(2,u.byteLength+8),u.byteLength+6),i[u.byteLength+9]=242,i[u.byteLength+10]=47,i.slice(0,u.byteLength+11)}var z={setCommand:function(t,e){switch(t){case"HHD_G_0310":return function(t){var e=t.setData,r=0,n=0,i=new ArrayBuffer(2e3),a=new DataView(i,0);for(var o in e){var s=e[o];if(o=o.toLowerCase(),a.setUint8(r+1,parseInt(o)),"0x06"==o||"0x2a"==o||"0x42"==o)a.setUint8(r+2,4),a.setUint32(r+3,parseInt(s)),r+=6;else if("0x08"==o||"0x11"==o||"0x14"==o||"0x17"==o||"0x27"==o||"0x80"==o||"0x81"==o||"0x02"==o||"0x82"==o||"0x66"==o||"0x88"==o||"0x89"==o||"0x8a"==o||"0x8b"==o||"0x34"==o||"0x94"==o||"0x3e"==o)"0x8b"==o&&(s=100*parseInt(s)),a.setUint8(r+2,2),a.setUint16(r+3,parseInt(s)),r+=4;else if("0x0f"==o||"0x10"==o||"0x16"==o||"0x18"==o||"0x19"==o||"0x20"==o||"0x37"==o||"0x4f"==o||"0x23"==o||"0x5d"==o||"0x5e"==o||"0x5f"==o||"0x3b"==o||"0x4e"==o||"0x5c"==o||"0x98"==o||"0x2c"==o||"0x1a"==o||"0x2e"==o||"0x31"==o||"0x65"==o||"0x68"==o||"0x6b"==o||"0xfe"==o||"0x4d"==o||"0x99"==o||"0x9b"==o||"0x75"==o||"0xa3"==o||"0xb1"==o||"0xb2"==o||"0x50"==o||"0x51"==o||"0x83"==o||"0x85"==o||"0x86"==o||"0x52"==o||"0x53"==o||"0x30"==o||"0xc2"==o||"0xc3"==o||"0xc4"==o||"0xc6"==o)a.setUint8(r+2,1),a.setUint8(r+3,parseInt(s)),r+=3;else if("0x15"==o||"0x9a"==o||"0xfc"==o||"0x28"==o||"0xc7"==o||"0xc8"==o||"0x92"==o){var c=C.HexToUint8Array(s);a.setUint8(r+2,c.length);for(var l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);r+=c.length+2}else if("0x24"==o||"0x46"==o){var u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName)),a.setUint8(r+2,u.length+1),a.setUint8(r+3,s.cmd);for(var f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);r+=u.length+3}else if("0x45"==o){var h=s;a.setUint8(r+2,6*h.length);for(l=0;l<h.length;l++){c=C.HexToUint8Array(h[l]);for(var g=0;g<c.length;g++)a.setUint8(r+3+g+6*l,c[g])}r+=6*h.length+2}else if("0x47"==o||"0x49"==o){h=s.deviceCodeList;a.setUint8(r+3,h.length);var p=0;for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+4+p,c[g]),p++;var d=0;if(s.userName){d=(u=C.stringToUint8Arraytwo(s.userName)).length;for(f=0;f<u.length;f++)a.setUint8(r+4+f+p,u[f])}a.setUint8(r+2,p+1+d),r+=p+3+d}else if("0x4a"==o){var v=s.deviceCodeList,x=0;a.setUint8(r+3,v.length),x+=1;var y=0;for(l=0;l<v.length;l++){for(c=C.HexToUint8Array(v[l]),g=0;g<c.length;g++)a.setUint8(r+4+g+y,c[g]);y+=6}switch(x+=y,s.Cmd){case"0x01":a.setUint8(r+3+x,1),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x03":a.setUint8(r+3+x,3),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0F":a.setUint8(r+3+x,15),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3;break;case"0x13":a.setUint8(r+3+x,19),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0x0B":a.setUint8(r+3+x,11),a.setUint8(r+3+x+1,2),a.setUint16(r+3+x+2,parseInt(Number(s.CmdValue))),x+=4;break;case"0xF0":a.setUint8(r+3+x,240),a.setUint8(r+3+x+1,1),a.setUint8(r+3+x+2,parseInt(Number(s.CmdValue))),x+=3}u=[];s.userName&&(u=C.stringToUint8Arraytwo(s.userName));var U=u.length;for(f=0;f<U;f++)a.setUint8(r+3+x+f,u[f]);x+=U,a.setUint8(r+2,x),r+=r+x+2}else if("0x41"==o||"0x4b"==o){h=s;a.setUint8(r+2,7*h.length);for(l=0;l<h.length;l++)for(c=C.HexToUint8Array(h[l]),g=0;g<c.length;g++)a.setUint8(r+3+g+7*l,c[g]);r+=7*h.length+2}else if("0x3f"==o){a.setUint8(r+2,18*s.length);g=0;s.forEach((function(t){var e;e=6==t.LoraTHSensor.length?C.stringToUint8Arraytwo(t.LoraTHSensor):e=C.HexToUint8Array(t.LoraTHSensor);for(var n=0;n<e.length;n++)a.setUint8(r+3+g+n,e[n]);a.setUint16(r+g+9,parseInt(t.THSensorName)),a.setUint16(r+g+11,parseInt(t.TempUpperLimit)),a.setUint16(r+g+13,parseInt(t.TempLowerLimit)),a.setUint8(r+g+15,parseInt(t.ContOverHeatTIME)),a.setUint8(r+g+16,parseInt(t.HumUpperLimit)),a.setUint16(r+g+17,parseInt(t.HumLowerLimit)),a.setUint16(r+g+19,parseInt(t.ContSuperWetTIME)),g+=18})),r+=2+g}else if("0x6c"==o){a.setUint8(r+2,2);h=s.split(",");a.setUint8(r+3,parseInt(h[0])),a.setUint8(r+4,parseInt(h[1])),r+=4}else if("0x62"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.RemoteShootChannelNo)),a.setUint8(r+4,parseInt(s.ShootingDuration)),r+=4;else if("0x22"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TrackBlindSpotData)),a.setUint8(r+4,parseInt(s.EventBlindSpotData)),r+=4;else if("0x43"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.TimeforConsecIncorrPwdEntries)),a.setUint8(r+4,parseInt(s.NumberofConsecIncorrPwdEntries)),r+=4;else if("0x40"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.DurationOfInactivity)),a.setUint16(r+5,parseInt(s.ShortConnTransInterval)),r+=6;else if("0x90"==o)a.setUint8(r+2,4),a.setUint16(r+3,parseInt(s.LowVoltageValue)),a.setUint16(r+5,parseInt(s.TransmissionInterval)),r+=6;else if("0x91"==o){h=s;a.setUint8(r+2,22*h.length);for(l=0;l<h.length;l++){var m=h[l];for(c=C.HexToUint8Array(m.StartDate+m.EndDate),g=0;g<c.length;g++)a.setUint8(r+3+g+22*l,c[g]);a.setUint32(r+17+22*l,parseInt(m.ReturnInterval)),a.setUint16(r+21+22*l,parseInt(m.StaticTimingThreshold)),a.setUint16(r+23+22*l,parseInt(m.StaticReturnInterva))}r+=22*h.length+2}else if("0xa0"==o){a.setUint8(r+3,parseInt(s.BindingBoxSlotNO));for(c=C.HexToUint8Array(s.BindingELockBleMAC),g=0;g<c.length;g++)a.setUint8(r+4+g,c[g]);for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+c.length+f,u[f]);var w=1+c.length+u.length;a.setUint8(r+2,w),r+=w+2}else if("0xa1"==o){a.setUint8(r+3,parseInt(s.RemoteBoxOpenChannelNo));for(u=C.stringToUint8Arraytwo(s.userName),f=0;f<u.length;f++)a.setUint8(r+4+f,u[f]);var _=1+u.length;a.setUint8(r+2,_),r+=_+2}else if("0xa2"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.SetSlotNO)),a.setUint16(r+4,parseInt(s.SetFullChargeCurrValue)),r+=5;else if("0xa4"==o)a.setUint8(r+2,2),a.setUint8(r+3,parseInt(s.FaultBoxID)),a.setUint8(r+4,parseInt(s.DisableBoxID)),r+=4;else if("0xa5"==o){a.setUint8(r+2,4);var b=C.HexToUint8Array(s.IlluminationStartTime);for(g=0;g<b.length;g++)a.setUint8(r+3+g,b[g]);var A=C.HexToUint8Array(s.IlluminationEndTime);for(g=0;g<A.length;g++)a.setUint8(r+3+b.length+g,A[g]);r+=6}else if("0xb0"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.TempSensorEnableFlag)),a.setUint16(r+4,parseInt(s.TempAlarmThreshold)),r+=5;else if("0x32"==o)a.setUint8(r+2,4),a.setInt16(r+3,10*Number(s.TempMinLimit)),a.setInt16(r+5,10*Number(s.TempMaxLimit)),r+=6;else if("0x33"==o)a.setUint8(r+2,4),a.setUint16(r+3,10*Number(s.HumMinLimit)),a.setUint16(r+5,10*Number(s.HumMaxLimit)),r+=6;else if("0x6a"==o)a.setUint8(r+2,3),a.setUint8(r+3,parseInt(s.RecordingActivationMode)),a.setUint8(r+4,parseInt(s.FrameRate)),a.setUint8(r+5,parseInt(s.VideoQuality)),r+=5;else{for(c=C.stringToUint8Arraytwo(s),l=0;l<c.length;l++)a.setUint8(r+3+l,c[l]);a.setUint8(r+2,c.length),r+=2+c.length}n++}if(0==n)return;if(a.setUint8(0,n),n>0){var S=new Uint8Array(2);S[0]=3,S[1]=16;var B=new Uint8Array(r+1);for(l=0;l<r+1;l++)B[l]=a.getUint8(l);return console.log("原始报文",C.ab2hex(B)),N(S,B,t)}return!1}(e);case"HHD_G_0312":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=3,r[1]=18;var n=0;for(var i in e)n++;var a=new Uint8Array(n+1);a[0]=n;var o=0;for(var i in e)a[1+o]=e[i],o++;return N(r,a,t)}(e);case"HHD_G_0214":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=20;var n=e.CardLists,i=new Uint8Array(6*n.length+1),a=0,o=e.address;return i[0]=o,n.forEach((function(t,e){if(i[a+1]=e+100*o>>8,i[a+2]=e+100*o,0!=t)for(var r=C.HexToUint8Array(t),n=0;n<4;n++)i[a+3+n]=r[n];a+=6})),N(r,i,t)}(e);case"HHD_G_0216":return function(t){var e=t.setData,r=new Uint8Array(2);r[0]=2,r[1]=22;var n=new Uint8Array(1);return n[0]=e.address,N(r,n,t)}(e)}}},F=a(a({},O),z),j=Object.freeze({__proto__:null,default:F}),V=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modules={Block:!1!==e.Block?H:null,JTGlock:!1!==e.JTGlock?P:null,Glock:!1!==e.Glock?F:null},this.version="__VERSION__"},n=[{key:"loadModule",value:(a=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.modules[e]){t.next=16;break}t.t0=e,t.next="Block"===t.t0?4:"JTGlock"===t.t0?8:"Glock"===t.t0?12:16;break;case 4:return t.next=6,Promise.resolve().then((function(){return L}));case 6:return this.modules.Block=t.sent.default,t.abrupt("break",16);case 8:return t.next=10,Promise.resolve().then((function(){return M}));case 10:return this.modules.JTGlock=t.sent.default,t.abrupt("break",16);case 12:return t.next=14,Promise.resolve().then((function(){return j}));case 14:return this.modules.Glock=t.sent.default,t.abrupt("break",16);case 16:return t.abrupt("return",this.modules[e]);case 17:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,r=arguments;return new Promise((function(n,i){var o=a.apply(t,r);function s(t){e(o,n,i,s,c,"next",t)}function c(t){e(o,n,i,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"Block",get:function(){return this.modules.Block}},{key:"JTGlock",get:function(){return this.modules.JTGlock}},{key:"Glock",get:function(){return this.modules.Glock}}],n&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,a,s}();return V}();
|