Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ArtcGuiZhouAPI.js 3.9KB

1
  1. const _0x3950=['forceDisconnectBleDev','postCommand','getBleDeviceInfo','已断开','透传通道参数错误','onScanResult','exports','DISCONNECT_OK','msg','ETC','BleStatusResult','disconnectBle','data','startScanBleDevice','connectBleDev','code','DISCONNECT_FAIL','执行成功'];const _0x39ed=function(_0x3950c8,_0x39eda8){_0x3950c8=_0x3950c8-0x0;let _0x1bb899=_0x3950[_0x3950c8];return _0x1bb899;};import _0x1ba307,{handshake}from'./ArtcBleUtil';import{ArtcBleStatusCodes,ArtcStatusDescriptions}from'./ReturnStatusCode';function scanBle(_0x245fd2,_0xc82da){_0x1ba307[_0x39ed('0xd')](_0x39ed('0x9'),_0x245fd2,_0x26b59c=>{if(_0x26b59c[_0x39ed('0xf')]===ArtcBleStatusCodes['OK']){_0xc82da[_0x39ed('0x5')](_0x26b59c['data']);}},_0x21cbbe=>{_0xc82da['onIsEnable'](new _0x1ba307['BleStatusResult'](_0x21cbbe[_0x39ed('0xf')],_0x21cbbe[_0x39ed('0x8')]));});}function closBluetooth(_0x4dd7ad){_0x1ba307['stopScanBleDevice'](_0x560813=>{_0x4dd7ad(_0x560813);});}function connectDevice(_0x413b07,_0x2f3547,_0x41bf7f){_0x1ba307[_0x39ed('0xe')](_0x413b07,{'success':_0x4d95c1=>{if(_0x4d95c1['code']===ArtcBleStatusCodes['OK']){_0x2f3547(new _0x1ba307['BleStatusResult'](_0x4d95c1['code'],_0x4d95c1[_0x39ed('0xc')]));_0x41bf7f(new _0x1ba307[(_0x39ed('0xa'))](_0x4d95c1['code'],'已连接'));}else{_0x41bf7f(new _0x1ba307['BleStatusResult'](_0x4d95c1['code'],_0x4d95c1[_0x39ed('0xc')]));}},'fail':_0xb623b8=>{_0x41bf7f(new _0x1ba307['BleStatusResult'](_0xb623b8[_0x39ed('0xf')],_0xb623b8['data']));}});}function disconnectDevice(_0x4f0e5c){_0x1ba307[_0x39ed('0xb')](_0x4b6fe3=>{if(_0x4b6fe3[_0x39ed('0xf')]===ArtcBleStatusCodes[_0x39ed('0x7')]){_0x4f0e5c(new _0x1ba307['BleStatusResult'](_0x4b6fe3['code'],_0x4b6fe3['msg']));}else{_0x4f0e5c(_0x4b6fe3);}});}function transCmd(_0x576528,_0x240f1f,_0x1cd795){let _0x1c0d39=0x1;if(_0x240f1f==='10'){_0x1c0d39=0x0;}else if(_0x240f1f==='20'){_0x1c0d39=0x1;}else{_0x1cd795(new _0x1ba307['BleStatusResult'](ArtcBleStatusCodes['Argument_ERROR'],_0x39ed('0x4')));return;}_0x1ba307[_0x39ed('0x1')](_0x1c0d39,_0x576528,{'success':_0x35259d=>{_0x1cd795(new _0x1ba307['BleStatusResult'](_0x35259d[_0x39ed('0xf')],'执行成功',_0x35259d['data']));},'fail':_0x5a7879=>{_0x1cd795(new _0x1ba307[(_0x39ed('0xa'))](_0x5a7879['code'],_0x5a7879[_0x39ed('0xc')]));}},0xf*0x3e8);}function devCmd(_0x2d97a5,_0x9f7678){if(typeof _0x2d97a5!=='string'&&_0x2d97a5%0x2!==0x0){_0x9f7678(new _0x1ba307[(_0x39ed('0xa'))](ArtcBleStatusCodes['Argument_ERROR'],'指令参数错误'));return;}_0x1ba307[_0x39ed('0x2')](_0x2d97a5,{'success':_0x444ae4=>{_0x9f7678(new _0x1ba307[(_0x39ed('0xa'))](_0x444ae4['code'],_0x39ed('0x11'),_0x444ae4['data']));},'fail':_0x1d9a99=>{_0x9f7678(new _0x1ba307[(_0x39ed('0xa'))](_0x1d9a99[_0x39ed('0xf')],_0x1d9a99['data']));}});}function handshakeETC(_0x655494){_0x1ba307['handshake']({'success':_0x555e5c=>{_0x655494(new _0x1ba307['BleStatusResult'](_0x555e5c[_0x39ed('0xf')],'执行成功',_0x555e5c['data']));},'fail':_0x5481bf=>{_0x655494(new _0x1ba307[(_0x39ed('0xa'))](_0x5481bf['code'],_0x5481bf[_0x39ed('0xc')]));}});}function disconnectDeviceBluetooth(_0xa63955){_0x1ba307['bleConnectionState']({});const _0x5a5c31=setTimeout(()=>{_0xa63955(new _0x1ba307[(_0x39ed('0xa'))](ArtcBleStatusCodes[_0x39ed('0x10')],'断开失败'));},0xc*0x3e8);_0x1ba307[_0x39ed('0x0')](_0x5ab57b=>{if(_0x5ab57b===ArtcBleStatusCodes['DISCONNECT_OK']){clearTimeout(_0x5a5c31);_0xa63955(new _0x1ba307[(_0x39ed('0xa'))](_0x5ab57b,_0x39ed('0x3')));}});}function bleDisconnectStatusListener(_0x554239){_0x1ba307['bleConnectionState'](_0x18e959=>{if(_0x18e959===ArtcBleStatusCodes['DISCONNECT_OK']){_0x554239(new _0x1ba307[(_0x39ed('0xa'))](_0x18e959,'连接断开'));}});}module[_0x39ed('0x6')]={'scanBle':scanBle,'closBluetooth':closBluetooth,'connectDevice':connectDevice,'disconnectDevice':disconnectDevice,'transCmd':transCmd,'disconnectDeviceBluetooth':disconnectDeviceBluetooth,'devCmd':devCmd,'handshakeETC':handshakeETC};