Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-appdev-plugin-wificonf-blecombo

Package Overview
Dependencies
Maintainers
3
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qcloud-iotexplorer-appdev-plugin-wificonf-blecombo - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

2

lib/protocols/BleComboLLSync/BleComboLLSyncDeviceAdapter.js

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

"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboLLSyncDeviceAdapter=exports.LLSyncComboConfig=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"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,U16ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U16ToHexString,U8ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U8ToHexString,REPORT_EVENT_TYPE=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,byteUtil=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.byteUtil;exports.LLSyncComboConfig={waitGetDeviceInfoTime:1e4,waitSetWiFiModeTime:1e4,waitSetWiFiInfoTime:1e4,waitSetWiFiConnectTime:2e4,waitSetWiFiTokenTime:1e4,waitDevLogInfoTime:1e4},exports.BleComboLLSyncDeviceAdapter=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4Mp(((_a=function(t){function e(){var o=null!==t&&t.apply(this,arguments)||this;return o.reporter={info:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.message,n=void 0===r?"":r,i=tslib_1.__rest(_,["message"]),l=o,s=l.explorerDeviceId,a=l.deviceId,c=l.isConnected;e.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{serviceId:e.serviceId,message:n||(t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]?t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]+")":t),timeCost:i.timeCost||0,action:t,data:tslib_1.__assign({deviceId:s,bleDeviceId:a,isConnected:c},i)})},error:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.error,n=tslib_1.__rest(_,["error"]),i=o,l=i.explorerDeviceId,s=i.deviceId,a=i.isConnected;r.code&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]&&(r.msg=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]),e.options.reporter.error(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]&&t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]+":"+(r&&(r.message||r.errMsg||r.msg||r.code))+")",timeCost:n.timeCost||0,action:t,error:r,data:tslib_1.__assign(tslib_1.__assign({deviceId:l,bleDeviceId:s,isConnected:a},n),r)})}},o}return tslib_1.__extends(e,t),e.injectOptions=function(t){e.options=t},e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,o=e.type,_=e.data;if("unknown"!==o)return console.log("check this in notifyMessage",this,{type:o,data:_}),this.emit(o,{type:o,data:_})},e.prototype.connectDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,t.prototype.connectDevice.call(this,e)];case 1:return o.sent(),[4,this.afterConnectDevice()];case 2:return o.sent(),[2]}}))}))},e.prototype.afterConnectDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,e,o,_,r;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.getDeviceInfo()];case 1:if(t=n.sent(),e=t.version,o=t.mtu,_=t.needSetMtu,r=t.deviceName,this.deviceName=r,this.bleVersion=e,this.mtu=o,this.reporter.info("CONNECT_DEVICE",{data:{version:e,mtu:o,needSetMtu:_,deviceName:r}}),!_)return[3,5];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.setMtu(this.mtu)];case 3:return n.sent(),this.writeMtuResult("success"),[3,5];case 4:return n.sent(),this.writeMtuResult("fail"),[3,5];case 5:return[2,r]}}))}))},e.prototype.getDeviceInfo=function(){return this.writeAndWait4Response(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEVICE_INFO],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};var e=parseInt(t.slice(2,3).join(""),16),o=parseInt(t.slice(3,5).join(""),16),_=!!(o>>15),r=8191&o,n=parseInt(t[5],16),i=hex2str(t.slice(6).join(""));if(n!==i.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};return{version:e,mtu:r,needSetMtu:_,deviceName:i}}),{timeout:exports.LLSyncComboConfig.waitGetDeviceInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiMode=function(t){void 0===t&&(t=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.STA_WIFI_MODE);var e=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE]+U8ToHexString(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WIFI_MODE_MAP[t]);return this.writeAndWait4Response(e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiModeTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiInfo=function(t){var e=t.ssid,o=t.password,_=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)))||[],r=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(o)))||[];console.log("----data----",{ssid:e,password:o,ssidHexArray:_,passwordHexArray:r});var n=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO],U16ToHexString(_.length+r.length),U8ToHexString(_.length)],_,[U8ToHexString(r.length)],r),[tslib_1.__spread([U8ToHexString(_.length)],_),tslib_1.__spread([U8ToHexString(r.length)],r)],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO);return this.writeAndWait4Response(n,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendConnectWiFiAndGetWiFiConnectState=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_INVALID};var e=parseInt(t.slice(3,4).join(""),16),o=parseInt(t.slice(5,6).join(""),16),_="";return o&&(_=hex2str(t.slice(6,6+o))),{connected:!e,ssid:_}}),{timeout:exports.LLSyncComboConfig.waitSetWiFiConnectTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendToken=function(t){var e=t.token,o=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)));console.log("----data----",{token:e,tokenHexArray:o});var _=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN],U16ToHexString(o.length)],o),[o],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN);return this.writeAndWait4Response(_,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiTokenTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.getModuleLog=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_INVALID};var e=parseInt(t.slice(1,3).join(""),16);return{logStr:hex2str(t.slice(4,4+e))}}),{timeout:exports.LLSyncComboConfig.waitDevLogInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapterBase)).serviceId16="0000FFF0-0000-1000-8000-00805F9B34FB",_a.serviceId="0000FFF0-65D0-4E20-B56A-E493541BA4E2",_a.deviceFilter=function(t){if(!t.advertisServiceUUIDs||!t.advertisServiceUUIDs.find((function(t){return t===_a.serviceId16}))||!t.advertisData)return null;var e=_a.options.reporter;try{var o=Math.floor(10*Math.random())%10==1||!0,_=arrayBufferToHexStringArray(t.advertisData);o&&e.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:_a.serviceId,hexArr:_.join(",")});var r,n=parseInt(_[2],16)>>4,i=_.slice(3,9);return t.name&&-1===t.name.indexOf("_")&&(t.name=t.name+"_"+i.slice(0,2).join("")),r=hex2str(_.slice(9)),o&&e.info(REPORT_EVENT_TYPE,{message:"解析广播",serviceId:_a.serviceId,data:{deviceProductId:r||"x"}}),tslib_1.__assign(tslib_1.__assign({},t),{standardBleCombo:!0,serviceId:_a.serviceId,deviceName:"",productId:r,extendInfo:{moduleVersion:n}})}catch(t){e.error(REPORT_EVENT_TYPE,{message:"协议广播出错",error:t})}},_a));
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboLLSyncDeviceAdapter=exports.LLSyncComboConfig=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"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,U16ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U16ToHexString,U8ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U8ToHexString,REPORT_EVENT_TYPE=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,byteUtil=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.byteUtil;exports.LLSyncComboConfig={waitGetDeviceInfoTime:1e4,waitSetWiFiModeTime:1e4,waitSetWiFiInfoTime:1e4,waitSetWiFiConnectTime:2e4,waitSetWiFiTokenTime:1e4,waitDevLogInfoTime:1e4},exports.BleComboLLSyncDeviceAdapter=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4Mp(((_a=function(t){function e(){var o=null!==t&&t.apply(this,arguments)||this;return o.reporter={info:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.message,n=void 0===r?"":r,i=tslib_1.__rest(_,["message"]),l=o,s=l.explorerDeviceId,a=l.deviceId,c=l.isConnected;e.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{serviceId:e.serviceId,message:n||(t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]?t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]+")":t),timeCost:i.timeCost||0,action:t,data:tslib_1.__assign({deviceId:s,bleDeviceId:a,isConnected:c},i)})},error:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.error,n=tslib_1.__rest(_,["error"]),i=o,l=i.explorerDeviceId,s=i.deviceId,a=i.isConnected;r.code&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]&&(r.msg=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]),e.options.reporter.error(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]&&t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]+":"+(r&&(r.message||r.errMsg||r.msg||r.code))+")",timeCost:n.timeCost||0,action:t,error:r,data:tslib_1.__assign(tslib_1.__assign({deviceId:l,bleDeviceId:s,isConnected:a},n),r)})}},o}return tslib_1.__extends(e,t),e.injectOptions=function(t){e.options=t},e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,o=e.type,_=e.data;if("unknown"!==o)return console.log("check this in notifyMessage",this,{type:o,data:_}),this.emit(o,{type:o,data:_})},e.prototype.connectDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,t.prototype.connectDevice.call(this,e)];case 1:return o.sent(),[4,this.afterConnectDevice()];case 2:return o.sent(),[2]}}))}))},e.prototype.afterConnectDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,e,o,_,r;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.getDeviceInfo()];case 1:if(t=n.sent(),e=t.version,o=t.mtu,_=t.needSetMtu,r=t.deviceName,this.deviceName=r,this.bleVersion=e,this.mtu=o,this.reporter.info("CONNECT_DEVICE",{data:{version:e,mtu:o,needSetMtu:_,deviceName:r}}),!_)return[3,5];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.setMtu(this.mtu)];case 3:return n.sent(),this.writeMtuResult("success"),[3,5];case 4:return n.sent(),this.writeMtuResult("fail"),[3,5];case 5:return[2,r]}}))}))},e.prototype.getDeviceInfo=function(){return this.writeAndWait4Response(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEVICE_INFO],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};var e=parseInt(t.slice(2,3).join(""),16),o=parseInt(t.slice(3,5).join(""),16),_=!!(o>>15),r=8191&o,n=parseInt(t[5],16),i=hex2str(t.slice(6).join(""));if(n!==i.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};return{version:e,mtu:r,needSetMtu:_,deviceName:i}}),{timeout:exports.LLSyncComboConfig.waitGetDeviceInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiMode=function(t){void 0===t&&(t=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.STA_WIFI_MODE);var e=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE]+U8ToHexString(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WIFI_MODE_MAP[t]);return this.writeAndWait4Response(e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiModeTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiInfo=function(t){var e=t.ssid,o=t.password,_=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)))||[],r=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(o)))||[];console.log("----data----",{ssid:e,password:o,ssidHexArray:_,passwordHexArray:r});var n=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO],U16ToHexString(_.length+r.length),U8ToHexString(_.length)],_,[U8ToHexString(r.length)],r),[tslib_1.__spread([U8ToHexString(_.length)],_),tslib_1.__spread([U8ToHexString(r.length)],r)],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO);return this.writeAndWait4Response(n,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendConnectWiFiAndGetWiFiConnectState=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_INVALID};var e=parseInt(t.slice(3,4).join(""),16),o=parseInt(t.slice(5,6).join(""),16),_="";return o&&(_=hex2str(t.slice(6,6+o))),{connected:!e,ssid:_}}),{timeout:exports.LLSyncComboConfig.waitSetWiFiConnectTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendToken=function(t){var e=t.token,o=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)));console.log("----data----",{token:e,tokenHexArray:o});var _=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN],U16ToHexString(o.length)],o),[o],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN);return this.writeAndWait4Response(_,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiTokenTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.getModuleLog=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_INVALID};var e=parseInt(t.slice(1,3).join(""),16);return{logStr:hex2str(t.slice(4,4+e))}}),{timeout:exports.LLSyncComboConfig.waitDevLogInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapterBase)).options={reporter:console},_a.serviceId16="0000FFF0-0000-1000-8000-00805F9B34FB",_a.serviceId="0000FFF0-65D0-4E20-B56A-E493541BA4E2",_a.deviceFilter=function(t){if(!t.advertisServiceUUIDs||!t.advertisServiceUUIDs.find((function(t){return t===_a.serviceId16}))||!t.advertisData)return null;console.log("options",_a.options);var e=(_a.options||{}).reporter,o=void 0===e?console:e;try{var _=Math.floor(10*Math.random())%10==1||!0,r=arrayBufferToHexStringArray(t.advertisData);_&&o.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:_a.serviceId,hexArr:r.join(",")});var n,i=parseInt(r[2],16)>>4,l=r.slice(3,9);return t.name&&-1===t.name.indexOf("_")&&(t.name=t.name+"_"+l.slice(0,2).join("")),n=hex2str(r.slice(9)),_&&o.info(REPORT_EVENT_TYPE,{message:"解析广播",serviceId:_a.serviceId,data:{deviceProductId:n||"x"}}),tslib_1.__assign(tslib_1.__assign({},t),{standardBleCombo:!0,serviceId:_a.serviceId,deviceName:"",productId:n,extendInfo:{moduleVersion:i}})}catch(t){o.error(REPORT_EVENT_TYPE,{message:"协议广播出错",error:t})}},_a));
//# sourceMappingURL=BleComboLLSyncDeviceAdapter.js.map
{
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-blecombo",
"version": "1.1.3",
"version": "1.1.4",
"description": "",

@@ -30,4 +30,3 @@ "main": "lib/index.js",

"url": "https://github.com/tencentyun/qcloud-iotexplorer-appdev-sdk/issues"
},
"gitHead": "db62a7e354efc7ef91e027a1b662bfb66ebceff5"
}
}

@@ -42,8 +42,8 @@ # qcloud-iotexplorer-appdev-plugin-wificonf-blecombo

```ts
import { BleComboDeviceAdapter, StandardBleComboDeviceAdapter, BlueToothAdapter } from 'qcloud-iotexplorer-appdev-plugin-wificonf-blecombo';
export const blueToothAdapter = new BlueToothAdapter({
import { BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter } from 'qcloud-iotexplorer-appdev-plugin-wificonf-blecombo';
import { BlueToothAdapter } from 'qcloud-iotexplorer-bluetooth-adapter';
export const bluetoothAdapter = new BlueToothAdapter({
deviceAdapters: [
BleComboDeviceAdapter,
StandardBleComboDeviceAdapter,
BleComboEspDeviceAdapter,
BleComboLLSyncDeviceAdapter,
],

@@ -55,6 +55,7 @@ });

通过 blueToothAdapter.startSearch方法,我们可以发现设备,获得设备列表。
通过 bluetoothAdapter.startSearch方法,我们可以发现设备,获得设备列表。
```ts
await blueToothAdapter.startSearch({
const serviceIds = [BleComboLLSyncDeviceAdapter.serviceId];
await bluetoothAdapter.startSearch({
ignoreDeviceIds,

@@ -65,4 +66,4 @@ serviceIds,

console.log('----error', error);
// 搜素设备出错
blueToothAdapter.stopSearch();
// 搜索设备出错
bluetoothAdapter.stopSearch();
},

@@ -81,3 +82,3 @@ onSearch: (devices) => {

用户从上面获取到的设备中选择一个,并发起连接操作时,可以调用 `blueToothAdapter.connectDevice` 方法进行连接。连接成功后会返回一个 deviceAdapter,可以用来向连接的设备发送Wi-Fi,token等数据。
用户从上面获取到的设备中选择一个,并发起连接操作时,可以调用 `bluetoothAdapter.connectDevice` 方法进行连接。连接成功后会返回一个 deviceAdapter,可以用来向连接的设备发送Wi-Fi,token等数据。

@@ -87,3 +88,3 @@ ```ts

// device参数是上一步获取的devices中的某一个item
const deviceAdapter = await blueToothAdapter.connectDevice(device);
const deviceAdapter = await bluetoothAdapter.connectDevice(device);

@@ -120,3 +121,3 @@ if (!deviceAdapter) {

break;
case WifiConfStepCode.BLE_SEND_TOKEN_SUCCESS: // 发送token到设备成功,设备开始连接云端
case WifiConfStepCode.BLE_SEND_TOKEN_SUCCESS: // 发送token到设备成功,设备开始连接云端,可以在设备连接到云端后,进行设备的绑定操作
onStepChange(3);

@@ -123,0 +124,0 @@ break;

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc