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

qcloud-iotexplorer-appdev-plugin-wificonf-softap

Package Overview
Dependencies
Maintainers
5
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.1.16 to 1.1.21

softap配网流程图 .jpg

2

lib/index.d.ts

@@ -0,3 +1,3 @@

import { WifiConfOption } from 'qcloud-iotexplorer-appdev-plugin-wificonf-core';
import { AppDevPlugin, AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk';
import { WifiConfOption } from 'qcloud-iotexplorer-appdev-plugin-wificonf-core';
declare module 'qcloud-iotexplorer-appdev-sdk' {

@@ -4,0 +4,0 @@ interface AppDevPlugins {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SoftAp=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),WifiConfErrorMsg=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfErrorMsg,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,UdpServer=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.UdpServer,reconnectWifi=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.reconnectWifi,tryRequest=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.tryRequest,connectWifi=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.connectWifi,SoftAp=function(e){function o(o,t){var r=e.call(this,o,t)||this;return r.udpAddress="192.168.4.1",r.udpPort=8266,r.connectAborted=!1,r.udpAddress=r.options.udpAddress||r.udpAddress,r.udpPort=r.options.udpPort||r.udpPort,r}return tslib_1.__extends(o,e),o.prototype.start=function(e){var o=(void 0===e?{}:e).doNotRetry,t=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,r,i=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:e=Date.now(),this.onProgress({code:WifiConfStepCode.WIFI_CONF_START}),s.label=1;case 1:return s.trys.push([1,5,,8]),this.options.softAPInfo?[4,connectWifi(this.options.softAPInfo,{onProgress:function(e){i.onProgress.call(i,e)}})]:[3,3];case 2:s.sent(),s.label=3;case 3:return this.onProgress({code:WifiConfStepCode.PROTOCOL_START}),[4,this.doBusiness()];case 4:return o=s.sent(),this.onProgress({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:tslib_1.__assign({timeCost:Date.now()-e},o)}),this.onComplete(o),[3,8];case 5:return r=s.sent(),console.error(r),r&&r.code in WifiConfErrorMsg&&(r.uiMsg=WifiConfErrorMsg[r.code]),t||!this.options.autoRetry?[3,7]:[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.issueHandler({error:r,targetWifiInfo:this.options.targetWifiInfo,wifiConfType:this.options.wifiConfType,onProgress:function(e){i.onProgress.call(i,e)}})];case 6:if(s.sent())return this.onProgress({code:WifiConfStepCode.WIFI_CONF_AUTO_RETRY}),[2,this.start({doNotRetry:!0})];s.label=7;case 7:return this.connectAborted=!0,this.onProgress({code:WifiConfStepCode.WIFI_CONF_FAIL,detail:{error:r}}),this.onError({code:"WIFI_CONF_FAIL",detail:{error:r}}),[3,8];case 8:return[2]}}))}))},o.prototype.doBusiness=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,t,r,i,s,n=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return this.onProgress({code:WifiConfStepCode.CREATE_UDP_CONNECTION_START}),e=Date.now(),o=new UdpServer({address:this.udpAddress,port:this.udpPort,sdk:this.sdk,retryTime:10}),t=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),r=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),o.onError((function(e){return t.reject({code:"UDP_ERROR",errMsg:e})})),o.onProgressError((function(e){return r.reject({code:"BUSINESS_DEVICE_ERROR",message:e})})),i=function(){return tslib_1.__awaiter(n,void 0,void 0,(function(){var t,r,i,s,n,d,c,_,p,a,u,f,l,S=this;return tslib_1.__generator(this,(function(C){switch(C.label){case 0:return[4,(t=function(e){return tslib_1.__awaiter(S,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay(e||this.options.stepInterval)];case 1:return o.sent(),this.connectAborted&&qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.logger.debug("connection aborted"),[2]}}))}))})()];case 1:return C.sent(),this.onProgress({code:WifiConfStepCode.CREATE_UDP_CONNECTION_SUCCESS,detail:{timeCost:Date.now()-e}}),this.onProgress({code:WifiConfStepCode.PROTOCOL_START}),this.onProgress({code:WifiConfStepCode.SOFTAP_SEND_TARGET_WIFIINFO_START}),r=Date.now(),[4,o.send({cmdType:1,ssid:this.options.targetWifiInfo.SSID,password:this.options.targetWifiInfo.password,token:this.options.wifiConfToken})];case 2:switch(i=C.sent(),s=i.protoVersion,n=tslib_1.__rest(i,["protoVersion"]),s||(s="1.0"),this.onProgress({code:WifiConfStepCode.SOFTAP_SEND_TARGET_WIFIINFO_SUCCESS,detail:{data:n,timeCost:Date.now()-r,protoVersion:s}}),d={},s){case"1.0":return[3,3];case"2.0":return[3,13]}return[3,18];case 3:if("dataRecived"!==n.deviceReply)throw{code:"BUSINESS_INVALID_RESPONSE",detail:n};return[4,t(1e4)];case 4:return C.sent(),this.onProgress({code:WifiConfStepCode.SOFTAP_GET_DEVICE_SIGNATURE_START}),[4,o.send({cmdType:0,timestamp:parseInt(String(Date.now()/1e3),10)})];case 5:if(c=C.sent(),_=c.mqttState,p=c.wifiState,a=tslib_1.__rest(c,["mqttState","wifiState"]),"connected"!==_)throw{code:"BUSINESS_DEVICE_CONNECT_MQTT_FAIL"};if("connected"!==p)throw{code:"BUSINESS_DEVICE_CONNECT_WIFI_FAIL"};return this.onProgress({code:WifiConfStepCode.SOFTAP_GET_DEVICE_SIGNATURE_SUCCESS}),o.destroy(),[4,t()];case 6:return C.sent(),[4,reconnectWifi(this.options.targetWifiInfo,{onProgress:function(e){S.onProgress.call(S,e)},ignoreError:!0})];case 7:return C.sent(),[4,t()];case 8:C.sent(),this.onProgress({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-r,protoVersion:s}}),this.onProgress({code:WifiConfStepCode.BUSINESS_START}),this.onProgress({code:WifiConfStepCode.BUSINESS_ADD_DEVICE_START,detail:{data:{Signature:a.signature,DeviceTimestamp:a.timestamp,ProductId:a.productId,DeviceName:a.deviceName,ConnId:a.connId,FamilyId:this.options.familyId}}}),C.label=9;case 9:return C.trys.push([9,11,,12]),[4,tryRequest((function(){return S.sdk.requestApi("addDeviceBySigInFamily",{Signature:a.signature,DeviceTimestamp:a.timestamp,ProductId:a.productId,DeviceName:a.deviceName,ConnId:a.connId,FamilyId:S.options.familyId},{isTokenApi:!0})}),{reporter:this.sdk.reporter})];case 10:return C.sent(),[3,12];case 11:throw u=C.sent(),tslib_1.__assign(tslib_1.__assign({},u),{code:"BUSINESS_ADD_DEVICE_FAIL"});case 12:return d={productId:a.productId,deviceName:a.deviceName},[3,19];case 13:return o.destroy(),[4,t()];case 14:return C.sent(),[4,reconnectWifi(this.options.targetWifiInfo,{onProgress:function(e){S.onProgress.call(S,e)},ignoreError:!0})];case 15:return C.sent(),this.onProgress({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-r,protoVersion:s}}),this.onProgress({code:WifiConfStepCode.BUSINESS_START}),[4,t()];case 16:return C.sent(),f=n.productId,l=n.deviceName,[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:this.options.wifiConfToken,productId:f,deviceName:l,familyId:this.options.familyId,roomId:this.options.roomId,onProgress:function(e){S.onProgress.call(S,e)},sdk:this.sdk})];case 17:return C.sent(),d={productId:f,deviceName:l},[3,19];case 18:throw{code:"SOFTAP_MODULE_VERSION_ERROR"};case 19:return[2,{productId:d.productId,deviceName:d.deviceName}]}}))}))},[4,Promise.race([i(),t.promise,r.promise])];case 1:return s=d.sent(),this.onProgress({code:WifiConfStepCode.BUSINESS_SUCCESS,detail:{response:s}}),[2,s]}}))}))},o}(qcloud_iotexplorer_appdev_plugin_wificonf_core_1.WifiConfProtocolBase);exports.SoftAp=SoftAp;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SoftAp=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),WifiConfErrorMsg=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfErrorMsg,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,UdpServer=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.UdpServer,reconnectWifi=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.reconnectWifi,tryRequest=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.tryRequest,connectWifi=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.utils.connectWifi,SoftAp=function(e){function o(o,t){var r=e.call(this,o,t)||this;return r.udpAddress="192.168.4.1",r.udpPort=8266,r.connectAborted=!1,r.udpAddress=r.options.udpAddress||r.udpAddress,r.udpPort=r.options.udpPort||r.udpPort,r}return tslib_1.__extends(o,e),o.prototype.start=function(e){var o=(void 0===e?{}:e).doNotRetry,t=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,r,i=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:e=Date.now(),this.onProgress({code:WifiConfStepCode.WIFI_CONF_START,reportEvents:["配网"]}),s.label=1;case 1:return s.trys.push([1,5,,8]),this.options.softAPInfo?[4,connectWifi(this.options.softAPInfo,{onProgress:function(e){i.onProgress.call(i,e)}})]:[3,3];case 2:s.sent(),s.label=3;case 3:return this.onProgress({code:WifiConfStepCode.PROTOCOL_START}),[4,this.doBusiness()];case 4:return o=s.sent(),this.onProgress({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:tslib_1.__assign({timeCost:Date.now()-e},o)}),this.onComplete(o),[3,8];case 5:return r=s.sent(),console.error(r),r&&r.code in WifiConfErrorMsg&&(r.uiMsg=WifiConfErrorMsg[r.code]),t||!this.options.autoRetry?[3,7]:[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.issueHandler({error:r,targetWifiInfo:this.options.targetWifiInfo,wifiConfType:this.options.wifiConfType,onProgress:function(e){i.onProgress.call(i,e)}})];case 6:if(s.sent())return this.onProgress({code:WifiConfStepCode.WIFI_CONF_AUTO_RETRY}),[2,this.start({doNotRetry:!0})];s.label=7;case 7:return this.connectAborted=!0,this.onProgress({code:WifiConfStepCode.WIFI_CONF_FAIL,detail:{error:r},reportEvents:["配网"]}),this.onError({code:"WIFI_CONF_FAIL",detail:{error:r}}),[3,8];case 8:return[2]}}))}))},o.prototype.doBusiness=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,t,r,i,s,n=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:return this.onProgress({code:WifiConfStepCode.CREATE_UDP_CONNECTION_START,reportEvents:["udp"]}),e=Date.now(),o=new UdpServer({address:this.udpAddress,port:this.udpPort,sdk:this.sdk,retryTime:10}),t=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),r=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),o.onError((function(e){return t.reject({code:"UDP_ERROR",errMsg:e})})),o.onProgressError((function(e){return r.reject({code:"BUSINESS_DEVICE_ERROR",message:e})})),i=function(){return tslib_1.__awaiter(n,void 0,void 0,(function(){var t,r,i,s,n,d,c,_,p,a,u,f,l,S=this;return tslib_1.__generator(this,(function(C){switch(C.label){case 0:return[4,(t=function(e){return tslib_1.__awaiter(S,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay(e||this.options.stepInterval)];case 1:return o.sent(),this.connectAborted&&qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.logger.debug("connection aborted"),[2]}}))}))})()];case 1:return C.sent(),this.onProgress({code:WifiConfStepCode.CREATE_UDP_CONNECTION_SUCCESS,detail:{timeCost:Date.now()-e},reportEvents:["udp"]}),this.onProgress({code:WifiConfStepCode.PROTOCOL_START,reportEvents:["发送wifi"]}),this.onProgress({code:WifiConfStepCode.SOFTAP_SEND_TARGET_WIFIINFO_START}),r=Date.now(),[4,o.send({cmdType:1,ssid:this.options.targetWifiInfo.SSID,password:this.options.targetWifiInfo.password,token:this.options.wifiConfToken})];case 2:switch(i=C.sent(),s=i.protoVersion,n=tslib_1.__rest(i,["protoVersion"]),s||(s="1.0"),this.onProgress({code:WifiConfStepCode.SOFTAP_SEND_TARGET_WIFIINFO_SUCCESS,detail:{data:n,timeCost:Date.now()-r,protoVersion:s}}),d={},s){case"1.0":return[3,3];case"2.0":return[3,13]}return[3,18];case 3:if("dataRecived"!==n.deviceReply)throw{code:"BUSINESS_INVALID_RESPONSE",detail:n};return[4,t(1e4)];case 4:return C.sent(),this.onProgress({code:WifiConfStepCode.SOFTAP_GET_DEVICE_SIGNATURE_START}),[4,o.send({cmdType:0,timestamp:parseInt(String(Date.now()/1e3),10)})];case 5:if(c=C.sent(),_=c.mqttState,p=c.wifiState,a=tslib_1.__rest(c,["mqttState","wifiState"]),"connected"!==_)throw{code:"BUSINESS_DEVICE_CONNECT_MQTT_FAIL"};if("connected"!==p)throw{code:"BUSINESS_DEVICE_CONNECT_WIFI_FAIL"};return this.onProgress({code:WifiConfStepCode.SOFTAP_GET_DEVICE_SIGNATURE_SUCCESS}),o.destroy(),[4,t()];case 6:return C.sent(),[4,reconnectWifi(this.options.targetWifiInfo,{onProgress:function(e){S.onProgress.call(S,e)},ignoreError:!0})];case 7:return C.sent(),[4,t()];case 8:C.sent(),this.onProgress({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-r,protoVersion:s},reportEvents:["发送wifi"]}),this.onProgress({code:WifiConfStepCode.BUSINESS_START}),this.onProgress({code:WifiConfStepCode.BUSINESS_ADD_DEVICE_START,detail:{data:{Signature:a.signature,DeviceTimestamp:a.timestamp,ProductId:a.productId,DeviceName:a.deviceName,ConnId:a.connId,FamilyId:this.options.familyId}}}),C.label=9;case 9:return C.trys.push([9,11,,12]),[4,tryRequest((function(){return S.sdk.requestApi("addDeviceBySigInFamily",{Signature:a.signature,DeviceTimestamp:a.timestamp,ProductId:a.productId,DeviceName:a.deviceName,ConnId:a.connId,FamilyId:S.options.familyId},{isTokenApi:!0})}),{reporter:this.sdk.reporter})];case 10:return C.sent(),[3,12];case 11:throw u=C.sent(),tslib_1.__assign(tslib_1.__assign({},u),{code:"BUSINESS_ADD_DEVICE_FAIL"});case 12:return d={productId:a.productId,deviceName:a.deviceName},[3,19];case 13:return o.destroy(),[4,t()];case 14:return C.sent(),[4,reconnectWifi(this.options.targetWifiInfo,{onProgress:function(e){S.onProgress.call(S,e)},ignoreError:!0})];case 15:return C.sent(),this.onProgress({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-r,protoVersion:s},reportEvents:["发送wifi"]}),this.onProgress({code:WifiConfStepCode.BUSINESS_START}),[4,t()];case 16:return C.sent(),f=n.productId,l=n.deviceName,[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:this.options.wifiConfToken,productId:f,deviceName:l,familyId:this.options.familyId,roomId:this.options.roomId,onProgress:function(e){S.onProgress.call(S,e)},sdk:this.sdk})];case 17:return C.sent(),d={productId:f,deviceName:l},[3,19];case 18:throw{code:"SOFTAP_MODULE_VERSION_ERROR"};case 19:return[2,{productId:d.productId,deviceName:d.deviceName}]}}))}))},[4,Promise.race([i(),t.promise,r.promise])];case 1:return s=d.sent(),this.onProgress({code:WifiConfStepCode.BUSINESS_SUCCESS,detail:{response:s},reportEvents:["addDevice"]}),[2,s]}}))}))},o}(qcloud_iotexplorer_appdev_plugin_wificonf_core_1.WifiConfProtocolBase);exports.SoftAp=SoftAp;
//# sourceMappingURL=index.js.map
{
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-softap",
"version": "1.1.16",
"version": "1.1.21",
"description": "",

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

"dependencies": {
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^1.1.18",
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^1.1.20",
"qcloud-iotexplorer-appdev-sdk": "^1.1.15",
"tslib": "^2.0.1"
},
"gitHead": "01d5cbbf2faf316bc5e9fd3a2db17e6b0977d0c4"
"gitHead": "47e931e1d63e0c3cc26746ed1a70754060aaf83d"
}

@@ -97,2 +97,3 @@ # qcloud-iotexplorer-appdev-plugin-wificonf-softap

}
```
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