Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-bluetooth-adapter-llsync

Package Overview
Dependencies
15
Maintainers
5
Versions
126
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.7 to 1.5.0

2

lib/base/LLSync/LLSyncDeviceAdapter.d.ts

@@ -31,2 +31,3 @@ import { DeviceFilterFunction } from 'qcloud-iotexplorer-bluetooth-adapter';

mtu: number;
disableWsEventHandle: boolean;
get ready(): boolean;

@@ -47,2 +48,3 @@ get needUserCheck(): boolean;

stopListenLLEvents(): void;
setWsEventHandleEnabled(enabled: any): void;
onPropertyReport(data: any): Promise<void>;

@@ -49,0 +51,0 @@ onGetStatus(): Promise<never>;

2

lib/base/LLSync/LLSyncDeviceAdapter.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StandardDeviceAdapter=exports.LLSyncDeviceAdapter=void 0;var tslib_1=require("tslib"),constants=tslib_1.__importStar(require("../../constants")),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants_1=require("../../constants"),libs_1=require("../../libs"),utils=tslib_1.__importStar(require("../../libs")),Models_1=require("./Models"),LLSyncDeviceAdapterBase_1=require("../LLSyncDeviceAdapterBase"),LLSyncOtaProcessor_1=require("./LLSyncOtaProcessor"),LLSyncProtocol_1=require("./LLSyncProtocol"),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;
"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(!o.disableWsEventHandle&&(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.disableWsEventHandle||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.setWsEventHandleEnabled=function(e){this.disableWsEventHandle=!e},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],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,macStr:E?"":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:E?"":n.slice(3,9).join(":")}});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;
//# sourceMappingURL=LLSyncDeviceAdapter.js.map

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncOtaProcessor=exports.getPackageDataToSend=exports.generateFileChunks=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),constants=tslib_1.__importStar(require("../../constants")),libs_1=require("../../libs"),LLSyncProtocol_1=require("./LLSyncProtocol"),arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,genPromise=_a.genPromise,delay=_a.delay,byteUtil=_a.byteUtil;exports.generateFileChunks=function(e,t){for(var r=t.alreadyReceiveSize,o=[],s=t.maxLengthPerPackage-3,n=Math.min(Math.ceil((e.fileSize-r)/s),t.maxPackageNumPerCircle),i=0;i<n;i++){var a=Math.min(r+s,e.fileSize),c=e.fileBuffer.slice(r,a);o.push(c),r=a}return o},exports.getPackageDataToSend=function(e,t){for(var r=[],o=parseInt(constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA],16),s=t;s<e.length;s++){var n=e[s].byteLength+1;r.push(tslib_1.__spread([libs_1.U8ToHexString(o),libs_1.U8ToHexString(n),libs_1.U8ToHexString(s)],arrayBufferToHexStringArray(e[s])).join(""))}return r};var LLSyncOtaProcessor=function(){function e(e){this.otaInProgress=!1,this.deviceAdapter=e}return Object.defineProperty(e.prototype,"reporter",{get:function(){return this.deviceAdapter.reporter},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"otaVersion",{get:function(){return this.deviceAdapter.otaVersion},enumerable:!1,configurable:!0}),e.prototype.onProgress=function(e,t){void 0===t&&(t={});var r=constants.OTA_UPDATE_STEPS_MESSAGE[e];this.reporter.info(e,tslib_1.__assign({message:r},t)),"function"==typeof this._onProgressCb&&this._onProgressCb({code:e,msg:r,detail:t})},e.prototype.cancelOta=function(){this.otaInProgress&&this.processPromise.reject({code:"USER_CANCEL_OTA_UPDATE"})},e.prototype.startOta=function(e){var t=e.onProgress;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,o,s,n,i,a,c,_,l;return tslib_1.__generator(this,(function(T){switch(T.label){case 0:if(this.otaInProgress)throw{code:"OTA_UPDATE_IN_PROGRESS",msg:"OTA升级进行中,请勿重复操作"};this.otaInProgress=!0,this.processPromise=genPromise(),this._onProgressCb=t,T.label=1;case 1:return T.trys.push([1,8,9,10]),this.onProgress(constants.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO),[4,this.getOtaUpdateInfo()];case 2:if(e=T.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO_SUCCESS,{otaUpdateInfo:e}),!e.needUpdate)throw{code:this.otaVersion?"MODULE_VERSION_IS_UPDATED":"MODULE_DONNOT_SUPPORT"};return this.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE),[4,this.downloadOtaFile(e)];case 3:return r=T.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOAD_OTA_FILE_SUCCESS,{fileInfo:r}),this.onProgress(constants.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_START),[4,this.sendOTARequest({fileInfo:r,otaUpdateInfo:e})];case 4:return o=T.sent(),s=o.supportUploadFromBreak,n=o.otaUpdateProgressInfo,this.onProgress(constants.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_SUCCESS,{supportUploadFromBreak:s,otaUpdateProgressInfo:n}),this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_START),i=Date.now(),[4,this.sendOtaFile({fileInfo:r,otaUpdateProgressInfo:n})];case 5:return T.sent(),[4,this.reportAndConfirmUpdateStatus({otaUpdateProgressInfo:n})];case 6:return a=T.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_SUCCESS,{timeCost:Date.now()-i,response:a}),this.onProgress(constants.OTA_UPDATE_STEPS.WAITING_MODULE_UPDATE),c=Date.now(),[4,this.checkRebootStatus({otaUpdateInfo:e,rebootMaxTime:n.rebootMaxTime})];case 7:return T.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS,{timeCost:Date.now()-c}),this.processPromise=null,[2,{code:constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS,msg:constants.OTA_UPDATE_STEPS_MESSAGE[constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS]}];case 8:throw _=T.sent(),console.log("---ota fail---",_),_||(_={}),_.code&&constants.OTA_UPDATE_ERRORS[_.code]?_.msg=constants.OTA_UPDATE_ERRORS[_.code]+":"+_.code:(l="MODULE_DONNOT_SUPPORT",_.msg=l+":"+constants.OTA_UPDATE_ERRORS[l]+":"+_.code+":"+(_.msg||_.errMsg||""),_.code=l),this.reporter.error("MODULE_UPDATE_FAIL",{error:_}),_;case 9:return this.otaInProgress=!1,[7];case 10:return[2]}}))}))},e.prototype.reportAndConfirmUpdateStatus=function(e){var t=e.otaUpdateProgressInfo;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){return e=""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA_END],[2,this.deviceAdapter.writeAndWait4Response(e,constants.UPDATE_DATA_CHECK_REPLY,(function(e){var t=e.data;if(console.log("---checkUpdateState---",t),!t.length)throw{code:constants.UPDATE_REPLY_INVALID};var r=parseInt(t.slice(2).join(""),16),o=constants.MODULE_UPDATE_DATA_REPLAY_CODE_MAP[r>>7];o=void 0===o?"MODULE_UPDATE_CHECK_FILE_FAIL":o;var s=(r<<1&255)>>1;if(console.log("------UPDATE_DATA_CHECK_REPLY——code----",o,s),o===constants.OTA_UPDATE_STEPS.MODULE_UPDATE_CHECK_FILE_SUCCESS)return{code:o};throw{code:o,msg:constants.MODULE_UPDATE_REPLAY_DATA_CODE_MAP[s]}}),{timeout:t.retryTimeGap*t.retryTimes,timeoutCode:"UPDATE_DATA_REPLAY_TIMEOUT",writeId:constants.LL_OTA_WRITE_ID,shouldWrapSplitDataFn:!1})]}))}))},e.prototype.getOtaUpdateInfo=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,o;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.deviceAdapter.models.getDeviceOTAInfo({DeviceId:this.deviceAdapter.explorerDeviceId})];case 1:return e=s.sent(),t=e.FirmwareURL,r=e.TargetVersion,console.log("----",r,t,this.otaVersion),o={needUpdate:!1,targetVersion:r,otaUrl:t},this.otaVersion&&r!==this.otaVersion&&(o.needUpdate=!0),[2,o];case 2:return s.sent(),[2,Promise.reject({code:"GET_OTA_INFO_FAIL"})];case 3:return[2]}}))}))},e.prototype.sendOTARequest=function(e){var t=this,r=e.fileInfo,o=e.otaUpdateInfo,s=byteUtil.hexString2hexArray(libs_1.str2hexStr(o.targetVersion)),n=byteUtil.hexString2hexArray(libs_1.U32ToHexString(r.fileSize)+""+libs_1.U32ToHexString(r.fileCrc)+libs_1.U8ToHexString(s.length)+s.join("")),i=this.deviceAdapter.sliceData(tslib_1.__spread([""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_REQUEST],libs_1.U16ToHexString(n.length)],n),[n],constants.UPDATE_REPLY);return this.deviceAdapter.writeAndWait4Response(i,constants.UPDATE_REPLY,(function(e){if(console.log("receive send OTA request",e),!e.length)throw{code:constants.UPDATE_REPLY_INVALID};var r=parseInt(e.slice(2,3).join(""),16),o=!!(1&r),s=!!(r>>1&1),n=e.slice(3);if(!o){var i=parseInt(n.slice(0,1),16);throw{code:"MODULE_DONNOT_ALLOW",detail:{code:i,msg:constants.MODULE_UPDATE_REPLAY_CODE_MAP[i]}}}var a={maxPackageNumPerCircle:parseInt(n.slice(0,1).join(""),16),maxLengthPerPackage:parseInt(n.slice(1,2).join(""),16),retryTimeGap:1e3*parseInt(n.slice(2,3).join(""),16),retryTimes:5,rebootMaxTime:1e3*parseInt(n.slice(3,4).join(""),16),alreadyReceiveSize:parseInt(n.slice(4,8).join(""),16),sendWaitGap:parseInt(n.slice(8,9).join("")||0,16)};return a.maxLengthPerPackage=Math.min(a.maxLengthPerPackage,t.deviceAdapter.mtu),{supportUploadFromBreak:s,otaUpdateProgressInfo:a}}),{timeout:LLSyncProtocol_1.LLSyncConfig.waitUpdateReplyInt,timeoutCode:constants.WAIT_GET_UPDATE_INFO_TIMEOUT,writeId:constants.LL_OTA_WRITE_ID})},e.prototype.reportSendOtaDataSuccess=function(){var e=""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA_END];return this.deviceAdapter.write(e,{writeId:constants.LL_OTA_WRITE_ID})},e.prototype.sendOtaFile=function(e){var t=e.fileInfo,r=e.otaUpdateProgressInfo;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_DETAIL,{progress:Math.ceil(r.alreadyReceiveSize/t.fileSize*100)}),e=exports.generateFileChunks(t,r),o=genPromise(),s=function(){console.log("disconnect while send data"),o.reject({code:"BLE_CONNECTION_BREAK"})},this.deviceAdapter.once("disconnect",s),[4,Promise.race([this.processPromise.promise,o.promise,this.sendFileChunks({fileChunks:e,otaUpdateProgressInfo:r})])];case 1:return n=i.sent().fileSize,console.log("----on--update---data-reply---then",n),r.alreadyReceiveSize=n,r.alreadyReceiveSize!==t.fileSize?[2,this.sendOtaFile({fileInfo:t,otaUpdateProgressInfo:r})]:[2]}}))}))},e.prototype.sendFileChunks=function(e){var t=e.fileChunks,r=e.otaUpdateProgressInfo,o=e.seq,s=void 0===o?0:o,n=e.retryTime,i=void 0===n?0:n;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,n,a,c,_,l,T;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:if(console.log("----send file chunks",t,r,s,i),i>r.retryTimes)throw console.log("----UPDATE_DATA_REPLAY_TIMEOUT---reject---",i),{code:"UPDATE_DATA_REPLAY_TIMEOUT"};d.label=1;case 1:d.trys.push([1,11,,12]),e=exports.getPackageDataToSend(t,s),o=constants.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE,d.label=2;case 2:if(!(o>0))return[3,7];d.label=3;case 3:return d.trys.push([3,5,,6]),[4,this.deviceAdapter.writeData(e,{writeId:constants.LL_OTA_WRITE_ID,waitGap:r.sendWaitGap||10})];case 4:return d.sent(),[3,7];case 5:if(n=d.sent(),console.log("---write error, retry time:---",constants.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE-o,n),!--o)throw n;return[3,6];case 6:return[3,2];case 7:return d.trys.push([7,9,,10]),[4,this.confirmFileChunkReceived({otaUpdateProgressInfo:r})];case 8:return a=d.sent(),c=a.seq,_=a.fileSize,console.log("---receive update reply",c,_,t.length),c!==t.length?(console.log("---confirmFileChunkSendStatus fail---","seqReceived and fileSended not match, resend file",c,t.length),[2,this.sendFileChunks({fileChunks:t,otaUpdateProgressInfo:r,seq:c||s,retryTime:i+1})]):[2,{fileSize:_}];case 9:return l=d.sent(),console.log("---confirmFileChunkSendStatus fail---",l),[2,Promise.reject(l)];case 10:return[3,12];case 11:return T=d.sent(),[2,Promise.reject(tslib_1.__assign({code:"BLE_WRITE_ERROR"},T))];case 12:return[2]}}))}))},e.prototype.confirmFileChunkReceived=function(e){var t,r=this,o=e.otaUpdateProgressInfo,s=genPromise(),n=function(e){var r=e.data;if(clearTimeout(t),!r.length)return s.reject({code:constants.UPDATE_REPLY_INVALID});var o=parseInt(r.slice(2,3).join(""),16),n=parseInt(r.slice(3,7).join(""),16);return s.resolve({seq:o,fileSize:n})};return console.log("---confirmFileChunkReceived---:listen data"),this.deviceAdapter.once(constants.UPDATE_DATA_REPLY,n),Promise.race([s.promise,new Promise((function(e,s){t=setTimeout((function(){r.deviceAdapter.off(constants.UPDATE_DATA_REPLY,n),s({code:"UPDATE_DATA_REPLAY_TIMEOUT"})}),o.retryTimeGap*o.retryTimes)}))])},e.prototype.checkRebootStatus=function(e){var t=e.otaUpdateInfo,r=e.rebootMaxTime;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n,i,a=this;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return e=genPromise(),o=!1,s=0,n=function(){return tslib_1.__awaiter(a,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:if(!(s<=constants.WAIT_MODULE_UPDATE_CONNECT_TIMES))return[3,7];r=this.deviceAdapter.deviceName,console.log("--try connect--",o,s,r),n.label=1;case 1:return n.trys.push([1,4,,6]),[4,this.deviceAdapter.connectDevice()];case 2:return n.sent(),[4,this.deviceAdapter.authenticateConnection({deviceName:r})];case 3:return n.sent(),this.otaVersion!==t.targetVersion?[2,e.reject({code:"MODULE_UPDATE_FAIL"})]:[2,e.resolve({code:constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS})];case 4:return n.sent(),s+=1,[4,delay(constants.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP)];case 5:return n.sent(),[3,6];case 6:return[3,0];case 7:return[2,e.reject({code:"MODULE_UPDATE_CONNECT_TIMEOUT"})]}}))}))},i=function(){return tslib_1.__awaiter(a,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return console.log("--on/disconnect--"),n(),[2]}))}))},this.deviceAdapter.once("disconnect",i),[4,Promise.race([e.promise,new Promise((function(e,t){setTimeout((function(){o=!0,a.deviceAdapter.off("disconnect",i),t({code:constants.WAIT_MODULE_UPDATE_TIMEOUT})}),10*r)}))])];case 1:return[2,c.sent()]}}))}))},e.prototype.downloadOtaFile=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,s,n,i=this;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:return[4,libs_1.downloadFile(e.otaUrl,{onProgress:function(e){i.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE_DETAIL,e)}})];case 1:return t=a.sent(),r=t.fileSize,o=t.fileBuffer,console.log(r,o),(s=new libs_1.CRC32).update(new Int8Array(o)),n=s.getValue(),[2,{fileSize:r,fileCrc:n,fileBuffer:o}]}}))}))},e}();exports.LLSyncOtaProcessor=LLSyncOtaProcessor;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncOtaProcessor=exports.getPackageDataToSend=exports.generateFileChunks=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),constants=tslib_1.__importStar(require("../../constants")),libs_1=require("../../libs"),LLSyncProtocol_1=require("./LLSyncProtocol"),arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,genPromise=_a.genPromise,delay=_a.delay,byteUtil=_a.byteUtil;exports.generateFileChunks=function(e,t){for(var r=t.alreadyReceiveSize,o=[],n=t.maxLengthPerPackage-3,s=Math.min(Math.ceil((e.fileSize-r)/n),t.maxPackageNumPerCircle),i=0;i<s;i++){var a=Math.min(r+n,e.fileSize),c=e.fileBuffer.slice(r,a);o.push(c),r=a}return o},exports.getPackageDataToSend=function(e,t){for(var r=[],o=parseInt(constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA],16),n=t;n<e.length;n++){var s=e[n].byteLength+1;r.push(tslib_1.__spread([libs_1.U8ToHexString(o),libs_1.U8ToHexString(s),libs_1.U8ToHexString(n)],arrayBufferToHexStringArray(e[n])).join(""))}return r};var LLSyncOtaProcessor=function(){function e(e){this.otaInProgress=!1,this.deviceAdapter=e}return Object.defineProperty(e.prototype,"reporter",{get:function(){return this.deviceAdapter.reporter},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"otaVersion",{get:function(){return this.deviceAdapter.otaVersion},enumerable:!1,configurable:!0}),e.prototype.onProgress=function(e,t){void 0===t&&(t={});var r=constants.OTA_UPDATE_STEPS_MESSAGE[e];this.reporter.info(e,tslib_1.__assign({message:r},t)),"function"==typeof this._onProgressCb&&this._onProgressCb({code:e,msg:r,detail:t})},e.prototype.cancelOta=function(){this.otaInProgress&&this.processPromise.reject({code:"USER_CANCEL_OTA_UPDATE"})},e.prototype.startOta=function(e){var t=e.onProgress;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,r,o,n,s,i,a,c,_,l;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:if(this.otaInProgress)throw{code:"OTA_UPDATE_IN_PROGRESS",msg:"OTA升级进行中,请勿重复操作"};this.otaInProgress=!0,this.processPromise=genPromise(),this._onProgressCb=t,d.label=1;case 1:return d.trys.push([1,8,9,10]),this.onProgress(constants.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO),[4,this.getOtaUpdateInfo()];case 2:if(e=d.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.GET_OTA_UPDATE_INFO_SUCCESS,{otaUpdateInfo:e}),!e.needUpdate)throw{code:this.otaVersion?"MODULE_VERSION_IS_UPDATED":"MODULE_DONNOT_SUPPORT"};return this.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE),[4,this.downloadOtaFile(e)];case 3:return r=d.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOAD_OTA_FILE_SUCCESS,{fileInfo:r}),this.onProgress(constants.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_START),[4,this.sendOTARequest({fileInfo:r,otaUpdateInfo:e})];case 4:return o=d.sent(),n=o.supportUploadFromBreak,s=o.otaUpdateProgressInfo,this.onProgress(constants.OTA_UPDATE_STEPS.REQUEST_MODULE_UPDATE_SUCCESS,{supportUploadFromBreak:n,otaUpdateProgressInfo:s}),this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_START),i=Date.now(),[4,this.sendOtaFile({fileInfo:r,otaUpdateProgressInfo:s})];case 5:return d.sent(),[4,this.reportAndConfirmUpdateStatus({otaUpdateProgressInfo:s})];case 6:return a=d.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_SUCCESS,{timeCost:Date.now()-i,response:a}),this.onProgress(constants.OTA_UPDATE_STEPS.WAITING_MODULE_UPDATE),c=Date.now(),[4,this.checkRebootStatus({otaUpdateInfo:e,rebootMaxTime:s.rebootMaxTime})];case 7:return d.sent(),this.onProgress(constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS,{timeCost:Date.now()-c}),this.processPromise=null,[2,{code:constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS,msg:constants.OTA_UPDATE_STEPS_MESSAGE[constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS]}];case 8:throw _=d.sent(),console.log("---ota fail---",_),_||(_={}),_.code&&constants.OTA_UPDATE_ERRORS[_.code]?_.msg=constants.OTA_UPDATE_ERRORS[_.code]+":"+_.code:(l="MODULE_DONNOT_SUPPORT",_.msg=l+":"+constants.OTA_UPDATE_ERRORS[l]+":"+_.code+":"+(_.msg||_.errMsg||""),_.code=l),this.reporter.error("MODULE_UPDATE_FAIL",{error:_}),_;case 9:return this.otaInProgress=!1,[7];case 10:return[2]}}))}))},e.prototype.reportAndConfirmUpdateStatus=function(e){var t=e.otaUpdateProgressInfo;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){return e=""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA_END],[2,this.deviceAdapter.writeAndWait4Response(e,constants.UPDATE_DATA_CHECK_REPLY,(function(e){var t=e.data;if(console.log("---checkUpdateState---",t),!t.length)throw{code:constants.UPDATE_REPLY_INVALID};var r=parseInt(t.slice(2).join(""),16),o=constants.MODULE_UPDATE_DATA_REPLAY_CODE_MAP[r>>7];o=void 0===o?"MODULE_UPDATE_CHECK_FILE_FAIL":o;var n=(r<<1&255)>>1;if(console.log("------UPDATE_DATA_CHECK_REPLY——code----",o,n),o===constants.OTA_UPDATE_STEPS.MODULE_UPDATE_CHECK_FILE_SUCCESS)return{code:o};throw{code:o,msg:constants.MODULE_UPDATE_REPLAY_DATA_CODE_MAP[n]}}),{timeout:t.retryTimeGap*t.retryTimes,timeoutCode:"UPDATE_DATA_REPLAY_TIMEOUT",writeId:constants.LL_OTA_WRITE_ID,shouldWrapSplitDataFn:!1})]}))}))},e.prototype.getOtaUpdateInfo=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r,o;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deviceAdapter.models.getDeviceOTAInfo({DeviceId:this.deviceAdapter.explorerDeviceId})];case 1:return e=n.sent(),t=e.FirmwareURL,r=e.TargetVersion,console.log("----",r,t,this.otaVersion),o={needUpdate:!1,targetVersion:r,otaUrl:t},this.otaVersion&&r!==this.otaVersion&&(o.needUpdate=!0),[2,o];case 2:return n.sent(),[2,Promise.reject({code:"GET_OTA_INFO_FAIL"})];case 3:return[2]}}))}))},e.prototype.sendOTARequest=function(e){var t=this,r=e.fileInfo,o=e.otaUpdateInfo,n=byteUtil.hexString2hexArray(libs_1.str2hexStr(o.targetVersion)),s=byteUtil.hexString2hexArray(libs_1.U32ToHexString(r.fileSize)+""+libs_1.U32ToHexString(r.fileCrc)+libs_1.U8ToHexString(n.length)+n.join("")),i=this.deviceAdapter.sliceData(tslib_1.__spread([""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_REQUEST],libs_1.U16ToHexString(s.length)],s),[s],constants.UPDATE_REPLY);return this.deviceAdapter.writeAndWait4Response(i,constants.UPDATE_REPLY,(function(e){if(console.log("receive send OTA request",e),!e.length)throw{code:constants.UPDATE_REPLY_INVALID};var r=parseInt(e.slice(2,3).join(""),16),o=!!(1&r),n=!!(r>>1&1),s=e.slice(3);if(!o){var i=parseInt(s.slice(0,1),16);throw{code:"MODULE_DONNOT_ALLOW",detail:{code:i,msg:constants.MODULE_UPDATE_REPLAY_CODE_MAP[i]}}}var a={maxPackageNumPerCircle:parseInt(s.slice(0,1).join(""),16),maxLengthPerPackage:parseInt(s.slice(1,2).join(""),16),retryTimeGap:1e3*parseInt(s.slice(2,3).join(""),16),retryTimes:5,rebootMaxTime:1e3*parseInt(s.slice(3,4).join(""),16),alreadyReceiveSize:parseInt(s.slice(4,8).join(""),16),sendWaitGap:parseInt(s.slice(8,9).join("")||0,16)};return a.maxLengthPerPackage=Math.min(a.maxLengthPerPackage,t.deviceAdapter.mtu),{supportUploadFromBreak:n,otaUpdateProgressInfo:a}}),{timeout:LLSyncProtocol_1.LLSyncConfig.waitUpdateReplyInt,timeoutCode:constants.WAIT_GET_UPDATE_INFO_TIMEOUT,writeId:constants.LL_OTA_WRITE_ID})},e.prototype.reportSendOtaDataSuccess=function(){var e=""+constants.LL_OTA_WRITE_PREFIX[constants.OTA_UPDATE_DATA_END];return this.deviceAdapter.write(e,{writeId:constants.LL_OTA_WRITE_ID})},e.prototype.sendOtaFile=function(e){var t=e.fileInfo,r=e.otaUpdateProgressInfo;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,n,s;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return this.onProgress(constants.OTA_UPDATE_STEPS.SEND_UPDATE_DATA_DETAIL,{progress:Math.ceil(r.alreadyReceiveSize/t.fileSize*100)}),e=exports.generateFileChunks(t,r),o=genPromise(),n=function(){console.log("disconnect while send data"),o.reject({code:"BLE_CONNECTION_BREAK"})},this.deviceAdapter.once("disconnect",n),[4,Promise.race([this.processPromise.promise,o.promise,this.sendFileChunks({fileChunks:e,otaUpdateProgressInfo:r})])];case 1:return s=i.sent().fileSize,console.log("----on--update---data-reply---then",s),r.alreadyReceiveSize=s,r.alreadyReceiveSize!==t.fileSize?[2,this.sendOtaFile({fileInfo:t,otaUpdateProgressInfo:r})]:[2]}}))}))},e.prototype.sendFileChunks=function(e){var t=e.fileChunks,r=e.otaUpdateProgressInfo,o=e.seq,n=void 0===o?0:o,s=e.retryTime,i=void 0===s?0:s;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,a,c,_,l,d;return tslib_1.__generator(this,(function(T){switch(T.label){case 0:if(console.log("----send file chunks",t,r,n,i),i>r.retryTimes)throw console.log("----UPDATE_DATA_REPLAY_TIMEOUT---reject---",i),{code:"UPDATE_DATA_REPLAY_TIMEOUT"};T.label=1;case 1:T.trys.push([1,11,,12]),e=exports.getPackageDataToSend(t,n),o=constants.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE,T.label=2;case 2:if(!(o>0))return[3,7];T.label=3;case 3:return T.trys.push([3,5,,6]),[4,this.deviceAdapter.writeData(e,{writeId:constants.LL_OTA_WRITE_ID,waitGap:r.sendWaitGap||10})];case 4:return T.sent(),[3,7];case 5:if(s=T.sent(),console.log("---write error, retry time:---",constants.UPDATE_WRITE_ERROR_TIMES_PER_CIRCLE-o,s),!--o)throw s;return[3,6];case 6:return[3,2];case 7:return T.trys.push([7,9,,10]),[4,this.confirmFileChunkReceived({otaUpdateProgressInfo:r})];case 8:return a=T.sent(),c=a.seq,_=a.fileSize,console.log("---receive update reply",c,_,t.length),c!==t.length?(console.log("---confirmFileChunkSendStatus fail---","seqReceived and fileSended not match, resend file",c,t.length),[2,this.sendFileChunks({fileChunks:t,otaUpdateProgressInfo:r,seq:c||n,retryTime:i+1})]):[2,{fileSize:_}];case 9:return l=T.sent(),console.log("---confirmFileChunkSendStatus fail---",l),[2,Promise.reject(l)];case 10:return[3,12];case 11:return d=T.sent(),[2,Promise.reject(tslib_1.__assign({code:"BLE_WRITE_ERROR"},d))];case 12:return[2]}}))}))},e.prototype.confirmFileChunkReceived=function(e){var t,r=this,o=e.otaUpdateProgressInfo,n=genPromise(),s=function(e){var r=e.data;if(clearTimeout(t),!r.length)return n.reject({code:constants.UPDATE_REPLY_INVALID});var o=parseInt(r.slice(2,3).join(""),16),s=parseInt(r.slice(3,7).join(""),16);return n.resolve({seq:o,fileSize:s})};return console.log("---confirmFileChunkReceived---:listen data"),this.deviceAdapter.once(constants.UPDATE_DATA_REPLY,s),Promise.race([n.promise,new Promise((function(e,n){t=setTimeout((function(){r.deviceAdapter.off(constants.UPDATE_DATA_REPLY,s),n({code:"UPDATE_DATA_REPLAY_TIMEOUT"})}),o.retryTimeGap*o.retryTimes)}))])},e.prototype.checkRebootStatus=function(e){var t=e.otaUpdateInfo,r=e.rebootMaxTime;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,n,s,i,a,c,_=this;return tslib_1.__generator(this,(function(l){switch(l.label){case 0:return e=genPromise(),o=!1,n=0,s=function(r){var s=(void 0===r?{}:r).allowSkipConnect,i=void 0!==s&&s;return tslib_1.__awaiter(_,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:if(!(n<=constants.WAIT_MODULE_UPDATE_CONNECT_TIMES)||o)return[3,9];r=this.deviceAdapter.deviceName,s.label=1;case 1:return s.trys.push([1,6,,8]),i&&this.deviceAdapter.isConnected&&this.deviceAdapter.authorized?(console.log("llsync ota connectAndCheckVersion: already connected to device"),[3,5]):[3,2];case 2:return console.log("--try connect--",o,n,r),[4,this.deviceAdapter.connectDevice()];case 3:return s.sent(),[4,this.deviceAdapter.authenticateConnection({deviceName:r})];case 4:s.sent(),s.label=5;case 5:return this.otaVersion!==t.targetVersion?[2,e.reject({code:"MODULE_UPDATE_FAIL"})]:[2,e.resolve({code:constants.OTA_UPDATE_STEPS.MODULE_UPDATE_SUCCESS})];case 6:return s.sent(),n+=1,[4,delay(constants.WAIT_MODULE_UPDATE_CONNECT_TIME_GAP)];case 7:return s.sent(),[3,8];case 8:return[3,0];case 9:return[2,e.reject({code:"MODULE_UPDATE_CONNECT_TIMEOUT"})]}}))}))},i=function(){_.deviceAdapter.off("disconnect",a),_.deviceAdapter.off("authorized",c)},a=function(){return tslib_1.__awaiter(_,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return console.log("--on/disconnect--"),i(),s(),[2]}))}))},this.deviceAdapter.once("disconnect",a),c=function(){return tslib_1.__awaiter(_,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return i(),s({allowSkipConnect:!0}),[2]}))}))},this.deviceAdapter.once("authorized",c),[4,Promise.race([e.promise,new Promise((function(e,t){setTimeout((function(){o=!0,i(),t({code:constants.WAIT_MODULE_UPDATE_TIMEOUT})}),10*r)}))])];case 1:return[2,l.sent()]}}))}))},e.prototype.downloadOtaFile=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,o,n,s,i=this;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:return[4,libs_1.downloadFile(e.otaUrl,{onProgress:function(e){i.onProgress(constants.OTA_UPDATE_STEPS.DOWNLOADING_OTA_FILE_DETAIL,e)}})];case 1:return t=a.sent(),r=t.fileSize,o=t.fileBuffer,console.log(r,o),(n=new libs_1.CRC32).update(new Int8Array(o)),s=n.getValue(),[2,{fileSize:r,fileCrc:s,fileBuffer:o}]}}))}))},e}();exports.LLSyncOtaProcessor=LLSyncOtaProcessor;
//# sourceMappingURL=LLSyncOtaProcessor.js.map

@@ -16,2 +16,8 @@ import { Reporter } from 'qcloud-iotexplorer-appdev-sdk';

}
interface WriteDataParams {
data: any;
writeId?: string;
waitGap?: number;
retryTime?: number;
}
/**

@@ -24,2 +30,3 @@ * 处理底层数据传输及协议层数据传输

protocol: LLSyncProtocol;
private writeDataQueue;
constructor(props: any);

@@ -35,8 +42,6 @@ notifyMessage({ type, data }?: any): Promise<any>;

sliceData(data: any, tmpData: any, mode: any): string[];
writeData(data: any, { writeId, waitGap, retryTime, }?: {
writeId?: string;
waitGap?: number;
retryTime?: number;
}): Promise<any>;
writeData(data: any, params?: Omit<WriteDataParams, 'data'>): Promise<void>;
setMtu(mtu: any): Promise<any>;
private writeDataInternal;
}
export {};

@@ -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,_)}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;
"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"),qcloud_iotexplorer_common_libs_1=require("qcloud-iotexplorer-common-libs"),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.writeDataQueue=new qcloud_iotexplorer_common_libs_1.SimpleQueue({autoStart:!0,handler:function(t){var e=t.businessData;return r.writeDataInternal(e)},onTaskSuccess:function(t){var e=t.businessData;return"function"==typeof e.onSuccess&&e.onSuccess()},onTaskError:function(t,e){var r=e.businessData;return"function"==typeof r.onError&&r.onError(t)}}),r}return tslib_1.__extends(e,t),e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,r=e.type,n=e.data;if("unknown"!==r)return console.log("check this in notifyMessage",this,{type:r,data:n}),this.emit(r,{type:r,data:n})},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 n=void 0===r?{}:r,o=n.timeout,i=n.timeoutCode,s=n.timeoutHandler,a=n.wrapSplitDataMode,u=n.shouldWrapSplitDataFn,c=void 0===u||u,l=n.afterBindEvent;return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,n,u,_,d,p=this;return tslib_1.__generator(this,(function(v){switch(v.label){case 0:r=genPromise(),console.log("wait4EventResponse",{eventName:t}),n=!1,u=function(o){return tslib_1.__awaiter(p,void 0,void 0,(function(){return tslib_1.__generator(this,(function(i){try{n?console.log("Target event: "+t+" triggered, but is already timeout"):(r.resolve(e(o)),n=!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){o&&o>0&&setTimeout((function(){n||(console.log("Wait for target event: "+t+" timeout"),n=!0,p.off(t,_),"function"==typeof s?(console.log("trigger timeout handler"),e(s())):r({code:i}))}),o)}))])];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,n){var o=void 0===n?{}:n,i=o.timeout,s=o.timeoutCode,a=o.timeoutHandler,u=o.writeId,c=o.wrapSplitDataMode,l=o.shouldWrapSplitDataFn,_=void 0===l||l;return tslib_1.__awaiter(this,void 0,void 0,(function(){var n=this;return tslib_1.__generator(this,(function(o){return[2,this.wait4EventResponse(e,r,{timeout:i,timeoutCode:s,timeoutHandler:a,wrapSplitDataMode:c,shouldWrapSplitDataFn:_,afterBindEvent:function(){return n.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 n=t.slice(0,r===constants.GET_STATUS?2:1);return console.log("---head----",n),utils.sliceData(e,{mtu:this.mtu,head:n,mode:r})},e.prototype.writeData=function(t,e){var r=this;return void 0===e&&(e={}),new Promise((function(n,o){r.writeDataQueue.push(tslib_1.__assign({data:t,onSuccess:n,onError:o},e))}))},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.prototype.writeDataInternal=function(t){var e=t.data,r=t.writeId,n=t.waitGap,o=void 0===n?100:n,i=t.retryTime,s=void 0===i?5:i;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,n,i,a,u,c,l,_;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:Array.isArray(e)||(e=[e]),d.label=1;case 1:d.trys.push([1,10,11,12]),t=tslib_1.__values(e),n=t.next(),d.label=2;case 2:if(n.done)return[3,9];i=n.value,a=s,d.label=3;case 3:return d.trys.push([3,5,,7]),[4,this.write(i,{writeId:r})];case 4:return d.sent(),[3,8];case 5:if(u=d.sent(),console.log("--- LLSync core writeData error ---- retry time "+a,u),--a<=0)throw u;return[4,delay(Math.min(10*o*(s-a),constants.MAX_WRITE_DATA_WAIT_GAP))];case 6:return d.sent(),[3,7];case 7:if(a>0)return[3,3];d.label=8;case 8:return n=t.next(),[3,2];case 9:return[3,12];case 10:return c=d.sent(),l={error:c},[3,12];case 11:try{n&&!n.done&&(_=t.return)&&_.call(t)}finally{if(l)throw l.error}return[7];case 12:return[2]}}))}))},e}(qcloud_iotexplorer_bluetooth_adapter_1.DeviceAdapter);exports.LLSyncDeviceAdapterBase=LLSyncDeviceAdapterBase;
//# sourceMappingURL=LLSyncDeviceAdapterBase.js.map
{
"name": "qcloud-iotexplorer-bluetooth-adapter-llsync",
"version": "1.4.7",
"version": "1.5.0",
"description": "",

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

"dependencies": {
"event-emitter-for-miniprogram": "^0.4.7",
"iotexplorer-ui-dev-config": "^1.4.7",
"qcloud-iotexplorer-appdev-sdk": "^1.4.7",
"qcloud-iotexplorer-bluetooth-adapter": "^0.4.7",
"qcloud-iotexplorer-common-libs": "^0.4.7",
"event-emitter-for-miniprogram": "^0.4.8",
"iotexplorer-ui-dev-config": "^1.4.8",
"qcloud-iotexplorer-appdev-sdk": "^1.5.0",
"qcloud-iotexplorer-bluetooth-adapter": "^0.5.0",
"qcloud-iotexplorer-common-libs": "^0.5.0",
"shortid-for-miniprogram": "^2.2.15",

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

},
"gitHead": "685a0f8f4af5c9c951b80164ceb093eb3e246f53"
"gitHead": "f03807d371775b909231323905b97f8a853eb48a"
}

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc