Appearance
锁设置
说明:主要对锁设置进行一些基础操作,例如读取锁设置、更新锁设置等。
读取设置
- 调用方法
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}");
},
)- 参数说明
| 名称 | 类型 | 是否必需 | 示例 | 描述 |
|---|---|---|---|---|
| lockId | int | Y | 500 | 锁id |
| onSuccess | TCallback<ApiResponse>? | N | (result) {} | 读取设置成功回调 |
| onError | ErrCallback? | 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}");
},
)- 参数说明
| 名称 | 类型 | 是否必需 | 示例 | 描述 |
|---|---|---|---|---|
| lockId | int | Y | 500 | 锁id |
| lockSettings | EnableLockSettings | Y | EnableLockSettings(...) | 锁设置信息 |
| onSuccess | VoidCallback? | N | () {} | 更新锁设置成功回调 |
| onError | ErrCallback? | N | (error) {} | 更新锁设置失败回调 |
EnableLockSettings 参数说明
| 名称 | 类型 | 是否必需 | 示例 | 描述 |
|---|---|---|---|---|
| featureBit | int | Y | 30 | 功能位对应值 |
| featureEnable | bool | Y | true | 开关,不论是否带参数都由这个控制启用/关闭 |
| parameter | dynamic? | N | PassageModeConfig(...) | 带参数的功能位必传 |
功能位定义(设置锁支持功能)
| 功能昵称 | 对应位值 | 值描述 | 是否需要传递参数 |
|---|---|---|---|
| 自动闭锁 | 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,
});
}