Skip to content

密码管理

用户自定义的固定密码,通过门锁键盘输入验证开锁。

离线密码

算法生成的离线密码无需通过指令添加,详见 离线密码

指令列表

指令码名称方向说明
0x0500ListPasswordsAPP → 设备获取密码列表
0x0501GetPasswordAPP → 设备获取密码详情
0x0502AddPasswordAPP → 设备添加密码
0x0503UpdatePasswordAPP → 设备更新密码
0x0504DeletePasswordAPP → 设备删除密码
0x0505ClearPasswordsAPP → 设备清空所有密码

数据结构

protobuf
message Password {
  uint32 credential_id = 1;    // 凭证ID(锁内唯一)
  uint32 user_id = 2;          // 归属用户ID
  string password = 3;         // 密码内容(4-10位数字)
  uint32 created_by = 4;       // 创建者用户ID
  uint64 created_at = 5;       // 创建时间(UNIX毫秒时间戳)
  ValidityPeriod validity = 6; // 有效期
  uint32 use_count_limit = 7;  // 使用次数限制(0=不限)
  uint32 use_count = 8;        // 已使用次数
  string label = 9;            // 标签
  bool is_duress = 10;         // 是否胁迫凭证
}
字段类型说明
credential_iduint32凭证ID,锁内唯一标识
user_iduint32归属用户ID
passwordstring密码内容,4-10 位纯数字
created_byuint32创建者用户ID
created_atuint64创建时间(UNIX毫秒时间戳)
validityValidityPeriod有效期,详见 凭证期限
use_count_limituint32使用次数限制,0 表示不限制
use_countuint32已使用次数
labelstring用户自定义标签
is_duressbool是否胁迫凭证

密码规则

规则说明
长度4-10 位
字符纯数字 0-9
唯一性同一门锁内密码不可重复

安全建议

避免使用简单密码如 123456000000、生日等易被猜测的组合。

ListPasswords - 获取密码列表

指令码: 0x0500

ListPasswordsReq

protobuf
message ListPasswordsReq {
  optional uint32 user_id = 1;  // 按用户ID筛选(不指定则返回所有)
}

ListPasswordsResp

protobuf
message ListPasswordsResp {
  uint32 code = 1;
  string message = 2;
  repeated Password passwords = 3;  // 密码列表
}

密码脱敏

列表查询时 password 字段返回脱敏内容(如 12****56),完整密码需通过 GetPassword 获取。

GetPassword - 获取密码详情

指令码: 0x0501

GetPasswordReq

protobuf
message GetPasswordReq {
  uint32 credential_id = 1;  // 凭证ID
}

GetPasswordResp

protobuf
message GetPasswordResp {
  uint32 code = 1;
  string message = 2;
  Password password = 3;  // 密码详情(含完整密码)
}

AddPassword - 添加密码

指令码: 0x0502

AddPasswordReq

protobuf
message AddPasswordReq {
  string password = 1;                  // 密码内容(4-10位数字,必填)
  optional uint32 user_id = 2;          // 归属用户ID(不指定则自动创建用户)
  optional ValidityPeriod validity = 3; // 有效期
  optional uint32 use_count_limit = 4;  // 使用次数限制
  optional string label = 5;            // 标签
  optional bool is_duress = 6;          // 是否胁迫凭证
}
字段必填说明
password4-10 位纯数字
user_id不指定时自动创建新用户
validity不指定时永久有效
use_count_limit默认 0(不限制)
label默认空字符串
is_duress默认 false

AddPasswordResp

protobuf
message AddPasswordResp {
  uint32 code = 1;
  string message = 2;
  uint32 credential_id = 3;  // 新建的凭证ID
  uint32 user_id = 4;        // 归属用户ID
}

UpdatePassword - 更新密码

指令码: 0x0503

密码可更新

与生物特征凭证不同,密码内容本身可以通过 UpdatePassword 修改。

UpdatePasswordReq

protobuf
message UpdatePasswordReq {
  uint32 credential_id = 1;             // 凭证ID(必填)
  optional string password = 2;         // 新密码内容
  optional ValidityPeriod validity = 3; // 有效期
  optional uint32 use_count_limit = 4;  // 使用次数限制
  optional string label = 5;            // 标签
  optional bool is_duress = 6;          // 是否胁迫凭证
}

UpdatePasswordResp

protobuf
message UpdatePasswordResp {
  uint32 code = 1;
  string message = 2;
}

DeletePassword - 删除密码

指令码: 0x0504

DeletePasswordReq

protobuf
message DeletePasswordReq {
  uint32 credential_id = 1;  // 凭证ID
}

DeletePasswordResp

protobuf
message DeletePasswordResp {
  uint32 code = 1;
  string message = 2;
}

ClearPasswords - 清空所有密码

指令码: 0x0505

危险操作

此操作将删除门锁上所有自定义密码,不可恢复。离线密码不受影响。

ClearPasswordsReq

protobuf
message ClearPasswordsReq {
  // 无参数
}

ClearPasswordsResp

protobuf
message ClearPasswordsResp {
  uint32 code = 1;
  string message = 2;
  uint32 count = 3;  // 删除的数量
}

相关文档

物联网设备通信协议文档