Skip to content

公共模块

说明:本文档包含微信小程序 SDK 的公共数据结构和返回码说明。

Result 方法的统一返回结构

说明:Result 类是所有有返回结果的方法的统一返回结构,以下接口文档的返回只列出 data 中的数据结构。

  • 使用方式
javascript
const { Result } = requirePlugin('starCloud')

// Result.Success 中 code=0,message='成功',data 根据不同方法返回不同数据,默认为 {}
const { code, data, message } = Result.Success

// 常用判断方式
if (code === Result.Success.code) {
  // 逻辑代码
} else {
  // 错误处理
}
  • 返回码说明
code变量名描述
0Success成功
-1Fail失败
-10NotMoreData没有更多数据
-20NotAvailableBluetooth蓝牙尚未打开,请先打开蓝牙
-21NotAvailableBluetoothPermission小程序蓝牙功能被禁用,请打开小程序蓝牙权限
-22NotAvailableWeChatNearbyDevicesPermission蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试
-23NotAvailableWeChatLocationPermission蓝牙功能需要定位权限,请前往设置开启微信的定位权限后再试
-24NotAvailableWeChatNearbyDevicesEmpty蓝牙功能需要定位服务,请前往设置开启定位服务后再试
-25NotAvailableWeChatBluetoothPermission微信的蓝牙权限被禁用,请前往设置开启微信的蓝牙权限后再试
-30DeviceHasBeenReset设备已被重置
251ReadyHasPassword该密码已存在

AccountInfo 账号信息

名称类型描述
uidNumber用户uid
usernameString用户名
passwordString密码

LockInfo 锁信息

名称类型描述
deviceIdString设备 ID
serviceIdString服务 ID
notifyCharacteristicIdString通知特征值 ID
writeCharacteristicIdString写入特征值 ID
pwdTimestampNumber密码时间戳(毫秒)
featureValueString功能值
featureSettingValueString功能设置值
featureSettingParamsArray<Number>功能设置参数
lockUserNoNumber锁用户编号
lockIdNumber锁 ID
keyIdNumber钥匙 ID
adminPwdString管理密码
bluetoothBluetooth蓝牙信息
lockConfigLockConfig锁配置信息

Bluetooth 蓝牙信息

名称类型描述
bluetoothDeviceIdString蓝牙设备 ID
bluetoothDeviceNameString蓝牙设备名称
publicKeyArray<Number>公钥
privateKeyArray<Number>私钥
signKeyArray<Number>签名密钥

LockConfig 锁配置信息

名称类型描述
vendorString厂商
productNumber产品号
modelString型号
fwVersionString固件版本
hwVersionString硬件版本
serialNum0String序列号 0
serialNum1String序列号 1
btDeviceNameString蓝牙设备名称
electricQuantityNumber电量
electricQuantityStandbyNumber备用电量
restoreCountNumber重置次数
restoreDateNumber重置日期(时间戳秒)
icPartNoString芯片型号
indateNumber入网日期(时间戳秒)
macStringMAC 地址
timezoneOffsetNumber时区偏移(秒)

物联网设备通信协议文档