aiot-smc-ble-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

快速使用

获取wifi列表

import { 
  getSetting,
  authorize,
  startWifi,
  getWifiList,
  onGetWifiList
} from 'aiot-smc-ble-sdk';

try {
  // 弹窗授权
  const { authSetting } = await getSetting();
  console.log(authSetting);
  if (!authSetting['scope.userLocation']) {
    await authorize({ scope: 'scope.userLocation' });
  }
  await startWifi();
  // 发起Wi-Fi查询
  await getWifiList();
      
} catch (error) {
  console.log('err', error);
}
// 监听Wi-Fi列表获取
onGetWifiList((wifiList: WifiInfo[]) => {
  console.log(wifiList);
})
// 关闭监听
offGetWifiList(fn)

蓝牙配网

import ScmBleSdk, { ConnectStatusMap } from '@ali/aiot-smc-ble-sdk';

const bleSdk = new ScmBleSdk();
bleSdk.startConnect({
  ssid: 'ilop-fe',
  password: '12345678',
  userid: '-1', // 一方音箱是精灵ID,生态设备固定传 -1
  token: 'ZEzUDO'
});

配网进度监听

enum ConnectStatus = {
  PENDING = 1, // 初始状态
  SCAN = 2, // 扫描
  CONNECTED = 3, // 已连接
  SEND = 4, // 发送数据给数据
  SUCCESS = 8, // 配网成功
  ERROR = 9 // 配网失败
  
}

bleSdk.onConnectStatusChange(fn) // or bleSdk.on('connectStatusChange', fn);
bleSdk.offConnectStatusChange(fn) // or bleSdk.ff('connectStatusChange', fn);

Readme

Keywords

none

Package Sidebar

Install

npm i aiot-smc-ble-sdk

Weekly Downloads

4

Version

0.1.5

License

ISC

Unpacked Size

49.4 kB

Total Files

7

Last publish

Collaborators

  • suhan_lyo