Skip to content

锁设置

说明:主要对锁设置进行一些基础操作,例如读取锁设置、更新锁设置等。

读取设置

  • 调用方法
Dart
await StarCloudTool.cloudSDK.readLockSetting(
  lockId: widget.lock.lockId,
  onSuccess: (result) {
    if (result is ApiResponse) {
      final response = result as ApiResponse;
      print("读取成功:${response}");
    }
  },
  onError: (err) {
    print("读取失败:${err}");
  },
)
  • 参数说明
名称类型是否必需示例描述
lockIdintY500锁id
onSuccessTCallback<ApiResponse>?N(result) {}读取设置成功回调
onErrorErrCallback?N(error) {}读取设置失败回调
  • 响应说明

接口响应值,按需取出对应设置即可

更新锁设置

  • 调用方法
Dart
// 不带参数示例:启用防撬报警
await StarCloudTool.cloudSDK.enableLockSettings(
  lockId: widget.lock.lockId,
  lockSettings: EnableLockSettings(
    featureBit: 30,
    featureEnable: true,
    parameter: null,
  ),
  onSuccess: () {
    print("启用成功");
  },
  onError: (err) {
    print("启用失败:${err}");
  },
)

// 带参数示例:设置常开模式
await StarCloudTool.cloudSDK.updateLockSetting(
  lockId: widget.lock.lockId,
  lockSettings: EnableLockSettings(
    featureBit: 50,
    featureEnable: true,
    parameter: PassageModeConfig(
      weekDays: [1, 2, 3],
      endDate: 720,
      startDate: 480,
      isAllDay: false,
      autoUnlock: true,
    ),
  ),
  onSuccess: () {
    print("更新成功");
  },
  onError: (err) {
    print("更新失败:${err}");
  },
)
  • 参数说明
名称类型是否必需示例描述
lockIdintY500锁id
lockSettingsEnableLockSettingsYEnableLockSettings(...)锁设置信息
onSuccessVoidCallback?N() {}更新锁设置成功回调
onErrorErrCallback?N(error) {}更新锁设置失败回调

EnableLockSettings 参数说明

名称类型是否必需示例描述
featureBitintY30功能位对应值
featureEnableboolYtrue开关,不论是否带参数都由这个控制启用/关闭
parameterdynamic?NPassageModeConfig(...)带参数的功能位必传

功能位定义(设置锁支持功能)

功能昵称对应位值值描述是否需要传递参数
自动闭锁29对应参数结构Y
锁提示音33对应参数结构Y
常开模式50对应参数结构Y
远程开锁28-N
防撬报警30-N
重置键配置31-N

参数结构定义

常开模式参数结构定义

Dart
class PassageModeConfig {
  List<int> weekDays;
  int startDate; // 开始时间(分钟)例如:480=08:00 720=12:00
  int endDate; // 结束时间(分钟)例如:480=08:00 720=12:00
  bool isAllDay; // 是否全天
  bool autoUnlock; // 自动开锁

  PassageModeConfig({
    required this.weekDays,
    required this.startDate,
    required this.endDate,
    required this.isAllDay,
    required this.autoUnlock,
  });
}

自动闭锁参数结构定义

Dart
class AutoCloseLockConfig {
  int autoCloseLockSecond; // 自动闭锁延时秒数

  AutoCloseLockConfig({
    required this.autoCloseLockSecond,
  });
}

语音提示音设置参数结构定义

Dart
class LockSoundConfig {
  int lockSoundVolume; // 音量值(1-5)

  LockSoundConfig({
    required this.lockSoundVolume,
  });
}

物联网设备通信协议文档