qcloud-iotexplorer-bluetooth-adapter-llsync
Advanced tools
Comparing version 1.3.17 to 1.3.25
@@ -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"),arrayBufferToHexStringArray=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.arrayBufferToHexStringArray,convertToMs=function(e){if("number"!=typeof e)throw new Error("timestamp should be a number");return e.toString().length>=13?e:1e3*e},LLSyncDeviceAdapter=function(e){function t(r){var o=e.call(this,r)||this,s=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return tslib_1.__awaiter(o,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))]}}))}))}};o.models=new Models_1.Models(t.options.appDevSdk),o.userIdentify=t.getUserIdentify(),o.on("disconnect",(function(){o.authorized=!1})),o.appDevSdk=t.options.appDevSdk,o.protocol=new LLSyncProtocol_1.LLSyncProtocol(o),o.otaProcessor=new LLSyncOtaProcessor_1.LLSyncOtaProcessor(o),Object.assign(o,{bindDevice:s(o.bindDevice.bind(o)),unbindDevice:s(o.unbindDevice.bind(o)),controlDevice:s(o.controlDevice.bind(o)),controlAction:s(o.controlAction.bind(o)),authenticateConnection:s(o.authenticateConnection.bind(o)),reconnectDevice:s(o.authenticateConnection.bind(o)),startOta:s(o.startOta.bind(o)),cancelOta:s(o.cancelOta.bind(o)),userCancelBindDevice:s(o.protocol.cancelUserCheck.bind(o.protocol,"cancel"))}),o.init(),o.reporter={info:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.message,n=void 0===s?"":s,i=r.serviceId,c=tslib_1.__rest(r,["message","serviceId"]),a=o,d=a.explorerDeviceId,l=a.deviceId,u=a.isConnected;t.options.appDevSdk.reporter.info(constants_1.REPORT_EVENT_TYPE,{serviceId:i||t.serviceId,message:n||(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,n=tslib_1.__rest(r,["error"]),i=o,c=i.explorerDeviceId,a=i.deviceId,d=i.isConnected;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:n.timeCost||0,action:e,error:s,data:tslib_1.__assign(tslib_1.__assign({deviceId:c,bleDeviceId:a,isConnected:d},n),s)})}};var n=function(e){var t=e.deviceId,r=e.deviceData;if(console.log("llsync receive onControl",t,r,o.ready,o.explorerDeviceId),o.ready&&t===o.explorerDeviceId){var s={};Object.keys(r).forEach((function(e){s[e]=r[e].Value})),o.controlDevice({deviceData:s})}},i=function(e){var t=e.deviceId,r=e.Payload;o.ready&&t===o.explorerDeviceId&&o.controlAction({actionData:r})};return o.on("authorized",(function(){o.init(!0),o.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,n),o.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,i)})).on("disconnect",(function(){o.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,n),o.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,i)})),o}return tslib_1.__extends(t,e),t.getUserIdentify=function(){var e,r,o,s;return libs_1.getUserIdentify(null===(s=null===(o=null===(r=null===(e=t.options)||void 0===e?void 0:e.appDevSdk)||void 0===r?void 0:r.loginManager)||void 0===o?void 0:o.userInfo)||void 0===s?void 0:s.UserID)},t.injectOptions=function(e){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 o=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(o,void 0,void 0,(function(){var r,o,s,n,i,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),o=(r=this).productConfig,s=r.productInfo,[4,Promise.all([o?Promise.resolve(o):this.models.getProduct({ProductId:this.productId}),s?Promise.resolve(s):this.models.getProductConfig({ProductId:this.productId})])];case 1:return n=tslib_1.__read.apply(void 0,[d.sent(),2]),i=n[0],c=n[1],this.dataTemplate=libs_1.getProductDateTemplate(i),this.productInfo=i,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,o,s,n,i;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]),o=r[0],s=r[1],!o||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:o})];case 3:return c.sent(),[3,5];case 4:return n=c.sent(),console.error("update psk to DeviceConfig fail",n),[3,5];case 5:if(!(i=s||o))throw{code:constants.PSK_GET_ERROR};return[2,i]}}))}))},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.onPropertyReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,s,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),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}),r=t["_sys _timestamp"],[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:r?convertToMs(r):Date.now()})];case 1:return(o=i.sent().Data)&&(s=JSON.parse(o),this.protocol.reportPropertyReportResult(s.code)),[3,3];case 2:return n=i.sent(),this.reporter.error(constants.REPORT_RESULT_ERROR,{error:n}),this.protocol.reportPropertyReportResult(-1),[3,3];case 3:return[2]}}))}))},t.prototype.onGetStatus=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,o,s,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.models.getDeviceData({ProductId:this.productId,DeviceName:this.deviceName})];case 1:return e=i.sent(),t={},Object.keys(e).forEach((function(r){t[r]=e[r].Value})),r=utils.convertPropertiesChangeToTlv(t,this.dataTemplate),o=r.tlvData,s=r.tmpData,this.reporter.info(constants.GET_STATUS,{properties:t,tlvData:utils.formatArrayToReportString(o),tmpData:s}),this.protocol.reportGetStatusResult(0,o,s),[3,3];case 2:return n=i.sent(),this.reporter.error(constants.GET_STATUS_ERROR,{error:n}),this.protocol.reportGetStatusResult(-1),[2,Promise.reject(this.normalizeError(n))];case 3:return[2]}}))}))},t.prototype.onEventReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,s,n,i,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:d.trys.push([0,8,,9]),console.log("onEventReport check this",this),t=utils.getStrLength(e),r=utils.convertEventTlvToJsObject(e.slice(2,2+t),this.dataTemplate),o=r.eventId,s=r.params,n=r.eventIndex,i={DeviceId:this.explorerDeviceId,EventId:o,Params:JSON.stringify(s)},this.reporter.info(constants.EVENT_REPLY,tslib_1.__assign(tslib_1.__assign({},i),{eventIndex:n})),d.label=1;case 1:return d.trys.push([1,6,,7]),[4,this.models.reportDeviceEvent(i)];case 2: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,4];case 3:return d.sent(),[3,5];case 4:this.protocol.reportEventReportResult(0,n),d.label=5;case 5:return[3,7];case 6:throw c=d.sent(),console.error({error:c,eventIndex:n}),this.protocol.reportEventReportResult(-1,n),c;case 7:return[3,9];case 8:return a=d.sent(),this.reporter.error(constants.EVENT_REPLY_ERROR,{error:a}),[2,Promise.reject(this.normalizeError(a))];case 9: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,o,s,n,i,c,a,d,l,u;return tslib_1.__generator(this,(function(p){switch(p.label){case 0:return p.trys.push([0,7,,8]),this.reporter.info(constants.BIND_AUTH),e=Date.now(),[4,this.protocol.requestBindDevice({needUserCheck:this.needUserCheck,isDynamicRegister:this.extendInfo.isDynamicRegister})];case 1:o=p.sent(),s=o.sign,n=o.timestamp,i=o.nonce,c=o.deviceName,this.deviceName=c,p.label=2;case 2:return p.trys.push([2,4,,5]),a={Signature:s,DeviceTimestamp:n,DeviceId:this.explorerDeviceId,ConnId:""+i,FamilyId:t,RoomId:r,BindType:"bluetooth_sign"},this.reporter.info(constants.BIND_AUTH_DETAIL,a),[4,this.models.addDeviceBySigInFamily(a)];case 3:return p.sent(),[3,5];case 4:return d=p.sent(),this.protocol.reportBindError(d.code),[2,Promise.reject(this.normalizeError(d))];case 5:return l=this,[4,this.protocol.reportBindSuccess(e)];case 6:return l.localPsk=p.sent(),[2,this.explorerDeviceId];case 7:return u=p.sent(),console.log(u),console.log("error in bindDevice",u),this.reporter.error(constants.BIND_AUTH_FAIL,{error:u}),[2,Promise.reject(this.normalizeError(u))];case 8:return[2]}}))}))},t.prototype.unbindDevice=function(e){var t=e.familyId,r=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n,i;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:if(c.trys.push([0,5,,6]),!r)throw{code:constants.DEVICE_NAME_IS_EMPTY};return e=Date.now(),[4,this.getDevicePsk(r)];case 1:return o=c.sent(),this.reporter.info(constants.UNBIND_AUTH,{localPsk:o}),[4,this.protocol.getUnbindAuthSign()];case 2:if(s=c.sent().sign,n=utils.encrypt(constants.UNBIND_RESPONSE,o),s!==n)throw{code:constants.UNBIND_REPLY_ERROR};return this.localPsk=o,this.deviceName=r,[4,this.models.deleteDeviceFromFamily({FamilyId:t,DeviceId:this.explorerDeviceId})];case 3:return c.sent(),this.reporter.info(constants.UNBIND_RESULT_AUTH_SUCCESS,{timeCost:Date.now()-e}),[4,this.protocol.reportUnbindResult("success")];case 4:return c.sent(),this.stopListenLLEvents(),this.authorized=!1,this.disconnectDevice(),[3,6];case 5:return i=c.sent(),this.protocol.reportUnbindResult("fail"),this.reporter.error(constants.UNBIND_RESULT_AUTH_FAIL,{error:i}),[2,Promise.reject(this.normalizeError(i))];case 6:return[2]}}))}))},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(),[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,o,s,n,i;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(),o=r.outputParams,s=r.actionIndex,n=r.actionId,[4,this.models.publishDeviceActionMessage({deviceName:this.deviceName,productId:this.productId,actionId:n,clientToken:t.clientToken,output:o})];case 3:return c.sent(),this.reporter.info(constants.CONTROL_ACTION_SUCCESS,{outputParams:o,actionIndex:s,actionId:n}),[3,5];case 4:return i=c.sent(),this.reporter.error(constants.CONTROL_ACTION_ERROR,{error:i}),[2,Promise.reject(this.normalizeError(i))];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,o,s,n,i,c,a,d,l,u,p;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),console.log("start authenticate connection",t),!t)throw{code:constants.DEVICE_NAME_IS_EMPTY};return e=Date.now(),[4,this.getDevicePsk(t)];case 1:return r=v.sent(),this.localPsk=r,this.reporter.info(constants.CONNECT_AUTH,{localPsk:r}),[4,this.protocol.getDeviceAuthInfo()];case 2:if(o=v.sent(),s=o.sign,n=o.timestamp,i=utils.encrypt(""+(n+60)+this.productId+t,r),s!==i)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return[4,this.protocol.getDeviceInfo()];case 3:if(c=v.sent(),a=c.version,d=c.mtu,l=c.needSetMtu,u=c.otaVersion,this.deviceName=t,this.bleVersion=a,this.mtu=d,!l)return[3,7];v.label=4;case 4:return v.trys.push([4,6,,7]),[4,this.setMtu(this.mtu)];case 5:return v.sent(),this.writeMtuResult("success"),[3,7];case 6:return v.sent(),this.writeMtuResult("fail"),[3,7];case 7:return this.otaVersion=u,u&&this.models.reportOTAVersion({Version:u,DeviceId:this.explorerDeviceId}),this.reporter.info(constants.CONNECT_RESULT_WRITE_SUCCESS,{timeCost:Date.now()-e,version:a,mtu:d,otaVersion:u}),this.authorized=!0,this.emit("authorized",{version:a,mtu:d,otaVersion:u}),this.stopListenLLEvents(),this.startListenLLEvents(),[3,9];case 8:return p=v.sent(),this.protocol.reportConnectError(),this.reporter.error(constants.CONNECT_RESULT_WRITE_FAIL,{error:p}),[2,Promise.reject(this.normalizeError(p))];case 9:return[2]}}))}))},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 o=t.options.appDevSdk.reporter;try{var s=Math.floor(10*Math.random())%10==1||!0,n=arrayBufferToHexStringArray(e.advertisData);s&&o.info(constants_1.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:t.serviceId,hexArr:n.join(",")});var i=parseInt(n[2],16)-(parseInt(n[2],16)>>2<<2),c=parseInt(n[2],16)>>4,a=parseInt(n[2],16)>>2&1,d=r.productId&&r.deviceName?r.productId+"/"+r.deviceName:"",l=d?utils.get8ByteFromStr(""+d.replace("/","")):"",u=!!d,p="",v="",_="",h=constants.DEVICE_STATE_MAP[i],E=[constants.DEVICE_HAS_BINDED,constants.DEVICE_HAS_CONNECTED].indexOf(h)>-1;if(E)_=n.slice(3,11).join("").toLocaleLowerCase(),v=n.slice(11).join("").toLocaleLowerCase(),p=r.productId;else{var f=n.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+f.slice(0,2).join("")),p=libs_1.hex2str(n.slice(9))}s&&o.info(constants_1.REPORT_EVENT_TYPE,{message:"解析广播",serviceId:t.serviceId,data:{bindState:h||"x",targetDeviceId:d,targetDeviceIdentify:l,deviceUserIdentify:v||"x",deviceProductId:p||"x",deviceIdentify:_||"x",isDynamicRegister:!!a}});var D=function(){var o=tslib_1.__assign(tslib_1.__assign({},e),{serviceId:t.serviceId,deviceName:r.deviceName||"",productId:p,extendInfo:{bindState:constants.DEVICE_STATE_MAP[h],moduleVersion:c,isDynamicRegister:!!a,standard:!0}});return console.log("---设备匹配成功---",o),o};return u&&E&&_===l?D():u||E?null:D()}catch(e){console.error("llsync device filter error",e),o.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"),arrayBufferToHexStringArray=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.arrayBufferToHexStringArray,convertToMs=function(e){if("number"!=typeof e)throw new Error("timestamp should be a number");return e.toString().length>=13?e:1e3*e},LLSyncDeviceAdapter=function(e){function t(r){var o=e.call(this,r)||this,s=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return tslib_1.__awaiter(o,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))]}}))}))}};o.models=new Models_1.Models(t.options.appDevSdk),o.userIdentify=t.getUserIdentify(),o.on("disconnect",(function(){o.authorized=!1})),o.appDevSdk=t.options.appDevSdk,o.protocol=new LLSyncProtocol_1.LLSyncProtocol(o),o.otaProcessor=new LLSyncOtaProcessor_1.LLSyncOtaProcessor(o),Object.assign(o,{bindDevice:s(o.bindDevice.bind(o)),unbindDevice:s(o.unbindDevice.bind(o)),controlDevice:s(o.controlDevice.bind(o)),controlAction:s(o.controlAction.bind(o)),authenticateConnection:s(o.authenticateConnection.bind(o)),reconnectDevice:s(o.authenticateConnection.bind(o)),startOta:s(o.startOta.bind(o)),cancelOta:s(o.cancelOta.bind(o)),userCancelBindDevice:s(o.protocol.cancelUserCheck.bind(o.protocol,"cancel"))}),o.init(),o.reporter={info:function(e,r){void 0===e&&(e=""),void 0===r&&(r={});var s=r.message,n=void 0===s?"":s,i=r.serviceId,c=tslib_1.__rest(r,["message","serviceId"]),a=o,d=a.explorerDeviceId,l=a.deviceId,u=a.isConnected;t.options.appDevSdk.reporter.info(constants_1.REPORT_EVENT_TYPE,{serviceId:i||t.serviceId,message:n||(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,n=tslib_1.__rest(r,["error"]),i=o,c=i.explorerDeviceId,a=i.deviceId,d=i.isConnected;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:n.timeCost||0,action:e,error:s,data:tslib_1.__assign(tslib_1.__assign({deviceId:c,bleDeviceId:a,isConnected:d},n),s)})}};var n=function(e){var t=e.deviceId,r=e.deviceData;if(console.log("llsync receive onControl",t,r,o.ready,o.explorerDeviceId),o.ready&&t===o.explorerDeviceId){var s={};Object.keys(r).forEach((function(e){s[e]=r[e].Value})),o.controlDevice({deviceData:s})}},i=function(e){var t=e.deviceId,r=e.Payload;o.ready&&t===o.explorerDeviceId&&o.controlAction({actionData:r})};return o.on("authorized",(function(){o.init(!0),o.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,n),o.appDevSdk.on(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,i)})).on("disconnect",(function(){o.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsControl,n),o.appDevSdk.off(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.constants.EventTypes.WsActionPush,i)})),o}return tslib_1.__extends(t,e),t.getUserIdentify=function(){var e,r,o,s;return libs_1.getUserIdentify(null===(s=null===(o=null===(r=null===(e=t.options)||void 0===e?void 0:e.appDevSdk)||void 0===r?void 0:r.loginManager)||void 0===o?void 0:o.userInfo)||void 0===s?void 0:s.UserID)},t.injectOptions=function(e){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 o=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(o,void 0,void 0,(function(){var r,o,s,n,i,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),o=(r=this).productConfig,s=r.productInfo,[4,Promise.all([o?Promise.resolve(o):this.models.getProduct({ProductId:this.productId}),s?Promise.resolve(s):this.models.getProductConfig({ProductId:this.productId})])];case 1:return n=tslib_1.__read.apply(void 0,[d.sent(),2]),i=n[0],c=n[1],this.dataTemplate=libs_1.getProductDateTemplate(i),this.productInfo=i,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,o,s,n,i;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]),o=r[0],s=r[1],!o||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:o})];case 3:return c.sent(),[3,5];case 4:return n=c.sent(),console.error("update psk to DeviceConfig fail",n),[3,5];case 5:if(!(i=s||o))throw{code:constants.PSK_GET_ERROR};return[2,i]}}))}))},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.onPropertyReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,s,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),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}),r=t["_sys _timestamp"],[4,this.models.reportBlueToothDeviceData({ProductId:this.productId,DeviceName:this.deviceName,Data:t,DataTimeStamp:r?convertToMs(r):Date.now()})];case 1:return(o=i.sent().Data)&&(s=JSON.parse(o),this.protocol.reportPropertyReportResult(s.code)),[3,3];case 2:return n=i.sent(),this.reporter.error(constants.REPORT_RESULT_ERROR,{error:n}),this.protocol.reportPropertyReportResult(-1),[3,3];case 3:return[2]}}))}))},t.prototype.onGetStatus=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,o,s,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.models.getDeviceData({ProductId:this.productId,DeviceName:this.deviceName})];case 1:return e=i.sent(),t={},Object.keys(e).forEach((function(r){t[r]=e[r].Value})),r=utils.convertPropertiesChangeToTlv(t,this.dataTemplate),o=r.tlvData,s=r.tmpData,this.reporter.info(constants.GET_STATUS,{properties:t,tlvData:utils.formatArrayToReportString(o),tmpData:s}),this.protocol.reportGetStatusResult(0,o,s),[3,3];case 2:return n=i.sent(),this.reporter.error(constants.GET_STATUS_ERROR,{error:n}),this.protocol.reportGetStatusResult(-1),[2,Promise.reject(this.normalizeError(n))];case 3:return[2]}}))}))},t.prototype.onEventReport=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,s,n,i,c,a;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:d.trys.push([0,8,,9]),console.log("onEventReport check this",this),t=utils.getStrLength(e),r=utils.convertEventTlvToJsObject(e.slice(2,2+t),this.dataTemplate),o=r.eventId,s=r.params,n=r.eventIndex,i={DeviceId:this.explorerDeviceId,EventId:o,Params:JSON.stringify(s)},this.reporter.info(constants.EVENT_REPLY,tslib_1.__assign(tslib_1.__assign({},i),{eventIndex:n})),d.label=1;case 1:return d.trys.push([1,6,,7]),[4,this.models.reportDeviceEvent(i)];case 2: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,4];case 3:return d.sent(),[3,5];case 4:this.protocol.reportEventReportResult(0,n),d.label=5;case 5:return[3,7];case 6:throw c=d.sent(),console.error({error:c,eventIndex:n}),this.protocol.reportEventReportResult(-1,n),c;case 7:return[3,9];case 8:return a=d.sent(),this.reporter.error(constants.EVENT_REPLY_ERROR,{error:a}),[2,Promise.reject(this.normalizeError(a))];case 9: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,o,s,n,i,c,a,d,l,u,p;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),this.reporter.info(constants.BIND_AUTH),e=Date.now(),[4,this.protocol.requestBindDevice({needUserCheck:this.needUserCheck,isDynamicRegister:this.extendInfo.isDynamicRegister})];case 1:o=v.sent(),s=o.sign,n=o.timestamp,i=o.nonce,c=o.deviceName,this.deviceName=c,v.label=2;case 2:return v.trys.push([2,4,,5]),a={Signature:s,DeviceTimestamp:n,DeviceId:this.explorerDeviceId,ConnId:""+i,FamilyId:t,RoomId:r,BindType:"bluetooth_sign"},this.reporter.info(constants.BIND_AUTH_DETAIL,a),[4,this.models.addDeviceBySigInFamily(a)];case 3:return v.sent(),[3,5];case 4:return d=v.sent(),this.protocol.reportBindError(d.code),[2,Promise.reject(this.normalizeError(d))];case 5:return l=this,[4,this.protocol.reportBindSuccess(e)];case 6:l.localPsk=v.sent();try{if(this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({},this.extendInfo)),!this.extendInfo.macStr)return[2];u={productId:this.productId,deviceName:c,deviceInfo:{mac:this.extendInfo.macStr}},this.reporter.info(constants.BIND_AUTH_DETAIL,tslib_1.__assign({msg:"START_REPORT_DEVICE_INFO"},u)),this.models.reportDeviceInfo(u)}catch(e){}return[2,this.explorerDeviceId];case 7:return p=v.sent(),console.log(p),console.log("error in bindDevice",p),this.reporter.error(constants.BIND_AUTH_FAIL,{error:p}),[2,Promise.reject(this.normalizeError(p))];case 8:return[2]}}))}))},t.prototype.unbindDevice=function(e){var t=e.familyId,r=e.deviceName;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n,i;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:if(c.trys.push([0,5,,6]),!r)throw{code:constants.DEVICE_NAME_IS_EMPTY};return e=Date.now(),[4,this.getDevicePsk(r)];case 1:return o=c.sent(),this.reporter.info(constants.UNBIND_AUTH,{localPsk:o}),[4,this.protocol.getUnbindAuthSign()];case 2:if(s=c.sent().sign,n=utils.encrypt(constants.UNBIND_RESPONSE,o),s!==n)throw{code:constants.UNBIND_REPLY_ERROR};return this.localPsk=o,this.deviceName=r,[4,this.models.deleteDeviceFromFamily({FamilyId:t,DeviceId:this.explorerDeviceId})];case 3:return c.sent(),this.reporter.info(constants.UNBIND_RESULT_AUTH_SUCCESS,{timeCost:Date.now()-e}),[4,this.protocol.reportUnbindResult("success")];case 4:return c.sent(),this.stopListenLLEvents(),this.authorized=!1,this.disconnectDevice(),[3,6];case 5:return i=c.sent(),this.protocol.reportUnbindResult("fail"),this.reporter.error(constants.UNBIND_RESULT_AUTH_FAIL,{error:i}),[2,Promise.reject(this.normalizeError(i))];case 6:return[2]}}))}))},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(),[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,o,s,n,i;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(),o=r.outputParams,s=r.actionIndex,n=r.actionId,[4,this.models.publishDeviceActionMessage({deviceName:this.deviceName,productId:this.productId,actionId:n,clientToken:t.clientToken,output:o})];case 3:return c.sent(),this.reporter.info(constants.CONTROL_ACTION_SUCCESS,{outputParams:o,actionIndex:s,actionId:n}),[3,5];case 4:return i=c.sent(),this.reporter.error(constants.CONTROL_ACTION_ERROR,{error:i}),[2,Promise.reject(this.normalizeError(i))];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,o,s,n,i,c,a,d,l,u,p;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),console.log("start authenticate connection",t),!t)throw{code:constants.DEVICE_NAME_IS_EMPTY};return e=Date.now(),[4,this.getDevicePsk(t)];case 1:return r=v.sent(),this.localPsk=r,this.reporter.info(constants.CONNECT_AUTH,{localPsk:r}),[4,this.protocol.getDeviceAuthInfo()];case 2:if(o=v.sent(),s=o.sign,n=o.timestamp,i=utils.encrypt(""+(n+60)+this.productId+t,r),s!==i)throw{code:constants.CONNECT_SIGN_AUTH_ERROR};return[4,this.protocol.getDeviceInfo()];case 3:if(c=v.sent(),a=c.version,d=c.mtu,l=c.needSetMtu,u=c.otaVersion,this.deviceName=t,this.bleVersion=a,this.mtu=d,!l)return[3,7];v.label=4;case 4:return v.trys.push([4,6,,7]),[4,this.setMtu(this.mtu)];case 5:return v.sent(),this.writeMtuResult("success"),[3,7];case 6:return v.sent(),this.writeMtuResult("fail"),[3,7];case 7:return this.otaVersion=u,u&&this.models.reportOTAVersion({Version:u,DeviceId:this.explorerDeviceId}),this.reporter.info(constants.CONNECT_RESULT_WRITE_SUCCESS,{timeCost:Date.now()-e,version:a,mtu:d,otaVersion:u}),this.authorized=!0,this.emit("authorized",{version:a,mtu:d,otaVersion:u}),this.stopListenLLEvents(),this.startListenLLEvents(),[3,9];case 8:return p=v.sent(),this.protocol.reportConnectError(),this.reporter.error(constants.CONNECT_RESULT_WRITE_FAIL,{error:p}),[2,Promise.reject(this.normalizeError(p))];case 9:return[2]}}))}))},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 o=t.options.appDevSdk.reporter;try{var s=Math.floor(10*Math.random())%10==1||!0,n=arrayBufferToHexStringArray(e.advertisData);s&&o.info(constants_1.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:t.serviceId,hexArr:n.join(",")});var i=parseInt(n[2],16)-(parseInt(n[2],16)>>2<<2),c=parseInt(n[2],16)>>4,a=parseInt(n[2],16)>>2&1,d=r.productId&&r.deviceName?r.productId+"/"+r.deviceName:"",l=d?utils.get8ByteFromStr(""+d.replace("/","")):"",u=!!d,p="",v="",_="",h=constants.DEVICE_STATE_MAP[i],f=[constants.DEVICE_HAS_BINDED,constants.DEVICE_HAS_CONNECTED].indexOf(h)>-1;if(f)_=n.slice(3,11).join("").toLocaleLowerCase(),v=n.slice(11).join("").toLocaleLowerCase(),p=r.productId;else{var E=n.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+E.slice(0,2).join("")),p=libs_1.hex2str(n.slice(9))}s&&o.info(constants_1.REPORT_EVENT_TYPE,{message:"解析广播",serviceId:t.serviceId,data:{bindState:h||"x",targetDeviceId:d,targetDeviceIdentify:l,deviceUserIdentify:v||"x",deviceProductId:p||"x",deviceIdentify:_||"x",isDynamicRegister:!!a,macStr:f?"":n.slice(3,9).join(":")}});var D=function(){var o=tslib_1.__assign(tslib_1.__assign({},e),{serviceId:t.serviceId,deviceName:r.deviceName||"",productId:p,extendInfo:{bindState:constants.DEVICE_STATE_MAP[h],moduleVersion:c,isDynamicRegister:!!a,standard:!0,macStr:f?"":n.slice(3,9).join(":")}});return console.log("---设备匹配成功---",o),o};return u&&f&&_===l?D():u||f?null:D()}catch(e){console.error("llsync device filter error",e),o.error(constants_1.REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},t}(LLSyncDeviceAdapterBase_1.LLSyncDeviceAdapterBase);exports.LLSyncDeviceAdapter=LLSyncDeviceAdapter,exports.StandardDeviceAdapter=LLSyncDeviceAdapter; | ||
//# sourceMappingURL=LLSyncDeviceAdapter.js.map |
@@ -50,2 +50,7 @@ import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
}): Promise<any>; | ||
reportDeviceInfo({ productId, deviceName, deviceInfo, }: { | ||
productId: any; | ||
deviceName: any; | ||
deviceInfo: any; | ||
}): Promise<any>; | ||
publishDeviceActionMessage({ productId, deviceName, clientToken, actionId, output, }: { | ||
@@ -52,0 +57,0 @@ productId: any; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Models=void 0;var tslib_1=require("tslib"),iotexplorer_ui_dev_config_1=require("iotexplorer-ui-dev-config"),Models=function(){function e(e){this.appDevSdk=e}return e.prototype.getDeviceConfig=function(e){var t=e.DeviceId,i=e.DeviceKey,r=void 0===i?"*":i,n=e.isUserConfig,o=void 0!==n&&n;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,i,n,a;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:e={},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.appDevSdk.requestApi(o?"AppGetUserDeviceConfig":"AppGetDeviceConfig",{DeviceId:t,DeviceKey:r})];case 2:return i=s.sent(),e=i.Configs,[3,4];case 3:return n=s.sent(),console.warn("AppGetDeviceConfig fail",n),[3,4];case 4:if("*"===r)return[2,e];if("string"==typeof(a=e[r])&&~a.indexOf("{"))try{a=JSON.parse(a)}catch(e){console.warn("parse device value fail",e)}return[2,a]}}))}))},e.prototype.setDeviceConfig=function(e){var t=e.DeviceId,i=e.DeviceKey,r=e.DeviceValue,n=e.isUserConfig,o=void 0!==n&&n;return"string"!=typeof r&&(r=JSON.stringify(r)),this.appDevSdk.requestApi(o?"AppSetUserDeviceConfig":"AppSetDeviceConfig",{DeviceId:t,DeviceKey:i,DeviceValue:r})},e.prototype.reportBlueToothDeviceData=function(e){var t=e.ProductId,i=e.DeviceName,r=e.Data,n=e.DataTimeStamp;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return r||(r={}),"string"!=typeof r&&(r=JSON.stringify(r)),[2,this.appDevSdk.requestApi("AppReportDataAsDevice",{ProductId:t,DeviceName:i,Data:r,DataTimeStamp:n})]}))}))},e.prototype.getDeviceData=function(e){var t=e.ProductId,i=e.DeviceName;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[4,this.appDevSdk.requestApi("AppGetDeviceData",{ProductId:t,DeviceName:i})];case 1:e=r.sent().Data;try{return"string"==typeof e&&(e=JSON.parse(e)),[2,e]}catch(e){return console.error("parse json fail",{ProductId:t,DeviceName:i},e),[2,{}]}return[2]}}))}))},e.prototype.reportDeviceEvent=function(e){var t=e.DeviceId,i=e.EventId,r=e.Params;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppReportDeviceEvent",{DeviceId:t,EventId:i,Params:r,Method:"ReportEventAsDevice"})]}))}))},e.prototype.addDeviceBySigInFamily=function(e){var t=e.Signature,i=e.DeviceTimestamp,r=e.ProductId,n=e.DeviceName,o=e.DeviceId,a=e.ConnId,s=e.FamilyId,c=e.RoomId,u=e.SignMethod,p=void 0===u?"hmacsha1":u,d=e.BindType,v=void 0===d?"other_sign":d;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppSigBindDeviceInFamily",{Signature:t,DeviceTimestamp:i,ProductId:r,DeviceName:n,DeviceId:o,ConnId:a,FamilyId:s,RoomId:c,BindType:v,SignMethod:p})];case 1:return[2,e.sent().Data.AppDeviceInfo]}}))}))},e.prototype.deleteDeviceFromFamily=function(e){var t=e.FamilyId,i=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppDeleteDeviceInFamily",{FamilyId:t,DeviceId:i})]}))}))},e.prototype.publishDeviceActionMessage=function(e){var t=e.productId,i=e.deviceName,r=e.clientToken,n=e.actionId,o=e.output;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,a;return tslib_1.__generator(this,(function(s){return e={method:"action_reply",clientToken:r,ActionId:n,timestamp:Math.floor(Date.now()/1e3),response:o,code:0,status:"action execute success!"},a={ProductId:t,DeviceName:i,Topic:"$thing/up/action/"+t+"/"+i,Payload:JSON.stringify(e)},console.log("---reply action---",a),[2,this.appDevSdk.requestApi("AppPublishMsgAsDevice",a)]}))}))},e.prototype.reportOTAVersion=function(e){var t=e.Version,i=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppReportFirmwareVersion",{Version:t,DeviceId:i})]}))}))},e.prototype.getDeviceOTAInfo=function(e){var t=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppGetDeviceOTAInfo",{DeviceId:t})]}))}))},e.prototype.getProduct=function(e){var t=e.ProductId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppGetProducts",{ProductIds:[t]})];case 1:return[2,e.sent().Products[0]]}}))}))},e.prototype.getProductConfig=function(e){var t=e.ProductId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,i;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,this.appDevSdk.requestApi("AppGetProductsConfig",{ProductIds:[t]})];case 1:return e=r.sent().Data,i={},e.forEach((function(e){try{e.Config=JSON.parse(e.Config)}catch(t){e.Config={}}i[e.ProductId]=iotexplorer_ui_dev_config_1.initializeUIDevConfig(e.Config)})),[2,i[t]]}}))}))},e.prototype.dynamicRegisterDevice=function(e){var t=e.deviceName,i=e.productId,r=e.timestamp,n=e.nonce,o=e.sign;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppDeviceDynamicRegister",{DeviceId:i+"/"+t,DeviceTimestamp:r,Nonce:n,Signature:o})];case 1:return[2,{payload:e.sent().Payload}]}}))}))},e}();exports.Models=Models; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Models=void 0;var tslib_1=require("tslib"),iotexplorer_ui_dev_config_1=require("iotexplorer-ui-dev-config"),shortid_for_miniprogram_1=tslib_1.__importDefault(require("shortid-for-miniprogram")),Models=function(){function e(e){this.appDevSdk=e}return e.prototype.getDeviceConfig=function(e){var t=e.DeviceId,i=e.DeviceKey,r=void 0===i?"*":i,o=e.isUserConfig,n=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,i,o,a;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:e={},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.appDevSdk.requestApi(n?"AppGetUserDeviceConfig":"AppGetDeviceConfig",{DeviceId:t,DeviceKey:r})];case 2:return i=s.sent(),e=i.Configs,[3,4];case 3:return o=s.sent(),console.warn("AppGetDeviceConfig fail",o),[3,4];case 4:if("*"===r)return[2,e];if("string"==typeof(a=e[r])&&~a.indexOf("{"))try{a=JSON.parse(a)}catch(e){console.warn("parse device value fail",e)}return[2,a]}}))}))},e.prototype.setDeviceConfig=function(e){var t=e.DeviceId,i=e.DeviceKey,r=e.DeviceValue,o=e.isUserConfig,n=void 0!==o&&o;return"string"!=typeof r&&(r=JSON.stringify(r)),this.appDevSdk.requestApi(n?"AppSetUserDeviceConfig":"AppSetDeviceConfig",{DeviceId:t,DeviceKey:i,DeviceValue:r})},e.prototype.reportBlueToothDeviceData=function(e){var t=e.ProductId,i=e.DeviceName,r=e.Data,o=e.DataTimeStamp;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return r||(r={}),"string"!=typeof r&&(r=JSON.stringify(r)),[2,this.appDevSdk.requestApi("AppReportDataAsDevice",{ProductId:t,DeviceName:i,Data:r,DataTimeStamp:o})]}))}))},e.prototype.getDeviceData=function(e){var t=e.ProductId,i=e.DeviceName;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[4,this.appDevSdk.requestApi("AppGetDeviceData",{ProductId:t,DeviceName:i})];case 1:e=r.sent().Data;try{return"string"==typeof e&&(e=JSON.parse(e)),[2,e]}catch(e){return console.error("parse json fail",{ProductId:t,DeviceName:i},e),[2,{}]}return[2]}}))}))},e.prototype.reportDeviceEvent=function(e){var t=e.DeviceId,i=e.EventId,r=e.Params;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppReportDeviceEvent",{DeviceId:t,EventId:i,Params:r,Method:"ReportEventAsDevice"})]}))}))},e.prototype.addDeviceBySigInFamily=function(e){var t=e.Signature,i=e.DeviceTimestamp,r=e.ProductId,o=e.DeviceName,n=e.DeviceId,a=e.ConnId,s=e.FamilyId,c=e.RoomId,p=e.SignMethod,u=void 0===p?"hmacsha1":p,d=e.BindType,v=void 0===d?"other_sign":d;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppSigBindDeviceInFamily",{Signature:t,DeviceTimestamp:i,ProductId:r,DeviceName:o,DeviceId:n,ConnId:a,FamilyId:s,RoomId:c,BindType:v,SignMethod:u})];case 1:return[2,e.sent().Data.AppDeviceInfo]}}))}))},e.prototype.deleteDeviceFromFamily=function(e){var t=e.FamilyId,i=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppDeleteDeviceInFamily",{FamilyId:t,DeviceId:i})]}))}))},e.prototype.reportDeviceInfo=function(e){var t=e.productId,i=e.deviceName,r=e.deviceInfo;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o;return tslib_1.__generator(this,(function(n){return e={method:"report_info",clientToken:t+"/"+i+"-"+shortid_for_miniprogram_1.default(),params:r},o={ProductId:t,DeviceName:i,Topic:"$thing/up/property/"+t+"/"+i,Payload:JSON.stringify(e)},[2,this.appDevSdk.requestApi("AppPublishMsgAsDevice",o)]}))}))},e.prototype.publishDeviceActionMessage=function(e){var t=e.productId,i=e.deviceName,r=e.clientToken,o=e.actionId,n=e.output;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,a;return tslib_1.__generator(this,(function(s){return e={method:"action_reply",clientToken:r,ActionId:o,timestamp:Math.floor(Date.now()/1e3),response:n,code:0,status:"action execute success!"},a={ProductId:t,DeviceName:i,Topic:"$thing/up/action/"+t+"/"+i,Payload:JSON.stringify(e)},console.log("---reply action---",a),[2,this.appDevSdk.requestApi("AppPublishMsgAsDevice",a)]}))}))},e.prototype.reportOTAVersion=function(e){var t=e.Version,i=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppReportFirmwareVersion",{Version:t,DeviceId:i})]}))}))},e.prototype.getDeviceOTAInfo=function(e){var t=e.DeviceId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.appDevSdk.requestApi("AppGetDeviceOTAInfo",{DeviceId:t})]}))}))},e.prototype.getProduct=function(e){var t=e.ProductId;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppGetProducts",{ProductIds:[t]})];case 1:return[2,e.sent().Products[0]]}}))}))},e.prototype.getProductConfig=function(e){var t=e.ProductId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,i;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,this.appDevSdk.requestApi("AppGetProductsConfig",{ProductIds:[t]})];case 1:return e=r.sent().Data,i={},e.forEach((function(e){try{e.Config=JSON.parse(e.Config)}catch(t){e.Config={}}i[e.ProductId]=iotexplorer_ui_dev_config_1.initializeUIDevConfig(e.Config)})),[2,i[t]]}}))}))},e.prototype.dynamicRegisterDevice=function(e){var t=e.deviceName,i=e.productId,r=e.timestamp,o=e.nonce,n=e.sign;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.appDevSdk.requestApi("AppDeviceDynamicRegister",{DeviceId:i+"/"+t,DeviceTimestamp:r,Nonce:o,Signature:n})];case 1:return[2,{payload:e.sent().Payload}]}}))}))},e}();exports.Models=Models; | ||
//# sourceMappingURL=Models.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncDeviceAdapterBase=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),utils=tslib_1.__importStar(require("../libs")),constants=tslib_1.__importStar(require("../constants")),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),libs_1=require("../libs"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,genPromise=_a.genPromise,delay=_a.delay,envDetect=_a.envDetect,LLSyncDeviceAdapterBase=function(t){function e(e){var r=t.call(this,e)||this;return r.on("message",r.notifyMessage.bind(r)),r}return tslib_1.__extends(e,t),e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,r=e.type,i=e.data;if("unknown"!==r)return console.log("check this in notifyMessage",this,{type:r,data:i}),this.emit(r,{type:r,data:i})},e.prototype.handleBLEMessage=function(t){var e=parseInt(t.slice(0,1),16),r={type:constants.INDICATE_TYPE_MAP[e]||"unknown",data:t.splice(1)};return console.log("Message(hex)",r),r},e.prototype.wait4EventResponse=function(t,e,r){var i=void 0===r?{}:r,n=i.timeout,o=i.timeoutCode,s=i.timeoutHandler,a=i.wrapSplitDataMode,u=i.shouldWrapSplitDataFn,c=void 0===u||u,l=i.afterBindEvent;return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,i,u,d,_,p=this;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:r=genPromise(),console.log("wait4EventResponse",{eventName:t}),i=!1,u=function(n){return tslib_1.__awaiter(p,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){try{i?console.log("Target event: "+t+" triggered, but is already timeout"):(r.resolve(e(n)),i=!0)}catch(t){r.reject(t)}finally{this.off(t,d)}return[2]}))}))},d=c?utils.wrapEventHandler(u,a):u,this.on(t,d),v.label=1;case 1:return v.trys.push([1,5,,6]),"function"!=typeof l?[3,3]:[4,l()];case 2:v.sent(),v.label=3;case 3:return[4,Promise.race([r.promise,new Promise((function(e,r){n&&n>0&&setTimeout((function(){i||(console.log("Wait for target event: "+t+" timeout"),i=!0,p.off(t,d),"function"==typeof s?(console.log("trigger timeout handler"),e(s())):r({code:o}))}),n)}))])];case 4:return[2,v.sent()];case 5:return _=v.sent(),this.off(t,d),[2,Promise.reject(_)];case 6:return[2]}}))}))},e.prototype.writeAndWait4Response=function(t,e,r,i){var n=void 0===i?{}:i,o=n.timeout,s=n.timeoutCode,a=n.timeoutHandler,u=n.writeId,c=n.wrapSplitDataMode,l=n.shouldWrapSplitDataFn,d=void 0===l||l;return tslib_1.__awaiter(this,void 0,void 0,(function(){var i=this;return tslib_1.__generator(this,(function(n){return[2,this.wait4EventResponse(e,r,{timeout:o,timeoutCode:s,timeoutHandler:a,wrapSplitDataMode:c,shouldWrapSplitDataFn:d,afterBindEvent:function(){return i.writeData(t,{writeId:u}).catch((function(t){return Promise.reject(tslib_1.__assign({code:constants.BLE_WRITE_ERROR},t))}))}})]}))}))},e.prototype.writeMtuResult=function(t){var e="success"===t?0:65535,r=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.WRITE_MTU_RESULT]+libs_1.U16ToHexString(e);this.write(r,{writeId:constants.DEVICE_INFO_WRITE_ID})},e.prototype.sliceData=function(t,e,r){if(!this.mtu||t.join("").length<=2*this.mtu)return[t.join("")];var i=t.slice(0,r===constants.GET_STATUS?2:1);return console.log("---head----",i),utils.sliceData(e,{mtu:this.mtu,head:i,mode:r})},e.prototype.writeData=function(t,e){var r=void 0===e?{}:e,i=r.writeId,n=r.waitGap,o=void 0===n?100:n,s=r.retryTime,a=void 0===s?5:s;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:Array.isArray(t)||(t=[t]),e=0,s.label=1;case 1:return e<t.length?0===e?[3,3]:[4,delay(o)]:[3,10];case 2:s.sent(),s.label=3;case 3:r=a,s.label=4;case 4:return s.trys.push([4,6,,8]),[4,this.write(t[e],{writeId:i})];case 5:return s.sent(),[3,9];case 6:if(n=s.sent(),console.log("--- LLSync core writeData error ---- retry time "+r,n),--r<=0)throw n;return[4,delay(Math.min(10*o*(a-r),constants.MAX_WRITE_DATA_WAIT_GAP))];case 7:return s.sent(),[3,8];case 8:if(r>0)return[3,4];s.label=9;case 9:return e++,[3,1];case 10:return[2]}}))}))},e.prototype.setMtu=function(t){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 envDetect.isIOS?[2]:[4,this.setBLEMTU({deviceId:this.deviceId,mtu:t})];case 1:return e=r.sent(),this.reporter.info(constants.ANDROID_SET_MTU,{mtu:t,ret:e}),[2,e]}}))}))},e}(qcloud_iotexplorer_bluetooth_adapter_1.DeviceAdapter);exports.LLSyncDeviceAdapterBase=LLSyncDeviceAdapterBase; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncDeviceAdapterBase=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),utils=tslib_1.__importStar(require("../libs")),constants=tslib_1.__importStar(require("../constants")),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),libs_1=require("../libs"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,genPromise=_a.genPromise,delay=_a.delay,envDetect=_a.envDetect,LLSyncDeviceAdapterBase=function(t){function e(e){var r=t.call(this,e)||this;return r.on("message",r.notifyMessage.bind(r)),r}return tslib_1.__extends(e,t),e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,r=e.type,i=e.data;if("unknown"!==r)return console.log("check this in notifyMessage",this,{type:r,data:i}),this.emit(r,{type:r,data:i})},e.prototype.handleBLEMessage=function(t){var e=parseInt(t.slice(0,1),16),r={type:constants.INDICATE_TYPE_MAP[e]||"unknown",data:t.splice(1)};return console.log("Message(hex)",r),r},e.prototype.wait4EventResponse=function(t,e,r){var i=void 0===r?{}:r,n=i.timeout,o=i.timeoutCode,s=i.timeoutHandler,a=i.wrapSplitDataMode,u=i.shouldWrapSplitDataFn,c=void 0===u||u,l=i.afterBindEvent;return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,i,u,_,d,p=this;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:r=genPromise(),console.log("wait4EventResponse",{eventName:t}),i=!1,u=function(n){return tslib_1.__awaiter(p,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){try{i?console.log("Target event: "+t+" triggered, but is already timeout"):(r.resolve(e(n)),i=!0)}catch(t){r.reject(t)}finally{this.off(t,_)}return[2]}))}))},_=c?utils.wrapEventHandler(u,a):u,this.on(t,_),v.label=1;case 1:return v.trys.push([1,5,,6]),"function"!=typeof l?[3,3]:[4,l()];case 2:v.sent(),v.label=3;case 3:return[4,Promise.race([r.promise,new Promise((function(e,r){n&&n>0&&setTimeout((function(){i||(console.log("Wait for target event: "+t+" timeout"),i=!0,p.off(t,_),"function"==typeof s?(console.log("trigger timeout handler"),e(s())):r({code:o}))}),n)}))])];case 4:return[2,v.sent()];case 5:return d=v.sent(),this.off(t,_),[2,Promise.reject(d)];case 6:return[2]}}))}))},e.prototype.writeAndWait4Response=function(t,e,r,i){var n=void 0===i?{}:i,o=n.timeout,s=n.timeoutCode,a=n.timeoutHandler,u=n.writeId,c=n.wrapSplitDataMode,l=n.shouldWrapSplitDataFn,_=void 0===l||l;return tslib_1.__awaiter(this,void 0,void 0,(function(){var i=this;return tslib_1.__generator(this,(function(n){return[2,this.wait4EventResponse(e,r,{timeout:o,timeoutCode:s,timeoutHandler:a,wrapSplitDataMode:c,shouldWrapSplitDataFn:_,afterBindEvent:function(){return i.writeData(t,{writeId:u}).catch((function(t){return Promise.reject(tslib_1.__assign({code:constants.BLE_WRITE_ERROR},t))}))}})]}))}))},e.prototype.writeMtuResult=function(t){var e="success"===t?0:65535,r=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.WRITE_MTU_RESULT]+libs_1.U16ToHexString(e);this.write(r,{writeId:constants.DEVICE_INFO_WRITE_ID})},e.prototype.sliceData=function(t,e,r){if(!this.mtu||t.join("").length<=2*this.mtu)return[t.join("")];var i=t.slice(0,r===constants.GET_STATUS?2:1);return console.log("---head----",i),utils.sliceData(e,{mtu:this.mtu,head:i,mode:r})},e.prototype.writeData=function(t,e){var r=void 0===e?{}:e,i=r.writeId,n=r.waitGap,o=void 0===n?100:n,s=r.retryTime,a=void 0===s?5:s;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,n;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:Array.isArray(t)||(t=[t]),e=0,s.label=1;case 1:if(!(e<t.length))return[3,8];r=a,s.label=2;case 2:return s.trys.push([2,4,,6]),[4,this.write(t[e],{writeId:i})];case 3:return s.sent(),[3,7];case 4:if(n=s.sent(),console.log("--- LLSync core writeData error ---- retry time "+r,n),--r<=0)throw n;return[4,delay(Math.min(10*o*(a-r),constants.MAX_WRITE_DATA_WAIT_GAP))];case 5:return s.sent(),[3,6];case 6:if(r>0)return[3,2];s.label=7;case 7:return e++,[3,1];case 8:return[2]}}))}))},e.prototype.setMtu=function(t){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 envDetect.isIOS?[2]:[4,this.setBLEMTU({deviceId:this.deviceId,mtu:t})];case 1:return e=r.sent(),this.reporter.info(constants.ANDROID_SET_MTU,{mtu:t,ret:e}),[2,e]}}))}))},e}(qcloud_iotexplorer_bluetooth_adapter_1.DeviceAdapter);exports.LLSyncDeviceAdapterBase=LLSyncDeviceAdapterBase; | ||
//# sourceMappingURL=LLSyncDeviceAdapterBase.js.map |
@@ -163,22 +163,2 @@ export declare const REPORT_EVENT_TYPE = "standard-ble"; | ||
export declare const BLE_IOT_DATA_TYPE_ARRAY = "array"; | ||
export declare const TLV_TYPE_INDEX: { | ||
bool: number; | ||
int: number; | ||
string: number; | ||
float: number; | ||
enum: number; | ||
timestamp: number; | ||
struct: number; | ||
array: number; | ||
}; | ||
export declare const TLV_TYPE_LENGTH: { | ||
bool: number; | ||
int: number; | ||
float: number; | ||
enum: number; | ||
timestamp: number; | ||
}; | ||
export declare const TEMPLATE_PROPERTY = "properties"; | ||
export declare const TEMPLATE_EVENTS = "events"; | ||
export declare const TEMPLATE_ACTIONS = "actions"; | ||
export declare const OTA_UPDATE_REQUEST = "OTA_UPDATE_REQUEST"; | ||
@@ -227,18 +207,2 @@ export declare const OTA_UPDATE_DATA = "OTA_UPDATE_DATA"; | ||
export declare const GET_DEV_LOG_INFO_TIMEOUT = "GET_DEV_LOG_INFO_TIMEOUT"; | ||
export declare const NOT_SPLIT = "NOT_SPLIT"; | ||
export declare const SPLIT_FIRST = "SPLIT_FIRST"; | ||
export declare const SPLIT_MIDDLE = "SPLIT_MIDDLE"; | ||
export declare const SPLIT_LAST = "SPLIT_LAST"; | ||
export declare const SPLIT_MAP: { | ||
0: string; | ||
1: string; | ||
2: string; | ||
3: string; | ||
}; | ||
export declare const SPLIT_INDEX_MAP: { | ||
NOT_SPLIT: number; | ||
SPLIT_FIRST: number; | ||
SPLIT_MIDDLE: number; | ||
SPLIT_LAST: number; | ||
}; | ||
export declare const OTA_UPDATE_STEPS: { | ||
@@ -245,0 +209,0 @@ GET_OTA_UPDATE_INFO: string; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l,_m,_o,_p;Object.defineProperty(exports,"__esModule",{value:!0}),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.SPLIT_INDEX_MAP=exports.SPLIT_MAP=exports.SPLIT_LAST=exports.SPLIT_MIDDLE=exports.SPLIT_FIRST=exports.NOT_SPLIT=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.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_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.TEMPLATE_ACTIONS=exports.TEMPLATE_EVENTS=exports.TEMPLATE_PROPERTY=exports.TLV_TYPE_LENGTH=exports.TLV_TYPE_INDEX=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.INDICATE_TYPE_MAP=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.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.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 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.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.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.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,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.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.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.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.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.TLV_TYPE_INDEX=((_f={})[exports.BLE_IOT_DATA_TYPE_BOOL]=0,_f[exports.BLE_IOT_DATA_TYPE_INT]=1,_f[exports.BLE_IOT_DATA_TYPE_STRING]=2,_f[exports.BLE_IOT_DATA_TYPE_FLOAT]=3,_f[exports.BLE_IOT_DATA_TYPE_ENUM]=4,_f[exports.BLE_IOT_DATA_TYPE_TIME]=5,_f[exports.BLE_IOT_DATA_TYPE_STRUCT]=6,_f[exports.BLE_IOT_DATA_TYPE_ARRAY]=7,_f),exports.TLV_TYPE_LENGTH=((_g={})[exports.BLE_IOT_DATA_TYPE_BOOL]=1,_g[exports.BLE_IOT_DATA_TYPE_INT]=4,_g[exports.BLE_IOT_DATA_TYPE_FLOAT]=4,_g[exports.BLE_IOT_DATA_TYPE_ENUM]=2,_g[exports.BLE_IOT_DATA_TYPE_TIME]=4,_g),exports.TEMPLATE_PROPERTY="properties",exports.TEMPLATE_EVENTS="events",exports.TEMPLATE_ACTIONS="actions",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=((_h={})[exports.OTA_UPDATE_REQUEST]="00",_h[exports.OTA_UPDATE_DATA]="01",_h[exports.OTA_UPDATE_DATA_END]="02",_h),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.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.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.NOT_SPLIT="NOT_SPLIT",exports.SPLIT_FIRST="SPLIT_FIRST",exports.SPLIT_MIDDLE="SPLIT_MIDDLE",exports.SPLIT_LAST="SPLIT_LAST",exports.SPLIT_MAP={0:exports.NOT_SPLIT,1:exports.SPLIT_FIRST,2:exports.SPLIT_MIDDLE,3:exports.SPLIT_LAST},exports.SPLIT_INDEX_MAP=((_j={})[exports.NOT_SPLIT]=0,_j[exports.SPLIT_FIRST]=1,_j[exports.SPLIT_MIDDLE]=2,_j[exports.SPLIT_LAST]=3,_j),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_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=((_k={})[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO]="获取固件版本信息",_k[exports.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO_SUCCESS]="获取固件版本信息成功",_k[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE]="正在下载OTA文件",_k[exports.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE_DETAIL]="正在下载OTA文件详情",_k[exports.OTA_UPDATE_STEPS.DOWNLOAD_OTA_FILE_SUCCESS]="下载OTA文件成功",_k[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_START]="开始检查设备端固件升级支持情况",_k[exports.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_SUCCESS]="检查设备端固件升级支持情况成功",_k[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_START]="开始发送固件升级文件",_k[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_DETAIL]="固件升级文件详情",_k[exports.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_SUCCESS]="固件升级文件发送成功",_k[exports.OTA_UPDATE_STEPS.WAITING_MODULE_UPDATE]="开始烧录固件升级文件",_k[exports.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS]="设备端固件升级成功",_k),exports.OTA_UPDATE_ERRORS=((_l={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]="获取设备端分片包回包超时",_l[exports.WAIT_MODULE_UPDATE_TIMEOUT]="等待设备端升级超时",_l.UPDATE_DATA_REPLAY_TIMEOUT="发送固件升级文件超时",_l.MODULE_UPDATE_FAIL="设备端固件升级失败",_l.MODULE_UPDATE_CONNECT_TIMEOUT="设备端固件升级连接设备超时",_l.BLE_CONNECTION_BREAK="蓝牙连接断开",_l),exports.BLE_COMBO_ERRORS=((_m={})[exports.SET_WIFI_MODE_RESULT_INVALID]="设置WiFi模式返回格式错误",_m[exports.SET_WIFI_MODE_RESULT_TIMEOUT]="设置WiFi模式返回超时,请稍后再试",_m[exports.SET_WIFI_INFO_RESULT_INVALID]="WiFi信息传输返回格式错误",_m[exports.SET_WIFI_INFO_RESULT_TIMEOUT]="WiFi信息传输返回超时,请稍后再试",_m[exports.SET_WIFI_CONNECT_RESULT_INVALID]="WiFi连接失败",_m[exports.SET_WIFI_CONNECT_RESULT_TIMEOUT]="获取WiFi连接状态超时",_m[exports.SET_WIFI_TOKEN_RESULT_INVALID]="发送配网token结果非法",_m[exports.SET_WIFI_TOKEN_RESULT_TIMEOUT]="发送配网token结果超时,请稍后再试",_m[exports.GET_DEV_LOG_INFO_INVALID]="获取配网日志格式错误",_m[exports.GET_DEV_LOG_INFO_TIMEOUT]="获取配网日志超时,请稍后再试",_m),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(((_o={})[exports.USER_NEED_LOGIN]="用户未登录,不能连接蓝牙",_o[exports.CONTROL_ACTION_ERROR]="行为调用失败",_o[exports.CONNECT_DEVICE_ERROR]="连接设备失败",_o[exports.CANNOT_FIND_DEVICE]="无法找到设备",_o[exports.USER_NEED_LOGIN]="请重新登录",_o[exports.WAIT_CONNECT_REPLY_TIMEOUT]="等待连接回复超时",_o[exports.CONNECT_REPLY_INVALID]="等待连接回复非法",_o[exports.GET_USER_CHECK_REJECT]="用户端确认拒绝",_o[exports.WAIT_USER_CHECK_TIMEOUT]="等待用户确认超时",_o[exports.GET_USER_CHECK_TIMEOUT_TIMEOUT]="获取设备端用户确认超时时间超时,使用默认超时时间",_o[exports.GET_USER_CHECK_TIMEOUT_ERROR]="获取设备端用户确认超时时间失败,使用默认超时时间",_o[exports.DEVICE_NAME_IS_EMPTY]="设备名称非法",_o[exports.PSK_GET_ERROR]="获取local psk失败",_o[exports.CONNECT_SIGN_AUTH_ERROR]="获取连接认证失败",_o[exports.WAIT_UNBIND_REPLY_TIMEOUT]="获取解绑回复超时",_o[exports.UNBIND_REPLY_INVALID]="解绑回复非法",_o[exports.UNBIND_REPLY_ERROR]="解绑回复失败",_o[exports.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT]="等待控制设备回复超时",_o[exports.CONTROL_DEVICE_REPLY_ERROR]="控制设备失败",_o[exports.CONTROL_REPLY_INVALID]="等待控制设备回复非法",_o[exports.BIND_AUTH_FAIL]="绑定鉴权失败",_o[exports.UNBIND_RESULT_AUTH_FAIL]="解绑小程序端鉴权失败",_o[exports.CONNECT_RESULT_WRITE_FAIL]="连接小程序端鉴权失败",_o[exports.CONTROL_REPLY_CODE_INVALID]="设备端控制回包code非0",_o[exports.REPORT_RESULT_ERROR]="上报设备最新状态失败",_o[exports.GET_STATUS_ERROR]="获取最新状态失败",_o[exports.EVENT_REPLY_ERROR]="EVENT_REPLY_ERROR",_o[exports.BLE_WRITE_ERROR]="设备写入失败",_o[exports.WAIT_GET_DEVICE_INFO_TIMEOUT]="获取设备信息超时",_o[exports.DEVICE_INFO_INVALID]="设备版本和MTU信息非法",_o.ID_TEMPLATE_IS_NOT_EXIT="设备端传的id在物模型里面不存在",_o.TYPE_IN_MODULE_IS_WRONG="设备端的type和后台的不一致",_o),exports.OTA_UPDATE_ERRORS),((_p={})[exports.REGISTER_DEVICE_ERROR]="从云端动态注册失败",_p[exports.REGISTER_DEVICE_INFO_REPLY_INVALID]="设备端回复的云端注册信息非法",_p[exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT]="等待设备端回复的云端注册信息超时",_p)); | ||
"use strict";var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l;Object.defineProperty(exports,"__esModule",{value:!0}),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.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_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.INDICATE_TYPE_MAP=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.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.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 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.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.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.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,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.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.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.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.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.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.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.OTA_UPDATE_ERRORS),((_l={})[exports.REGISTER_DEVICE_ERROR]="从云端动态注册失败",_l[exports.REGISTER_DEVICE_INFO_REPLY_INVALID]="设备端回复的云端注册信息非法",_l[exports.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT]="等待设备端回复的云端注册信息超时",_l)); | ||
//# sourceMappingURL=constants.js.map |
@@ -18,4 +18,5 @@ import { StandardDeviceAdapter } from '../base'; | ||
characteristicsMap: {}; | ||
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">; | ||
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">; | ||
_bluetoothApi: any; | ||
communicationMode: import("qcloud-iotexplorer-bluetooth-adapter").CommunicationMode; | ||
_getNotifyId({ serviceId }?: { | ||
@@ -85,2 +86,4 @@ serviceId?: string; | ||
destroy(): void; | ||
advertFilter(advert: any): any; | ||
onScanAdvert(params: any): void; | ||
_cleanupMap: {}; | ||
@@ -87,0 +90,0 @@ _normalizeError(error: any): any; |
@@ -1,61 +0,1 @@ | ||
import * as constants from '../constants'; | ||
export declare const getTypeFromHead: (head: any) => number; | ||
export declare const getTypeIndexFromHead: (head: any) => number; | ||
export declare const getTypeHead: (head: any, suffix: any) => string; | ||
export declare const genHead: (type: any, id: any) => string; | ||
export declare const stringToTlv: (value: any) => string[]; | ||
/** | ||
* | ||
* @param {String} tlvHex tlv的十六进制字符串 | ||
* @param {Object} templateData 物模型数据,给解析tlv数据的时候提供参考 | ||
* @param {String} mode properties|events|actions | ||
*/ | ||
export declare const tlvHex: string[]; | ||
export declare const convertPropertiesTlvToJsObject: (tlvHex: any, templateData: any) => {}; | ||
export declare const convertActionControlToTlv: (action: { | ||
actionId: string; | ||
clientToken: string; | ||
method: 'action'; | ||
params: any; | ||
timestamp: number; | ||
}, templateData: any) => { | ||
actionIndex: any; | ||
tlvData: string[]; | ||
tmpData: string[][]; | ||
}; | ||
export declare const convertPropertiesChangeToTlv: (jsObj: any, templateData: any) => { | ||
tlvData: string[]; | ||
tmpData: string[][]; | ||
}; | ||
export declare const eventTlvData: string[]; | ||
export declare const convertEventTlvToJsObject: (tlvHex: any, templateData: any) => { | ||
eventId: any; | ||
eventIndex: number; | ||
params: {}; | ||
}; | ||
export declare const convertActionOutputTlvToJsObject: (tlvHex: any, templateData: any) => { | ||
actionId: any; | ||
actionIndex: number; | ||
outputParams: {}; | ||
}; | ||
export declare const TlvDataTypeIndexMap: { | ||
PROPERTY_REPORT: number; | ||
EVENT_REPORT: number; | ||
ACTION_REPLY: number; | ||
default: number; | ||
}; | ||
export declare type TlvDataType = keyof typeof TlvDataTypeIndexMap; | ||
/** | ||
* @description 处理分片的数据,把它拼起来 | ||
* @returns {null/Array} null表示尚未完成 | ||
*/ | ||
export declare const getTlvDataParser: (type?: TlvDataType) => (data: string) => string | string[] | null | undefined; | ||
/** | ||
* @description 对数据进行分片处理 | ||
* @returns {Array} 分片后的数据 | ||
*/ | ||
export declare const sliceData: (data: string[][], { head, mtu, mode, }: { | ||
head: string[]; | ||
mtu: number; | ||
mode: string; | ||
}) => string[]; | ||
export * from 'qcloud-iotexplorer-common-libs/lib/libs/bluetooth/tlvJson'; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.sliceData=exports.getTlvDataParser=exports.TlvDataTypeIndexMap=exports.convertActionOutputTlvToJsObject=exports.convertEventTlvToJsObject=exports.eventTlvData=exports.convertPropertiesChangeToTlv=exports.convertActionControlToTlv=exports.convertPropertiesTlvToJsObject=exports.tlvHex=exports.stringToTlv=exports.genHead=exports.getTypeHead=exports.getTypeIndexFromHead=exports.getTypeFromHead=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants=tslib_1.__importStar(require("../constants")),util_1=require("./util"),byteUtil=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.byteUtil;exports.getTypeFromHead=function(t){return parseInt(t,16)>>5},exports.getTypeIndexFromHead=function(t){return 31&parseInt(t,16)},exports.getTypeHead=function(t,e){return"string"==typeof t&&(t=parseInt(t,2)),"string"==typeof e&&(e=parseInt(e,2)),byteUtil.byteToHex(t<<5|31&e)},exports.genHead=function(t,e){var n=constants.TLV_TYPE_INDEX[t];return byteUtil.byteToHex(n<<5|31&e)},exports.stringToTlv=function(t){var e=""+util_1.U16ToHexString(t.length)+byteUtil.byteArrayToHex(byteUtil.stringToByteArray(t));return byteUtil.hexString2hexArray(e)||[""]};var parseTlv=function(t){var e,n=t.type,o=t.tlvHex,a=t.hexIndex,r=t.needResolveType,s=void 0===r||r,T=constants.TLV_TYPE_LENGTH,l=constants.BLE_IOT_DATA_TYPE_BOOL,_=constants.BLE_IOT_DATA_TYPE_INT,c=constants.BLE_IOT_DATA_TYPE_ENUM,p=constants.BLE_IOT_DATA_TYPE_FLOAT,i=constants.BLE_IOT_DATA_TYPE_TIME,v=constants.BLE_IOT_DATA_TYPE_STRING,d=constants.BLE_IOT_DATA_TYPE_STRUCT,u=constants.BLE_IOT_DATA_TYPE_ARRAY;switch(s&&++a,n){case l:e=parseInt(o[a],16),a++;break;case i:case c:e=parseInt(o.slice(a,a+=T[n]).join(""),16);break;case p:e=parseFloat(""+byteUtil.hexArray2Float32(o.slice(a,a+=T[n]),3));break;case _:e=byteUtil.hex2Int32(o.slice(a,a+=T[n]));break;case v:var x=o.slice(a),I=util_1.getStrLength(x);a+=2,x=o.slice(a,a+=I),e=util_1.hex2str(x);break;case u:case d:x=o.slice(a),I=util_1.getStrLength(x);a+=2,e=x=o.slice(a,a+=I)}return{hexIndex:a,value:e}},loopParseTlv=function(t,e,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);for(var a={},r=n;r<e.length;){var s=exports.getTypeFromHead(e[r]),T=t[exports.getTypeIndexFromHead(e[r])];if(!T)throw{code:"ID_TEMPLATE_IS_NOT_EXIT"};var l=o?T.dataType.type:T.define.type;if(console.log("---type---",s,constants.TLV_TYPE_INDEX[l]),s!==constants.TLV_TYPE_INDEX[l])throw{code:"TYPE_IN_MODULE_IS_WRONG"};var _=parseTlv({type:l,tlvHex:e,hexIndex:r});if(r=_.hexIndex,l===constants.BLE_IOT_DATA_TYPE_ARRAY){for(var c=_.value||[],p=[],i=T.define.arrayInfo.type,v=0;v<c.length;){var d=parseTlv({type:i,tlvHex:c,hexIndex:v,needResolveType:!1}),u=d.hexIndex,x=d.value;v=u,i===constants.BLE_IOT_DATA_TYPE_STRUCT?p.push(loopParseTlv(T.define.arrayInfo.specs,x,0,!0)):p.push(x)}console.log("ARRAY",T,_,p),a[T.id]=p}else l===constants.BLE_IOT_DATA_TYPE_STRUCT?(console.log("STRUCT",T.define.specs,_.value),a[T.id]=loopParseTlv(T.define.specs,_.value,0,!0)):a[T.id]=_.value}return a},getIndexMap=function(t){var e={};return t.map((function(t,n){e[t.id]=n})),e},convertToTlv=function(t){var e=t.type,n=t.typeIndex,o=void 0===n?0:n,a=t.value,r=t.templateConfig,s=void 0===r?{}:r,T=t.needGenHead,l=void 0===T||T,_=constants.BLE_IOT_DATA_TYPE_BOOL,c=constants.BLE_IOT_DATA_TYPE_INT,p=constants.BLE_IOT_DATA_TYPE_ENUM,i=constants.BLE_IOT_DATA_TYPE_FLOAT,v=constants.BLE_IOT_DATA_TYPE_TIME,d=constants.BLE_IOT_DATA_TYPE_STRING,u=constants.BLE_IOT_DATA_TYPE_STRUCT,x=constants.BLE_IOT_DATA_TYPE_ARRAY,I=byteUtil.hexString2hexArray,E=byteUtil.int32ToHex,A=byteUtil.byteToHex,y=byteUtil.convertNumberToByte,P=[];switch(e){case _:P=[A(y(a))];break;case v:case c:P=I(E(a))||[""];break;case p:P=I(util_1.U16ToHexString(a))||[""];break;case i:P=byteUtil.float32ToHexArray(parseFloat(a))||[""];break;case d:P=exports.stringToTlv(a);break;case u:var g=getIndexMap(s),D=loopConvertToTlv(a,g,s,!0).tlvData,O=D.length;P=tslib_1.__spread(byteUtil.hexString2hexArray(util_1.U16ToHexString(O)),D);break;case x:var f=s[0],h=a;f&&Array.isArray(h)&&h.forEach((function(t){var e=convertToTlv({type:f.type,value:t,needGenHead:!1,templateConfig:f.type===u?f.specs:{}});P.push.apply(P,tslib_1.__spread(e))})),P=tslib_1.__spread(byteUtil.hexString2hexArray(util_1.U16ToHexString(P.length)),P)}return l&&P.unshift(exports.genHead(e,o)),tslib_1.__spread(P)},loopConvertToTlv=function(t,e,n,o){void 0===o&&(o=!1);var a=[];Object.keys(t).forEach((function(r){var s=e[r],T=n[s]&&(o?n[s].dataType:n[s].define),l=null==T?void 0:T.type;if(!l)throw{code:"TEMPLATE_NOT_MATCH",detail:{jsObj:t,templateConfig:n}};var _=void 0;switch(l){case constants.BLE_IOT_DATA_TYPE_ARRAY:_=[n[s].define.arrayInfo];break;case constants.BLE_IOT_DATA_TYPE_STRUCT:_=n[s].define.specs;break;default:_={}}a[s]=convertToTlv({type:l,typeIndex:s,value:t[r],templateConfig:_})}));var r=[];return a.map((function(t){(null==t?void 0:t.length)&&r.push.apply(r,tslib_1.__spread(t))})),console.log("---tlvData---",r),{tlvData:r,tmpData:a}};exports.tlvHex=["00","00","81","00","00","22","00","00","00","00","43","00","0C","64","65","66","61","75","6C","74","20","6E","61","6D","65"],exports.convertPropertiesTlvToJsObject=function(t,e){var n=constants.TEMPLATE_PROPERTY;console.log("---tlvHex--",t);var o=e[n];if(!o)throw{code:"NO_SUCH_MODE_FOR_THIS_PRODUCT"};return loopParseTlv(o,t)},exports.convertActionControlToTlv=function(t,e){console.log("---convertActionControlToTlv--",t);var n=e[constants.TEMPLATE_ACTIONS],o=getIndexMap(n)[t.actionId],a=n[o],r=t.params,s=getIndexMap(a.input);console.log("---jsObj--",r,s);var T=loopConvertToTlv(r,s,a.input);return{actionIndex:o,tlvData:T.tlvData,tmpData:T.tmpData}},exports.convertPropertiesChangeToTlv=function(t,e){var n=constants.TEMPLATE_PROPERTY;console.log("---jsObj--",t,e);var o=e[n],a=getIndexMap(o),r=loopConvertToTlv(t,a,o),s=r.tlvData,T=r.tmpData;return console.warn("---tlvData---",s),console.warn("---tmpData---",T),{tlvData:s,tmpData:T}},exports.eventTlvData=["01","60","00","00","80","3F"],exports.convertEventTlvToJsObject=function(t,e){var n=constants.TEMPLATE_EVENTS,o=parseInt(t[0],16),a=e[n][o];if(!a)throw{code:"NO_SUCH_MODE_FOR_THIS_PRODUCT"};var r=loopParseTlv(a.params,t,1);return{eventId:a.id,eventIndex:o,params:r}},exports.convertActionOutputTlvToJsObject=function(t,e){var n=parseInt(t[0],16),o=e[constants.TEMPLATE_ACTIONS][n];if(!o)throw{code:"NO_SUCH_MODE_FOR_THIS_PRODUCT"};var a=loopParseTlv(o.output,t,1);return{actionId:o.id,actionIndex:n,outputParams:a}},exports.TlvDataTypeIndexMap=((_a={})[constants.PROPERTY_REPORT]=2,_a[constants.EVENT_REPORT]=3,_a[constants.ACTION_REPLY]=4,_a.default=2,_a),exports.getTlvDataParser=function(t){void 0===t&&(t="default");var e=[];return function(n){console.log("----data----",n);var o=util_1.getStrLength(n),a=o>>14,r=o>>13&1,s=constants.SPLIT_MAP[a];switch(console.log(a,s,t),s){case constants.SPLIT_FIRST:return e=tslib_1.__spread(n.slice(2)),null;case constants.SPLIT_MIDDLE:return e=e.concat(n.slice(void 0!==exports.TlvDataTypeIndexMap[t]?exports.TlvDataTypeIndexMap[t]:2)),null;case constants.SPLIT_LAST:return(e=e.concat(n.slice(void 0!==exports.TlvDataTypeIndexMap[t]?exports.TlvDataTypeIndexMap[t]:2))).splice.apply(e,tslib_1.__spread([0,0],byteUtil.hexString2hexArray(util_1.U16ToHexString(r<<15|e.length))||[])),console.log("----completeData---",e),e;case constants.NOT_SPLIT:return n}}},exports.sliceData=function(t,e){var n=e.head,o=e.mtu,a=e.mode,r=[],s=[],T=o-1-2;return t.forEach((function(t){if(t.length<T)s.push(t);else for(var e=a===constants.CONTROL_ACTION,n=e?1:0;n<t.length;n+=T)e?s.push(tslib_1.__spread([t[1]],t.slice(n,n+T))):s.push(t.slice(n,n+T))})),s.forEach((function(t,e){var o,a=n.join("");o=0===e?constants.SPLIT_INDEX_MAP[constants.SPLIT_FIRST]:e===s.length-1?constants.SPLIT_INDEX_MAP[constants.SPLIT_LAST]:constants.SPLIT_INDEX_MAP[constants.SPLIT_MIDDLE],a+=util_1.U16ToHexString(o<<14|t.length),a+=t.join(""),r.push(a)})),r}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib");tslib_1.__exportStar(require("qcloud-iotexplorer-common-libs/lib/libs/bluetooth/tlvJson"),exports); | ||
//# sourceMappingURL=tlvJson.js.map |
@@ -1,11 +0,5 @@ | ||
import { TlvDataType } from './tlvJson'; | ||
import { TlvDataType } from 'qcloud-iotexplorer-common-libs/lib/libs/bluetooth/tlvJson'; | ||
export declare const getStrLength: (hex: any) => number; | ||
export declare const U16ToHexString: (length: any) => string; | ||
export declare const U32ToHexString: (length: any) => string; | ||
export declare const U8ToHexString: (length: any) => string; | ||
export declare const md5: (string: any) => any; | ||
export declare const get8ByteFromStr: (str: any) => string; | ||
export * from 'qcloud-iotexplorer-common-libs/lib/utils'; | ||
export declare const getUserIdentify: (userId: string) => string; | ||
export declare const getProductDateTemplate: (productInfo: any) => any; | ||
export declare const gen4BytesIntHex: () => string; | ||
export declare const wrapEventHandler: (cb: any, dataType?: TlvDataType) => ({ data }: { | ||
@@ -16,9 +10,1 @@ data: any; | ||
export declare const formatArrayToReportString: (data: any) => any; | ||
export declare function hex2str(hex: any): any; | ||
export declare function str2hexStr(str: any): string; | ||
export declare const downloadFile: (url: any, { onProgress }?: { | ||
onProgress: any; | ||
}) => Promise<{ | ||
fileSize: number; | ||
fileBuffer: ArrayBuffer; | ||
}>; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _this=this;Object.defineProperty(exports,"__esModule",{value:!0}),exports.downloadFile=exports.str2hexStr=exports.hex2str=exports.formatArrayToReportString=exports.encrypt=exports.wrapEventHandler=exports.gen4BytesIntHex=exports.getProductDateTemplate=exports.getUserIdentify=exports.get8ByteFromStr=exports.md5=exports.U8ToHexString=exports.U32ToHexString=exports.U16ToHexString=exports.getStrLength=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),tlvJson_1=require("./tlvJson"),spark_md5_1=tslib_1.__importDefault(require("spark-md5")),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,noop=_a.noop,byteUtil=_a.byteUtil,CryptoJS=_a.CryptoJS;function hex2str(t){var e;return e="string"==typeof t?t.match(/[\da-f]{2}/gi):t,byteUtil.byteArrayToString(new Int8Array(e.map((function(t){return parseInt(t,16)}))))}function str2hexStr(t){return byteUtil.byteArrayToHex(byteUtil.stringToByteArray(t))}exports.getStrLength=function(t){return parseInt(t.slice(0,2).join(""),16)},exports.U16ToHexString=function(t){var e=t.toString(16).toUpperCase();return""+"0000".slice(0,4-e.length)+e},exports.U32ToHexString=function(t){var e=t.toString(16).toUpperCase();return""+"00000000".slice(0,8-e.length)+e},exports.U8ToHexString=function(t){var e=t.toString(16).toUpperCase();if(e.length>2)throw"length error,must less then 255";return""+"00".slice(0,2-e.length)+e},exports.md5=function(t){return spark_md5_1.default.hash(t)},exports.get8ByteFromStr=function(t){for(var e=exports.md5(t),r=byteUtil.hexStringToByteArray(e.substring(0,e.length/2)),o=byteUtil.hexStringToByteArray(e.substring(e.length/2)),n=[],s=0;s<r.length;s++)n[s]=r[s]^o[s];return byteUtil.byteArrayToHex(n)},exports.getUserIdentify=function(t){return exports.get8ByteFromStr(exports.md5(t))},exports.getProductDateTemplate=function(t){try{if(!t)throw{code:"GET_PRODUCT_INFO_FAIL",msg:"获取产品信息失败"};var e=t.DataTemplate;return"string"==typeof e&&(e=JSON.parse(e)),e}catch(t){throw tslib_1.__assign({code:"TEMPLATE_ERROR"},t)}},exports.gen4BytesIntHex=function(){var t=Math.floor(Math.random()*Math.pow(10,9)).toString(16);return""+t+"feaa12dd".slice(0,8-t.length)},exports.wrapEventHandler=function(t,e){void 0===e&&(e="default");var r=tlvJson_1.getTlvDataParser(e);return function(e){var o=e.data;console.log("event triggered",o);var n=r(o);console.log("----result",n,_this),null!==n&&t(n)}},exports.encrypt=function(t,e){var r=CryptoJS.enc.Hex.parse(String(e)),o=CryptoJS.HmacSHA1(String(t),r);return console.log("encrypt",r,t,o.toString(CryptoJS.enc.Hex)),o.toString(CryptoJS.enc.Hex)},exports.formatArrayToReportString=function(t){return t.join(",")},exports.hex2str=hex2str,exports.str2hexStr=str2hexStr,exports.downloadFile=function(t,e){var r=(void 0===e?{}:e).onProgress,o=void 0===r?noop:r;return new Promise((function(e){wx.downloadFile({url:t,success:function(t){console.log(t),wx.getFileSystemManager().readFile({filePath:t.tempFilePath,success:function(t){console.log(t);var r=t.data.byteLength;e({fileSize:r,fileBuffer:t.data})}})}}).onProgressUpdate((function(t){return o(t)}))}))}; | ||
"use strict";var _this=this;Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatArrayToReportString=exports.encrypt=exports.wrapEventHandler=exports.getUserIdentify=exports.getStrLength=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_common_libs_1=require("qcloud-iotexplorer-common-libs"),getTlvDataParser=qcloud_iotexplorer_common_libs_1.tlvJson.getTlvDataParser;exports.getStrLength=qcloud_iotexplorer_common_libs_1.tlvJson.getStrLength,tslib_1.__exportStar(require("qcloud-iotexplorer-common-libs/lib/utils"),exports),exports.getUserIdentify=function(e){return qcloud_iotexplorer_common_libs_1.utils.get8ByteFromStr(qcloud_iotexplorer_common_libs_1.utils.md5(e))},exports.wrapEventHandler=function(e,r){void 0===r&&(r="default");var t=getTlvDataParser(r);return function(r){var o=r.data;console.log("event triggered",o);var l=t(o);console.log("----result",l,_this),null!==l&&e(l)}},exports.encrypt=qcloud_iotexplorer_common_libs_1.utils.hmacSHA1,exports.formatArrayToReportString=function(e){return e.join(",")}; | ||
//# sourceMappingURL=util.js.map |
@@ -13,4 +13,5 @@ export declare const StandardDeviceAdapter4Mp: (new (...args: any[]) => { | ||
characteristicsMap: {}; | ||
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">; | ||
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">; | ||
_bluetoothApi: any; | ||
communicationMode: import("qcloud-iotexplorer-bluetooth-adapter").CommunicationMode; | ||
_getNotifyId({ serviceId }?: { | ||
@@ -84,2 +85,4 @@ serviceId?: string; | ||
destroy(): void; | ||
advertFilter(advert: any): any; | ||
onScanAdvert(params: any): void; | ||
_cleanupMap: {}; | ||
@@ -86,0 +89,0 @@ _normalizeError(error: any): any; |
{ | ||
"name": "qcloud-iotexplorer-bluetooth-adapter-llsync", | ||
"version": "1.3.17", | ||
"version": "1.3.25", | ||
"description": "", | ||
@@ -17,6 +17,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"event-emitter-for-miniprogram": "^0.0.13", | ||
"iotexplorer-ui-dev-config": "^1.0.26", | ||
"qcloud-iotexplorer-appdev-sdk": "^1.1.15", | ||
"qcloud-iotexplorer-bluetooth-adapter": "^0.3.14", | ||
"event-emitter-for-miniprogram": "^0.0.20", | ||
"iotexplorer-ui-dev-config": "^1.0.34", | ||
"qcloud-iotexplorer-appdev-sdk": "^1.1.22", | ||
"qcloud-iotexplorer-bluetooth-adapter": "^0.3.22", | ||
"qcloud-iotexplorer-common-libs": "^0.0.9", | ||
"shortid-for-miniprogram": "^2.2.15", | ||
@@ -26,3 +27,3 @@ "spark-md5": "^3.0.1", | ||
}, | ||
"gitHead": "65392aeec6cf458344d7190a22133508332ac8f8" | ||
"gitHead": "878fc4bfed5e8f694e0f9db751d9d586768f11ef" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
54
12
197861
8
1270
+ Addedevent-emitter-for-miniprogram@0.0.20(transitive)
+ Addedqcloud-iotexplorer-common-libs@0.0.9(transitive)
- Removedevent-emitter-for-miniprogram@0.0.13(transitive)