Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-appdev-plugin-wificonf-simpleconfig

Package Overview
Dependencies
16
Maintainers
6
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    qcloud-iotexplorer-appdev-plugin-wificonf-simpleconfig

腾讯云物联网开发平台应用开发小程序端WIFI配网方式之SimpleConfig SDK


Version published
Weekly downloads
16
decreased by-78.38%
Maintainers
6
Install size
7.10 MB
Created
Weekly downloads
 

Readme

Source

qcloud-iotexplorer-appdev-plugin-wificonf-simpleconfig

腾讯云物联网开发平台应用开发小程序端WIFI配网方式之SimpleConfig SDK

安装依赖

npm install qcloud-iotexplorer-appdev-sdk
npm install qcloud-iotexplorer-appdev-plugin-wificonf-core

安装SDK

npm install qcloud-iotexplorer-appdev-plugin-wificonf-simpleconfig

使用

step1.向sdk里面注册simpleconfig插件,sdk的初始化方式请参考qcloud-iotexplorer-appdev-sdk

import SimpleConfigPlug from 'qcloud-iotexplorer-appdev-plugin-wificonf-simpleconfig';

sdk.usePlugin(SimpleConfigPlug);

step2.开始simpleconfig配网,配网流程祥见官方文档

import { constants as WifiConfConstants } from 'qcloud-iotexplorer-appdev-plugin-wificonf-core';

const {
  MpStatType, MyStatDimension, WifiConfErrorMsg, WifiConfStepCode,
} = WifiConfConstants;

/**
 * simpleconfig一键配网
 */
export function SimpleConfigConfigure({
  token,
  wifiInfo = {
    SSID: '';
    password: '';
    BSSID: '';
  },
  familyId = 'default',
  roomId,
  reporter,
  onStepChange,
  onStatusChange,
}) {
  const onProgress = (data) => {
    reporter.info(data.code, data.detail);

    switch (data.code) {
      case WifiConfStepCode.PROTOCOL_SUCCESS:
        onStepChange(1);
        break;
      case WifiConfStepCode.CREATE_UDP_CONNECTION_SUCCESS:
        onStepChange(2);
        break;
      case WifiConfStepCode.BUSINESS_QUERY_TOKEN_STATE_SUCCESS:
        onStepChange(3);
        break;
      case WifiConfStepCode.WIFI_CONF_SUCCESS:
        onStepChange(4);
        break;
    }
  };

  const onComplete = ({ productId, deviceName }) => {
    onStatusChange({
      status: 'success',
      productId,
      deviceName,
    });
  };

  const onError = async ({ code, detail }) => {
    reporter.error(code, detail);

    onStatusChange({ status: 'error' });
  };

  sdk.plugins['wifiConfSimpleConfig'].start({
    wifiConfToken: token,
    targetWifiInfo: wifiInfo,
    autoRetry: true, // 自动处理故障流程
    familyId,
    roomId,
    onProgress,
    onComplete,
    onError
  });
}

FAQs

Last updated on 15 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc