Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qcloud-iotexplorer-bluetooth-adapter-llsync

Package Overview
Dependencies
Maintainers
5
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qcloud-iotexplorer-bluetooth-adapter-llsync - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2-alpha.0

2

lib/base/LLSync/LLSyncDeviceAdapter.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StandardDeviceAdapter=exports.LLSyncDeviceAdapter=void 0;var tslib_1=require("tslib"),constants=tslib_1.__importStar(require("../../constants")),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants_1=require("../../constants"),libs_1=require("../../libs"),utils=tslib_1.__importStar(require("../../libs")),Models_1=require("./Models"),LLSyncDeviceAdapterBase_1=require("../LLSyncDeviceAdapterBase"),LLSyncOtaProcessor_1=require("./LLSyncOtaProcessor"),LLSyncProtocol_1=require("./LLSyncProtocol"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,arrayBufferToHexStringArray=_a.arrayBufferToHexStringArray,envDetect=_a.envDetect,delay=_a.delay,convertToMs=function(e){if("number"!=typeof e)throw new Error("timestamp should be a number");return e.toString().length>=13?e:1e3*e},WRITE_TO_DEVICE_CONF={timeout:LLSyncProtocol_1.LLSyncConfig.waitGetRegisterDeviceInfo,timeoutCode:constants.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID},LLSyncDeviceAdapter=function(e){function t(r){var n=e.call(this,r)||this;n._enableWsEventHandle=!0,n._enableLLEventHandle=!0;var s=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return tslib_1.__awaiter(n,void 0,void 0,(function(){return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,this.init()];case 1:return r.sent(),[2,e.apply(void 0,tslib_1.__spread(t))]}}))}))}};n.models=new Models_1.Models(t.options.appDevSdk),n.userIdentify=t.getUserIdentify(),n.on("disconnect",(function(){n.authorized=!1})),n.appDevSdk=t.options.appDevSdk,n.protocol=new LLSyncProtocol_1.LLSyncProtocol(n),n.otaProcessor=new LLSyncOtaProcessor_1.LLSyncOtaProcessor(n),Object.assign(n,{bindDevice:s(n.bindDevice.bind(n)),unbindDevice:s(n.unbindDevice.bind(n)),controlDevice:s(n.controlDevice.bind(n)),controlAction:s(n.controlAction.bind(n)),authenticateConnection:s(n.authenticateConnection.bind(n)),reconnectDevice:s(n.authenticateConnection.bind(n)),startOta:s(n.startOta.bind(n)),cancelOta:s(n.cancelOta.bind(n)),userCancelBindDevice:s(n.protocol.cancelUserCheck.bind(n.protocol,"cancel"))}),n.init(),n.reporter={info:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.message,i=void 0===s?"":s,o=r.serviceId,c=tslib_1.__rest(r,["message","serviceId"]),a=n,d=a.explorerDeviceId,l=a.deviceId,u=a.isConnected;t.options.appDevSdk.reporter.info(constants_1.REPORT_EVENT_TYPE,{serviceId:o||t.serviceId,message:i||(e&&constants.ACTION_DESC[e]?e+"("+constants.ACTION_DESC[e]+")":e),timeCost:c.timeCost||0,action:e,data:tslib_1.__assign({deviceId:d,bleDeviceId:l,isConnected:u},c)})},error:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.error,i=tslib_1.__rest(r,["error"]),o=n,c=o.explorerDeviceId,a=o.deviceId,d=o.isConnected;s&&s.code&&constants.ERROR_MESSAGES[s.code]&&(s.msg=constants.ERROR_MESSAGES[s.code]),t.options.appDevSdk.reporter.error(constants_1.REPORT_EVENT_TYPE,{message:constants.ERROR_MESSAGES[e]?e+"("+constants.ERROR_MESSAGES[e]+":"+(s&&(s.message||s.errMsg||s.msg||s.code))+")":"",timeCost:i.timeCost||0,action:e,error:s,data:tslib_1.__assign(tslib_1.__assign({deviceId:c,bleDeviceId:a,isConnected:d},i),s)})}};var i=function(e){var t=e.deviceId,r=e.deviceData;if(n._enableWsEventHandle&&(console.log("llsync receive onControl",t,r,n.ready,n.explorerDeviceId),n.ready&&t===n.explorerDeviceId)){var s={};Object.keys(r).forEach((function(e){s[e]=r[e].Value})),n.controlDevice({deviceData:s})}},o=function(e){var t=e.deviceId,r=e.Payload;n._enableWsEventHandle&&n.ready&&t===n.explorerDeviceId&&n.controlAction({actionData:r})};return n.on("authorized",(function(){n.init(!0),n.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,i),n.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,o)})).on("disconnect",(function(){n.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,i),n.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,o)})),n}return tslib_1.__extends(t,e),t.getUserIdentify=function(){var e,r,n,s;return libs_1.getUserIdentify(null===(s=null===(n=null===(r=null===(e=t.options)||void 0===e?void 0:e.appDevSdk)||void 0===r?void 0:r.loginManager)||void 0===n?void 0:n.userInfo)||void 0===s?void 0:s.UserID)},t.injectOptions=function(e){e.appDevSdk.reporter&&e.appDevSdk.requestApi||console.warn("invalid appDevSdk",e.appDevSdk),t.options=e},Object.defineProperty(t.prototype,"ready",{get:function(){return console.log("isConnected",this.isConnected,"isAuthorized",this.authorized),this.isConnected&&this.authorized},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"needUserCheck",{get:function(){var e,t,r;try{return!!parseInt((null===(r=null===(t=null===(e=null==this?void 0:this.productConfig)||void 0===e?void 0:e.BleConfig)||void 0===t?void 0:t.bindingBootConfig)||void 0===r?void 0:r.confirmRequired)||"0")}catch(e){return console.warn("LLSync check confirmRequired fail",e),!1}},enumerable:!1,configurable:!0}),t.prototype.normalizeError=function(t){return!(t=e.prototype._normalizeError.call(this,t)).msg&&t.code&&constants.ERROR_MESSAGES[t.code]&&(t.msg=constants.ERROR_MESSAGES[t.code]),t},t.prototype.init=function(r){return tslib_1.__awaiter(this,void 0,void 0,(function(){var n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:if(!t.options)throw"标准蓝牙适配器未初始化Options";return[4,e.prototype.init.call(this)];case 1:return s.sent(),r&&(this.productInfo=this.productConfig=this._initPromise=null),[2,this._initPromise||(this._initPromise=new Promise((function(e,t){return tslib_1.__awaiter(n,void 0,void 0,(function(){var r,n,s,i,o,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),n=(r=this).productConfig,s=r.productInfo,[4,Promise.all([n?Promise.resolve(n):this.models.getProduct({ProductId:this.productId}),s?Promise.resolve(s):this.models.getProductConfig({ProductId:this.productId})])];case 1:return i=tslib_1.__read.apply(void 0,[d.sent(),2]),o=i[0],c=i[1],this.dataTemplate=libs_1.getProductDateTemplate(o),this.productInfo=o,this.productConfig=c,console.log("init llsync done",{productInfo:this.productInfo,productConfig:this.productConfig,dataTemplate:this.dataTemplate}),e(),[3,3];case 2:return a=d.sent(),console.error("init standard device adapter fail",a),t(a),this._initPromise=null,[3,3];case 3:return[2]}}))}))})))]}}))}))},t.prototype.getDevicePsk=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return t={DeviceId:this.productId+"/"+(e||this.deviceName),DeviceKey:LLSyncProtocol_1.LLSyncConfig.BLE_PSK_DEVICE_KEY},[4,Promise.all([this.models.getDeviceConfig(tslib_1.__assign(tslib_1.__assign({},t),{isUserConfig:!0})),this.models.getDeviceConfig(t)])];case 1:if(r=tslib_1.__read.apply(void 0,[c.sent(),2]),n=r[0],s=r[1],!n||s)return[3,5];c.label=2;case 2:return c.trys.push([2,4,,5]),[4,this.models.setDeviceConfig({DeviceId:t.DeviceId,DeviceKey:t.DeviceKey,DeviceValue:n})];case 3:return c.sent(),[3,5];case 4:return i=c.sent(),console.error("update psk to DeviceConfig fail",i),[3,5];case 5:if(!(o=s||n))throw{code:constants.PSK_GET_ERROR};return[2,o]}}))}))},t.prototype.startOta=function(e){var t=e.onProgress;return this.otaProcessor.startOta({onProgress:t})},t.prototype.cancelOta=function(){return this.otaProcessor.cancelOta()},t.prototype.startListenLLEvents=function(){this.on(constants.PROPERTY_REPORT,utils.wrapEventHandler(this.onPropertyReport.bind(this),constants.PROPERTY_REPORT)),this.on(constants.GET_STATUS,this.onGetStatus.bind(this)),this.on(constants.EVENT_REPORT,utils.wrapEventHandler(this.onEventReport.bind(this),constants.EVENT_REPORT))},t.prototype.stopListenLLEvents=function(){this.off(constants.PROPERTY_REPORT),this.off(constants.GET_STATUS),this.off(constants.EVENT_REPORT)},t.prototype.setWsEventHandleEnabled=function(e){this._enableWsEventHandle=e},t.prototype.setLLEventHandleEnabled=function(e){this._enableLLEventHandle=e},t.prototype.onPropertyReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:if(!this._enableLLEventHandle)return[2];try{console.log("onPropertyReport check this",this),t=utils.convertPropertiesTlvToJsObject(e.slice(2),this.dataTemplate),this.reporter.info(constants.REPORT_RESULT,{data:utils.formatArrayToReportString(e),jsObj:t}),this.emit("propertyReport",{deviceData:t})}catch(e){return this.reporter.error(constants.REPORT_RESULT_ERROR,{error:e}),this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.ParseDataFail),[2]}o.label=1;case 1:return o.trys.push([1,3,,4]),r=t["_sys _timestamp"],[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:r?convertToMs(r):Date.now()})];case 2:if(n=o.sent().Data){if((s=JSON.parse(n)).code)throw{code:constants.PROPERTY_REPORT_API_FAIL,reportReplyCode:s.code};this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.Success)}return[3,4];case 3:return i=o.sent(),this.reporter.error(constants.REPORT_RESULT_ERROR,{error:i}),this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.Fail),[3,4];case 4:return[2]}}))}))},t.prototype.onGetStatus=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,n,s,i;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:if(!this._enableLLEventHandle)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.models.getDeviceData({ProductId:this.productId,DeviceName:this.deviceName})];case 2:return e=o.sent(),t={},Object.keys(e).forEach((function(r){t[r]=e[r].Value})),r=utils.convertPropertiesChangeToTlv(t,this.dataTemplate),n=r.tlvData,s=r.tmpData,this.reporter.info(constants.GET_STATUS,{properties:t,tlvData:utils.formatArrayToReportString(n),tmpData:s}),this.protocol.reportGetStatusResult(0,n,s),[3,4];case 3:return i=o.sent(),this.reporter.error(constants.GET_STATUS_ERROR,{error:i}),this.protocol.reportGetStatusResult(-1),[2,Promise.reject(this.normalizeError(i))];case 4:return[2]}}))}))},t.prototype.onEventReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i,o,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:if(!this._enableLLEventHandle)return[2];d.label=1;case 1:d.trys.push([1,9,,10]),console.log("onEventReport check this",this),t=utils.getStrLength(e),r=utils.convertEventTlvToJsObject(e.slice(2,2+t),this.dataTemplate),n=r.eventId,s=r.params,i=r.eventIndex,o={DeviceId:this.explorerDeviceId,EventId:n,Params:JSON.stringify(s)},this.emit("eventReport",{eventIndex:i,params:s}),this.reporter.info(constants.EVENT_REPLY,tslib_1.__assign(tslib_1.__assign({},o),{eventIndex:i})),d.label=2;case 2:return d.trys.push([2,7,,8]),[4,this.models.reportDeviceEvent(o)];case 3:return d.sent(),console.log("reportDeviceEvent success"),e.length-2>t?(console.log("have more event data to report",e.length,t),[4,this.onEventReport({data:e.slice(t+2+1)})]):[3,5];case 4:return d.sent(),[3,6];case 5:this.protocol.reportEventReportResult(0,i),d.label=6;case 6:return[3,8];case 7:throw c=d.sent(),console.error({error:c,eventIndex:i}),this.protocol.reportEventReportResult(-1,i),c;case 8:return[3,10];case 9:return a=d.sent(),this.reporter.error(constants.EVENT_REPLY_ERROR,{error:a}),[2,Promise.reject(this.normalizeError(a))];case 10:return[2]}}))}))},t.prototype.bindDevice=function(e){var t=e.familyId,r=e.roomId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n,s,i,o,c,a,d,l,u,_,p,v,h,E,I,f;return tslib_1.__generator(this,(function(D){switch(D.label){case 0:e=this.extendInfo,n=e.isDynamicRegister,s=e.isEncrypted,libs_1.log("bindDevice isEncrypted:",{isEncrypted:s,isDynamicRegister:n}),this.isEncrypted=s,D.label=1;case 1:return D.trys.push([1,6,,7]),s?[4,this.bindDeviceEncrypted({isDynamicRegister:n})]:[3,3];case 2:return I=D.sent(),i=I.sign,o=I.timestamp,c=I.nonce,a=I.deviceName,d=I.secretKey,[3,5];case 3:return[4,this.protocol.requestBindDevice({needUserCheck:this.needUserCheck,isDynamicRegister:n})];case 4:f=D.sent(),i=f.sign,o=f.timestamp,c=f.nonce,a=f.deviceName,D.label=5;case 5:return this.extendInfo.isDynamicRegister=!1,[3,7];case 6:return l=D.sent(),libs_1.log("get bind sign failed, isEncrypted:",s,l),!s&&this.protocol.reportBindError(l.code),[2,Promise.reject(this.normalizeError(l))];case 7:D.trys.push([7,16,,17]),this.reporter.info(constants.BIND_AUTH),u=Date.now(),this.deviceName=a,D.label=8;case 8:return D.trys.push([8,10,,11]),_={Signature:i,DeviceTimestamp:o,DeviceId:this.explorerDeviceId,ConnId:""+c,FamilyId:t,RoomId:r,BindType:"bluetooth_sign",SignMethod:s?"hmacsha256":"hmacsha1"},this.reporter.info(constants.BIND_AUTH_DETAIL,_),[4,this.models.addDeviceBySigInFamily(_)];case 9:return D.sent(),[3,11];case 10:return p=D.sent(),s?this.protocol.reportBindEncryptedError(d):this.protocol.reportBindError(p.code),[2,Promise.reject(this.normalizeError(p))];case 11:return s?[4,this.protocol.reportBindEncryptedSuccess(u,d)]:[3,13];case 12:return D.sent(),[3,15];case 13:return v=this,[4,this.protocol.reportBindSuccess(u)];case 14:v.localPsk=D.sent(),D.label=15;case 15:try{if(this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({},this.extendInfo)),!this.extendInfo.macStr)return[2];h={productId:this.productId,deviceName:a,deviceInfo:{mac:this.extendInfo.macStr}},this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({msg:"START_REPORT_DEVICE_INFO"},h)),this.models.reportDeviceInfo(h)}catch(e){}return[2,this.explorerDeviceId];case 16:return E=D.sent(),console.log(E),console.log("error in bindDevice",E),this.reporter.error(constants.BIND_AUTH_FAIL,{error:E}),[2,Promise.reject(this.normalizeError(E))];case 17:return[2]}}))}))},t.prototype.bindDeviceEncrypted=function(e){var t=e.isDynamicRegister,r=void 0!==t&&t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,n,s,i,o,c,a,d,l,u,_,p,v;return tslib_1.__generator(this,(function(h){switch(h.label){case 0:return h.trys.push([0,9,,10]),e=void 0,t=void 0,r?[4,this.getDeviceNameWithRegister()]:[3,2];case 1:return p=h.sent(),e=p.deviceName,t=p.nonce,[3,4];case 2:return[4,this.getDeviceNameEncrypted()];case 3:v=h.sent(),e=v.deviceName,t=v.nonce,h.label=4;case 4:return this.deviceName=e,[4,this.models.getDeviceSignAgitated({DeviceId:this.productId+"/"+e,Content:t})];case 5:return n=h.sent(),libs_1.log("get device sign response: ",n),s=n.AgitatedSignature,i=n.Timestamp,o=n.AgitatedContent,[4,this.requestBindEncrypted(s,i)];case 6:return c=h.sent(),a=c.deviceSign,d=c.R2,[4,this.verifyDeviceSign(o,d,a)];case 7:return l=h.sent(),libs_1.log("ks:",l),[4,this.notifyBindDevice(l)];case 8:return u=h.sent(),this.secretKey=l,libs_1.log("get notifyRes:",u),[2,{sign:u.sign,timestamp:Number(i),nonce:libs_1.hex2Base64(t),secretKey:l,deviceName:e}];case 9:return _=h.sent(),console.warn("bind device encrypted failed",_),[2,Promise.reject(_)];case 10:return[2]}}))}))},t.prototype.requestBindEncrypted=function(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,n,s,i,o,c,a,d,l,u=this;return tslib_1.__generator(this,(function(_){switch(_.label){case 0:return r=constants.DEVICE_INFO_WRITE_PREFIX,n=constants.REQUEST_BIND,s=r[n],i=Number(t).toString(16),o=libs_1.base64toHEX(e),c=libs_1.randomBytesHex(16),a=""+s+c+i+o,libs_1.log("REQUEST_BIND_PAYLOAD: ",s+"/"+c+"/"+i+"/"+o),[4,this.sendBleData(a,n).then((function(e){var t=parseInt(e.slice(2,3).join(""),16);if(1===t)throw{code:constants.REQUEST_BIND_FAILED};var r=e.slice(3,19).join("").toLowerCase(),n=parseInt(e.slice(19,23).join(""),16).toString(),s=e.slice(23).join("").toLowerCase(),i="/".charCodeAt(0).toString(16),o=""+r+i+libs_1.str2hexStr(n)+i;return libs_1.log("bind request response",{nonce:r,timestamp:n,sign:s,R2:o}),u.reporter.info(constants.REQUEST_BIND_SUCCESS,{nonce:r,timestamp:n,sign:s,R2:o}),{ack:t,timestamp:n,R2:o,deviceSign:s}}))];case 1:return d=_.sent(),l=d.deviceSign,libs_1.log("verify sign succeed",l),[2,d]}}))}))},t.prototype.verifyDeviceSign=function(e,t,r){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.models.getDeviceSecret({DeviceId:this.productId+"/"+this.deviceName,AppNonce:e,DeviceNonce:t,DeviceNonceSign:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.getDeviceNameWithRegister=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,n,s,i,o,c,a=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME],t=Math.floor(Date.now()/1e3),r=parseInt(utils.gen4BytesIntHex(),16),n=""+e+r.toString(16)+t.toString(16),[4,this.sendBleData(n,constants.GET_DEVICE_NAME_WITH_REGISTER).then((function(e){var t=parseInt(e[2],16);if(1===t)throw libs_1.log("get register data failed",{ack:t,data:e}),{code:constants.GET_DEVICE_NAME_WITH_REGISTER_FAILED};var r=parseInt(e.slice(3,4).join(""),16),n=libs_1.hex2str(e.slice(4,4+r)),s=libs_1.hex2str(e.slice(4+r));return libs_1.log("register data",{bleData:e,sign:s,deviceName:n}),{deviceName:n,sign:s}}))];case 1:return s=d.sent(),i=s.deviceName,o=s.sign,[4,this.models.dynamicRegisterDevice({deviceName:i,sign:o,productId:this.productId,timestamp:t,nonce:r})];case 2:return c=d.sent().payload,libs_1.log("dynamic register payload",c),[4,this.sendBleData(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME_WITH_REGISTER]+libs_1.str2hexStr(c),constants.GET_DEVICE_NAME).then((function(e){var t=parseInt(e[2],16);if(1===t)throw a.reporter.error(constants.REGISTER_DEVICE_INFO_REPLY_INVALID,{ack:t,data:e}),{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var r=e.slice(3,19).join(""),n=libs_1.hex2str(e.slice(19));return libs_1.log("dyna register res",{deviceName:n,sign:r}),{deviceName:n,nonce:r}}))];case 3:return[2,d.sent()]}}))}))},t.prototype.getDeviceNameEncrypted=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r=this;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME],[4,this.writeAndWait4Response([e],constants.GET_DEVICE_NAME,(function(e){if(!e.length)throw{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var t=libs_1.getStrLength(e),n=parseInt(e.slice(2,3).join(""),16),s=e.slice(3,19).join(""),i=libs_1.hex2str(e.slice(19));return r.reporter.info(constants.GET_DEVICE_NAME,{allLength:t,nonce:s,ack:n,deviceName:i}),{nonce:s,deviceName:i}}),WRITE_TO_DEVICE_CONF)];case 1:return t=n.sent(),libs_1.log("getDeviceName res",t),[2,t]}}))}))},t.prototype.encrypt=function(e,t,r){void 0===r&&(r={}),libs_1.log("start to encrypt data",e);var n=this.appDevSdk.utils.CryptoJS,s=function(e){"hex"===r.contentType&&(e=n.enc.Hex.parse(e));var s=n.AES.encrypt(e,n.enc.Hex.parse(t),{mode:n.mode.ECB,padding:n.pad.Pkcs7});return libs_1.base64toHEX(s.toString())};return"string"==typeof e?s(e):e.map(s)},t.prototype.notifyBindDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return t=constants.DEVICE_INFO_WRITE_PREFIX[constants.NOTIFY_BIND],"BindRequest",r=this.encrypt("BindRequest",e),[4,this.sendBleData(""+t+r,constants.NOTIFY_BIND).then((function(t){var r=parseInt(t.slice(2,3).join(""),16);if(1===r){var s={code:constants.NOTIFY_BIND_FAILED};throw n.reporter.error(constants.NOTIFY_BIND_FAILED,{ack:r,error:s,res:t}),s}var i=t.slice(3).join(""),o=utils.decrypt(i,e);return libs_1.log("bind decrypted sign:",o),n.reporter.info(constants.NOTIFY_BIND_SUCCESS,{ack:r,sign:o}),{ack:r,sign:o}}))];case 1:return[2,s.sent()]}}))}))},t.prototype.unbindDevice=function(e){var t=e.familyId,r=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:e=Date.now(),c.label=1;case 1:return c.trys.push([1,9,,10]),this.isEncrypted?[4,this.unbindDeviceEncrypted()]:[3,3];case 2:return c.sent(),[3,6];case 3:if(!r)throw{code:constants.DEVICE_NAME_IS_EMPTY};return[4,this.getDevicePsk(r)];case 4:return n=c.sent(),this.reporter.info(constants.UNBIND_AUTH,{localPsk:n}),[4,this.protocol.getUnbindAuthSign()];case 5:if(s=c.sent().sign,i=utils.encrypt(constants.UNBIND_RESPONSE,n),s!==i)throw{code:constants.UNBIND_REPLY_ERROR};this.localPsk=n,this.deviceName=r,c.label=6;case 6:return[4,this.models.deleteDeviceFromFamily({FamilyId:t,DeviceId:this.explorerDeviceId})];case 7:return c.sent(),this.reporter.info(constants.UNBIND_RESULT_AUTH_SUCCESS,{timeCost:Date.now()-e}),[4,this.protocol.reportUnbindResult("success")];case 8:return c.sent(),this.stopListenLLEvents(),this.authorized=!1,this.disconnectDevice(),[3,10];case 9:return o=c.sent(),this.protocol.reportUnbindResult("fail"),this.reporter.error(constants.UNBIND_RESULT_AUTH_FAIL,{error:o}),[2,Promise.reject(this.normalizeError(o))];case 10:return[2]}}))}))},t.prototype.unbindDeviceEncrypted=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r=this;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_REQUEST],"UnbindRequest",t=this.encrypt("UnbindRequest",this.sessionKey),[4,this.sendBleData(""+e+t,constants.UNBIND_REQUEST).then((function(e){if(libs_1.log("unbind res encrypted data",e),1===parseInt(e[2],16))throw{code:constants.UNBIND_REPLY_INVALID};var t=utils.decrypt(e.slice(3).join(""),r.sessionKey);if(libs_1.log("unbind payload",libs_1.hex2str(t)),"UnbindResponse"===libs_1.hex2str(t))return!0;throw{code:constants.UNBIND_REPLY_ERROR}}))];case 1:return[2,n.sent()]}}))}))},t.prototype.controlDevice=function(e){var t=e.deviceData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),console.log("controlDevice check this",this),this.reporter.info(constants.CONTROL_DEVICE,{deviceData:t}),[4,this.protocol.controlDeviceProperty(t)];case 1:return r.sent(),this.emit("controlPropertySuccess",{deviceData:t}),[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:Date.now()})];case 2:return r.sent(),[3,4];case 3:return e=r.sent(),this.reporter.error(constants.CONTROL_DEVICE_REPLY_ERROR,{error:e}),[2,Promise.reject(this.normalizeError(e))];case 4:return[2]}}))}))},t.prototype.controlAction=function(e){var t=e.actionData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),console.log("controlAction check this",this),[4,this.protocol.controlDeviceAction(t)];case 1:return e=c.sent().output,[4,utils.convertActionOutputTlvToJsObject(e,this.dataTemplate)];case 2:return r=c.sent(),n=r.outputParams,s=r.actionIndex,i=r.actionId,[4,this.models.publishDeviceActionMessage({deviceName:this.deviceName,productId:this.productId,actionId:i,clientToken:t.clientToken,output:n})];case 3:return c.sent(),this.reporter.info(constants.CONTROL_ACTION_SUCCESS,{outputParams:n,actionIndex:s,actionId:i}),[3,5];case 4:return o=c.sent(),this.reporter.error(constants.CONTROL_ACTION_ERROR,{error:o}),[2,Promise.reject(this.normalizeError(o))];case 5:return[2]}}))}))},t.prototype.authenticateConnection=function(e){var t=(void 0===e?{}:e).deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o,c,a,d,l,u,_,p,v,h;return tslib_1.__generator(this,(function(E){switch(E.label){case 0:if(E.trys.push([0,18,,19]),console.log("start authenticate connection",t),!t)throw{code:constants.DEVICE_NAME_IS_EMPTY};return[4,this.models.getDeviceConfig({DeviceId:this.productId+"/"+t,DeviceKey:LLSyncProtocol_1.LLSyncConfig.Secret_Encrypt_Key})];case 1:return e=E.sent(),envDetect.isIOS&&this.extendInfo.moduleVersion>=2?[4,this.protocol.notifyAppOnIOSDevice()]:[3,4];case 2:return E.sent(),[4,delay(100)];case 3:E.sent(),E.label=4;case 4:if(r=void 0,n=void 0,s=void 0,i=void 0,o=Date.now(),!e)return[3,9];this.isEncrypted=!0,this.authorized=!1,this.secretKey=e,E.label=5;case 5:return E.trys.push([5,7,,8]),[4,this.authConnectionEncrypted({deviceName:t})];case 6:return v=E.sent(),r=v.version,n=v.mtu,s=v.needSetMtu,i=v.otaVersion,[3,8];case 7:return c=E.sent(),libs_1.log("auth connection encrypted faild",c),[2,Promise.reject(c)];case 8:return[3,13];case 9:return[4,this.getDevicePsk(t)];case 10:return a=E.sent(),this.localPsk=a,this.reporter.info(constants.CONNECT_AUTH,{localPsk:a}),[4,this.protocol.getDeviceAuthInfo()];case 11:if(d=E.sent(),l=d.sign,u=d.timestamp,_=utils.encrypt(""+(u+60)+this.productId+t,a),l!==_)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return[4,this.protocol.getDeviceInfo()];case 12:h=E.sent(),r=h.version,n=h.mtu,s=h.needSetMtu,i=h.otaVersion,E.label=13;case 13:if(this.deviceName=t,this.bleVersion=r,this.mtu=n,!s)return[3,17];E.label=14;case 14:return E.trys.push([14,16,,17]),[4,this.setMtu(this.mtu)];case 15:return E.sent(),this.writeMtuResult("success"),[3,17];case 16:return E.sent(),this.writeMtuResult("fail"),[3,17];case 17:return this.otaVersion=i,i&&this.models.reportOTAVersion({Version:i,DeviceId:this.explorerDeviceId}),this.reporter.info(constants.CONNECT_RESULT_WRITE_SUCCESS,{timeCost:Date.now()-o,version:r,mtu:n,otaVersion:i}),this.authorized=!0,this.emit("authorized",{version:r,mtu:n,otaVersion:i}),this.stopListenLLEvents(),this.startListenLLEvents(),this.extendInfo.moduleVersion>=2&&this.protocol.notifyAppReady(),[3,19];case 18:return p=E.sent(),this.protocol.reportConnectError(),this.reporter.error(constants.CONNECT_RESULT_WRITE_FAIL,{error:p}),[2,Promise.reject(this.normalizeError(p))];case 19:return[2]}}))}))},t.prototype.authConnectionEncrypted=function(e){var t=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o,c,a,d,l,u,_=this;return tslib_1.__generator(this,(function(p){switch(p.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX,r=constants.CONNECT_REQUEST,n=constants.CONNECT_ACK,s=""+e[r]+this.encrypt("ConnectRequest",this.secretKey),[4,this.sendBleData(s,r).then((function(e){libs_1.log("connect res",e);var t=parseInt(e[2],16),r=e.slice(3,19).join(""),n=e.slice(19).join("");if(1===t)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return{ack:t,R3:r,sign:n}}))];case 1:return i=p.sent(),o=i.R3,c=i.sign,[4,this.models.getDeviceSign({DeviceId:this.productId+"/"+(t||this.deviceName),Content:""+o+";".charCodeAt(0).toString(16)+this.secretKey,ContentType:"hex"})];case 2:if(a=p.sent(),libs_1.log("get sessionKey",a),d=this.encrypt(o,a,{contentType:"hex"}),libs_1.log("verify sign:",d,c),d.toLowerCase()!==c.toLowerCase())throw{code:constants.CONNECT_SIGN_VERIFY_ERROR};return this.sessionKey=a,l=""+e[n]+this.encrypt("ConnectResult",this.sessionKey),[4,this.sendBleData(l,n).then((function(e){if(1===parseInt(e[2],16))throw{code:constants.CONNECT_SIGN_VERIFY_ERROR};var t=e.slice(3,19).join(""),r=utils.decrypt(t,_.sessionKey);libs_1.log("decrypted data",r,t);var n=_.appDevSdk.utils.byteUtil.hexString2hexArray(r),s=parseInt(n[0],16),i=parseInt(n.slice(1,3).join(""),16),o=n.slice(4).join("");return{version:s,mtu:8191&i,needSetMtu:!!(i>>15),otaVersion:o?libs_1.hex2str(o):o}}))];case 3:return u=p.sent(),libs_1.log("connect ack res",u),[2,u]}}))}))},t.prototype.getAdvertisingData=function(){var e,t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){if(!(r=null===(e=this.extendInfo)||void 0===e?void 0:e.moduleVersion)||r<3)throw{code:"MODULE_VERSION_NOT_SUPPORT_GET_ADV_DATA",msg:"LLSync 版本 "+r+" 不支持 getAdvertisingData"};if((null===(t=this.extendInfo)||void 0===t?void 0:t.isEncrypted)&&this.authorized)throw{code:"GET_ADV_DATA_NOT_SUPPORTED_IN_CURRENT_STATE",msg:"LLSync 加密协议连接鉴权完成后暂不支持获取广播信息"};return[2,this.protocol.getAdvertisingData()]}))}))},t.prototype.sendHeartbeat=function(){var e;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(r){return!(t=null===(e=this.extendInfo)||void 0===e?void 0:e.moduleVersion)||t<3?(console.warn("LLSyncDeviceAdapter.sendHeartbeat noop: moduleVersion "+t+" not support heartbeat"),[2]):[2,this.protocol.sendHeartbeat()]}))}))},t.prototype.notifyLocalRssi=function(e){var t=e.rssi;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){return(e=Math.round(t))<-255&&(e=-255),e>0&&(e=0),[2,this.protocol.notifyLocalRssi({rssi:e})]}))}))},t.prototype.sendBleData=function(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){return r=this.protocol._parseDataBeforeConnect(e,t),[2,this.writeAndWait4Response(r,t,(function(e){return e}),WRITE_TO_DEVICE_CONF)]}))}))},t.prototype.toString=function(){return"[LLSyncDeviceAdapter]"},t.serviceId16="0000FFE0-0000-1000-8000-00805F9B34FB",t.serviceId="0000FFE0-65D0-4E20-B56A-E493541BA4E2",t.deviceFilter=function(e,r){if(!e.advertisServiceUUIDs||!e.advertisServiceUUIDs.find((function(e){return e===t.serviceId16}))||!e.advertisData)return null;var n=t.options.appDevSdk.reporter;try{var s=Math.floor(10*Math.random())%10==1||!0,i=arrayBufferToHexStringArray(e.advertisData);s&&n.info(constants_1.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:t.serviceId,hexArr:i.join(",")});var o=parseInt(i[2],16),c=o-(o>>2<<2),a=o>>4,d=o>>2&1,l=o>>3&1;libs_1.log("BLE_STATE =>",o.toString(2));var u=r.productId&&r.deviceName?r.productId+"/"+r.deviceName:"",_=u?utils.get8ByteFromStr(""+u.replace("/","")):"",p=!!u,v="",h="",E="",I=constants.DEVICE_STATE_MAP[c],f=[constants.DEVICE_HAS_BINDED,constants.DEVICE_HAS_CONNECTED].indexOf(I)>-1;if(f)E=i.slice(3,11).join("").toLocaleLowerCase(),h=i.slice(11).join("").toLocaleLowerCase(),v=r.productId;else{var D=i.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+D.slice(0,2).join("")),v=libs_1.hex2str(i.slice(9))}s&&n.info(constants_1.REPORT_EVENT_TYPE,{message:"解析广播",serviceId:t.serviceId,data:{bindState:I||"x",targetDeviceId:u,targetDeviceIdentify:_,deviceUserIdentify:h||"x",deviceProductId:v||"x",deviceIdentify:E||"x",isDynamicRegister:!!d,isEncrypted:!!l,macStr:f?"":i.slice(3,9).join(":")}});var y=function(){var n=tslib_1.__assign(tslib_1.__assign({},e),{serviceId:t.serviceId,deviceName:r.deviceName||"",productId:v,extendInfo:{bindState:constants.DEVICE_STATE_MAP[I],moduleVersion:a,isDynamicRegister:!!d,isEncrypted:!!l,standard:!0,macStr:f?"":i.slice(3,9).join(":")}});return console.log("---设备匹配成功---",n),n};return p&&f&&E===_?y():p||f?null:y()}catch(e){console.error("llsync device filter error",e),n.error(constants_1.REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},t}(LLSyncDeviceAdapterBase_1.LLSyncDeviceAdapterBase);exports.LLSyncDeviceAdapter=LLSyncDeviceAdapter,exports.StandardDeviceAdapter=LLSyncDeviceAdapter;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StandardDeviceAdapter=exports.LLSyncDeviceAdapter=void 0;var tslib_1=require("tslib"),constants=tslib_1.__importStar(require("../../constants")),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants_1=require("../../constants"),libs_1=require("../../libs"),utils=tslib_1.__importStar(require("../../libs")),Models_1=require("./Models"),LLSyncDeviceAdapterBase_1=require("../LLSyncDeviceAdapterBase"),LLSyncOtaProcessor_1=require("./LLSyncOtaProcessor"),LLSyncProtocol_1=require("./LLSyncProtocol"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,arrayBufferToHexStringArray=_a.arrayBufferToHexStringArray,envDetect=_a.envDetect,delay=_a.delay,convertToMs=function(e){if("number"!=typeof e)throw new Error("timestamp should be a number");return e.toString().length>=13?e:1e3*e},WRITE_TO_DEVICE_CONF={timeout:LLSyncProtocol_1.LLSyncConfig.waitGetRegisterDeviceInfo,timeoutCode:constants.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID},LLSyncDeviceAdapter=function(e){function t(r){var n=e.call(this,r)||this;n._enableWsEventHandle=!0,n._enableLLEventHandle=!0;var s=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return tslib_1.__awaiter(n,void 0,void 0,(function(){return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,this.init()];case 1:return r.sent(),[2,e.apply(void 0,tslib_1.__spread(t))]}}))}))}};n.models=new Models_1.Models(t.options.appDevSdk),n.userIdentify=t.getUserIdentify(),n.on("disconnect",(function(){n.authorized=!1})),n.appDevSdk=t.options.appDevSdk,n.protocol=new LLSyncProtocol_1.LLSyncProtocol(n),n.otaProcessor=new LLSyncOtaProcessor_1.LLSyncOtaProcessor(n),Object.assign(n,{bindDevice:s(n.bindDevice.bind(n)),unbindDevice:s(n.unbindDevice.bind(n)),controlDevice:s(n.controlDevice.bind(n)),controlAction:s(n.controlAction.bind(n)),authenticateConnection:s(n.authenticateConnection.bind(n)),reconnectDevice:s(n.authenticateConnection.bind(n)),startOta:s(n.startOta.bind(n)),cancelOta:s(n.cancelOta.bind(n)),userCancelBindDevice:s(n.protocol.cancelUserCheck.bind(n.protocol,"cancel"))}),n.init(),n.reporter={info:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.message,i=void 0===s?"":s,o=r.serviceId,c=tslib_1.__rest(r,["message","serviceId"]),a=n,d=a.explorerDeviceId,l=a.deviceId,u=a.isConnected;t.options.appDevSdk.reporter.info(constants_1.REPORT_EVENT_TYPE,{serviceId:o||t.serviceId,message:i||(e&&constants.ACTION_DESC[e]?e+"("+constants.ACTION_DESC[e]+")":e),timeCost:c.timeCost||0,action:e,data:tslib_1.__assign({deviceId:d,bleDeviceId:l,isConnected:u},c)})},error:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.error,i=tslib_1.__rest(r,["error"]),o=n,c=o.explorerDeviceId,a=o.deviceId,d=o.isConnected;s&&s.code&&constants.ERROR_MESSAGES[s.code]&&(s.msg=constants.ERROR_MESSAGES[s.code]),t.options.appDevSdk.reporter.error(constants_1.REPORT_EVENT_TYPE,{message:constants.ERROR_MESSAGES[e]?e+"("+constants.ERROR_MESSAGES[e]+":"+(s&&(s.message||s.errMsg||s.msg||s.code))+")":"",timeCost:i.timeCost||0,action:e,error:s,data:tslib_1.__assign(tslib_1.__assign({deviceId:c,bleDeviceId:a,isConnected:d},i),s)})}};var i=function(e){var t=e.deviceId,r=e.deviceData;if(n._enableWsEventHandle&&(console.log("llsync receive onControl",t,r,n.ready,n.explorerDeviceId),n.ready&&t===n.explorerDeviceId)){var s={};Object.keys(r).forEach((function(e){s[e]=r[e].Value})),n.controlDevice({deviceData:s})}},o=function(e){var t=e.deviceId,r=e.Payload;n._enableWsEventHandle&&n.ready&&t===n.explorerDeviceId&&n.controlAction({actionData:r})};return n.on("authorized",(function(){n.init(!0),n.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,i),n.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,o)})).on("disconnect",(function(){n.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,i),n.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,o)})),n}return tslib_1.__extends(t,e),t.getUserIdentify=function(){var e,r,n,s;return libs_1.getUserIdentify(null===(s=null===(n=null===(r=null===(e=t.options)||void 0===e?void 0:e.appDevSdk)||void 0===r?void 0:r.loginManager)||void 0===n?void 0:n.userInfo)||void 0===s?void 0:s.UserID)},t.injectOptions=function(e){e.appDevSdk.reporter&&e.appDevSdk.requestApi||console.warn("invalid appDevSdk",e.appDevSdk),t.options=e},Object.defineProperty(t.prototype,"ready",{get:function(){return console.log("isConnected",this.isConnected,"isAuthorized",this.authorized),this.isConnected&&this.authorized},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"needUserCheck",{get:function(){var e,t,r;try{return!!parseInt((null===(r=null===(t=null===(e=null==this?void 0:this.productConfig)||void 0===e?void 0:e.BleConfig)||void 0===t?void 0:t.bindingBootConfig)||void 0===r?void 0:r.confirmRequired)||"0")}catch(e){return console.warn("LLSync check confirmRequired fail",e),!1}},enumerable:!1,configurable:!0}),t.prototype.normalizeError=function(t){return!(t=e.prototype._normalizeError.call(this,t)).msg&&t.code&&constants.ERROR_MESSAGES[t.code]&&(t.msg=constants.ERROR_MESSAGES[t.code]),t},t.prototype.init=function(r){return tslib_1.__awaiter(this,void 0,void 0,(function(){var n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:if(!t.options)throw"标准蓝牙适配器未初始化Options";return[4,e.prototype.init.call(this)];case 1:return s.sent(),r&&(this.productInfo=this.productConfig=this._initPromise=null),[2,this._initPromise||(this._initPromise=new Promise((function(e,t){return tslib_1.__awaiter(n,void 0,void 0,(function(){var r,n,s,i,o,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),n=(r=this).productConfig,s=r.productInfo,[4,Promise.all([n?Promise.resolve(n):this.models.getProduct({ProductId:this.productId}),s?Promise.resolve(s):this.models.getProductConfig({ProductId:this.productId})])];case 1:return i=tslib_1.__read.apply(void 0,[d.sent(),2]),o=i[0],c=i[1],this.dataTemplate=libs_1.getProductDateTemplate(o),this.productInfo=o,this.productConfig=c,console.log("init llsync done",{productInfo:this.productInfo,productConfig:this.productConfig,dataTemplate:this.dataTemplate}),e(),[3,3];case 2:return a=d.sent(),console.error("init standard device adapter fail",a),t(a),this._initPromise=null,[3,3];case 3:return[2]}}))}))})))]}}))}))},t.prototype.getDevicePsk=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return t={DeviceId:this.productId+"/"+(e||this.deviceName),DeviceKey:LLSyncProtocol_1.LLSyncConfig.BLE_PSK_DEVICE_KEY},[4,Promise.all([this.models.getDeviceConfig(tslib_1.__assign(tslib_1.__assign({},t),{isUserConfig:!0})),this.models.getDeviceConfig(t)])];case 1:if(r=tslib_1.__read.apply(void 0,[c.sent(),2]),n=r[0],s=r[1],!n||s)return[3,5];c.label=2;case 2:return c.trys.push([2,4,,5]),[4,this.models.setDeviceConfig({DeviceId:t.DeviceId,DeviceKey:t.DeviceKey,DeviceValue:n})];case 3:return c.sent(),[3,5];case 4:return i=c.sent(),console.error("update psk to DeviceConfig fail",i),[3,5];case 5:if(!(o=s||n))throw{code:constants.PSK_GET_ERROR};return[2,o]}}))}))},t.prototype.startOta=function(e){var t=e.onProgress;return this.otaProcessor.startOta({onProgress:t})},t.prototype.cancelOta=function(){return this.otaProcessor.cancelOta()},t.prototype.startListenLLEvents=function(){this.on(constants.PROPERTY_REPORT,utils.wrapEventHandler(this.onPropertyReport.bind(this),constants.PROPERTY_REPORT)),this.on(constants.GET_STATUS,this.onGetStatus.bind(this)),this.on(constants.EVENT_REPORT,utils.wrapEventHandler(this.onEventReport.bind(this),constants.EVENT_REPORT))},t.prototype.stopListenLLEvents=function(){this.off(constants.PROPERTY_REPORT),this.off(constants.GET_STATUS),this.off(constants.EVENT_REPORT)},t.prototype.setWsEventHandleEnabled=function(e){this._enableWsEventHandle=e},t.prototype.setLLEventHandleEnabled=function(e){this._enableLLEventHandle=e},t.prototype.onPropertyReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:if(!this._enableLLEventHandle)return[2];try{console.log("onPropertyReport check this",this),t=utils.convertPropertiesTlvToJsObject(e.slice(2),this.dataTemplate),this.reporter.info(constants.REPORT_RESULT,{data:utils.formatArrayToReportString(e),jsObj:t}),this.emit("propertyReport",{deviceData:t})}catch(e){return this.reporter.error(constants.REPORT_RESULT_ERROR,{error:e}),this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.ParseDataFail),[2]}o.label=1;case 1:return o.trys.push([1,3,,4]),r=t["_sys _timestamp"],[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:r?convertToMs(r):Date.now()})];case 2:if(n=o.sent().Data){if((s=JSON.parse(n)).code)throw{code:constants.PROPERTY_REPORT_API_FAIL,reportReplyCode:s.code};this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.Success)}return[3,4];case 3:return i=o.sent(),this.reporter.error(constants.REPORT_RESULT_ERROR,{error:i}),this.protocol.reportPropertyReportResult(constants.PropertyReportReplyResult.Fail),[3,4];case 4:return[2]}}))}))},t.prototype.onGetStatus=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,n,s,i;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:if(!this._enableLLEventHandle)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.models.getDeviceData({ProductId:this.productId,DeviceName:this.deviceName})];case 2:return e=o.sent(),t={},Object.keys(e).forEach((function(r){t[r]=e[r].Value})),r=utils.convertPropertiesChangeToTlv(t,this.dataTemplate),n=r.tlvData,s=r.tmpData,this.reporter.info(constants.GET_STATUS,{properties:t,tlvData:utils.formatArrayToReportString(n),tmpData:s}),this.protocol.reportGetStatusResult(0,n,s),[3,4];case 3:return i=o.sent(),this.reporter.error(constants.GET_STATUS_ERROR,{error:i}),this.protocol.reportGetStatusResult(-1),[2,Promise.reject(this.normalizeError(i))];case 4:return[2]}}))}))},t.prototype.onEventReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,s,i,o,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:if(!this._enableLLEventHandle)return[2];d.label=1;case 1:d.trys.push([1,9,,10]),console.log("onEventReport check this",this),t=utils.getStrLength(e),r=utils.convertEventTlvToJsObject(e.slice(2,2+t),this.dataTemplate),n=r.eventId,s=r.params,i=r.eventIndex,o={DeviceId:this.explorerDeviceId,EventId:n,Params:JSON.stringify(s)},this.emit("eventReport",{eventIndex:i,params:s}),this.reporter.info(constants.EVENT_REPLY,tslib_1.__assign(tslib_1.__assign({},o),{eventIndex:i})),d.label=2;case 2:return d.trys.push([2,7,,8]),[4,this.models.reportDeviceEvent(o)];case 3:return d.sent(),console.log("reportDeviceEvent success"),e.length-2>t?(console.log("have more event data to report",e.length,t),[4,this.onEventReport({data:e.slice(t+2+1)})]):[3,5];case 4:return d.sent(),[3,6];case 5:this.protocol.reportEventReportResult(0,i),d.label=6;case 6:return[3,8];case 7:throw c=d.sent(),console.error({error:c,eventIndex:i}),this.protocol.reportEventReportResult(-1,i),c;case 8:return[3,10];case 9:return a=d.sent(),this.reporter.error(constants.EVENT_REPLY_ERROR,{error:a}),[2,Promise.reject(this.normalizeError(a))];case 10:return[2]}}))}))},t.prototype.bindDevice=function(e){var t=e.familyId,r=e.roomId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n,s,i,o,c,a,d,l,u,_,p,v,h,E,I,f;return tslib_1.__generator(this,(function(D){switch(D.label){case 0:e=this.extendInfo,n=e.isDynamicRegister,s=e.isEncrypted,libs_1.log("bindDevice isEncrypted:",{isEncrypted:s,isDynamicRegister:n}),this.isEncrypted=s,D.label=1;case 1:return D.trys.push([1,6,,7]),s?[4,this.bindDeviceEncrypted({isDynamicRegister:n})]:[3,3];case 2:return I=D.sent(),i=I.sign,o=I.timestamp,c=I.nonce,a=I.deviceName,d=I.secretKey,[3,5];case 3:return[4,this.protocol.requestBindDevice({needUserCheck:this.needUserCheck,isDynamicRegister:n})];case 4:f=D.sent(),i=f.sign,o=f.timestamp,c=f.nonce,a=f.deviceName,D.label=5;case 5:return this.extendInfo.isDynamicRegister=!1,[3,7];case 6:return l=D.sent(),libs_1.log("get bind sign failed, isEncrypted:",s,l),!s&&this.protocol.reportBindError(l.code),[2,Promise.reject(this.normalizeError(l))];case 7:D.trys.push([7,16,,17]),this.reporter.info(constants.BIND_AUTH),u=Date.now(),this.deviceName=a,D.label=8;case 8:return D.trys.push([8,10,,11]),_={Signature:i,DeviceTimestamp:o,DeviceId:this.explorerDeviceId,ConnId:""+c,FamilyId:t,RoomId:r,BindType:"bluetooth_sign",SignMethod:s?"hmacsha256":"hmacsha1"},this.reporter.info(constants.BIND_AUTH_DETAIL,_),[4,this.models.addDeviceBySigInFamily(_)];case 9:return D.sent(),[3,11];case 10:return p=D.sent(),s?this.protocol.reportBindEncryptedError(d):this.protocol.reportBindError(p.code),[2,Promise.reject(this.normalizeError(p))];case 11:return s?[4,this.protocol.reportBindEncryptedSuccess(u,d)]:[3,13];case 12:return D.sent(),[3,15];case 13:return v=this,[4,this.protocol.reportBindSuccess(u)];case 14:v.localPsk=D.sent(),D.label=15;case 15:try{if(this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({},this.extendInfo)),!this.extendInfo.macStr)return[2];h={productId:this.productId,deviceName:a,deviceInfo:{mac:this.extendInfo.macStr}},this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({msg:"START_REPORT_DEVICE_INFO"},h)),this.models.reportDeviceInfo(h)}catch(e){}return[2,this.explorerDeviceId];case 16:return E=D.sent(),console.log(E),console.log("error in bindDevice",E),this.reporter.error(constants.BIND_AUTH_FAIL,{error:E}),[2,Promise.reject(this.normalizeError(E))];case 17:return[2]}}))}))},t.prototype.bindDeviceEncrypted=function(e){var t=e.isDynamicRegister,r=void 0!==t&&t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,n,s,i,o,c,a,d,l,u,_,p,v;return tslib_1.__generator(this,(function(h){switch(h.label){case 0:return h.trys.push([0,9,,10]),e=void 0,t=void 0,r?[4,this.getDeviceNameWithRegister()]:[3,2];case 1:return p=h.sent(),e=p.deviceName,t=p.nonce,[3,4];case 2:return[4,this.getDeviceNameEncrypted()];case 3:v=h.sent(),e=v.deviceName,t=v.nonce,h.label=4;case 4:return this.deviceName=e,[4,this.models.getDeviceSignAgitated({DeviceId:this.productId+"/"+e,Content:t})];case 5:return n=h.sent(),libs_1.log("get device sign response: ",n),s=n.AgitatedSignature,i=n.Timestamp,o=n.AgitatedContent,[4,this.requestBindEncrypted(s,i)];case 6:return c=h.sent(),a=c.deviceSign,d=c.R2,[4,this.verifyDeviceSign(o,d,a)];case 7:return l=h.sent(),libs_1.log("ks:",l),[4,this.notifyBindDevice(l)];case 8:return u=h.sent(),this.secretKey=l,libs_1.log("get notifyRes:",u),[2,{sign:u.sign,timestamp:Number(i),nonce:libs_1.hex2Base64(t),secretKey:l,deviceName:e}];case 9:return _=h.sent(),console.warn("bind device encrypted failed",_),[2,Promise.reject(_)];case 10:return[2]}}))}))},t.prototype.requestBindEncrypted=function(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,n,s,i,o,c,a,d,l,u=this;return tslib_1.__generator(this,(function(_){switch(_.label){case 0:return r=constants.DEVICE_INFO_WRITE_PREFIX,n=constants.REQUEST_BIND,s=r[n],i=Number(t).toString(16),o=libs_1.base64toHEX(e),c=libs_1.randomBytesHex(16),a=""+s+c+i+o,libs_1.log("REQUEST_BIND_PAYLOAD: ",s+"/"+c+"/"+i+"/"+o),[4,this.sendBleData(a,n).then((function(e){var t=parseInt(e.slice(2,3).join(""),16);if(1===t)throw{code:constants.REQUEST_BIND_FAILED};var r=e.slice(3,19).join("").toLowerCase(),n=parseInt(e.slice(19,23).join(""),16).toString(),s=e.slice(23).join("").toLowerCase(),i="/".charCodeAt(0).toString(16),o=""+r+i+libs_1.str2hexStr(n)+i;return libs_1.log("bind request response",{nonce:r,timestamp:n,sign:s,R2:o}),u.reporter.info(constants.REQUEST_BIND_SUCCESS,{nonce:r,timestamp:n,sign:s,R2:o}),{ack:t,timestamp:n,R2:o,deviceSign:s}}))];case 1:return d=_.sent(),l=d.deviceSign,libs_1.log("verify sign succeed",l),[2,d]}}))}))},t.prototype.verifyDeviceSign=function(e,t,r){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.models.getDeviceSecret({DeviceId:this.productId+"/"+this.deviceName,AppNonce:e,DeviceNonce:t,DeviceNonceSign:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.getDeviceNameWithRegister=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,n,s,i,o,c,a=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME],t=Math.floor(Date.now()/1e3),r=parseInt(utils.gen4BytesIntHex(),16),n=""+e+r.toString(16)+t.toString(16),[4,this.sendBleData(n,constants.GET_DEVICE_NAME_WITH_REGISTER).then((function(e){var t=parseInt(e[2],16);if(1===t)throw libs_1.log("get register data failed",{ack:t,data:e}),{code:constants.GET_DEVICE_NAME_WITH_REGISTER_FAILED};var r=parseInt(e.slice(3,4).join(""),16),n=libs_1.hex2str(e.slice(4,4+r)),s=libs_1.hex2str(e.slice(4+r));return libs_1.log("register data",{bleData:e,sign:s,deviceName:n}),{deviceName:n,sign:s}}))];case 1:return s=d.sent(),i=s.deviceName,o=s.sign,[4,this.models.dynamicRegisterDevice({deviceName:i,sign:o,productId:this.productId,timestamp:t,nonce:r})];case 2:return c=d.sent().payload,libs_1.log("dynamic register payload",c),[4,this.sendBleData(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME_WITH_REGISTER]+libs_1.str2hexStr(c),constants.GET_DEVICE_NAME).then((function(e){var t=parseInt(e[2],16);if(1===t)throw a.reporter.error(constants.REGISTER_DEVICE_INFO_REPLY_INVALID,{ack:t,data:e}),{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var r=e.slice(3,19).join(""),n=libs_1.hex2str(e.slice(19));return libs_1.log("dyna register res",{deviceName:n,sign:r}),{deviceName:n,nonce:r}}))];case 3:return[2,d.sent()]}}))}))},t.prototype.getDeviceNameEncrypted=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r=this;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.GET_DEVICE_NAME],[4,this.writeAndWait4Response([e],constants.GET_DEVICE_NAME,(function(e){if(!e.length)throw{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var t=libs_1.getStrLength(e),n=parseInt(e.slice(2,3).join(""),16),s=e.slice(3,19).join(""),i=libs_1.hex2str(e.slice(19));return r.reporter.info(constants.GET_DEVICE_NAME,{allLength:t,nonce:s,ack:n,deviceName:i}),{nonce:s,deviceName:i}}),WRITE_TO_DEVICE_CONF)];case 1:return t=n.sent(),libs_1.log("getDeviceName res",t),[2,t]}}))}))},t.prototype.encrypt=function(e,t,r){void 0===r&&(r={}),libs_1.log("start to encrypt data",e);var n=this.appDevSdk.utils.CryptoJS,s=function(e){"hex"===r.contentType&&(e=n.enc.Hex.parse(e));var s=n.AES.encrypt(e,n.enc.Hex.parse(t),{mode:n.mode.ECB,padding:n.pad.Pkcs7});return libs_1.base64toHEX(s.toString())};return"string"==typeof e?s(e):e.map(s)},t.prototype.notifyBindDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return t=constants.DEVICE_INFO_WRITE_PREFIX[constants.NOTIFY_BIND],"BindRequest",r=this.encrypt("BindRequest",e),[4,this.sendBleData(""+t+r,constants.NOTIFY_BIND).then((function(t){var r=parseInt(t.slice(2,3).join(""),16);if(1===r){var s={code:constants.NOTIFY_BIND_FAILED};throw n.reporter.error(constants.NOTIFY_BIND_FAILED,{ack:r,error:s,res:t}),s}var i=t.slice(3).join(""),o=utils.decrypt(i,e);return libs_1.log("bind decrypted sign:",o),n.reporter.info(constants.NOTIFY_BIND_SUCCESS,{ack:r,sign:o}),{ack:r,sign:o}}))];case 1:return[2,s.sent()]}}))}))},t.prototype.unbindDevice=function(e){var t=e.familyId,r=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:e=Date.now(),c.label=1;case 1:return c.trys.push([1,9,,10]),this.isEncrypted?[4,this.unbindDeviceEncrypted()]:[3,3];case 2:return c.sent(),[3,6];case 3:if(!r)throw{code:constants.DEVICE_NAME_IS_EMPTY};return[4,this.getDevicePsk(r)];case 4:return n=c.sent(),this.reporter.info(constants.UNBIND_AUTH,{localPsk:n}),[4,this.protocol.getUnbindAuthSign()];case 5:if(s=c.sent().sign,i=utils.encrypt(constants.UNBIND_RESPONSE,n),s!==i)throw{code:constants.UNBIND_REPLY_ERROR};this.localPsk=n,this.deviceName=r,c.label=6;case 6:return[4,this.models.deleteDeviceFromFamily({FamilyId:t,DeviceId:this.explorerDeviceId})];case 7:return c.sent(),this.reporter.info(constants.UNBIND_RESULT_AUTH_SUCCESS,{timeCost:Date.now()-e}),[4,this.protocol.reportUnbindResult("success")];case 8:return c.sent(),this.stopListenLLEvents(),this.authorized=!1,this.disconnectDevice(),[3,10];case 9:return o=c.sent(),this.protocol.reportUnbindResult("fail"),this.reporter.error(constants.UNBIND_RESULT_AUTH_FAIL,{error:o}),[2,Promise.reject(this.normalizeError(o))];case 10:return[2]}}))}))},t.prototype.unbindDeviceEncrypted=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r=this;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_REQUEST],"UnbindRequest",t=this.encrypt("UnbindRequest",this.sessionKey),[4,this.sendBleData(""+e+t,constants.UNBIND_REQUEST).then((function(e){if(libs_1.log("unbind res encrypted data",e),1===parseInt(e[2],16))throw{code:constants.UNBIND_REPLY_INVALID};var t=utils.decrypt(e.slice(3).join(""),r.sessionKey);if(libs_1.log("unbind payload",libs_1.hex2str(t)),"UnbindResponse"===libs_1.hex2str(t))return!0;throw{code:constants.UNBIND_REPLY_ERROR}}))];case 1:return[2,n.sent()]}}))}))},t.prototype.controlDevice=function(e){var t=e.deviceData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),console.log("controlDevice check this",this),this.reporter.info(constants.CONTROL_DEVICE,{deviceData:t}),[4,this.protocol.controlDeviceProperty(t)];case 1:return r.sent(),this.emit("controlPropertySuccess",{deviceData:t}),[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:Date.now()})];case 2:return r.sent(),[3,4];case 3:return e=r.sent(),this.reporter.error(constants.CONTROL_DEVICE_REPLY_ERROR,{error:e}),[2,Promise.reject(this.normalizeError(e))];case 4:return[2]}}))}))},t.prototype.controlAction=function(e){var t=e.actionData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),console.log("controlAction check this",this),[4,this.protocol.controlDeviceAction(t)];case 1:return e=c.sent().output,[4,utils.convertActionOutputTlvToJsObject(e,this.dataTemplate)];case 2:return r=c.sent(),n=r.outputParams,s=r.actionIndex,i=r.actionId,[4,this.models.publishDeviceActionMessage({deviceName:this.deviceName,productId:this.productId,actionId:i,clientToken:t.clientToken,output:n})];case 3:return c.sent(),this.reporter.info(constants.CONTROL_ACTION_SUCCESS,{outputParams:n,actionIndex:s,actionId:i}),[3,5];case 4:return o=c.sent(),this.reporter.error(constants.CONTROL_ACTION_ERROR,{error:o}),[2,Promise.reject(this.normalizeError(o))];case 5:return[2]}}))}))},t.prototype.authenticateConnection=function(e){var t=(void 0===e?{}:e).deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o,c,a,d,l,u,_,p,v,h;return tslib_1.__generator(this,(function(E){switch(E.label){case 0:if(E.trys.push([0,18,,19]),console.log("start authenticate connection",t),!t)throw{code:constants.DEVICE_NAME_IS_EMPTY};return[4,this.models.getDeviceConfig({DeviceId:this.productId+"/"+t,DeviceKey:LLSyncProtocol_1.LLSyncConfig.Secret_Encrypt_Key})];case 1:return e=E.sent(),envDetect.isIOS&&this.extendInfo.moduleVersion>=2?[4,this.protocol.notifyAppOnIOSDevice()]:[3,4];case 2:return E.sent(),[4,delay(100)];case 3:E.sent(),E.label=4;case 4:if(r=void 0,n=void 0,s=void 0,i=void 0,o=Date.now(),!e)return[3,9];this.isEncrypted=!0,this.authorized=!1,this.secretKey=e,E.label=5;case 5:return E.trys.push([5,7,,8]),[4,this.authConnectionEncrypted({deviceName:t})];case 6:return v=E.sent(),r=v.version,n=v.mtu,s=v.needSetMtu,i=v.otaVersion,[3,8];case 7:return c=E.sent(),libs_1.log("auth connection encrypted faild",c),[2,Promise.reject(c)];case 8:return[3,13];case 9:return[4,this.getDevicePsk(t)];case 10:return a=E.sent(),this.localPsk=a,this.reporter.info(constants.CONNECT_AUTH,{localPsk:a}),[4,this.protocol.getDeviceAuthInfo()];case 11:if(d=E.sent(),l=d.sign,u=d.timestamp,_=utils.encrypt(""+(u+60)+this.productId+t,a),l!==_)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return[4,this.protocol.getDeviceInfo()];case 12:h=E.sent(),r=h.version,n=h.mtu,s=h.needSetMtu,i=h.otaVersion,E.label=13;case 13:if(this.deviceName=t,this.bleVersion=r,this.mtu=Math.max(constants.MIN_ATT_MTU,n)-constants.ATT_MTU_TO_LLSYNC_MTU_DELTA,!s)return[3,17];E.label=14;case 14:return E.trys.push([14,16,,17]),[4,this.setMtu(n)];case 15:return E.sent(),this.writeMtuResult("success"),[3,17];case 16:return E.sent(),this.writeMtuResult("fail"),[3,17];case 17:return this.otaVersion=i,i&&this.models.reportOTAVersion({Version:i,DeviceId:this.explorerDeviceId}),this.reporter.info(constants.CONNECT_RESULT_WRITE_SUCCESS,{timeCost:Date.now()-o,version:r,mtu:n,otaVersion:i}),this.authorized=!0,this.emit("authorized",{version:r,mtu:n,otaVersion:i}),this.stopListenLLEvents(),this.startListenLLEvents(),this.extendInfo.moduleVersion>=2&&this.protocol.notifyAppReady(),[3,19];case 18:return p=E.sent(),this.protocol.reportConnectError(),this.reporter.error(constants.CONNECT_RESULT_WRITE_FAIL,{error:p}),[2,Promise.reject(this.normalizeError(p))];case 19:return[2]}}))}))},t.prototype.authConnectionEncrypted=function(e){var t=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n,s,i,o,c,a,d,l,u,_=this;return tslib_1.__generator(this,(function(p){switch(p.label){case 0:return e=constants.DEVICE_INFO_WRITE_PREFIX,r=constants.CONNECT_REQUEST,n=constants.CONNECT_ACK,s=""+e[r]+this.encrypt("ConnectRequest",this.secretKey),[4,this.sendBleData(s,r).then((function(e){libs_1.log("connect res",e);var t=parseInt(e[2],16),r=e.slice(3,19).join(""),n=e.slice(19).join("");if(1===t)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return{ack:t,R3:r,sign:n}}))];case 1:return i=p.sent(),o=i.R3,c=i.sign,[4,this.models.getDeviceSign({DeviceId:this.productId+"/"+(t||this.deviceName),Content:""+o+";".charCodeAt(0).toString(16)+this.secretKey,ContentType:"hex"})];case 2:if(a=p.sent(),libs_1.log("get sessionKey",a),d=this.encrypt(o,a,{contentType:"hex"}),libs_1.log("verify sign:",d,c),d.toLowerCase()!==c.toLowerCase())throw{code:constants.CONNECT_SIGN_VERIFY_ERROR};return this.sessionKey=a,l=""+e[n]+this.encrypt("ConnectResult",this.sessionKey),[4,this.sendBleData(l,n).then((function(e){if(1===parseInt(e[2],16))throw{code:constants.CONNECT_SIGN_VERIFY_ERROR};var t=e.slice(3,19).join(""),r=utils.decrypt(t,_.sessionKey);libs_1.log("decrypted data",r,t);var n=_.appDevSdk.utils.byteUtil.hexString2hexArray(r),s=parseInt(n[0],16),i=parseInt(n.slice(1,3).join(""),16),o=n.slice(4).join("");return{version:s,mtu:8191&i,needSetMtu:!!(i>>15),otaVersion:o?libs_1.hex2str(o):o}}))];case 3:return u=p.sent(),libs_1.log("connect ack res",u),[2,u]}}))}))},t.prototype.getAdvertisingData=function(){var e,t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){if(!(r=null===(e=this.extendInfo)||void 0===e?void 0:e.moduleVersion)||r<3)throw{code:"MODULE_VERSION_NOT_SUPPORT_GET_ADV_DATA",msg:"LLSync 版本 "+r+" 不支持 getAdvertisingData"};if((null===(t=this.extendInfo)||void 0===t?void 0:t.isEncrypted)&&this.authorized)throw{code:"GET_ADV_DATA_NOT_SUPPORTED_IN_CURRENT_STATE",msg:"LLSync 加密协议连接鉴权完成后暂不支持获取广播信息"};return[2,this.protocol.getAdvertisingData()]}))}))},t.prototype.sendHeartbeat=function(){var e;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(r){return!(t=null===(e=this.extendInfo)||void 0===e?void 0:e.moduleVersion)||t<3?(console.warn("LLSyncDeviceAdapter.sendHeartbeat noop: moduleVersion "+t+" not support heartbeat"),[2]):[2,this.protocol.sendHeartbeat()]}))}))},t.prototype.notifyLocalRssi=function(e){var t=e.rssi;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){return(e=Math.round(t))<-255&&(e=-255),e>0&&(e=0),[2,this.protocol.notifyLocalRssi({rssi:e})]}))}))},t.prototype.sendBleData=function(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){return r=this.protocol._parseDataBeforeConnect(e,t),[2,this.writeAndWait4Response(r,t,(function(e){return e}),WRITE_TO_DEVICE_CONF)]}))}))},t.prototype.toString=function(){return"[LLSyncDeviceAdapter]"},t.serviceId16="0000FFE0-0000-1000-8000-00805F9B34FB",t.serviceId="0000FFE0-65D0-4E20-B56A-E493541BA4E2",t.deviceFilter=function(e,r){if(!e.advertisServiceUUIDs||!e.advertisServiceUUIDs.find((function(e){return e===t.serviceId16}))||!e.advertisData)return null;var n=t.options.appDevSdk.reporter;try{var s=Math.floor(10*Math.random())%10==1||!0,i=arrayBufferToHexStringArray(e.advertisData);s&&n.info(constants_1.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:t.serviceId,hexArr:i.join(",")});var o=parseInt(i[2],16),c=o-(o>>2<<2),a=o>>4,d=o>>2&1,l=o>>3&1;libs_1.log("BLE_STATE =>",o.toString(2));var u=r.productId&&r.deviceName?r.productId+"/"+r.deviceName:"",_=u?utils.get8ByteFromStr(""+u.replace("/","")):"",p=!!u,v="",h="",E="",I=constants.DEVICE_STATE_MAP[c],f=[constants.DEVICE_HAS_BINDED,constants.DEVICE_HAS_CONNECTED].indexOf(I)>-1;if(f)E=i.slice(3,11).join("").toLocaleLowerCase(),h=i.slice(11).join("").toLocaleLowerCase(),v=r.productId;else{var D=i.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+D.slice(0,2).join("")),v=libs_1.hex2str(i.slice(9))}s&&n.info(constants_1.REPORT_EVENT_TYPE,{message:"解析广播",serviceId:t.serviceId,data:{bindState:I||"x",targetDeviceId:u,targetDeviceIdentify:_,deviceUserIdentify:h||"x",deviceProductId:v||"x",deviceIdentify:E||"x",isDynamicRegister:!!d,isEncrypted:!!l,macStr:f?"":i.slice(3,9).join(":")}});var y=function(){var n=tslib_1.__assign(tslib_1.__assign({},e),{serviceId:t.serviceId,deviceName:r.deviceName||"",productId:v,extendInfo:{bindState:constants.DEVICE_STATE_MAP[I],moduleVersion:a,isDynamicRegister:!!d,isEncrypted:!!l,standard:!0,macStr:f?"":i.slice(3,9).join(":")}});return console.log("---设备匹配成功---",n),n};return p&&f&&E===_?y():p||f?null:y()}catch(e){console.error("llsync device filter error",e),n.error(constants_1.REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},t}(LLSyncDeviceAdapterBase_1.LLSyncDeviceAdapterBase);exports.LLSyncDeviceAdapter=LLSyncDeviceAdapter,exports.StandardDeviceAdapter=LLSyncDeviceAdapter;
//# sourceMappingURL=LLSyncDeviceAdapter.js.map

@@ -400,1 +400,3 @@ export declare const REPORT_EVENT_TYPE = "standard-ble";

export declare const WRITE_DATA_CANCEL_ERROR_CODE = "BLE_WRITE_CHARACTERISTIC_CANCELLED";
export declare const MIN_ATT_MTU = 23;
export declare const ATT_MTU_TO_LLSYNC_MTU_DELTA = 3;

@@ -1,2 +0,2 @@

"use strict";var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l;Object.defineProperty(exports,"__esModule",{value:!0}),exports.WRITE_DATA_CANCEL_ERROR_CODE=exports.PropertyReportReplyResult=exports.ERROR_MESSAGES=exports.MAX_WRITE_DATA_WAIT_GAP=exports.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE=exports.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP=exports.WAIT_MODULE_UPDATE_CONNECT_TIMES=exports.MODULE_UPDATE_REPLAY_DATA_CODE_MAP=exports.MODULE_UPDATE_DATA_REPLAY_CODE_MAP=exports.MODULE_UPDATE_REPLAY_CODE_MAP=exports.BLE_COMBO_ERRORS=exports.OTA_UPDATE_ERRORS=exports.OTA_UPDATE_STEPS_MESSAGE=exports.OTA_UPDATE_STEPS=exports.GET_DEV_LOG_INFO_TIMEOUT=exports.GET_DEV_LOG_INFO_INVALID=exports.SET_WIFI_TOKEN_RESULT_TIMEOUT=exports.SET_WIFI_TOKEN_RESULT_INVALID=exports.SET_WIFI_CONNECT_RESULT_TIMEOUT=exports.SET_WIFI_CONNECT_RESULT_INVALID=exports.SET_WIFI_INFO_RESULT_TIMEOUT=exports.SET_WIFI_INFO_RESULT_INVALID=exports.SET_WIFI_MODE_RESULT_TIMEOUT=exports.SET_WIFI_MODE_RESULT_INVALID=exports.WAIT_MODULE_UPDATE_TIMEOUT=exports.WAIT_GET_UPDATE_INFO_TIMEOUT=exports.GET_ADV_DATA_REPLY_INVALID=exports.GET_ADV_DATA_FAIL=exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT=exports.PROPERTY_REPORT_API_FAIL=exports.DEVICE_INFO_INVALID=exports.WAIT_GET_DEVICE_INFO_TIMEOUT=exports.BLE_WRITE_ERROR=exports.EVENT_REPLY_ERROR=exports.GET_STATUS_ERROR=exports.REPORT_RESULT_ERROR=exports.CONTROL_DEVICE_REPLY_ERROR=exports.CONTROL_REPLY_CODE_INVALID=exports.UNBIND_REPLY_ERROR=exports.CONNECT_SIGN_VERIFY_ERROR=exports.CONNECT_SIGN_AUTH_ERROR=exports.PSK_GET_ERROR=exports.DEVICE_NAME_IS_EMPTY=exports.CANNOT_FIND_DEVICE=exports.CONNECT_DEVICE_ERROR=exports.CONTROL_ACTION_ERROR=exports.CONTROL_REPLY_INVALID=exports.UNBIND_REPLY_INVALID=exports.WAIT_CONTROL_ACTION_REPLY_TIMEOUT=exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT=exports.WAIT_UNBIND_REPLY_TIMEOUT=exports.CONNECT_REPLY_INVALID=exports.WAIT_CONNECT_REPLY_TIMEOUT=exports.USER_NEED_LOGIN=exports.LL_OTA_WRITE_PREFIX=exports.OTA_UPDATE_DATA_END=exports.OTA_UPDATE_DATA=exports.OTA_UPDATE_REQUEST=exports.BLE_IOT_DATA_TYPE_ARRAY=exports.BLE_IOT_DATA_TYPE_STRUCT=exports.BLE_IOT_DATA_TYPE_TIME=exports.BLE_IOT_DATA_TYPE_ENUM=exports.BLE_IOT_DATA_TYPE_FLOAT=exports.BLE_IOT_DATA_TYPE_STRING=exports.BLE_IOT_DATA_TYPE_INT=exports.BLE_IOT_DATA_TYPE_BOOL=exports.ACTION_DESC=exports.WIFI_LOG_TYPE_MAP=exports.WIFI_MODE_MAP=exports.DEVICE_DATA_WRITE_SUFFIX=exports.DEVICE_DATA_WRITE_HEAD=exports.DEVICE_INFO_WRITE_PREFIX=exports.BleErrorMsg=exports.INDICATE_TYPE_MAP=exports.NOTIFY_BIND_SUCCESS=exports.NOTIFY_BIND_FAILED=exports.CONNECT_ACK=exports.CONNECT_REQUEST=exports.RESPONSE_BIND=exports.NOTIFY_BIND=exports.REQUEST_BIND_SUCCESS=exports.REQUEST_BIND_FAILED=exports.REQUEST_BIND=exports.GET_DEVICE_NAME_WITH_REGISTER_FAILED=exports.GET_DEVICE_NAME_WITH_REGISTER=exports.GET_DEVICE_NAME=exports.UNBIND_RESPONSE=exports.UNBIND_REQUEST=exports.REGISTER_DEVICE_SUCCESS=exports.REGISTER_DEVICE_ERROR=exports.REGISTER_DEVICE_INFO_REPLY_INVALID=exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT=exports.SEND_REGISTER_DEVICE_PAYLOAD=exports.REGISTER_DEVICE_INFO_REPLY=exports.WRITE_USER_CHECK_CANCEL=exports.WRITE_USER_CHECK_TIMEOUT=exports.GET_USER_CHECK_TIMEOUT_SUCCESS=exports.GET_USER_CHECK_TIMEOUT_ERROR=exports.GET_USER_CHECK_TIMEOUT_TIMEOUT=exports.USER_CHECK_TIMEOUT_CALLBACK=exports.USER_CHECK_TIMEOUT=exports.GET_USER_CHECK_REJECT=exports.GET_USER_CHECK_APPROVE=exports.WAIT_USER_CHECK_TIMEOUT=exports.GET_ADV_DATA_RESULT=exports.NULL_WIFI_MODE=exports.STA_WIFI_MODE=exports.GET_DEV_LOG_INFO=exports.SET_WIFI_TOKEN_RESULT=exports.SET_WIFI_CONNECT_RESULT=exports.SET_WIFI_INFO_RESULT=exports.SET_WIFI_MODE_RESULT=exports.GET_DEV_LOG=exports.SET_WIFI_TOKEN=exports.SET_WIFI_CONNECT=exports.SET_WIFI_INFO=exports.SET_WIFI_MODE=exports.GET_DEVICE_INFO=exports.NOTIFY_LOCAL_RSSI=exports.HEARTBEAT_RESP=exports.HEARTBEAT_REQ=exports.GET_ADV_DATA_REPLY=exports.GET_ADV_DATA=exports.APP_ON_IOS_DEVICE=exports.APP_IS_READY=exports.VERIFY_SIGN_FAIL=exports.MTU_MODULE_CALLBACK=exports.WRITE_MTU_RESULT=exports.CONTROL_ACTION_SUCCESS=exports.TIME_SYNC=exports.UNBIND_AUTH=exports.UNBIND_RESULT_AUTH_FAIL=exports.UNBIND_RESULT_AUTH_SUCCESS=exports.CONNECT_RESULT_WRITE_FAIL=exports.CONNECT_RESULT_WRITE_SUCCESS=exports.ANDROID_SET_MTU=exports.DEVICE_INFO=exports.CONNECT_AUTH=exports.BIND_AUTH_FAIL=exports.BIND_AUTH_SUCCESS=exports.BIND_AUTH_DETAIL=exports.SET_MTU_BEFORE_CONNECT=exports.BIND_AUTH=exports.UPDATE_REPLY_INVALID=exports.UPDATE_DATA_CHECK_REPLY=exports.UPDATE_DATA_REPLY=exports.UPDATE_REPLY=exports.ACTION_REPLY=exports.EVENT_REPLY=exports.EVENT_REPORT=exports.GET_STATUS=exports.CONTROL_REPLY=exports.REPORT_RESULT=exports.CONTROL_ACTION=exports.CONTROL_DEVICE=exports.PROPERTY_REPORT=exports.LL_OTA_WRITE_ID=exports.DEVICE_EVENT_WRITE_ID=exports.DEVICE_DATA_WRITE_ID=exports.DEVICE_INFO_WRITE_ID=exports.DEVICE_STATE_MAP=exports.DEVICE_HAS_CONNECTED=exports.DEVICE_WAITING_BIND=exports.DEVICE_NOT_BIND=exports.DEVICE_HAS_BINDED=exports.REPORT_EVENT_TYPE=void 0;var PropertyReportReplyResult,tslib_1=require("tslib");exports.REPORT_EVENT_TYPE="standard-ble",exports.DEVICE_HAS_BINDED="DEVICE_HAS_BINDED",exports.DEVICE_NOT_BIND="DEVICE_NOT_BIND",exports.DEVICE_WAITING_BIND="DEVICE_WAITING_BIND",exports.DEVICE_HAS_CONNECTED="DEVICE_HAS_CONNECTED",exports.DEVICE_STATE_MAP={0:exports.DEVICE_NOT_BIND,1:exports.DEVICE_WAITING_BIND,2:exports.DEVICE_HAS_BINDED,3:exports.DEVICE_HAS_CONNECTED},exports.DEVICE_INFO_WRITE_ID="0000FFE1-65D0-4E20-B56A-E493541BA4E2",exports.DEVICE_DATA_WRITE_ID="0000FFE2-65D0-4E20-B56A-E493541BA4E2",exports.DEVICE_EVENT_WRITE_ID="0000FFE3-65D0-4E20-B56A-E493541BA4E2",exports.LL_OTA_WRITE_ID="0000FFE4-65D0-4E20-B56A-E493541BA4E2",exports.PROPERTY_REPORT="PROPERTY_REPORT",exports.CONTROL_DEVICE="CONTROL_DEVICE",exports.CONTROL_ACTION="CONTROL_ACTION",exports.REPORT_RESULT="REPORT_RESULT",exports.CONTROL_REPLY="CONTROL_REPLY",exports.GET_STATUS="GET_STATUS",exports.EVENT_REPORT="EVENT_REPORT",exports.EVENT_REPLY="EVENT_REPLY",exports.ACTION_REPLY="ACTION_REPLY",exports.UPDATE_REPLY="UPDATE_REPLY",exports.UPDATE_DATA_REPLY="UPDATE_DATA_REPLY",exports.UPDATE_DATA_CHECK_REPLY="UPDATE_DATA_CHECK_REPLY",exports.UPDATE_REPLY_INVALID="UPDATE_REPLY_INVALID",exports.BIND_AUTH="BIND_AUTH",exports.SET_MTU_BEFORE_CONNECT="SET_MTU_BEFORE_CONNECT",exports.BIND_AUTH_DETAIL="BIND_AUTH_DETAIL",exports.BIND_AUTH_SUCCESS="BIND_AUTH_SUCCESS",exports.BIND_AUTH_FAIL="BIND_AUTH_FAIL",exports.CONNECT_AUTH="CONNECT_AUTH",exports.DEVICE_INFO="DEVICE_INFO",exports.ANDROID_SET_MTU="ANDROID_SET_MTU",exports.CONNECT_RESULT_WRITE_SUCCESS="CONNECT_RESULT_WRITE_SUCCESS",exports.CONNECT_RESULT_WRITE_FAIL="CONNECT_RESULT_WRITE_FAIL",exports.UNBIND_RESULT_AUTH_SUCCESS="UNBIND_RESULT_AUTH_SUCCESS",exports.UNBIND_RESULT_AUTH_FAIL="UNBIND_RESULT_AUTH_FAIL",exports.UNBIND_AUTH="UNBIND_AUTH",exports.TIME_SYNC="TIME_SYNC",exports.CONTROL_ACTION_SUCCESS="CONTROL_ACTION_SUCCESS",exports.WRITE_MTU_RESULT="WRITE_MTU_RESULT",exports.MTU_MODULE_CALLBACK="MTU_MODULE_CALLBACK",exports.VERIFY_SIGN_FAIL="VERIFY_SIGN_FAIL",exports.APP_IS_READY="APP_IS_READY",exports.APP_ON_IOS_DEVICE="APP_ON_IOS_DEVICE",exports.GET_ADV_DATA="GET_ADV_DATA",exports.GET_ADV_DATA_REPLY="GET_ADV_DATA_REPLY",exports.HEARTBEAT_REQ="HEARTBEAT_REQ",exports.HEARTBEAT_RESP="HEARTBEAT_RESP",exports.NOTIFY_LOCAL_RSSI="NOTIFY_LOCAL_RSSI",exports.GET_DEVICE_INFO="GET_DEVICE_INFO",exports.SET_WIFI_MODE="SET_WIFI_MODE",exports.SET_WIFI_INFO="SET_WIFI_INFO",exports.SET_WIFI_CONNECT="SET_WIFI_CONNECT",exports.SET_WIFI_TOKEN="SET_WIFI_TOKEN",exports.GET_DEV_LOG="GET_DEV_LOG",exports.SET_WIFI_MODE_RESULT="SET_WIFI_MODE_RESULT",exports.SET_WIFI_INFO_RESULT="SET_WIFI_INFO_RESULT",exports.SET_WIFI_CONNECT_RESULT="SET_WIFI_CONNECT_RESULT",exports.SET_WIFI_TOKEN_RESULT="SET_WIFI_TOKEN_RESULT",exports.GET_DEV_LOG_INFO="GET_DEV_LOG_INFO",exports.STA_WIFI_MODE="STA_WIFI_MODE",exports.NULL_WIFI_MODE="NULL_WIFI_MODE",exports.GET_ADV_DATA_RESULT="GET_ADV_DATA_RESULT",exports.WAIT_USER_CHECK_TIMEOUT="WAIT_USER_CHECK_TIMEOUT",exports.GET_USER_CHECK_APPROVE="GET_USER_CHECK_APPROVE",exports.GET_USER_CHECK_REJECT="GET_USER_CHECK_REJECT",exports.USER_CHECK_TIMEOUT="USER_CHECK_TIMEOUT",exports.USER_CHECK_TIMEOUT_CALLBACK="USER_CHECK_TIMEOUT_CALLBACK",exports.GET_USER_CHECK_TIMEOUT_TIMEOUT="GET_USER_CHECK_TIMEOUT_TIMEOUT",exports.GET_USER_CHECK_TIMEOUT_ERROR="GET_USER_CHECK_TIMEOUT_ERROR",exports.GET_USER_CHECK_TIMEOUT_SUCCESS="GET_USER_CHECK_TIMEOUT_SUCCESS",exports.WRITE_USER_CHECK_TIMEOUT=1,exports.WRITE_USER_CHECK_CANCEL=0,exports.REGISTER_DEVICE_INFO_REPLY="REGISTER_DEVICE_INFO_REPLY",exports.SEND_REGISTER_DEVICE_PAYLOAD="SEND_REGISTER_DEVICE_PAYLOAD",exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT="WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT",exports.REGISTER_DEVICE_INFO_REPLY_INVALID="REGISTER_DEVICE_INFO_REPLY_INVALID",exports.REGISTER_DEVICE_ERROR="REGISTER_DEVICE_ERROR",exports.REGISTER_DEVICE_SUCCESS="REGISTER_DEVICE_SUCCESS",exports.UNBIND_REQUEST="UnbindRequest",exports.UNBIND_RESPONSE="UnbindResponse",exports.GET_DEVICE_NAME="GET_DEVICE_NAME",exports.GET_DEVICE_NAME_WITH_REGISTER="GET_DEVICE_NAME_WITH_REGISTER",exports.GET_DEVICE_NAME_WITH_REGISTER_FAILED="GET_DEVICE_NAME_WITH_REGISTER_FAILED",exports.REQUEST_BIND="REQUEST_BIND",exports.REQUEST_BIND_FAILED="REQUEST_BIND_FAILED",exports.REQUEST_BIND_SUCCESS="REQUEST_BIND_SUCCESS",exports.NOTIFY_BIND="NOTIFY_BIND",exports.RESPONSE_BIND="RESPONSE_BIND",exports.CONNECT_REQUEST="CONNECT_REQUEST",exports.CONNECT_ACK="CONNECT_ACK",exports.NOTIFY_BIND_FAILED="NOTIFY_BIND_FAILED",exports.NOTIFY_BIND_SUCCESS="NOTIFY_BIND_SUCCESS",exports.INDICATE_TYPE_MAP={0:exports.PROPERTY_REPORT,1:exports.CONTROL_REPLY,2:exports.GET_STATUS,3:exports.EVENT_REPORT,4:exports.ACTION_REPLY,5:exports.BIND_AUTH,6:exports.CONNECT_AUTH,7:exports.UNBIND_AUTH,8:exports.DEVICE_INFO,9:exports.UPDATE_REPLY,10:exports.UPDATE_DATA_REPLY,11:exports.UPDATE_DATA_CHECK_REPLY,12:exports.MTU_MODULE_CALLBACK,13:exports.USER_CHECK_TIMEOUT_CALLBACK,14:exports.REGISTER_DEVICE_INFO_REPLY,17:exports.GET_DEVICE_NAME,18:exports.REQUEST_BIND,19:exports.NOTIFY_BIND,20:exports.RESPONSE_BIND,21:exports.CONNECT_REQUEST,22:exports.CONNECT_ACK,23:exports.UNBIND_REQUEST,24:exports.UNBIND_RESPONSE,25:exports.GET_DEVICE_NAME_WITH_REGISTER,26:exports.GET_ADV_DATA_REPLY,27:exports.HEARTBEAT_RESP,224:exports.SET_WIFI_MODE_RESULT,225:exports.SET_WIFI_INFO_RESULT,226:exports.SET_WIFI_CONNECT_RESULT,227:exports.SET_WIFI_TOKEN_RESULT,228:exports.GET_DEV_LOG_INFO},exports.BleErrorMsg={1:"BLE_QIOT_SIGN_ERR",2:"BLE_QIOT_BIND_ERR",3:"BLE_QIOT_CONN_ERR",4:"BLE_QIOT_UNBIND_ERR"},exports.DEVICE_INFO_WRITE_PREFIX=((_a={})[exports.TIME_SYNC]="00",_a[exports.CONNECT_AUTH]="01",_a[exports.BIND_AUTH_SUCCESS]="02",_a[exports.BIND_AUTH_FAIL]="03",_a[exports.UNBIND_AUTH]="04",_a[exports.CONNECT_RESULT_WRITE_SUCCESS]="05",_a[exports.CONNECT_RESULT_WRITE_FAIL]="06",_a[exports.UNBIND_RESULT_AUTH_SUCCESS]="07",_a[exports.UNBIND_RESULT_AUTH_FAIL]="08",_a[exports.WRITE_MTU_RESULT]="09",_a[exports.USER_CHECK_TIMEOUT]="0A",_a[exports.SEND_REGISTER_DEVICE_PAYLOAD]="0B",_a[exports.APP_IS_READY]="0C",_a[exports.APP_ON_IOS_DEVICE]="0D",_a[exports.GET_DEVICE_INFO]="E0",_a[exports.SET_WIFI_MODE]="E1",_a[exports.SET_WIFI_INFO]="E2",_a[exports.SET_WIFI_CONNECT]="E3",_a[exports.SET_WIFI_TOKEN]="E4",_a[exports.GET_DEV_LOG]="E5",_a[exports.GET_DEVICE_NAME]="11",_a[exports.REQUEST_BIND]="12",_a[exports.NOTIFY_BIND]="13",_a[exports.RESPONSE_BIND]="14",_a[exports.CONNECT_REQUEST]="15",_a[exports.CONNECT_ACK]="16",_a[exports.UNBIND_REQUEST]="17",_a[exports.UNBIND_RESPONSE]="18",_a[exports.GET_DEVICE_NAME_WITH_REGISTER]="19",_a[exports.GET_ADV_DATA]="1A",_a[exports.HEARTBEAT_REQ]="1B",_a[exports.NOTIFY_LOCAL_RSSI]="1C",_a),exports.DEVICE_DATA_WRITE_HEAD=((_b={})[exports.CONTROL_DEVICE]="000",_b[exports.REPORT_RESULT]="001",_b[exports.GET_STATUS]="001",_b[exports.EVENT_REPLY]="011",_b[exports.CONTROL_ACTION]="100",_b),exports.DEVICE_DATA_WRITE_SUFFIX=((_c={})[exports.CONTROL_DEVICE]="00000",_c[exports.REPORT_RESULT]="00000",_c[exports.GET_STATUS]="00010",_c),exports.WIFI_MODE_MAP=((_d={})[exports.NULL_WIFI_MODE]=0,_d[exports.STA_WIFI_MODE]=1,_d),exports.WIFI_LOG_TYPE_MAP={ERROR_LOG:0,NORMAL_LOG:1},exports.ACTION_DESC=((_e={})[exports.CONTROL_DEVICE]="远程控制",_e[exports.REPORT_RESULT]="属性上报结果通知",_e[exports.GET_STATUS]="写入设备最新状态",_e[exports.EVENT_REPLY]="处理设备端事件上报",_e[exports.CONTROL_ACTION]="对设备进行行为调用",_e[exports.CONTROL_ACTION_SUCCESS]="对设备进行行为调用成功",_e[exports.TIME_SYNC]="时间同步",_e[exports.CONNECT_AUTH]="连接鉴权",_e[exports.BIND_AUTH]="绑定鉴权",_e[exports.BIND_AUTH_DETAIL]="绑定鉴权详情",_e[exports.BIND_AUTH_SUCCESS]="绑定鉴权成功",_e[exports.UNBIND_AUTH]="解绑鉴权",_e[exports.CONNECT_RESULT_WRITE_SUCCESS]="连接小程序端鉴权成功",_e[exports.UNBIND_RESULT_AUTH_SUCCESS]="解绑小程序端鉴权成功",_e[exports.APP_IS_READY]="通知设备端小程序已经就绪",_e[exports.APP_ON_IOS_DEVICE]="通知设备端小程序运行于 iOS 环境",_e[exports.GET_ADV_DATA]="获取设备广播信息",_e[exports.HEARTBEAT_REQ]="蓝牙连接心跳",_e[exports.NOTIFY_LOCAL_RSSI]="同步小程序侧 RSSI",_e),exports.BLE_IOT_DATA_TYPE_BOOL="bool",exports.BLE_IOT_DATA_TYPE_INT="int",exports.BLE_IOT_DATA_TYPE_STRING="string",exports.BLE_IOT_DATA_TYPE_FLOAT="float",exports.BLE_IOT_DATA_TYPE_ENUM="enum",exports.BLE_IOT_DATA_TYPE_TIME="timestamp",exports.BLE_IOT_DATA_TYPE_STRUCT="struct",exports.BLE_IOT_DATA_TYPE_ARRAY="array",exports.OTA_UPDATE_REQUEST="OTA_UPDATE_REQUEST",exports.OTA_UPDATE_DATA="OTA_UPDATE_DATA",exports.OTA_UPDATE_DATA_END="OTA_UPDATE_DATA_END",exports.LL_OTA_WRITE_PREFIX=((_f={})[exports.OTA_UPDATE_REQUEST]="00",_f[exports.OTA_UPDATE_DATA]="01",_f[exports.OTA_UPDATE_DATA_END]="02",_f),exports.USER_NEED_LOGIN="USER_NEED_LOGIN",exports.WAIT_CONNECT_REPLY_TIMEOUT="WAIT_CONNECT_REPLY_TIMEOUT",exports.CONNECT_REPLY_INVALID="CONNECT_REPLY_INVALID",exports.WAIT_UNBIND_REPLY_TIMEOUT="WAIT_UNBIND_REPLY_TIMEOUT",exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT="WAIT_CONTROL_DEVICE_REPLY_TIMEOUT",exports.WAIT_CONTROL_ACTION_REPLY_TIMEOUT="WAIT_CONTROL_ACTION_REPLY_TIMEOUT",exports.UNBIND_REPLY_INVALID="UNBIND_REPLY_INVALID",exports.CONTROL_REPLY_INVALID="CONTROL_REPLY_INVALID",exports.CONTROL_ACTION_ERROR="CONTROL_ACTION_ERROR",exports.CONNECT_DEVICE_ERROR="CONNECT_DEVICE_ERROR",exports.CANNOT_FIND_DEVICE="CANNOT_FIND_DEVICE",exports.DEVICE_NAME_IS_EMPTY="DEVICE_NAME_IS_EMPTY",exports.PSK_GET_ERROR="PSK_GET_ERROR",exports.CONNECT_SIGN_AUTH_ERROR="CONNECT_SIGN_AUTH_ERROR",exports.CONNECT_SIGN_VERIFY_ERROR="CONNECT_SIGN_VERIFY_ERROR",exports.UNBIND_REPLY_ERROR="UNBIND_REPLY_ERROR",exports.CONTROL_REPLY_CODE_INVALID="CONTROL_REPLY_CODE_INVALID",exports.CONTROL_DEVICE_REPLY_ERROR="CONTROL_DEVICE_REPLY_ERROR",exports.REPORT_RESULT_ERROR="REPORT_RESULT_ERROR",exports.GET_STATUS_ERROR="GET_STATUS_ERROR",exports.EVENT_REPLY_ERROR="EVENT_REPLY_ERROR",exports.BLE_WRITE_ERROR="BLE_WRITE_ERROR",exports.WAIT_GET_DEVICE_INFO_TIMEOUT="WAIT_GET_DEVICE_INFO_TIMEOUT",exports.DEVICE_INFO_INVALID="DEVICE_INFO_INVALID",exports.PROPERTY_REPORT_API_FAIL="PROPERTY_REPORT_API_FAIL",exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT="WAIT_GET_ADV_DATA_REPLY_TIMEOUT",exports.GET_ADV_DATA_FAIL="GET_ADV_DATA_FAIL",exports.GET_ADV_DATA_REPLY_INVALID="GET_ADV_DATA_REPLY_INVALID",exports.WAIT_GET_UPDATE_INFO_TIMEOUT="WAIT_GET_UPDATE_INFO_TIMEOUT",exports.WAIT_MODULE_UPDATE_TIMEOUT="WAIT_MODULE_UPDATE_TIMEOUT",exports.SET_WIFI_MODE_RESULT_INVALID="SET_WIFI_MODE_RESULT_INVALID",exports.SET_WIFI_MODE_RESULT_TIMEOUT="SET_WIFI_MODE_RESULT_TIMEOUT",exports.SET_WIFI_INFO_RESULT_INVALID="SET_WIFI_INFO_INVALID",exports.SET_WIFI_INFO_RESULT_TIMEOUT="SET_WIFI_INFO_TIMEOUT",exports.SET_WIFI_CONNECT_RESULT_INVALID="SET_WIFI_CONNECT_RESULT_INVALID",exports.SET_WIFI_CONNECT_RESULT_TIMEOUT="SET_WIFI_CONNECT_RESULT_TIMEOUT",exports.SET_WIFI_TOKEN_RESULT_INVALID="SET_WIFI_TOKEN_RESULT_INVALID",exports.SET_WIFI_TOKEN_RESULT_TIMEOUT="SET_WIFI_TOKEN_RESULT_TIMEOUT",exports.GET_DEV_LOG_INFO_INVALID="GET_DEV_LOG_INFO_INVALID",exports.GET_DEV_LOG_INFO_TIMEOUT="GET_DEV_LOG_INFO_TIMEOUT",exports.OTA_UPDATE_STEPS={GET_OTA_UPDATE_INFO:"GET_OTA_UPDATE_INFO",GET_OTA_UPDATE_INFO_SUCCESS:"GET_OTA_UPDATE_INFO_SUCCESS",DOWNLOADING_OTA_FILE:"DOWNLOADING_OTA_FILE",DOWNLOADING_OTA_FILE_DETAIL:"DOWNLOADING_OTA_FILE_DETAIL",DOWNLOAD_OTA_FILE_SUCCESS:"DOWNLOAD_OTA_FILE_SUCCESS",REQUEST_MODULE_UPDATE_START:"REQUEST_MODULE_UPDATE",REQUEST_MODULE_UPDATE_SUCCESS:"REQUEST_MODULE_UPDATE_SUCCESS",MODULE_UPDATE_CHECK_FILE_SUCCESS:"MODULE_UPDATE_CHECK_FILE_SUCCESS",SEND_UPDATE_DATA_START:"SEND_UPDATE_DATA_START",SEND_UPDATE_DATA_DETAIL:"SEND_UPDATE_DATA_DETAIL",SEND_UPDATE_DATA_SUCCESS:"SEND_UPDATE_DATA_SUCCESS",WAITING_MODULE_UPDATE:"WAITING_MODULE_UPDATE",MODULE_UPDATE_SUCCESS:"MODULE_UPDATE_SUCCESS"},exports.OTA_UPDATE_STEPS_MESSAGE=((_g={})[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO]="获取固件版本信息",_g[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO_SUCCESS]="获取固件版本信息成功",_g[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE]="正在下载OTA文件",_g[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE_DETAIL]="正在下载OTA文件详情",_g[exports.OTA_UPDATE_STEPS.DOWNLOAD_OTA_FILE_SUCCESS]="下载OTA文件成功",_g[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_START]="开始检查设备端固件升级支持情况",_g[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_SUCCESS]="检查设备端固件升级支持情况成功",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_START]="开始发送固件升级文件",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_DETAIL]="固件升级文件详情",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_SUCCESS]="固件升级文件发送成功",_g[exports.OTA_UPDATE_STEPS.WAITING_MODULE_UPDATE]="开始烧录固件升级文件",_g[exports.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS]="设备端固件升级成功",_g),exports.OTA_UPDATE_ERRORS=((_h={GET_OTA_INFO_FAIL:"获取OTA升级信息失败",MODULE_VERSION_IS_UPDATED:"设备端固件已经是最新版",MODULE_DONNOT_SUPPORT:"设备端固件不支持",USER_CANCEL_OTA_UPDATE:"用户取消固件升级",MODULE_DONNOT_ALLOW:"设备端固件不允许,可能是当前状态不允许",MODULE_UPDATE_CHECK_FILE_FAIL:"升级文件校验失败",GET_FILE_CRC_ERROR:"获取文件和crc错误"})[exports.WAIT_GET_UPDATE_INFO_TIMEOUT]="获取设备端分片包回包超时",_h[exports.WAIT_MODULE_UPDATE_TIMEOUT]="等待设备端升级超时",_h.UPDATE_DATA_REPLAY_TIMEOUT="发送固件升级文件超时",_h.MODULE_UPDATE_FAIL="设备端固件升级失败",_h.MODULE_UPDATE_CONNECT_TIMEOUT="设备端固件升级连接设备超时",_h.BLE_CONNECTION_BREAK="蓝牙连接断开",_h),exports.BLE_COMBO_ERRORS=((_j={})[exports.SET_WIFI_MODE_RESULT_INVALID]="设置WiFi模式返回格式错误",_j[exports.SET_WIFI_MODE_RESULT_TIMEOUT]="设置WiFi模式返回超时,请稍后再试",_j[exports.SET_WIFI_INFO_RESULT_INVALID]="WiFi信息传输返回格式错误",_j[exports.SET_WIFI_INFO_RESULT_TIMEOUT]="WiFi信息传输返回超时,请稍后再试",_j[exports.SET_WIFI_CONNECT_RESULT_INVALID]="WiFi连接失败",_j[exports.SET_WIFI_CONNECT_RESULT_TIMEOUT]="获取WiFi连接状态超时",_j[exports.SET_WIFI_TOKEN_RESULT_INVALID]="发送配网token结果非法",_j[exports.SET_WIFI_TOKEN_RESULT_TIMEOUT]="发送配网token结果超时,请稍后再试",_j[exports.GET_DEV_LOG_INFO_INVALID]="获取配网日志格式错误",_j[exports.GET_DEV_LOG_INFO_TIMEOUT]="获取配网日志超时,请稍后再试",_j),exports.MODULE_UPDATE_REPLAY_CODE_MAP={0:"设备电量不足",1:"版本号错误"},exports.MODULE_UPDATE_DATA_REPLAY_CODE_MAP={1:exports.OTA_UPDATE_STEPS.MODULE_UPDATE_CHECK_FILE_SUCCESS,0:"MODULE_UPDATE_CHECK_FILE_FAIL"},exports.MODULE_UPDATE_REPLAY_DATA_CODE_MAP={0:"CRC错误",1:"文件读取失败",2:"文件错误"},exports.WAIT_MODULE_UPDATE_CONNECT_TIMES=5,exports.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP=2e3,exports.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE=5,exports.MAX_WRITE_DATA_WAIT_GAP=200,exports.ERROR_MESSAGES=tslib_1.__assign(tslib_1.__assign(((_k={})[exports.USER_NEED_LOGIN]="用户未登录,不能连接蓝牙",_k[exports.CONTROL_ACTION_ERROR]="行为调用失败",_k[exports.CONNECT_DEVICE_ERROR]="连接设备失败",_k[exports.CANNOT_FIND_DEVICE]="无法找到设备",_k[exports.USER_NEED_LOGIN]="请重新登录",_k[exports.WAIT_CONNECT_REPLY_TIMEOUT]="等待连接回复超时",_k[exports.CONNECT_REPLY_INVALID]="等待连接回复非法",_k[exports.GET_USER_CHECK_REJECT]="用户端确认拒绝",_k[exports.WAIT_USER_CHECK_TIMEOUT]="等待用户确认超时",_k[exports.GET_USER_CHECK_TIMEOUT_TIMEOUT]="获取设备端用户确认超时时间超时,使用默认超时时间",_k[exports.GET_USER_CHECK_TIMEOUT_ERROR]="获取设备端用户确认超时时间失败,使用默认超时时间",_k[exports.DEVICE_NAME_IS_EMPTY]="设备名称非法",_k[exports.PSK_GET_ERROR]="获取local psk失败",_k[exports.CONNECT_SIGN_AUTH_ERROR]="获取连接认证失败",_k[exports.WAIT_UNBIND_REPLY_TIMEOUT]="获取解绑回复超时",_k[exports.UNBIND_REPLY_INVALID]="解绑回复非法",_k[exports.UNBIND_REPLY_ERROR]="解绑回复失败",_k[exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT]="等待控制设备回复超时",_k[exports.CONTROL_DEVICE_REPLY_ERROR]="控制设备失败",_k[exports.CONTROL_REPLY_INVALID]="等待控制设备回复非法",_k[exports.BIND_AUTH_FAIL]="绑定鉴权失败",_k[exports.UNBIND_RESULT_AUTH_FAIL]="解绑小程序端鉴权失败",_k[exports.CONNECT_RESULT_WRITE_FAIL]="连接小程序端鉴权失败",_k[exports.CONTROL_REPLY_CODE_INVALID]="设备端控制回包code非0",_k[exports.REPORT_RESULT_ERROR]="上报设备最新状态失败",_k[exports.GET_STATUS_ERROR]="获取最新状态失败",_k[exports.EVENT_REPLY_ERROR]="EVENT_REPLY_ERROR",_k[exports.BLE_WRITE_ERROR]="设备写入失败",_k[exports.WAIT_GET_DEVICE_INFO_TIMEOUT]="获取设备信息超时",_k[exports.DEVICE_INFO_INVALID]="设备版本和MTU信息非法",_k.ID_TEMPLATE_IS_NOT_EXIT="设备端传的id在物模型里面不存在",_k.TYPE_IN_MODULE_IS_WRONG="设备端的type和后台的不一致",_k[exports.PROPERTY_REPORT_API_FAIL]="属性上报云端回复失败",_k),exports.OTA_UPDATE_ERRORS),((_l={})[exports.REGISTER_DEVICE_ERROR]="从云端动态注册失败",_l[exports.REGISTER_DEVICE_INFO_REPLY_INVALID]="设备端回复的云端注册信息非法",_l[exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT]="等待设备端回复的云端注册信息超时",_l[exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT]="等待设备端回复广播信息超时",_l[exports.GET_ADV_DATA_FAIL]="设备端回复获取广播信息失败",_l)),function(_){_[_.Success=0]="Success",_[_.Fail=1]="Fail",_[_.ParseDataFail=2]="ParseDataFail"}(PropertyReportReplyResult=exports.PropertyReportReplyResult||(exports.PropertyReportReplyResult={})),exports.WRITE_DATA_CANCEL_ERROR_CODE="BLE_WRITE_CHARACTERISTIC_CANCELLED";
"use strict";var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ATT_MTU_TO_LLSYNC_MTU_DELTA=exports.MIN_ATT_MTU=exports.WRITE_DATA_CANCEL_ERROR_CODE=exports.PropertyReportReplyResult=exports.ERROR_MESSAGES=exports.MAX_WRITE_DATA_WAIT_GAP=exports.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE=exports.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP=exports.WAIT_MODULE_UPDATE_CONNECT_TIMES=exports.MODULE_UPDATE_REPLAY_DATA_CODE_MAP=exports.MODULE_UPDATE_DATA_REPLAY_CODE_MAP=exports.MODULE_UPDATE_REPLAY_CODE_MAP=exports.BLE_COMBO_ERRORS=exports.OTA_UPDATE_ERRORS=exports.OTA_UPDATE_STEPS_MESSAGE=exports.OTA_UPDATE_STEPS=exports.GET_DEV_LOG_INFO_TIMEOUT=exports.GET_DEV_LOG_INFO_INVALID=exports.SET_WIFI_TOKEN_RESULT_TIMEOUT=exports.SET_WIFI_TOKEN_RESULT_INVALID=exports.SET_WIFI_CONNECT_RESULT_TIMEOUT=exports.SET_WIFI_CONNECT_RESULT_INVALID=exports.SET_WIFI_INFO_RESULT_TIMEOUT=exports.SET_WIFI_INFO_RESULT_INVALID=exports.SET_WIFI_MODE_RESULT_TIMEOUT=exports.SET_WIFI_MODE_RESULT_INVALID=exports.WAIT_MODULE_UPDATE_TIMEOUT=exports.WAIT_GET_UPDATE_INFO_TIMEOUT=exports.GET_ADV_DATA_REPLY_INVALID=exports.GET_ADV_DATA_FAIL=exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT=exports.PROPERTY_REPORT_API_FAIL=exports.DEVICE_INFO_INVALID=exports.WAIT_GET_DEVICE_INFO_TIMEOUT=exports.BLE_WRITE_ERROR=exports.EVENT_REPLY_ERROR=exports.GET_STATUS_ERROR=exports.REPORT_RESULT_ERROR=exports.CONTROL_DEVICE_REPLY_ERROR=exports.CONTROL_REPLY_CODE_INVALID=exports.UNBIND_REPLY_ERROR=exports.CONNECT_SIGN_VERIFY_ERROR=exports.CONNECT_SIGN_AUTH_ERROR=exports.PSK_GET_ERROR=exports.DEVICE_NAME_IS_EMPTY=exports.CANNOT_FIND_DEVICE=exports.CONNECT_DEVICE_ERROR=exports.CONTROL_ACTION_ERROR=exports.CONTROL_REPLY_INVALID=exports.UNBIND_REPLY_INVALID=exports.WAIT_CONTROL_ACTION_REPLY_TIMEOUT=exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT=exports.WAIT_UNBIND_REPLY_TIMEOUT=exports.CONNECT_REPLY_INVALID=exports.WAIT_CONNECT_REPLY_TIMEOUT=exports.USER_NEED_LOGIN=exports.LL_OTA_WRITE_PREFIX=exports.OTA_UPDATE_DATA_END=exports.OTA_UPDATE_DATA=exports.OTA_UPDATE_REQUEST=exports.BLE_IOT_DATA_TYPE_ARRAY=exports.BLE_IOT_DATA_TYPE_STRUCT=exports.BLE_IOT_DATA_TYPE_TIME=exports.BLE_IOT_DATA_TYPE_ENUM=exports.BLE_IOT_DATA_TYPE_FLOAT=exports.BLE_IOT_DATA_TYPE_STRING=exports.BLE_IOT_DATA_TYPE_INT=exports.BLE_IOT_DATA_TYPE_BOOL=exports.ACTION_DESC=exports.WIFI_LOG_TYPE_MAP=exports.WIFI_MODE_MAP=exports.DEVICE_DATA_WRITE_SUFFIX=exports.DEVICE_DATA_WRITE_HEAD=exports.DEVICE_INFO_WRITE_PREFIX=exports.BleErrorMsg=exports.INDICATE_TYPE_MAP=exports.NOTIFY_BIND_SUCCESS=exports.NOTIFY_BIND_FAILED=exports.CONNECT_ACK=exports.CONNECT_REQUEST=exports.RESPONSE_BIND=exports.NOTIFY_BIND=exports.REQUEST_BIND_SUCCESS=exports.REQUEST_BIND_FAILED=exports.REQUEST_BIND=exports.GET_DEVICE_NAME_WITH_REGISTER_FAILED=exports.GET_DEVICE_NAME_WITH_REGISTER=exports.GET_DEVICE_NAME=exports.UNBIND_RESPONSE=exports.UNBIND_REQUEST=exports.REGISTER_DEVICE_SUCCESS=exports.REGISTER_DEVICE_ERROR=exports.REGISTER_DEVICE_INFO_REPLY_INVALID=exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT=exports.SEND_REGISTER_DEVICE_PAYLOAD=exports.REGISTER_DEVICE_INFO_REPLY=exports.WRITE_USER_CHECK_CANCEL=exports.WRITE_USER_CHECK_TIMEOUT=exports.GET_USER_CHECK_TIMEOUT_SUCCESS=exports.GET_USER_CHECK_TIMEOUT_ERROR=exports.GET_USER_CHECK_TIMEOUT_TIMEOUT=exports.USER_CHECK_TIMEOUT_CALLBACK=exports.USER_CHECK_TIMEOUT=exports.GET_USER_CHECK_REJECT=exports.GET_USER_CHECK_APPROVE=exports.WAIT_USER_CHECK_TIMEOUT=exports.GET_ADV_DATA_RESULT=exports.NULL_WIFI_MODE=exports.STA_WIFI_MODE=exports.GET_DEV_LOG_INFO=exports.SET_WIFI_TOKEN_RESULT=exports.SET_WIFI_CONNECT_RESULT=exports.SET_WIFI_INFO_RESULT=exports.SET_WIFI_MODE_RESULT=exports.GET_DEV_LOG=exports.SET_WIFI_TOKEN=exports.SET_WIFI_CONNECT=exports.SET_WIFI_INFO=exports.SET_WIFI_MODE=exports.GET_DEVICE_INFO=exports.NOTIFY_LOCAL_RSSI=exports.HEARTBEAT_RESP=exports.HEARTBEAT_REQ=exports.GET_ADV_DATA_REPLY=exports.GET_ADV_DATA=exports.APP_ON_IOS_DEVICE=exports.APP_IS_READY=exports.VERIFY_SIGN_FAIL=exports.MTU_MODULE_CALLBACK=exports.WRITE_MTU_RESULT=exports.CONTROL_ACTION_SUCCESS=exports.TIME_SYNC=exports.UNBIND_AUTH=exports.UNBIND_RESULT_AUTH_FAIL=exports.UNBIND_RESULT_AUTH_SUCCESS=exports.CONNECT_RESULT_WRITE_FAIL=exports.CONNECT_RESULT_WRITE_SUCCESS=exports.ANDROID_SET_MTU=exports.DEVICE_INFO=exports.CONNECT_AUTH=exports.BIND_AUTH_FAIL=exports.BIND_AUTH_SUCCESS=exports.BIND_AUTH_DETAIL=exports.SET_MTU_BEFORE_CONNECT=exports.BIND_AUTH=exports.UPDATE_REPLY_INVALID=exports.UPDATE_DATA_CHECK_REPLY=exports.UPDATE_DATA_REPLY=exports.UPDATE_REPLY=exports.ACTION_REPLY=exports.EVENT_REPLY=exports.EVENT_REPORT=exports.GET_STATUS=exports.CONTROL_REPLY=exports.REPORT_RESULT=exports.CONTROL_ACTION=exports.CONTROL_DEVICE=exports.PROPERTY_REPORT=exports.LL_OTA_WRITE_ID=exports.DEVICE_EVENT_WRITE_ID=exports.DEVICE_DATA_WRITE_ID=exports.DEVICE_INFO_WRITE_ID=exports.DEVICE_STATE_MAP=exports.DEVICE_HAS_CONNECTED=exports.DEVICE_WAITING_BIND=exports.DEVICE_NOT_BIND=exports.DEVICE_HAS_BINDED=exports.REPORT_EVENT_TYPE=void 0;var PropertyReportReplyResult,tslib_1=require("tslib");exports.REPORT_EVENT_TYPE="standard-ble",exports.DEVICE_HAS_BINDED="DEVICE_HAS_BINDED",exports.DEVICE_NOT_BIND="DEVICE_NOT_BIND",exports.DEVICE_WAITING_BIND="DEVICE_WAITING_BIND",exports.DEVICE_HAS_CONNECTED="DEVICE_HAS_CONNECTED",exports.DEVICE_STATE_MAP={0:exports.DEVICE_NOT_BIND,1:exports.DEVICE_WAITING_BIND,2:exports.DEVICE_HAS_BINDED,3:exports.DEVICE_HAS_CONNECTED},exports.DEVICE_INFO_WRITE_ID="0000FFE1-65D0-4E20-B56A-E493541BA4E2",exports.DEVICE_DATA_WRITE_ID="0000FFE2-65D0-4E20-B56A-E493541BA4E2",exports.DEVICE_EVENT_WRITE_ID="0000FFE3-65D0-4E20-B56A-E493541BA4E2",exports.LL_OTA_WRITE_ID="0000FFE4-65D0-4E20-B56A-E493541BA4E2",exports.PROPERTY_REPORT="PROPERTY_REPORT",exports.CONTROL_DEVICE="CONTROL_DEVICE",exports.CONTROL_ACTION="CONTROL_ACTION",exports.REPORT_RESULT="REPORT_RESULT",exports.CONTROL_REPLY="CONTROL_REPLY",exports.GET_STATUS="GET_STATUS",exports.EVENT_REPORT="EVENT_REPORT",exports.EVENT_REPLY="EVENT_REPLY",exports.ACTION_REPLY="ACTION_REPLY",exports.UPDATE_REPLY="UPDATE_REPLY",exports.UPDATE_DATA_REPLY="UPDATE_DATA_REPLY",exports.UPDATE_DATA_CHECK_REPLY="UPDATE_DATA_CHECK_REPLY",exports.UPDATE_REPLY_INVALID="UPDATE_REPLY_INVALID",exports.BIND_AUTH="BIND_AUTH",exports.SET_MTU_BEFORE_CONNECT="SET_MTU_BEFORE_CONNECT",exports.BIND_AUTH_DETAIL="BIND_AUTH_DETAIL",exports.BIND_AUTH_SUCCESS="BIND_AUTH_SUCCESS",exports.BIND_AUTH_FAIL="BIND_AUTH_FAIL",exports.CONNECT_AUTH="CONNECT_AUTH",exports.DEVICE_INFO="DEVICE_INFO",exports.ANDROID_SET_MTU="ANDROID_SET_MTU",exports.CONNECT_RESULT_WRITE_SUCCESS="CONNECT_RESULT_WRITE_SUCCESS",exports.CONNECT_RESULT_WRITE_FAIL="CONNECT_RESULT_WRITE_FAIL",exports.UNBIND_RESULT_AUTH_SUCCESS="UNBIND_RESULT_AUTH_SUCCESS",exports.UNBIND_RESULT_AUTH_FAIL="UNBIND_RESULT_AUTH_FAIL",exports.UNBIND_AUTH="UNBIND_AUTH",exports.TIME_SYNC="TIME_SYNC",exports.CONTROL_ACTION_SUCCESS="CONTROL_ACTION_SUCCESS",exports.WRITE_MTU_RESULT="WRITE_MTU_RESULT",exports.MTU_MODULE_CALLBACK="MTU_MODULE_CALLBACK",exports.VERIFY_SIGN_FAIL="VERIFY_SIGN_FAIL",exports.APP_IS_READY="APP_IS_READY",exports.APP_ON_IOS_DEVICE="APP_ON_IOS_DEVICE",exports.GET_ADV_DATA="GET_ADV_DATA",exports.GET_ADV_DATA_REPLY="GET_ADV_DATA_REPLY",exports.HEARTBEAT_REQ="HEARTBEAT_REQ",exports.HEARTBEAT_RESP="HEARTBEAT_RESP",exports.NOTIFY_LOCAL_RSSI="NOTIFY_LOCAL_RSSI",exports.GET_DEVICE_INFO="GET_DEVICE_INFO",exports.SET_WIFI_MODE="SET_WIFI_MODE",exports.SET_WIFI_INFO="SET_WIFI_INFO",exports.SET_WIFI_CONNECT="SET_WIFI_CONNECT",exports.SET_WIFI_TOKEN="SET_WIFI_TOKEN",exports.GET_DEV_LOG="GET_DEV_LOG",exports.SET_WIFI_MODE_RESULT="SET_WIFI_MODE_RESULT",exports.SET_WIFI_INFO_RESULT="SET_WIFI_INFO_RESULT",exports.SET_WIFI_CONNECT_RESULT="SET_WIFI_CONNECT_RESULT",exports.SET_WIFI_TOKEN_RESULT="SET_WIFI_TOKEN_RESULT",exports.GET_DEV_LOG_INFO="GET_DEV_LOG_INFO",exports.STA_WIFI_MODE="STA_WIFI_MODE",exports.NULL_WIFI_MODE="NULL_WIFI_MODE",exports.GET_ADV_DATA_RESULT="GET_ADV_DATA_RESULT",exports.WAIT_USER_CHECK_TIMEOUT="WAIT_USER_CHECK_TIMEOUT",exports.GET_USER_CHECK_APPROVE="GET_USER_CHECK_APPROVE",exports.GET_USER_CHECK_REJECT="GET_USER_CHECK_REJECT",exports.USER_CHECK_TIMEOUT="USER_CHECK_TIMEOUT",exports.USER_CHECK_TIMEOUT_CALLBACK="USER_CHECK_TIMEOUT_CALLBACK",exports.GET_USER_CHECK_TIMEOUT_TIMEOUT="GET_USER_CHECK_TIMEOUT_TIMEOUT",exports.GET_USER_CHECK_TIMEOUT_ERROR="GET_USER_CHECK_TIMEOUT_ERROR",exports.GET_USER_CHECK_TIMEOUT_SUCCESS="GET_USER_CHECK_TIMEOUT_SUCCESS",exports.WRITE_USER_CHECK_TIMEOUT=1,exports.WRITE_USER_CHECK_CANCEL=0,exports.REGISTER_DEVICE_INFO_REPLY="REGISTER_DEVICE_INFO_REPLY",exports.SEND_REGISTER_DEVICE_PAYLOAD="SEND_REGISTER_DEVICE_PAYLOAD",exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT="WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT",exports.REGISTER_DEVICE_INFO_REPLY_INVALID="REGISTER_DEVICE_INFO_REPLY_INVALID",exports.REGISTER_DEVICE_ERROR="REGISTER_DEVICE_ERROR",exports.REGISTER_DEVICE_SUCCESS="REGISTER_DEVICE_SUCCESS",exports.UNBIND_REQUEST="UnbindRequest",exports.UNBIND_RESPONSE="UnbindResponse",exports.GET_DEVICE_NAME="GET_DEVICE_NAME",exports.GET_DEVICE_NAME_WITH_REGISTER="GET_DEVICE_NAME_WITH_REGISTER",exports.GET_DEVICE_NAME_WITH_REGISTER_FAILED="GET_DEVICE_NAME_WITH_REGISTER_FAILED",exports.REQUEST_BIND="REQUEST_BIND",exports.REQUEST_BIND_FAILED="REQUEST_BIND_FAILED",exports.REQUEST_BIND_SUCCESS="REQUEST_BIND_SUCCESS",exports.NOTIFY_BIND="NOTIFY_BIND",exports.RESPONSE_BIND="RESPONSE_BIND",exports.CONNECT_REQUEST="CONNECT_REQUEST",exports.CONNECT_ACK="CONNECT_ACK",exports.NOTIFY_BIND_FAILED="NOTIFY_BIND_FAILED",exports.NOTIFY_BIND_SUCCESS="NOTIFY_BIND_SUCCESS",exports.INDICATE_TYPE_MAP={0:exports.PROPERTY_REPORT,1:exports.CONTROL_REPLY,2:exports.GET_STATUS,3:exports.EVENT_REPORT,4:exports.ACTION_REPLY,5:exports.BIND_AUTH,6:exports.CONNECT_AUTH,7:exports.UNBIND_AUTH,8:exports.DEVICE_INFO,9:exports.UPDATE_REPLY,10:exports.UPDATE_DATA_REPLY,11:exports.UPDATE_DATA_CHECK_REPLY,12:exports.MTU_MODULE_CALLBACK,13:exports.USER_CHECK_TIMEOUT_CALLBACK,14:exports.REGISTER_DEVICE_INFO_REPLY,17:exports.GET_DEVICE_NAME,18:exports.REQUEST_BIND,19:exports.NOTIFY_BIND,20:exports.RESPONSE_BIND,21:exports.CONNECT_REQUEST,22:exports.CONNECT_ACK,23:exports.UNBIND_REQUEST,24:exports.UNBIND_RESPONSE,25:exports.GET_DEVICE_NAME_WITH_REGISTER,26:exports.GET_ADV_DATA_REPLY,27:exports.HEARTBEAT_RESP,224:exports.SET_WIFI_MODE_RESULT,225:exports.SET_WIFI_INFO_RESULT,226:exports.SET_WIFI_CONNECT_RESULT,227:exports.SET_WIFI_TOKEN_RESULT,228:exports.GET_DEV_LOG_INFO},exports.BleErrorMsg={1:"BLE_QIOT_SIGN_ERR",2:"BLE_QIOT_BIND_ERR",3:"BLE_QIOT_CONN_ERR",4:"BLE_QIOT_UNBIND_ERR"},exports.DEVICE_INFO_WRITE_PREFIX=((_a={})[exports.TIME_SYNC]="00",_a[exports.CONNECT_AUTH]="01",_a[exports.BIND_AUTH_SUCCESS]="02",_a[exports.BIND_AUTH_FAIL]="03",_a[exports.UNBIND_AUTH]="04",_a[exports.CONNECT_RESULT_WRITE_SUCCESS]="05",_a[exports.CONNECT_RESULT_WRITE_FAIL]="06",_a[exports.UNBIND_RESULT_AUTH_SUCCESS]="07",_a[exports.UNBIND_RESULT_AUTH_FAIL]="08",_a[exports.WRITE_MTU_RESULT]="09",_a[exports.USER_CHECK_TIMEOUT]="0A",_a[exports.SEND_REGISTER_DEVICE_PAYLOAD]="0B",_a[exports.APP_IS_READY]="0C",_a[exports.APP_ON_IOS_DEVICE]="0D",_a[exports.GET_DEVICE_INFO]="E0",_a[exports.SET_WIFI_MODE]="E1",_a[exports.SET_WIFI_INFO]="E2",_a[exports.SET_WIFI_CONNECT]="E3",_a[exports.SET_WIFI_TOKEN]="E4",_a[exports.GET_DEV_LOG]="E5",_a[exports.GET_DEVICE_NAME]="11",_a[exports.REQUEST_BIND]="12",_a[exports.NOTIFY_BIND]="13",_a[exports.RESPONSE_BIND]="14",_a[exports.CONNECT_REQUEST]="15",_a[exports.CONNECT_ACK]="16",_a[exports.UNBIND_REQUEST]="17",_a[exports.UNBIND_RESPONSE]="18",_a[exports.GET_DEVICE_NAME_WITH_REGISTER]="19",_a[exports.GET_ADV_DATA]="1A",_a[exports.HEARTBEAT_REQ]="1B",_a[exports.NOTIFY_LOCAL_RSSI]="1C",_a),exports.DEVICE_DATA_WRITE_HEAD=((_b={})[exports.CONTROL_DEVICE]="000",_b[exports.REPORT_RESULT]="001",_b[exports.GET_STATUS]="001",_b[exports.EVENT_REPLY]="011",_b[exports.CONTROL_ACTION]="100",_b),exports.DEVICE_DATA_WRITE_SUFFIX=((_c={})[exports.CONTROL_DEVICE]="00000",_c[exports.REPORT_RESULT]="00000",_c[exports.GET_STATUS]="00010",_c),exports.WIFI_MODE_MAP=((_d={})[exports.NULL_WIFI_MODE]=0,_d[exports.STA_WIFI_MODE]=1,_d),exports.WIFI_LOG_TYPE_MAP={ERROR_LOG:0,NORMAL_LOG:1},exports.ACTION_DESC=((_e={})[exports.CONTROL_DEVICE]="远程控制",_e[exports.REPORT_RESULT]="属性上报结果通知",_e[exports.GET_STATUS]="写入设备最新状态",_e[exports.EVENT_REPLY]="处理设备端事件上报",_e[exports.CONTROL_ACTION]="对设备进行行为调用",_e[exports.CONTROL_ACTION_SUCCESS]="对设备进行行为调用成功",_e[exports.TIME_SYNC]="时间同步",_e[exports.CONNECT_AUTH]="连接鉴权",_e[exports.BIND_AUTH]="绑定鉴权",_e[exports.BIND_AUTH_DETAIL]="绑定鉴权详情",_e[exports.BIND_AUTH_SUCCESS]="绑定鉴权成功",_e[exports.UNBIND_AUTH]="解绑鉴权",_e[exports.CONNECT_RESULT_WRITE_SUCCESS]="连接小程序端鉴权成功",_e[exports.UNBIND_RESULT_AUTH_SUCCESS]="解绑小程序端鉴权成功",_e[exports.APP_IS_READY]="通知设备端小程序已经就绪",_e[exports.APP_ON_IOS_DEVICE]="通知设备端小程序运行于 iOS 环境",_e[exports.GET_ADV_DATA]="获取设备广播信息",_e[exports.HEARTBEAT_REQ]="蓝牙连接心跳",_e[exports.NOTIFY_LOCAL_RSSI]="同步小程序侧 RSSI",_e),exports.BLE_IOT_DATA_TYPE_BOOL="bool",exports.BLE_IOT_DATA_TYPE_INT="int",exports.BLE_IOT_DATA_TYPE_STRING="string",exports.BLE_IOT_DATA_TYPE_FLOAT="float",exports.BLE_IOT_DATA_TYPE_ENUM="enum",exports.BLE_IOT_DATA_TYPE_TIME="timestamp",exports.BLE_IOT_DATA_TYPE_STRUCT="struct",exports.BLE_IOT_DATA_TYPE_ARRAY="array",exports.OTA_UPDATE_REQUEST="OTA_UPDATE_REQUEST",exports.OTA_UPDATE_DATA="OTA_UPDATE_DATA",exports.OTA_UPDATE_DATA_END="OTA_UPDATE_DATA_END",exports.LL_OTA_WRITE_PREFIX=((_f={})[exports.OTA_UPDATE_REQUEST]="00",_f[exports.OTA_UPDATE_DATA]="01",_f[exports.OTA_UPDATE_DATA_END]="02",_f),exports.USER_NEED_LOGIN="USER_NEED_LOGIN",exports.WAIT_CONNECT_REPLY_TIMEOUT="WAIT_CONNECT_REPLY_TIMEOUT",exports.CONNECT_REPLY_INVALID="CONNECT_REPLY_INVALID",exports.WAIT_UNBIND_REPLY_TIMEOUT="WAIT_UNBIND_REPLY_TIMEOUT",exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT="WAIT_CONTROL_DEVICE_REPLY_TIMEOUT",exports.WAIT_CONTROL_ACTION_REPLY_TIMEOUT="WAIT_CONTROL_ACTION_REPLY_TIMEOUT",exports.UNBIND_REPLY_INVALID="UNBIND_REPLY_INVALID",exports.CONTROL_REPLY_INVALID="CONTROL_REPLY_INVALID",exports.CONTROL_ACTION_ERROR="CONTROL_ACTION_ERROR",exports.CONNECT_DEVICE_ERROR="CONNECT_DEVICE_ERROR",exports.CANNOT_FIND_DEVICE="CANNOT_FIND_DEVICE",exports.DEVICE_NAME_IS_EMPTY="DEVICE_NAME_IS_EMPTY",exports.PSK_GET_ERROR="PSK_GET_ERROR",exports.CONNECT_SIGN_AUTH_ERROR="CONNECT_SIGN_AUTH_ERROR",exports.CONNECT_SIGN_VERIFY_ERROR="CONNECT_SIGN_VERIFY_ERROR",exports.UNBIND_REPLY_ERROR="UNBIND_REPLY_ERROR",exports.CONTROL_REPLY_CODE_INVALID="CONTROL_REPLY_CODE_INVALID",exports.CONTROL_DEVICE_REPLY_ERROR="CONTROL_DEVICE_REPLY_ERROR",exports.REPORT_RESULT_ERROR="REPORT_RESULT_ERROR",exports.GET_STATUS_ERROR="GET_STATUS_ERROR",exports.EVENT_REPLY_ERROR="EVENT_REPLY_ERROR",exports.BLE_WRITE_ERROR="BLE_WRITE_ERROR",exports.WAIT_GET_DEVICE_INFO_TIMEOUT="WAIT_GET_DEVICE_INFO_TIMEOUT",exports.DEVICE_INFO_INVALID="DEVICE_INFO_INVALID",exports.PROPERTY_REPORT_API_FAIL="PROPERTY_REPORT_API_FAIL",exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT="WAIT_GET_ADV_DATA_REPLY_TIMEOUT",exports.GET_ADV_DATA_FAIL="GET_ADV_DATA_FAIL",exports.GET_ADV_DATA_REPLY_INVALID="GET_ADV_DATA_REPLY_INVALID",exports.WAIT_GET_UPDATE_INFO_TIMEOUT="WAIT_GET_UPDATE_INFO_TIMEOUT",exports.WAIT_MODULE_UPDATE_TIMEOUT="WAIT_MODULE_UPDATE_TIMEOUT",exports.SET_WIFI_MODE_RESULT_INVALID="SET_WIFI_MODE_RESULT_INVALID",exports.SET_WIFI_MODE_RESULT_TIMEOUT="SET_WIFI_MODE_RESULT_TIMEOUT",exports.SET_WIFI_INFO_RESULT_INVALID="SET_WIFI_INFO_INVALID",exports.SET_WIFI_INFO_RESULT_TIMEOUT="SET_WIFI_INFO_TIMEOUT",exports.SET_WIFI_CONNECT_RESULT_INVALID="SET_WIFI_CONNECT_RESULT_INVALID",exports.SET_WIFI_CONNECT_RESULT_TIMEOUT="SET_WIFI_CONNECT_RESULT_TIMEOUT",exports.SET_WIFI_TOKEN_RESULT_INVALID="SET_WIFI_TOKEN_RESULT_INVALID",exports.SET_WIFI_TOKEN_RESULT_TIMEOUT="SET_WIFI_TOKEN_RESULT_TIMEOUT",exports.GET_DEV_LOG_INFO_INVALID="GET_DEV_LOG_INFO_INVALID",exports.GET_DEV_LOG_INFO_TIMEOUT="GET_DEV_LOG_INFO_TIMEOUT",exports.OTA_UPDATE_STEPS={GET_OTA_UPDATE_INFO:"GET_OTA_UPDATE_INFO",GET_OTA_UPDATE_INFO_SUCCESS:"GET_OTA_UPDATE_INFO_SUCCESS",DOWNLOADING_OTA_FILE:"DOWNLOADING_OTA_FILE",DOWNLOADING_OTA_FILE_DETAIL:"DOWNLOADING_OTA_FILE_DETAIL",DOWNLOAD_OTA_FILE_SUCCESS:"DOWNLOAD_OTA_FILE_SUCCESS",REQUEST_MODULE_UPDATE_START:"REQUEST_MODULE_UPDATE",REQUEST_MODULE_UPDATE_SUCCESS:"REQUEST_MODULE_UPDATE_SUCCESS",MODULE_UPDATE_CHECK_FILE_SUCCESS:"MODULE_UPDATE_CHECK_FILE_SUCCESS",SEND_UPDATE_DATA_START:"SEND_UPDATE_DATA_START",SEND_UPDATE_DATA_DETAIL:"SEND_UPDATE_DATA_DETAIL",SEND_UPDATE_DATA_SUCCESS:"SEND_UPDATE_DATA_SUCCESS",WAITING_MODULE_UPDATE:"WAITING_MODULE_UPDATE",MODULE_UPDATE_SUCCESS:"MODULE_UPDATE_SUCCESS"},exports.OTA_UPDATE_STEPS_MESSAGE=((_g={})[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO]="获取固件版本信息",_g[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO_SUCCESS]="获取固件版本信息成功",_g[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE]="正在下载OTA文件",_g[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE_DETAIL]="正在下载OTA文件详情",_g[exports.OTA_UPDATE_STEPS.DOWNLOAD_OTA_FILE_SUCCESS]="下载OTA文件成功",_g[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_START]="开始检查设备端固件升级支持情况",_g[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_SUCCESS]="检查设备端固件升级支持情况成功",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_START]="开始发送固件升级文件",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_DETAIL]="固件升级文件详情",_g[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_SUCCESS]="固件升级文件发送成功",_g[exports.OTA_UPDATE_STEPS.WAITING_MODULE_UPDATE]="开始烧录固件升级文件",_g[exports.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS]="设备端固件升级成功",_g),exports.OTA_UPDATE_ERRORS=((_h={GET_OTA_INFO_FAIL:"获取OTA升级信息失败",MODULE_VERSION_IS_UPDATED:"设备端固件已经是最新版",MODULE_DONNOT_SUPPORT:"设备端固件不支持",USER_CANCEL_OTA_UPDATE:"用户取消固件升级",MODULE_DONNOT_ALLOW:"设备端固件不允许,可能是当前状态不允许",MODULE_UPDATE_CHECK_FILE_FAIL:"升级文件校验失败",GET_FILE_CRC_ERROR:"获取文件和crc错误"})[exports.WAIT_GET_UPDATE_INFO_TIMEOUT]="获取设备端分片包回包超时",_h[exports.WAIT_MODULE_UPDATE_TIMEOUT]="等待设备端升级超时",_h.UPDATE_DATA_REPLAY_TIMEOUT="发送固件升级文件超时",_h.MODULE_UPDATE_FAIL="设备端固件升级失败",_h.MODULE_UPDATE_CONNECT_TIMEOUT="设备端固件升级连接设备超时",_h.BLE_CONNECTION_BREAK="蓝牙连接断开",_h),exports.BLE_COMBO_ERRORS=((_j={})[exports.SET_WIFI_MODE_RESULT_INVALID]="设置WiFi模式返回格式错误",_j[exports.SET_WIFI_MODE_RESULT_TIMEOUT]="设置WiFi模式返回超时,请稍后再试",_j[exports.SET_WIFI_INFO_RESULT_INVALID]="WiFi信息传输返回格式错误",_j[exports.SET_WIFI_INFO_RESULT_TIMEOUT]="WiFi信息传输返回超时,请稍后再试",_j[exports.SET_WIFI_CONNECT_RESULT_INVALID]="WiFi连接失败",_j[exports.SET_WIFI_CONNECT_RESULT_TIMEOUT]="获取WiFi连接状态超时",_j[exports.SET_WIFI_TOKEN_RESULT_INVALID]="发送配网token结果非法",_j[exports.SET_WIFI_TOKEN_RESULT_TIMEOUT]="发送配网token结果超时,请稍后再试",_j[exports.GET_DEV_LOG_INFO_INVALID]="获取配网日志格式错误",_j[exports.GET_DEV_LOG_INFO_TIMEOUT]="获取配网日志超时,请稍后再试",_j),exports.MODULE_UPDATE_REPLAY_CODE_MAP={0:"设备电量不足",1:"版本号错误"},exports.MODULE_UPDATE_DATA_REPLAY_CODE_MAP={1:exports.OTA_UPDATE_STEPS.MODULE_UPDATE_CHECK_FILE_SUCCESS,0:"MODULE_UPDATE_CHECK_FILE_FAIL"},exports.MODULE_UPDATE_REPLAY_DATA_CODE_MAP={0:"CRC错误",1:"文件读取失败",2:"文件错误"},exports.WAIT_MODULE_UPDATE_CONNECT_TIMES=5,exports.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP=2e3,exports.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE=5,exports.MAX_WRITE_DATA_WAIT_GAP=200,exports.ERROR_MESSAGES=tslib_1.__assign(tslib_1.__assign(((_k={})[exports.USER_NEED_LOGIN]="用户未登录,不能连接蓝牙",_k[exports.CONTROL_ACTION_ERROR]="行为调用失败",_k[exports.CONNECT_DEVICE_ERROR]="连接设备失败",_k[exports.CANNOT_FIND_DEVICE]="无法找到设备",_k[exports.USER_NEED_LOGIN]="请重新登录",_k[exports.WAIT_CONNECT_REPLY_TIMEOUT]="等待连接回复超时",_k[exports.CONNECT_REPLY_INVALID]="等待连接回复非法",_k[exports.GET_USER_CHECK_REJECT]="用户端确认拒绝",_k[exports.WAIT_USER_CHECK_TIMEOUT]="等待用户确认超时",_k[exports.GET_USER_CHECK_TIMEOUT_TIMEOUT]="获取设备端用户确认超时时间超时,使用默认超时时间",_k[exports.GET_USER_CHECK_TIMEOUT_ERROR]="获取设备端用户确认超时时间失败,使用默认超时时间",_k[exports.DEVICE_NAME_IS_EMPTY]="设备名称非法",_k[exports.PSK_GET_ERROR]="获取local psk失败",_k[exports.CONNECT_SIGN_AUTH_ERROR]="获取连接认证失败",_k[exports.WAIT_UNBIND_REPLY_TIMEOUT]="获取解绑回复超时",_k[exports.UNBIND_REPLY_INVALID]="解绑回复非法",_k[exports.UNBIND_REPLY_ERROR]="解绑回复失败",_k[exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT]="等待控制设备回复超时",_k[exports.CONTROL_DEVICE_REPLY_ERROR]="控制设备失败",_k[exports.CONTROL_REPLY_INVALID]="等待控制设备回复非法",_k[exports.BIND_AUTH_FAIL]="绑定鉴权失败",_k[exports.UNBIND_RESULT_AUTH_FAIL]="解绑小程序端鉴权失败",_k[exports.CONNECT_RESULT_WRITE_FAIL]="连接小程序端鉴权失败",_k[exports.CONTROL_REPLY_CODE_INVALID]="设备端控制回包code非0",_k[exports.REPORT_RESULT_ERROR]="上报设备最新状态失败",_k[exports.GET_STATUS_ERROR]="获取最新状态失败",_k[exports.EVENT_REPLY_ERROR]="EVENT_REPLY_ERROR",_k[exports.BLE_WRITE_ERROR]="设备写入失败",_k[exports.WAIT_GET_DEVICE_INFO_TIMEOUT]="获取设备信息超时",_k[exports.DEVICE_INFO_INVALID]="设备版本和MTU信息非法",_k.ID_TEMPLATE_IS_NOT_EXIT="设备端传的id在物模型里面不存在",_k.TYPE_IN_MODULE_IS_WRONG="设备端的type和后台的不一致",_k[exports.PROPERTY_REPORT_API_FAIL]="属性上报云端回复失败",_k),exports.OTA_UPDATE_ERRORS),((_l={})[exports.REGISTER_DEVICE_ERROR]="从云端动态注册失败",_l[exports.REGISTER_DEVICE_INFO_REPLY_INVALID]="设备端回复的云端注册信息非法",_l[exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT]="等待设备端回复的云端注册信息超时",_l[exports.WAIT_GET_ADV_DATA_REPLY_TIMEOUT]="等待设备端回复广播信息超时",_l[exports.GET_ADV_DATA_FAIL]="设备端回复获取广播信息失败",_l)),function(_){_[_.Success=0]="Success",_[_.Fail=1]="Fail",_[_.ParseDataFail=2]="ParseDataFail"}(PropertyReportReplyResult=exports.PropertyReportReplyResult||(exports.PropertyReportReplyResult={})),exports.WRITE_DATA_CANCEL_ERROR_CODE="BLE_WRITE_CHARACTERISTIC_CANCELLED",exports.MIN_ATT_MTU=23,exports.ATT_MTU_TO_LLSYNC_MTU_DELTA=3;
//# sourceMappingURL=constants.js.map
{
"name": "qcloud-iotexplorer-bluetooth-adapter-llsync",
"version": "2.3.1",
"version": "2.3.2-alpha.0",
"description": "",

@@ -17,8 +17,8 @@ "main": "lib/index.js",

"dependencies": {
"event-emitter-for-miniprogram": "^0.11.0",
"iotexplorer-ui-dev-config": "^1.8.0",
"event-emitter-for-miniprogram": "^0.11.1-alpha.0",
"iotexplorer-ui-dev-config": "^1.8.1-alpha.0",
"mp-debug": "^0.1.1",
"qcloud-iotexplorer-appdev-sdk": "^2.3.0",
"qcloud-iotexplorer-bluetooth-adapter": "^0.12.1",
"qcloud-iotexplorer-common-libs": "^0.12.0",
"qcloud-iotexplorer-appdev-sdk": "^2.3.1-alpha.0",
"qcloud-iotexplorer-bluetooth-adapter": "^0.12.2-alpha.0",
"qcloud-iotexplorer-common-libs": "^0.12.1-alpha.0",
"shortid-for-miniprogram": "^2.2.15",

@@ -31,3 +31,3 @@ "spark-md5": "^3.0.1",

},
"gitHead": "5a0ca29a7549a44693825b269f5fcc1b9d30e159"
"gitHead": "dd4d335baf0b423b8752c2f7336f8f901675fdb8"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc