Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-bluetooth-adapter-llsync

Package Overview
Dependencies
7
Maintainers
2
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0-beta to 1.2.1-beta

29

lib/base/LLSync/LLSyncProtocol.d.ts

@@ -45,3 +45,4 @@ import { LLSyncDeviceAdapter } from './LLSyncDeviceAdapter';

}): Promise<WriteStampResult>;
registerDevice({ nonce, bindDeviceData, }: {
registerDevice({ timestamp, nonce, bindDeviceData, }: {
timestamp: any;
nonce: any;

@@ -58,15 +59,15 @@ bindDeviceData: any;

/**
* 需要用户确认的绑定流程:
* 1. 请求绑定
* 2. 等待设备响应用户确认超时时间(老固件不会响应),若响应则设置用户超时定时器,超时未响应则设置默认超时时间
* 3. 等待用户确认
*
* Checklist:
* 1. 老版本固件,不返回超时时间(用错误的事件来模拟),能够设置默认的用户确认超时
* 2. 正常固件,及时返回超时时间,设置正确的用户确认超时
* 3. 用户UI上主动拒绝绑定,能够正确取消
* 4. 用户设备上主动拒绝绑定,能够正确取消
* 5. 不做任何响应,能够正确超时
* 6. 用户正常确认,能够正常绑定
*/
* 需要用户确认的绑定流程:
* 1. 请求绑定
* 2. 等待设备响应用户确认超时时间(老固件不会响应),若响应则设置用户超时定时器,超时未响应则设置默认超时时间
* 3. 等待用户确认
*
* Checklist:
* 1. 老版本固件,不返回超时时间(用错误的事件来模拟),能够设置默认的用户确认超时
* 2. 正常固件,及时返回超时时间,设置正确的用户确认超时
* 3. 用户UI上主动拒绝绑定,能够正确取消
* 4. 用户设备上主动拒绝绑定,能够正确取消
* 5. 不做任何响应,能够正确超时
* 6. 用户正常确认,能够正常绑定
*/
waitUserCheckAndBindDevice({ bindDeviceData, dataHandler, }: {

@@ -73,0 +74,0 @@ bindDeviceData: any;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncProtocol=exports.LLSyncConfig=void 0;var tslib_1=require("tslib"),constants=tslib_1.__importStar(require("../../constants")),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),libs_1=require("../../libs"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,noop=_a.noop,genPromise=_a.genPromise,byteUtil=_a.byteUtil;exports.LLSyncConfig={BLE_PSK_DEVICE_KEY:"ble_psk_device_ket",waitConnectReplyTime:1e4,waitBindReplyTime:1e4,waitGetRegisterDeviceInfo:1e4,waitGetCheckTimeoutReplyTime:1e4,waitGetCheckTimeoutDefaultReplyTime:6e4,waitControlReplyTime:1e4,waitGetDeviceInfoTime:1e4,waitUpdateReplyInt:1e4,mtuDefaultMap:{0:void 0,1:20,2:20}};var LLSyncProtocol=function(){function t(t){this._cleanupUserCheckHandleAfterCancel=noop,this.deviceAdapter=t}return Object.defineProperty(t.prototype,"reporter",{get:function(){return this.deviceAdapter.reporter},enumerable:!1,configurable:!0}),t.prototype.requestBindDevice=function(t){var e=t.needUserCheck,n=void 0!==e&&e,o=t.isDynamicRegister,i=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,e,o,s,r,a=this;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return t=Math.floor(Date.now()/1e3),e=parseInt(libs_1.gen4BytesIntHex(),16),o=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.TIME_SYNC]+e.toString(16)+t.toString(16),constants.TIME_SYNC),i?[4,this.registerDevice({bindDeviceData:o,nonce:e})]:[3,2];case 1:s=c.sent(),o=s.bleData,t=s.timestamp,c.label=2;case 2:return r={bindDeviceData:o,dataHandler:function(o){if(!o.length)throw{code:constants.CONNECT_REPLY_INVALID};if(n){var i=!(libs_1.getStrLength(o)>>15);if(console.log("bind auth response userCheckResult",i),!i)throw{code:constants.GET_USER_CHECK_REJECT}}var s=o.slice(2,22).join(""),r=libs_1.hex2str(o.slice(22)),c={sign:s.toLocaleLowerCase(),deviceName:r,nonce:e,timestamp:t+60};return a.reporter.info(constants.TIME_SYNC,c),c}},this.reporter.info(constants.TIME_SYNC,r),[2,n?this.waitUserCheckAndBindDevice(r):this.bindDeviceDirectly(r)]}}))}))},t.prototype.registerDevice=function(t){var e=t.nonce,n=t.bindDeviceData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,o,i,s,r,a,c;return tslib_1.__generator(this,(function(_){switch(_.label){case 0:return[4,this.deviceAdapter.writeAndWait4Response(n,constants.REGISTER_DEVICE_INFO_REPLY,(function(t){if(!t.length)throw{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var e=libs_1.getStrLength(t),n=parseInt(t.slice(2,3).join(""),16),o=libs_1.hex2str(t.slice(3,3+n));return{sign:t.slice(3+n,3+e).toLowerCase(),deviceName:o}}),{timeout:exports.LLSyncConfig.waitGetRegisterDeviceInfo,timeoutCode:constants.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})];case 1:t=_.sent(),o=t.deviceName,i=t.sign,this.reporter.info(constants.TIME_SYNC,{deviceName:o,sign:i}),s=Math.floor(Date.now()/1e3),_.label=2;case 2:return _.trys.push([2,4,,5]),[4,this.deviceAdapter.models.dynamicRegisterDevice({deviceName:o,sign:i,productId:this.deviceAdapter.productId,timestamp:s,nonce:e})];case 3:return r=_.sent().payload,a=this._parseDataBeforeConnect(constants.DEVICE_INFO_WRITE_PREFIX[constants.SEND_REGISTER_DEVICE_PAYLOAD]+(""+r.toString(16)+e.toString(16)+s.toString(16)),constants.SEND_REGISTER_DEVICE_PAYLOAD),this.reporter.info(constants.REGISTER_DEVICE_SUCCESS,{payload:r,bleData:a}),[2,{bleData:a,timestamp:s}];case 4:throw c=_.sent(),tslib_1.__assign(tslib_1.__assign({},c),{code:constants.REGISTER_DEVICE_ERROR});case 5:return[2]}}))}))},t.prototype.bindDeviceDirectly=function(t){var e=t.bindDeviceData,n=t.dataHandler;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return[2,this.deviceAdapter.writeAndWait4Response(e,constants.BIND_AUTH,n,{timeout:exports.LLSyncConfig.waitBindReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})]}))}))},t.prototype.waitUserCheckAndBindDevice=function(t){var e=t.bindDeviceData,n=t.dataHandler;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,o,i,s=this;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return t=genPromise(),i=function(e){clearTimeout(o),console.log("registerUserCheckTimer",e),o=setTimeout((function(){console.log("user check timeout",e),s.cancelUserCheck("timeout"),t.reject({code:constants.WAIT_USER_CHECK_TIMEOUT})}),e)},this.deviceAdapter.wait4EventResponse(constants.USER_CHECK_TIMEOUT_CALLBACK,(function(t){if(!t.length)return console.log("get user check timeout duration fail, trigger default timeout timer"),s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_ERROR),i(exports.LLSyncConfig.waitGetCheckTimeoutDefaultReplyTime);var e=1e3*parseInt(t.slice(2).join(""),16);s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_SUCCESS,{timeoutDuration:e}),i(e)}),{timeout:exports.LLSyncConfig.waitGetCheckTimeoutReplyTime,timeoutHandler:function(){s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_TIMEOUT),i(exports.LLSyncConfig.waitGetCheckTimeoutDefaultReplyTime-exports.LLSyncConfig.waitGetCheckTimeoutReplyTime)}}),this._cleanupUserCheckHandleAfterCancel=function(){console.log("process cleanup user check handler"),t.reject(null),s.deviceAdapter.off(constants.BIND_AUTH),s._cleanupUserCheckHandleAfterCancel=noop},[4,Promise.race([t.promise,this.deviceAdapter.writeAndWait4Response(e,constants.BIND_AUTH,n,{timeout:exports.LLSyncConfig.waitBindReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})])];case 1:return[2,r.sent()]}}))}))},t.prototype.cancelUserCheck=function(t){void 0===t&&(t="timeout"),console.log("cancel user check, reason: ",t),"cancel"===t&&this._cleanupUserCheckHandleAfterCancel();var e=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.USER_CHECK_TIMEOUT]+libs_1.U8ToHexString("timeout"===t?constants.WRITE_USER_CHECK_TIMEOUT:constants.WRITE_USER_CHECK_CANCEL);this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.getDeviceAuthInfo=function(){var t=Math.floor(Date.now()/1e3),e=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_AUTH]+t.toString(16)+libs_1.encrypt(t,this.deviceAdapter.localPsk),constants.CONNECT_AUTH);return this.deviceAdapter.writeAndWait4Response(e,constants.CONNECT_AUTH,(function(e){if(!e.length)throw{code:constants.CONNECT_REPLY_INVALID};return{sign:e.slice(2,22).join("").toLocaleLowerCase(),timestamp:t}}),{timeout:exports.LLSyncConfig.waitConnectReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.getDeviceInfo=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return[2,this.deviceAdapter.writeAndWait4Response(constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_RESULT_WRITE_SUCCESS],constants.DEVICE_INFO,(function(t){if(!t.length)throw{code:constants.DEVICE_INFO_INVALID};var e=parseInt(t.slice(2,3).join(""),16),n=parseInt(t.slice(3,5).join(""),16),o=!!(n>>15),i=8191&n,s=t.slice(6).join("");return{version:e,mtu:i,needSetMtu:o,otaVersion:s?libs_1.hex2str(s):s}}),{timeout:exports.LLSyncConfig.waitGetDeviceInfoTime,timeoutCode:constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})]}))}))},t.prototype.getUnbindAuthSign=function(){var t=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_AUTH]+libs_1.encrypt(constants.UNBIND_REQUEST,this.deviceAdapter.localPsk),constants.UNBIND_AUTH);return this.deviceAdapter.writeAndWait4Response(t,constants.UNBIND_AUTH,(function(t){if(!t.length)throw{code:constants.UNBIND_REPLY_INVALID};return{sign:t.slice(2,22).join("").toLocaleLowerCase()}}),{timeout:exports.LLSyncConfig.waitConnectReplyTime,timeoutCode:constants.WAIT_UNBIND_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.controlDeviceAction=function(t){var e=libs_1.convertActionControlToTlv(t,this.deviceAdapter.dataTemplate),n=e.actionIndex,o=e.tlvData,i=e.tmpData,s=this.deviceAdapter.sliceData(tslib_1.__spread([libs_1.getTypeHead(constants.DEVICE_DATA_WRITE_HEAD[constants.CONTROL_ACTION],n),libs_1.U16ToHexString(o.length)],o),i,constants.CONTROL_ACTION);return this.deviceAdapter.writeAndWait4Response(s,constants.ACTION_REPLY,(function(t){if(!t.length)throw{code:constants.CONTROL_REPLY_INVALID};var e=parseInt(t.slice(2,3).join(""),16),n=t.slice(3);if(0===e)return{success:!0,output:n};throw{code:constants.CONTROL_REPLY_CODE_INVALID,errCode:e}}),{timeout:exports.LLSyncConfig.waitControlReplyTime,timeoutCode:constants.WAIT_CONTROL_ACTION_REPLY_TIMEOUT,writeId:constants.DEVICE_DATA_WRITE_ID,wrapSplitDataMode:constants.ACTION_REPLY})},t.prototype.controlDeviceProperty=function(t){var e=libs_1.convertPropertiesChangeToTlv(t,this.deviceAdapter.dataTemplate),n=e.tlvData,o=e.tmpData,i=this.deviceAdapter.sliceData(tslib_1.__spread([libs_1.getTypeHead(constants.DEVICE_DATA_WRITE_HEAD[constants.CONTROL_DEVICE],constants.DEVICE_DATA_WRITE_SUFFIX[constants.CONTROL_DEVICE]),libs_1.U16ToHexString(n.length)],n),o,constants.CONTROL_DEVICE);return this.deviceAdapter.writeAndWait4Response(i,constants.CONTROL_REPLY,(function(t){if(!t.length)throw{code:constants.CONTROL_REPLY_INVALID};var e=parseInt(t.slice(2).join(""),16);if(0===e)return{code:0};throw{code:constants.CONTROL_REPLY_CODE_INVALID,errCode:e}}),{timeout:exports.LLSyncConfig.waitControlReplyTime,timeoutCode:constants.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT,writeId:constants.DEVICE_DATA_WRITE_ID})},t.prototype.reportBindSuccess=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return e=libs_1.gen4BytesIntHex(),this.reporter.info(constants.BIND_AUTH_SUCCESS,{identify:this.deviceAdapter.userIdentify,localPsk:e,timeCost:Date.now()-t}),n=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_SUCCESS]+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_SUCCESS]+e+this.deviceAdapter.userIdentify,this.deviceAdapter.writeData(this._parseDataBeforeConnect(n,constants.BIND_AUTH_SUCCESS),{writeId:constants.DEVICE_INFO_WRITE_ID}),[4,this.deviceAdapter.models.setDeviceConfig({DeviceId:this.deviceAdapter.explorerDeviceId,DeviceKey:exports.LLSyncConfig.BLE_PSK_DEVICE_KEY,DeviceValue:e})];case 1:return o.sent(),[2,e]}}))}))},t.prototype.reportBindError=function(t){var e=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_FAIL]+libs_1.str2hexStr(t);this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.reportConnectError=function(){var t=constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_RESULT_WRITE_FAIL];this.deviceAdapter.write(t,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.reportPropertyReportResult=function(t){void 0===t&&(t=0);var e=constants.DEVICE_DATA_WRITE_HEAD,n=constants.DEVICE_DATA_WRITE_SUFFIX,o=constants.REPORT_RESULT,i=constants.DEVICE_DATA_WRITE_ID,s=""+libs_1.getTypeHead(e[o],n[o])+byteUtil.byteToHex(byteUtil.convertNumberToByte(t));this.deviceAdapter.write(s,{writeId:i})},t.prototype.reportEventReportResult=function(t,e){void 0===t&&(t=0);var n=constants.DEVICE_DATA_WRITE_HEAD,o=constants.EVENT_REPLY,i=constants.DEVICE_DATA_WRITE_ID,s=""+libs_1.getTypeHead(n[o],e)+byteUtil.byteToHex(byteUtil.convertNumberToByte(t));this.deviceAdapter.write(s,{writeId:i})},t.prototype.reportGetStatusResult=function(t,e,n){void 0===t&&(t=0);var o=constants.DEVICE_DATA_WRITE_HEAD,i=constants.DEVICE_DATA_WRITE_SUFFIX,s=constants.GET_STATUS,r=constants.DEVICE_DATA_WRITE_ID,a=[""+libs_1.getTypeHead(o[s],i[s]),byteUtil.byteToHex(byteUtil.convertNumberToByte(t))];e&&(a=this.deviceAdapter.sliceData(a.concat(tslib_1.__spread([libs_1.U16ToHexString(e.length)],e)),n,constants.GET_STATUS)),this.deviceAdapter.writeData(a,{writeId:r})},t.prototype.reportUnbindResult=function(t){var e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_SUCCESS];return"fail"===t&&(e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_FAIL]),this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype._parseDataBeforeConnect=function(t,e){var n,o=this.deviceAdapter.extendInfo.moduleVersion;o&&(n=exports.LLSyncConfig.mtuDefaultMap[o],o>=2&&(n=exports.LLSyncConfig.mtuDefaultMap[2])),this.reporter.info(constants.SET_MTU_BEFORE_CONNECT,{version:o,mtuLength:n}),this.deviceAdapter.bleVersion=o,this.deviceAdapter.mtu=n;var i=byteUtil.hexString2hexArray(t.slice(2)),s=[i],r=[t.slice(0,2)];return o>0&&r.push(libs_1.U16ToHexString(i.length)),r=r.concat(i),this.deviceAdapter.sliceData(r,s,e)},t}();exports.LLSyncProtocol=LLSyncProtocol;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLSyncProtocol=exports.LLSyncConfig=void 0;var tslib_1=require("tslib"),constants=tslib_1.__importStar(require("../../constants")),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),libs_1=require("../../libs"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,noop=_a.noop,genPromise=_a.genPromise,byteUtil=_a.byteUtil;exports.LLSyncConfig={BLE_PSK_DEVICE_KEY:"ble_psk_device_ket",waitConnectReplyTime:1e4,waitBindReplyTime:1e4,waitGetRegisterDeviceInfo:1e4,waitGetCheckTimeoutReplyTime:1e4,waitGetCheckTimeoutDefaultReplyTime:6e4,waitControlReplyTime:1e4,waitGetDeviceInfoTime:1e4,waitUpdateReplyInt:1e4,mtuDefaultMap:{0:void 0,1:20,2:20}};var LLSyncProtocol=function(){function t(t){this._cleanupUserCheckHandleAfterCancel=noop,this.deviceAdapter=t}return Object.defineProperty(t.prototype,"reporter",{get:function(){return this.deviceAdapter.reporter},enumerable:!1,configurable:!0}),t.prototype.requestBindDevice=function(t){var e=t.needUserCheck,n=void 0!==e&&e,i=t.isDynamicRegister,o=void 0!==i&&i;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,e,i,s,r,a=this;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return t=Math.floor(Date.now()/1e3),e=parseInt(libs_1.gen4BytesIntHex(),16),i=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.TIME_SYNC]+e.toString(16)+t.toString(16),constants.TIME_SYNC),this.reporter.info(constants.TIME_SYNC,{timestamp:t,nonce:e,bindDeviceData:i,needUserCheck:n,isDynamicRegister:o}),o?[4,this.registerDevice({timestamp:t,bindDeviceData:i,nonce:e})]:[3,2];case 1:s=c.sent(),i=s.bleData,t=s.timestamp,c.label=2;case 2:return r={bindDeviceData:i,dataHandler:function(i){if(!i.length)throw{code:constants.CONNECT_REPLY_INVALID};if(n){var o=!(libs_1.getStrLength(i)>>15);if(console.log("bind auth response userCheckResult",o),!o)throw{code:constants.GET_USER_CHECK_REJECT}}var s=i.slice(2,22).join(""),r=libs_1.hex2str(i.slice(22)),c={sign:s.toLocaleLowerCase(),deviceName:r,nonce:e,timestamp:t+60};return a.reporter.info(constants.TIME_SYNC,c),c}},this.reporter.info(constants.TIME_SYNC,r),[2,n?this.waitUserCheckAndBindDevice(r):this.bindDeviceDirectly(r)]}}))}))},t.prototype.registerDevice=function(t){var e=t.timestamp,n=t.nonce,i=t.bindDeviceData;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,o,s,r,a,c,_,E,I=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return[4,this.deviceAdapter.writeAndWait4Response(i,constants.REGISTER_DEVICE_INFO_REPLY,(function(t){if(!t.length)throw{code:constants.REGISTER_DEVICE_INFO_REPLY_INVALID};var e=libs_1.getStrLength(t),n=parseInt(t.slice(2,3).join(""),16),i=libs_1.hex2str(t.slice(3,3+n)),o=libs_1.hex2str(t.slice(3+n,3+e));return I.reporter.info(constants.REGISTER_DEVICE_INFO_REPLY,{allLength:e,deviceNameLength:n,deviceName:i,sign:o}),{sign:o,deviceName:i}}),{timeout:exports.LLSyncConfig.waitGetRegisterDeviceInfo,timeoutCode:constants.WAIT_REGISTER_DEVICE_INFO_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})];case 1:t=d.sent(),o=t.deviceName,s=t.sign,this.reporter.info(constants.TIME_SYNC,{deviceName:o,sign:s}),r=0,d.label=2;case 2:return d.trys.push([2,4,,5]),[4,this.deviceAdapter.models.dynamicRegisterDevice({deviceName:o,sign:s,productId:this.deviceAdapter.productId,timestamp:e,nonce:n})];case 3:return a=d.sent().payload,c=Math.floor(Date.now()/1e3),r=1,_=this._parseDataBeforeConnect(constants.DEVICE_INFO_WRITE_PREFIX[constants.SEND_REGISTER_DEVICE_PAYLOAD]+""+libs_1.U8ToHexString(r)+libs_1.U8ToHexString(a.length)+libs_1.str2hexStr(a)+n.toString(16)+c.toString(16),constants.SEND_REGISTER_DEVICE_PAYLOAD),this.reporter.info(constants.REGISTER_DEVICE_SUCCESS,{payload:a,bleData:_}),[2,{bleData:_,timestamp:c}];case 4:throw E=d.sent(),tslib_1.__assign(tslib_1.__assign({},E),{code:constants.REGISTER_DEVICE_ERROR});case 5:return[2]}}))}))},t.prototype.bindDeviceDirectly=function(t){var e=t.bindDeviceData,n=t.dataHandler;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return[2,this.deviceAdapter.writeAndWait4Response(e,constants.BIND_AUTH,n,{timeout:exports.LLSyncConfig.waitBindReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})]}))}))},t.prototype.waitUserCheckAndBindDevice=function(t){var e=t.bindDeviceData,n=t.dataHandler;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,i,o,s=this;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return t=genPromise(),o=function(e){clearTimeout(i),console.log("registerUserCheckTimer",e),i=setTimeout((function(){console.log("user check timeout",e),s.cancelUserCheck("timeout"),t.reject({code:constants.WAIT_USER_CHECK_TIMEOUT})}),e)},this.deviceAdapter.wait4EventResponse(constants.USER_CHECK_TIMEOUT_CALLBACK,(function(t){if(!t.length)return console.log("get user check timeout duration fail, trigger default timeout timer"),s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_ERROR),o(exports.LLSyncConfig.waitGetCheckTimeoutDefaultReplyTime);var e=1e3*parseInt(t.slice(2).join(""),16);s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_SUCCESS,{timeoutDuration:e}),o(e)}),{timeout:exports.LLSyncConfig.waitGetCheckTimeoutReplyTime,timeoutHandler:function(){s.reporter.info(constants.GET_USER_CHECK_TIMEOUT_TIMEOUT),o(exports.LLSyncConfig.waitGetCheckTimeoutDefaultReplyTime-exports.LLSyncConfig.waitGetCheckTimeoutReplyTime)}}),this._cleanupUserCheckHandleAfterCancel=function(){console.log("process cleanup user check handler"),t.reject(null),s.deviceAdapter.off(constants.BIND_AUTH),s._cleanupUserCheckHandleAfterCancel=noop},[4,Promise.race([t.promise,this.deviceAdapter.writeAndWait4Response(e,constants.BIND_AUTH,n,{timeout:exports.LLSyncConfig.waitBindReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})])];case 1:return[2,r.sent()]}}))}))},t.prototype.cancelUserCheck=function(t){void 0===t&&(t="timeout"),console.log("cancel user check, reason: ",t),"cancel"===t&&this._cleanupUserCheckHandleAfterCancel();var e=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.USER_CHECK_TIMEOUT]+libs_1.U8ToHexString("timeout"===t?constants.WRITE_USER_CHECK_TIMEOUT:constants.WRITE_USER_CHECK_CANCEL);this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.getDeviceAuthInfo=function(){var t=Math.floor(Date.now()/1e3),e=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_AUTH]+t.toString(16)+libs_1.encrypt(t,this.deviceAdapter.localPsk),constants.CONNECT_AUTH);return this.deviceAdapter.writeAndWait4Response(e,constants.CONNECT_AUTH,(function(e){if(!e.length)throw{code:constants.CONNECT_REPLY_INVALID};return{sign:e.slice(2,22).join("").toLocaleLowerCase(),timestamp:t}}),{timeout:exports.LLSyncConfig.waitConnectReplyTime,timeoutCode:constants.WAIT_CONNECT_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.getDeviceInfo=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return[2,this.deviceAdapter.writeAndWait4Response(constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_RESULT_WRITE_SUCCESS],constants.DEVICE_INFO,(function(t){if(!t.length)throw{code:constants.DEVICE_INFO_INVALID};var e=parseInt(t.slice(2,3).join(""),16),n=parseInt(t.slice(3,5).join(""),16),i=!!(n>>15),o=8191&n,s=t.slice(6).join("");return{version:e,mtu:o,needSetMtu:i,otaVersion:s?libs_1.hex2str(s):s}}),{timeout:exports.LLSyncConfig.waitGetDeviceInfoTime,timeoutCode:constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})]}))}))},t.prototype.getUnbindAuthSign=function(){var t=this._parseDataBeforeConnect(""+constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_AUTH]+libs_1.encrypt(constants.UNBIND_REQUEST,this.deviceAdapter.localPsk),constants.UNBIND_AUTH);return this.deviceAdapter.writeAndWait4Response(t,constants.UNBIND_AUTH,(function(t){if(!t.length)throw{code:constants.UNBIND_REPLY_INVALID};return{sign:t.slice(2,22).join("").toLocaleLowerCase()}}),{timeout:exports.LLSyncConfig.waitConnectReplyTime,timeoutCode:constants.WAIT_UNBIND_REPLY_TIMEOUT,writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.controlDeviceAction=function(t){var e=libs_1.convertActionControlToTlv(t,this.deviceAdapter.dataTemplate),n=e.actionIndex,i=e.tlvData,o=e.tmpData,s=this.deviceAdapter.sliceData(tslib_1.__spread([libs_1.getTypeHead(constants.DEVICE_DATA_WRITE_HEAD[constants.CONTROL_ACTION],n),libs_1.U16ToHexString(i.length)],i),o,constants.CONTROL_ACTION);return this.deviceAdapter.writeAndWait4Response(s,constants.ACTION_REPLY,(function(t){if(!t.length)throw{code:constants.CONTROL_REPLY_INVALID};var e=parseInt(t.slice(2,3).join(""),16),n=t.slice(3);if(0===e)return{success:!0,output:n};throw{code:constants.CONTROL_REPLY_CODE_INVALID,errCode:e}}),{timeout:exports.LLSyncConfig.waitControlReplyTime,timeoutCode:constants.WAIT_CONTROL_ACTION_REPLY_TIMEOUT,writeId:constants.DEVICE_DATA_WRITE_ID,wrapSplitDataMode:constants.ACTION_REPLY})},t.prototype.controlDeviceProperty=function(t){var e=libs_1.convertPropertiesChangeToTlv(t,this.deviceAdapter.dataTemplate),n=e.tlvData,i=e.tmpData,o=this.deviceAdapter.sliceData(tslib_1.__spread([libs_1.getTypeHead(constants.DEVICE_DATA_WRITE_HEAD[constants.CONTROL_DEVICE],constants.DEVICE_DATA_WRITE_SUFFIX[constants.CONTROL_DEVICE]),libs_1.U16ToHexString(n.length)],n),i,constants.CONTROL_DEVICE);return this.deviceAdapter.writeAndWait4Response(o,constants.CONTROL_REPLY,(function(t){if(!t.length)throw{code:constants.CONTROL_REPLY_INVALID};var e=parseInt(t.slice(2).join(""),16);if(0===e)return{code:0};throw{code:constants.CONTROL_REPLY_CODE_INVALID,errCode:e}}),{timeout:exports.LLSyncConfig.waitControlReplyTime,timeoutCode:constants.WAIT_CONTROL_DEVICE_REPLY_TIMEOUT,writeId:constants.DEVICE_DATA_WRITE_ID})},t.prototype.reportBindSuccess=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return e=libs_1.gen4BytesIntHex(),this.reporter.info(constants.BIND_AUTH_SUCCESS,{identify:this.deviceAdapter.userIdentify,localPsk:e,timeCost:Date.now()-t}),n=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_SUCCESS]+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_SUCCESS]+e+this.deviceAdapter.userIdentify,this.deviceAdapter.writeData(this._parseDataBeforeConnect(n,constants.BIND_AUTH_SUCCESS),{writeId:constants.DEVICE_INFO_WRITE_ID}),[4,this.deviceAdapter.models.setDeviceConfig({DeviceId:this.deviceAdapter.explorerDeviceId,DeviceKey:exports.LLSyncConfig.BLE_PSK_DEVICE_KEY,DeviceValue:e})];case 1:return i.sent(),[2,e]}}))}))},t.prototype.reportBindError=function(t){var e=""+constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_FAIL]+libs_1.str2hexStr(t);this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.reportConnectError=function(){var t=constants.DEVICE_INFO_WRITE_PREFIX[constants.CONNECT_RESULT_WRITE_FAIL];this.deviceAdapter.write(t,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype.reportPropertyReportResult=function(t){void 0===t&&(t=0);var e=constants.DEVICE_DATA_WRITE_HEAD,n=constants.DEVICE_DATA_WRITE_SUFFIX,i=constants.REPORT_RESULT,o=constants.DEVICE_DATA_WRITE_ID,s=""+libs_1.getTypeHead(e[i],n[i])+byteUtil.byteToHex(byteUtil.convertNumberToByte(t));this.deviceAdapter.write(s,{writeId:o})},t.prototype.reportEventReportResult=function(t,e){void 0===t&&(t=0);var n=constants.DEVICE_DATA_WRITE_HEAD,i=constants.EVENT_REPLY,o=constants.DEVICE_DATA_WRITE_ID,s=""+libs_1.getTypeHead(n[i],e)+byteUtil.byteToHex(byteUtil.convertNumberToByte(t));this.deviceAdapter.write(s,{writeId:o})},t.prototype.reportGetStatusResult=function(t,e,n){void 0===t&&(t=0);var i=constants.DEVICE_DATA_WRITE_HEAD,o=constants.DEVICE_DATA_WRITE_SUFFIX,s=constants.GET_STATUS,r=constants.DEVICE_DATA_WRITE_ID,a=[""+libs_1.getTypeHead(i[s],o[s]),byteUtil.byteToHex(byteUtil.convertNumberToByte(t))];e&&(a=this.deviceAdapter.sliceData(a.concat(tslib_1.__spread([libs_1.U16ToHexString(e.length)],e)),n,constants.GET_STATUS)),this.deviceAdapter.writeData(a,{writeId:r})},t.prototype.reportUnbindResult=function(t){var e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_SUCCESS];return"fail"===t&&(e=constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_FAIL]),this.deviceAdapter.write(e,{writeId:constants.DEVICE_INFO_WRITE_ID})},t.prototype._parseDataBeforeConnect=function(t,e){var n,i=this.deviceAdapter.extendInfo.moduleVersion;i&&(n=exports.LLSyncConfig.mtuDefaultMap[i],i>=2&&(n=exports.LLSyncConfig.mtuDefaultMap[2])),this.reporter.info(constants.SET_MTU_BEFORE_CONNECT,{version:i,mtuLength:n}),this.deviceAdapter.bleVersion=i,this.deviceAdapter.mtu=n;var o=byteUtil.hexString2hexArray(t.slice(2)),s=[o],r=[t.slice(0,2)];return i>0&&r.push(libs_1.U16ToHexString(o.length)),r=r.concat(o),this.deviceAdapter.sliceData(r,s,e)},t}();exports.LLSyncProtocol=LLSyncProtocol;
//# sourceMappingURL=LLSyncProtocol.js.map

@@ -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().Configs,e=i,[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",{ProductId:i,DeviceName:t,DeviceTimestamp:r,Nonce:n,Signature:o})];case 1:return[2,{payload:e.sent().Data.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"),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().Configs,e=i,[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;
//# sourceMappingURL=Models.js.map
{
"name": "qcloud-iotexplorer-bluetooth-adapter-llsync",
"version": "1.2.0-beta",
"version": "1.2.1-beta",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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