蓝牙门锁

更新时间:2024-03-04 02:03:19下载pdf

本文介绍了蓝牙门锁功能列表以及与门锁成员、蓝牙连接、门锁记录、密码解锁、指纹解锁、卡片解锁等相关的操作。

类名介绍

类名 说明
ThingSmartBLELockDevice 蓝牙门锁设备操作类,继承自 ThingSmartDevice
ThingSmartBLELockDeviceDelegate 蓝牙门锁设备协议代理,拓展自 ThingSmartDeviceDelegate

名词解释

名词列表 说明
门锁劫持 指将特定的指纹、密码等,设置为劫持密码,当用户被劫持,并使用该密码开锁时,门会打开。同时,门锁将开门报警信息发送至家人手机或物业管理系统。
门锁成员 门锁成员分为 家庭成员非家庭成员
  • 家庭成员:涂鸦智能生活 App SDK 中的家庭成员概念。门锁 SDK 将对应的门锁密码编号与该账号关联起来。相关管理操作,请参考 家庭管理
  • 非家庭成员:即为门锁设备单独的成员,仅跟随门锁关联。用户可以创建并分配,门锁 SDK 将对应的门锁密码编号与该成员关联起来。
lockUserId 创建门锁成员时,云端为设备分配的固件成员 ID,代表着固件内记录的用户 ID。
userId 创建门锁成员时,云端分配的数据库记录 ID,代表着用户的唯一 ID。
dpCode 设备功能的标识符。每个设备功能都有对应的名称和编号,可参考 门锁功能列表

门锁成员

本小节介绍门锁成员中 家庭成员(Pro 门锁)非家庭成员(旧公版门锁) 的管理操作。

获取门锁成员列表

接口说明

该接口适用于低版本公版门锁。

- (void)getMemberListWithSuccess:(nullable void(^)(NSArray<ThingSmartBLELockMemberModel *> *members))success
                         failure:(ThingFailureError)failure;

接口说明

该接口适用于 Pro 门锁。

- (void)getProLockMemberListWithDevId:(NSString *)devId
                              success:(ThingSuccessID)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备ID
success 成功回调,成员列表
failure 失败回调

ThingSmartBLELockMemberModel 数据模型

字段 类型 描述
userId NSString 成员编号 ID
userContact NSString 联系方式
avatarUrl NSString 头像地址
nickName NSString 成员名称
userTimeSet NSString 成员时效性数据
phase NSUInteger 冻结情况
  • 0:冻结
  • 1:解冻
status NSUInteger 用户状态
lockUserId int 门锁上的用户 ID
userType NSUInteger 用户类型
  • 10:管理员
  • 20:普通成员
  • 30:没有名称的成员
supportOpenType NSArray 支持的开锁方式
shareUser NSString 分享的用户账号
productAttribute NSUInteger 设备产品属性

示例代码

Objective-C:

[self.lock getMemberListWithSuccess:^(NSArray<ThingSmartBLELockMemberModel *> * _Nonnull list) {
    NSLog(@"成员列表 %@", list);
} failure:^(NSError *error) {
    NSLog(@"查询成员列表失败,error: %@", error);
}];

Swift:

self.lock?.getMemberList(success: { (list) in
    print("成员列表 \(list)")
}, failure: { (error) in
    if let e = error {
        print("查询成员列表失败, error: \(e)")
    }
})

创建单个门锁成员

创建非家庭成员,后续可以单独为该成员绑定解锁方式。

App云端用户填写成员信息调用接口,创建用户生成门锁用户 ID、硬件成员 ID,返回创建结果处理、显示结果App云端创建门锁成员流程

接口说明

该接口适用于低版本公版门锁。

- (void)addMemberWithUserName:(NSString *)userName
                  allowUnlock:(BOOL)allowUnlock
                     timeType:(ThingMemberTimeType)timeType
                effectiveDate:(NSDate *)effectiveDate
                  invalidDate:(NSDate *)invalidDate
                      success:(nullable ThingSuccessBOOL)success
                      failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
userName 成员名称
allowUnlock 是否允许成员使用蓝牙解锁
timeType 时效性
  • ThingMemberTimeTypePermanent:表示永久
  • ThingMemberTimeTypePhase:表示分时间段
effectiveDate 生效时间
invalidDate 失效时间
success 成功回调
failure 失败回调

该接口仅创建非家庭成员。有关家庭成员的管理,请参考 家庭成员管理

接口说明

该接口适用于 Pro 门锁。

- (void)createProLockMemberWithHomeId:(long long)homeId
                         requestModel:(ThingSmartHomeAddMemberRequestModel *)requestModel
                              success:(ThingSuccessDict)success
                              failure:(ThingFailureError)failure;

参数说明

参数 说明
homeId 成员名称
requestModel 参考 家庭成员管理
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock addMemberWithUserName:#<成员名称># allowUnlock:YES timeType:ThingMemberTimeTypePhase effectiveDate:[NSDate date] invalidDate:[[NSDate date] dateByAddingTimeInterval:60 * 60 * 8] success:^(BOOL result) {
        NSLog(@"创建门锁成员成功");
    } failure:^(NSError *error) {
        NSLog(@"创建门锁成员失败,error: %@", error);
    }];

Swift:

    self.lock?.addMember(withUserName: "name", allowUnlock: true, timeType: .phase, effectiveDate: Date(), invalidDate: Date().addingTimeInterval(60 * 60 * 8), success: { (result) in
        print("创建门锁成员成功")
    }, failure: { (error) in
        if let e = error {
            print("创建门锁成员失败, error: \(e)")
        }
    })

修改门锁成员信息

修改门锁成员信息会和硬件进行交互,需要门锁保持蓝牙连接。

云端App门锁用户填写新的成员信息建立蓝牙连接发送更新用户信息指令回复更新结果调用接口,更新用户返回更新结果处理、显示结果云端App门锁更新门锁成员流程

接口说明

该接口适用于低版本公版门锁。

- (void)updateMemberWithUserName:(NSString *)userName
                        memberId:(NSString *)memberId
                     allowUnlock:(BOOL)allowUnlock
                        timeType:(ThingMemberTimeType)timeType
                   effectiveDate:(NSDate *)effectiveDate
                     invalidDate:(NSDate *)invalidDate
                         success:(nullable ThingSuccessBOOL)success
                         failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
userName 成员名称
memberId 成员 ID
allowUnlock 是否允许使用蓝牙解锁
timeType 时效性
  • ThingMemberTimeTypePermanent:表示永久
  • ThingMemberTimeTypePhase:表示分时间段
effectiveDate 生效时间
invalidDate 失效时间
success 成功回调
failure 失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)updateProLockMemberInfoWithRequestModel:(ThingSmartHomeMemberRequestModel *)memberRequestModel
                                        success:(ThingSuccessHandler)success
                                        failure:(ThingFailureError)failure;

参数说明

参数 说明
memberRequestModel 参考 家庭成员管理
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock updateMemberWithUserName:@"new name" memberId:@"0000008byw" allowUnlock:YES timeType:ThingMemberTimeTypePermanent effectiveDate:[NSDate date] invalidDate:[[NSDate date] dateByAddingTimeInterval:60 * 60 * 8] success:^(BOOL result) {
        NSLog(@"更新门锁成员成功");
    } failure:^(NSError *error) {
        NSLog(@"创建门锁成员失败,error: %@", error);
    }];

Swift:

    self.lock?.updateMember(withUserName: "new name", memberId: "0000008byw", allowUnlock: true, timeType: .phase, effectiveDate: Date(), invalidDate: Date().addingTimeInterval(60 * 60 * 8), success: { (result) in
            print("更新门锁成员信息成功")
        }, failure: { (error) in
            if let e = error {
                print("更新门锁成员信息失败, error: \(e)")
            }
        })

删除单个门锁成员

删除门锁成员会和硬件进行交互,会删除该用户下所有的开锁方式、密码等,需要门锁保持蓝牙连接。

云端App门锁用户确认删除成员建立蓝牙连接发送删除用户信息指令回复删除结果调用接口,删除用户返回删除结果处理、显示结果云端App门锁删除门锁成员流程

接口说明

该接口适用于低版本公版门锁。

- (void)removeMemberWithMemberId:(NSString *)memberId
                         success:(nullable ThingSuccessBOOL)success
                         failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
memberId 成员编号 ID
success 成功回调
failure 失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)removeProLockMemberWithUserId:(NSString *)userId
                              isAdmin:(BOOL)isAdmin
                              success:(ThingSuccessHandler)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
userId 用户 ID
isAdmin 是否是管理员
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock removeMemberWithMemberId:@"000000747d" success:^(BOOL result) {
        NSLog(@"删除门锁成员成功");
    } failure:^(NSError *error) {
        NSLog(@"删除门锁成员失败, error: %@", error);
    }];

Swift:

    self.lock?.removeMember(withMemberId: "", success: { (result) in
        print("删除门锁成员成功")
    }, failure: { (error) in
        if let e = error {
            print("删除门锁成员失败, error: \(e)")
        }
    })

修改单个成员时效(不支持低版本)

修改单个成员时效会和硬件进行交互,请保持门锁设备的蓝牙连接。

门锁App云端设备在线用户提交修改时效发送用户时效变更指令回复变更结果云端用户时效更新返回结果处理展示结果门锁App云端修改单个成员时效

接口说明

该接口适用于 Pro 门锁。

- (void)updateProLockMemberTimeWithDevId:(NSString *)devId
                                memberId:(NSString *)memberId
                           offlineUnlock:(BOOL)offlineUnlock
                                 isAdmin:(BOOL)isAdmin
                           effectiveDate:(nullable NSDate *)effectiveDate
                             invalidDate:(nullable NSDate *)invalidDate
                                schedule:(ThingSmartBLELockTimeScheduleInfo *)scheduleInfo
                                 success:(ThingSuccessID)success
                                 failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
memberId 成员编号 ID
offlineUnlock 是否支持离线解锁
isAdmin 是否管理员
effectiveDate 生效时间
invalidDate 失效时间
scheduleInfo 时效信息
success 成功回调
failure 失败回调

示例代码

Objective-C:

  //入参数据查询,详见 Demo
    [self.bleDevice updateProLockMemberTimeWithDevId:self.bleDevice.deviceModel.devId
                                            memberId:[self.dataSource[@"userId"] stringValue]
                                       offlineUnlock:NO
                                             isAdmin:isAdmin
                                       effectiveDate:[self.timeView getEffectiveData]
                                         invalidDate:[self.timeView getInvalidData]
                                            schedule:[self.timeView getScheduleInfo]
                                             success:^(id result) {
                NSLog(@"更新成员时效成功");
    } failure:^(NSError *error) {
                 NSLog(@"更新成员时效失败");
    }];

获取当前用户信息

接口说明

该接口适用于低版本公版门锁。

- (void)getCurrentMemberDetailWithDevId:(NSString *)devId
                                    gid:(long long)gid
                                success:(nullable ThingSuccessDict)success
                                failure:(nullable ThingFailureError)failure;

接口说明

该接口适用于 Pro 门锁。

- (void)getProCurrentMemberDetailWithDevId:(NSString *)devId
                                   success:(nullable ThingSuccessDict)success
                                   failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice getCurrentMemberDetailWithDevId:self.devId gid:self.bleDevice.deviceModel.homeId success:^(NSDictionary *dict) {
		NSLog(@"当前用户信息获取成功!");
} failure:^(NSError *error) {
		NSLog(@"当前用户信息获取失败!");
}];

蓝牙连接

蓝牙门锁需要 App 开启蓝牙后,部分功能才能正常使用。

查询蓝牙连接状态

蓝牙门锁需要 App 开启蓝牙后,部分功能才能正常使用。SDK 在正常情况下会自动连接,通常使用以下方法进行设备连接状态判断。

/// 设备和手机是否已建立蓝牙连接,如果为 NO,可以调用 autoConnect 进行连接
- (BOOL)isBLEConnected;

/// 查询设备连接状态(可判断网关是否在线)
- (BOOL)isOnline;

门锁蓝牙连接

如果查询结果显示门锁未连接蓝牙,调用此接口可以连接到门锁。

/// 如果没有连接成功或使用过程中断开,可以调用此方法进行连接
- (void)autoConnect;

蓝牙解锁和落锁

蓝牙近程解锁

用户App门锁蓝牙开启,连接上门锁单击开锁发送蓝牙开锁指令收到蓝牙开锁指令,开锁返回开锁结果处理、显示结果用户App门锁蓝牙解锁开门流程

接口说明

- (void)bleUnlock:(NSString *)lockUserId
          success:(ThingSuccessHandler)success
          failure:(ThingFailureError)failure;

参数说明

参数 说明
status 开锁还是关锁
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

    ThingSmartBLELockDevice *lock = [ThingSmartBLELockDevice deviceWithDeviceId:@"your_lock_device_id"];
    [lock bleCurrentMemberDetailWithDevId:self.devId gid:self.lock.deviceModel.homeId success:^(NSDictionary *dict) {
                NSString *bleUnlock = [dict objectForKey:@"lockUserId"];
                [self.bleLockDevice bleUnlock:bleUnlock success:^{
                    NSLog(@"开锁成功!");
                } failure:^(NSError *error) {
                    NSLog(@"开锁失败!");
                }];
            } failure:^(NSError *error) {
                NSLog(@"bleCurrentMemberDetailWithDevId failure!");
            }];

Swift:

lock.bleCurrentMemberDetail(withDevId: devId, gid: lock.deviceModel.homeId, success: { [self] dict in
    let bleUnlock = dict?["lockUserId"] as? String
    bleLockDevice.bleUnlock(bleUnlock, success: {
        print("开锁成功!")
    }, failure: { error in
        print("开锁失败!")
    })
}, failure: { error in
    print("bleCurrentMemberDetailWithDevId failure!")
});

蓝牙近程落锁

用户App门锁蓝牙开启,连接上门锁单击落锁发送蓝牙落锁指令收到蓝牙落锁指令,开锁返回落锁结果处理、显示结果用户App门锁蓝牙落锁流程

接口说明

- (void)bleManualLock:(ThingSuccessHandler)success
              failure:(ThingFailureError)failure;

参数说明

参数 说明
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

    ThingSmartBLELockDevice *lock = [ThingSmartBLELockDevice deviceWithDeviceId:@"your_lock_device_id"];
    [lock bleManualLock:^{
                NSLog(@"落锁成功!");
            } failure:^(NSError *error) {
                NSLog(@"落锁失败: %ld", error.code);
            }];

Swift:

    let lockDevice = ThingSmartBLELockDevice(deviceId: "your_lock_device_id")
    self.lock?.manualLock(withStatus: status, success: {
        print("落锁成功")
    }, failure: { (error) in
        if let e = error {
            print("落锁失败,error: \(e)")
        }
    })

蓝牙远程开关锁

门锁网关云端App用户连接单击开/关锁发送开/关锁请求下发开/关锁指令收到指令、开/关锁返回结果返回结果返回结果处理展示结果门锁网关云端App用户蓝牙落锁流程

接口说明

//远程解锁
- (void)remoteSwitchLock:(ThingSuccessBOOL)success
                 failure:(ThingFailureError)failure;
//远程关锁
- (void)manualLockWithStatus:(ThingSuccessHandler)success
                     failure:(ThingFailureError)failure;

参数说明

参数 说明
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

  ThingSmartBLELockDevice *lock = [ThingSmartBLELockDevice deviceWithDeviceId:@"your_lock_device_id"];
  [lock remoteSwitchLock:^{
              NSLog(@"远程解锁成功");
          } failure:^(NSError *error) {
              NSLog(@"远程解锁失败: %ld", error.code);
          }];

  [lock manualLockWithStatus:^{
              NSLog(@"远程落锁成功");
          } failure:^(NSError *error) {
              NSLog(@"远程落锁失败: %ld", error.code);
          }];

门锁记录

获取门锁告警记录

接口说明

- (void)getAlarmRecordListWithOffset:(int)offset
                               limit:(int)limit
                             success:(nullable void(^)(NSArray<ThingSmartLockRecordModel *> *records))success
                             failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
offset 页数
limit 条数
success 成功回调,结果为记录列表
failure 失败回调

ThingSmartLockRecordModel 数据模型

字段 类型 描述
userId NSString 成员 ID
userName NSString 用户昵称
time NSTimeInterval 发生时间,13 位时间戳
devId NSString 设备 ID
dpData NSDictionary DP 数据
tags NSInteger 标位
  • 0:表示其他
  • 1:表示劫持报警
dpsArray NSArray<NSDictionary *> 设备功能的数据组

示例代码

Objective-C:

    [self.lock getAlarmRecordListWithOffset:0 limit:50 success:^(NSArray<ThingSmartLockRecordModel *> * _Nonnull records) {
        NSLog(@"告警记录: %@", records);
    } failure:^(NSError *error) {
        NSLog(@"查询告警记录失败,error: %@", error);
    }];

Swift:

    self.lock?.getAlarmRecordList(withOffset: 0, limit: 50, success: { (records) in
        print("告警记录 \(records)")
    }, failure: { (error) in
        if let e = error {
            print("查询告警记录失败, error: \(e)")
        }
    })

获取门锁开锁记录

接口说明

- (void)getUnlockRecordListWithOffset:(int)offset
                                limit:(int)limit
                              success:(nullable void(^)(NSArray<ThingSmartBLELockRecordModel *> *records))success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
offset 页数
limit 条数
success 成功回调,结果为记录列表
failure 失败回调

示例代码

Objective-C:

    [self.lock getUnlockRecordListWithOffset:0 limit:50 success:^(NSArray<ThingSmartLockRecordModel *> * _Nonnull records) {
        NSLog(@"开锁记录: %@", records);
    } failure:^(NSError *error) {
        NSLog(@"查询开锁记录失败,error: %@", error);
    }];

Swift:

    self.lock?.getUnlockRecordList(withOffset: 0, limit: 50, success: { (records) in
        print("开锁记录 \(records)")
    }, failure: { (error) in
        if let e = error {
            print("查询开锁记录失败, error: \(e)")
        }
    })

获取门锁劫持告警记录

接口说明

- (void)getLockHijackRecordListWithDpCodes:(NSArray<NSString *> *)dpCodes
                                    offset:(NSInteger)offset
                                     limit:(NSInteger)limit
                                   success:(void(^)(NSArray<ThingSmartLockRecordModel *> *))success
                                   failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
dpCodes 劫持告警 DP code
offset 页数
limit 条数
success 成功回调,结果为记录列表
failure 失败回调

查询带筛选的新版记录(日志组件)

接口说明

- (void)getProUnlockRecordListWithDevId:(NSString *)devId
                          logCategories:(NSString *)logCategories
                                userIds:(NSString *)userIds
                    onlyShowMediaRecord:(BOOL)onlyShowMediaRecord
                              startTime:(NSInteger)startTime
                                endTime:(NSInteger)endTime
                             lastRowKey:(NSString *)lastRowKey
                                  limit:(NSInteger)limit
                                success:(ThingSuccessID)success
                                failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 页数
logCategories 日志大类
  • operation:操作日志
  • unlock_record:开门记录
  • close_record:关门记录
  • alarm_record:告警记录
userIds 需要筛选的用户 ID 列表,ID 之间以逗号(,)分隔,例如 12,13
onlyShowMediaRecord 是否仅显示带图片或者视频的记录,默认为 False,显示所有记录。
startTime 开始时间,单位为毫秒
endTime 结束时间,单位为毫秒
lastRowKey 上一页的数据 key
limit 每页数据个数
success 成功回调
failure 失败回调

返回数据字段说明

字段 类型 描述
hasNext Boolean 是否有分页
lastRowKey String 上一页的数据 Key
records List 记录列表,单个记录参考如下

单条记录

字段 类型 是否必返回 描述
logId Long 日志编号
logCategory String 日志类型
  • operation:操作日志
  • unlock_record:开门记录
  • close_record:关门记录
  • alarm_record:告警记录
logType String 日志类型,详情请参考 附录
recordType Integer 仅开门记录返回
  • 普通开门记录
  • 告警记录
unlockNameRosettaKey String 关锁记录的类型,详情请参考 附录
currentUser Boolean 是否是当前用户的记录,true表示是,非组合解锁必返回
userId String 用户编号,仅开门记录、劫持告警、操作记录返回
userName String 用户名称
memberBindableFlag Boolean 是否可以绑定到用户
unlockName String 解锁方式名称,可能为空
time Long 日志事件时间
relateDevName String 关联设备名称
relateOpMode String 关联解锁信息
data String 操作记录,数据格式定义请参考 附录
unionUnlockInfo UnionUnlockInfo 组合解锁信息
mediaInfoList List 视频和图片信息,仅可视对讲、Wi-Fi 低功耗常保活带视频或者图像的门锁有此字段,参考 MediaInfoBean

示例代码

Objective-C:

    [self.bleDevice getProUnlockRecordListWithDevId:self.bleDevice.deviceModel.devId
                                          logCategories:self.logCategories
                                                userIds:self.userIds
                                    onlyShowMediaRecord:NO
                                              startTime:self.startTime
                                                endTime:self.endTime
                                             lastRowKey:@""
                                                  limit:50
                                                success:^(id result) {
            NSLog(@"查询日志成功");
        } failure:^(NSError *error) {
            NSLog(@"查询日志失败");
        }];

解锁方式

获取成员已绑定的解锁方式列表

接口说明

- (void)getProBoundUnlockOpModeListWithDevId:(NSString *)devId
                                      userId:(NSString *)userId
                                     success:(ThingSuccessID)success
                                     failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
userId 成员 ID
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice getProBoundUnlockOpModeListWithDevId:self.bleDevice.deviceModel.devId
                                                  userId:[self.dataSource[@"userId"] stringValue]
                                                 success:^(id result) {
                NSLog(@"列表请求成功");
    } failure:^(NSError *error) {
                NSLog(@"列表请求失败");
    }];

判断是否有需要分配的开锁方式

接口说明

- (void)isProNeedAllocUnlockOpModeWithDevId:(NSString *)devId
                                    success:(ThingSuccessID)success
                                    failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice isProNeedAllocUnlockOpModeWithDevId:self.bleDevice.deviceModel.devId
                                                success:^(id result) {
                NSLog(@"接口请求成功");
    } failure:^(NSError *error) {
                NSLog(@"接口请求失败");
    }];

查询成员未绑定的解锁方式列表

接口说明

- (void)getProUnboundUnlockOpModeListWithDevId:(NSString *)devId
                                       success:(ThingSuccessID)success
                                       failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice getProUnboundUnlockOpModeListWithDevId:self.bleDevice.deviceModel.devId
                                                   success:^(id result) {
                NSLog(@"查询列表成功");
    } failure:^(NSError *error) {
                NSLog(@"查询列表失败");
    }];

开锁方式分配到人

接口说明

- (void)allocProUnlockOpModeWithDevId:(NSString *)devId
                               userId:(NSString *)userId
                            unlockIds:(NSString *)unlockIds
                              success:(ThingSuccessID)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
userId 成员 ID
unlockIds 解锁方式 ID
success 成功回调
failure 失败回调

示例代码

Objective-C:

//userId:被分配的成员 userId unlockIds:解锁方式 ID
    [self.bleDevice allocProUnlockOpModeWithDevId:self.bleDevice.deviceModel.devId
                                           userId:userId
                                        unlockIds:@[unlockId].thingsdk_JSONString
                                          success:^(id result) {
        NSLog(@"分配成功");
    } failure:^(NSError *error) {
                 NSLog(@"分配失败");
    }];

App 发起添加解锁方式

添加通用解锁方式时,需要门锁保持蓝牙连接。

云端App门锁用户确认解锁方式信息建立蓝牙连接发送添加解锁方式信息回复添加结果调用接口,设置防劫持返回结果处理、显示结果云端App门锁添加通用解锁方式流程

接口说明

- (void)addUnlockOpmodeForMemberWithMemberId:(NSString *)memberId
                                     isAdmin:(BOOL)isAdmin
                                unlockDpCode:(NSString *)unlockDpCode
                                unlockOpType:(ThingUnlockOpType)unlockOpType
                                  unlockName:(NSString *)unlockName
                               effectiveDate:(nullable NSDate *)effectiveDate
                                 invalidDate:(nullable NSDate *)invalidDate
                                       times:(int)times
                                  dataLength:(int)dataLength
                                 dataContent:(NSString *)dataContent
                                     timeout:(NSTimeInterval)timeout
                               needHijacking:(BOOL)needHijacking
                                     success:(nullable ThingSuccessString)success
                                     failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
memberId 成员编号 ID
isAdmin 是否是管理员
unlockDpCode 解锁方式对应的功能标识,详细可查看 门锁功能列表,例如卡片解锁对应 unlock_card
unlockOpType 解锁方式,可查看 ThingUnlockOpType 枚举
unlockName 解锁方式名称
effectiveDate 生效时间
invalidDate 失效时间
times 解锁方式可用次数
dataLength 数据长度,需要和数据内容长度保持一致
dataContent 数据内容
timeout 命令响应超时时间,如果是需要用户交互的,例如指纹,不用设置超时
needHijacking 是否需要设置防劫持
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock addUnlockOpmodeForMemberWithMemberId:@"00000074zg"
                                            isAdmin:NO
                                       unlockDpCode:@"unlock_password"
                                       unlockOpType:ThingUnlockOpTypePassword
                                         unlockName:@"密码 774641"
                                      effectiveDate:nil
                                        invalidDate:nil
                                              times:10
                                         dataLength:6
                                        dataContent:@"774641"
                                            timeout:6
                                      needHijacking:YES
                                            success:^(NSString *result) {
        NSLog(@"添加成功");
    } failure:^(NSError *error) {
        NSLog(@"添加失败 %@", error);
    }];

Swift:

    self.lock?.addUnlockOpmodeForMember(withMemberId: "00000074zg", isAdmin: false, unlockDpCode: "unlock_password", unlockOpType: ThingUnlockOpTypePassword, unlockName: "密码 774641", effectiveDate: nil, invalidDate: nil, times: 10, dataLength: 6, dataContent: "774641", timeout: 5, needHijacking: true, success: { (result) in
         print("添加成功")
    }, failure: { (error) in
        if let e = error {
            print("添加失败, error: \(e)")
        }
    })

App 发起更新解锁方式

修改、更新通用的解锁方式时,需要门锁保持蓝牙连接。

云端App门锁用户确认新解锁方式信息建立蓝牙连接发送更新解锁方式信息回复更新结果调用接口,设置防劫持返回结果处理、显示结果云端App门锁通用修改解锁方式流程

接口说明

- (void)modifyUnlockOpmodeForMemberWithMemberId:(NSString *)memberId
                                       opmodeId:(NSString *)opmodeId
                                        isAdmin:(BOOL)isAdmin
                                     firmwareId:(int)firmwareId
                                   unlockDpCode:(NSString *)unlockDpCode
                                   unlockOpType:(ThingUnlockOpType)unlockOpType
                                     unlockName:(NSString *)unlockName
                                  effectiveDate:(nullable NSDate *)effectiveDate
                                    invalidDate:(nullable NSDate *)invalidDate
                                          times:(int)times
                                     dataLength:(int)dataLength
                                    dataContent:(NSString *)dataContent
                                        timeout:(NSTimeInterval)timeout
                                  needHijacking:(BOOL)needHijacking
                                        success:(nullable ThingSuccessBOOL)success
                                        failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
memberId 成员编号 ID
opmodeId 开锁方式 ID,来源查询的开锁方式列表
isAdmin 是否是管理员
firmwareId 硬件 ID
unlockDpCode 解锁方式对应的功能标识,详细可查看 门锁功能列表,例如卡片解锁对应 unlock_card
unlockOpType 解锁方式,可查看 ThingUnlockOpType 枚举
unlockName 解锁方式名称
effectiveDate 生效时间
invalidDate 失效时间
times 解锁方式可用次数
dataLength 数据长度,需要和数据内容长度保持一致
dataContent 数据内容
timeout 命令响应超时时间,如果是需要用户交互的,例如指纹,不用设置超时
needHijacking 是否需要设置防劫持
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock modifyUnlockOpmodeForMemberWithMemberId:@"00000074zg"
                                              opmodeId:@"232323"
                                               isAdmin:NO
                                            firmwareId:15 //来源自开锁方式数据中的 opmodevalue
                                          unlockDpCode:@"unlock_password"
                                          unlockOpType:ThingUnlockOpTypePassword
                                            unlockName:@"密码 774641"
                                         effectiveDate:nil
                                           invalidDate:nil
                                                 times:10
                                            dataLength:6
                                           dataContent:@"774641"
                                               timeout:6
                                         needHijacking:YES
                                               success:^(NSString *result) {
        NSLog(@"更新成功");
    } failure:^(NSError *error) {
        NSLog(@"更新失败 %@", error);
    }];

Swift:

    self.lock?.modifyUnlockOpmodeForMember(withMemberId: "00000074zg", opmodeId: "232323", isAdmin: false, firmwareId: 15, unlockDpCode: "unlock_password", unlockOpType: ThingUnlockOpTypePassword, unlockName: "密码 774641", effectiveDate: nil, invalidDate: nil, times: 10, dataLength: 6, dataContent: "774641", timeout: 5, needHijacking: true, success: { (result) in
        print("更新成功")
    }, failure: { (error) in
        if let e = error {
            print("更新失败, error: \(e)")
        }
    })

App 发起删除解锁方式

接口说明

- (void)removeUnlockOpmodeForMemberWithOpmodeModel:(ThingSmartBLELockOpmodeModel *)opmodeModel
                                           isAdmin:(BOOL)isAdmin
                                      unlockDpCode:(NSString *)unlockDpCode
                                      unlockOpType:(ThingUnlockOpType)unlockOpType
                                           timeout:(NSTimeInterval)timeout
                                           success:(ThingSuccessHandler)success
                                           failure:(ThingFailureError)failure;

参数说明

参数 说明
opmodeModel 开锁方式模型
isAdmin 是否是管理员
unlockDpCode 解锁方式对应的功能标识,详细可查看 门锁功能列表,例如卡片解锁对应 unlock_card
unlockOpType 解锁方式,可查看 ThingUnlockOpType 枚举
timeout 命令响应超时时间,如果是需要用户交互的,例如指纹,不用设置超时
success 成功回调
failure 失败回调

示例代码

Objective-C:

    [self.lock removeUnlockOpmodeForMemberWithOpmodeModel:model
                                                  isAdmin:NO
                                             unlockDpCode:@"unlock_password"
                                             unlockOpType:ThingUnlockOpTypePassword
                                                  timeout:10
                                                  success:^{
        NSLog(@"删除成功");
    } failure:^(NSError *error) {
        NSLog(@"删除失败 %@", error);
    }]

Swift:

    self.lock?.removeUnlockOpmodeForMember(with: model, isAdmin: false, unlockDpCode: "unlock_password", unlockOpType: ThingUnlockOpTypePassword, timeout: 10, success: {
        print("删除成功")
    }, failure: { (error) in
        if let e = error {
            print("删除失败, error: \(e)")
        }
    })

App 发起取消录入指纹解锁方式

接口说明

- (void)cancelUnlockOpmodeForFingerWithAdmin:(BOOL)isAdmin
                                  lockUserId:(int)lockUserId
                                     success:(nullable ThingSuccessBOOL)success
                                     failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
isAdmin 是否是管理员
lockUserId 门锁上的用户 ID
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice cancelUnlockOpmodeForFingerWithAdmin:isAdmin
                                          lockUserId:self.lockUserId
                                             success:^(BOOL result) {
		NSLog(@"取消成功");
} failure:^(NSError *error) {
		NSLog(@"取消失败");
}];

查询单个解锁方式的详情

接口说明

- (void)getProUnlockOpModeDetailWithDevId:(NSString *)devId
                                 opModeId:(NSString *)opModeId
                                  success:(ThingSuccessID)success
                                  failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
opModeId 解锁方式序号
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice getProUnlockOpModeDetailWithDevId:devId
                                         opModeId:opModeId
                                          success:^(id result) {
		NSLog(@"查询成功");
} failure:^(NSError *error) {
		NSLog(@"查询失败");
}];

设置或取消劫持解锁方式

接口说明

- (void)addHijackingConfigWithDevId:(NSString *)devId
                               dpId:(NSString *)dpId
                            dpValue:(NSString *)dpValue
                            success:(ThingSuccessBOOL)success
                            failure:(nullable ThingFailureError)failure;

- (void)removeHijackingConfigWithDevId:(NSString *)devId
                                  dpId:(NSString *)dpId
                               dpValue:(NSString *)dpValue
                               success:(ThingSuccessID)success
                               failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
dpId DP ID
dpValue DP 值
success 成功回调
failure 失败回调

示例代码

Objective-C:

[self.bleDevice addHijackingConfigWithDevId:self.bleDevice.deviceModel.devId
                                       dpId:self.model.opmode
                                    dpValue:[self.dataSource[@"unlockId"] stringValue]
                                    success:^(BOOL result) {
		NSLog(@"添加劫持成功");	
} failure:^(NSError *error) {
		NSLog(@"添加劫持失败");
}];

[self.bleDevice removeHijackingConfigWithDevId:self.bleDevice.deviceModel.devId
                                          dpId:self.model.opmode
                                       dpValue:[self.dataSource[@"unlockId"] stringValue]
                                       success:^(id result) {
		NSLog(@"取消劫持成功");	
} failure:^(NSError *error) {
		NSLog(@"取消劫持失败");	
}];

开启或关闭解锁方式通知

请参考 App 发起更新解锁方式 接口。

密码管理

创建离线密码(单次、多次、清空)

接口说明

该接口适用于低版本公版门锁。

- (void)getOfflinePasswordWithDevId:(NSString *)devId
                            pwdType:(NSString *)pwdType
                           gmtStart:(NSInteger)gmtStart
                         gmtExpired:(NSInteger)gmtExpired
                            pwdName:(NSString *)pwdName
                            success:(ThingSuccessID)success
                            failure:(nullable ThingFailureError)failure;

接口说明

该接口适用于 Pro 门锁。

- (void)getProOfflinePasswordWithDevId:(NSString *)devId
                               pwdType:(NSString *)pwdType
                              gmtStart:(NSInteger)gmtStart
                            gmtExpired:(NSInteger)gmtExpired
                               pwdName:(NSString *)pwdName
                               success:(ThingSuccessID)success
                               failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
pwdType 密码类型
  • 0:多次
  • 1:单次
  • 9:清空密码
gmtStart 开始时间,如果是非多次密码,暂时设置为 0
gmtExpired 结束时间,如果是非多次密码,暂时设置为 0
pwdName 密码名称
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//离线一次性密码
[self.bleDevice getOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                            pwdType:@"1"
                                           gmtStart:0
                                         gmtExpired:0
                                            pwdName:@"离线一次性密码"
                                            success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

//低版本公版不限次数密码
[self.bleDevice getOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                            pwdType:@"0"
                                           gmtStart:effectiveTime
                                         gmtExpired:invalidTime
                                            pwdName:@"低版本公版不限次数密码"
                                            success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

//低版本公版清空码(所有)
[self.bleDevice getOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                            pwdType:@"9"
                                           gmtStart:0
                                         gmtExpired:0
                                            pwdName:@"低版本公版清空码(所有)"
                                            success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

//Pro 单次密码
[self.bleDevice getProOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                               pwdType:@"1"
                                              gmtStart:0
                                            gmtExpired:0
                                               pwdName:@"Pro 单次密码"
                                               success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

//Pro 不限次数密码
[self.bleDevice getProOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                               pwdType:@"0"
                                              gmtStart:effectiveTime
                                            gmtExpired:invalidTime
                                               pwdName:@"Pro 不限次数密码"
                                               success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

//Pro 清空码
[self.bleDevice getProOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                               pwdType:@"9"
                                              gmtStart:0
                                            gmtExpired:0
                                               pwdName:@"Pro 清空码"
                                               success:^(id result) {
                                    NSLog(@"接口成功");
        } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
        }];

获取单个离线密码的清空码

接口说明

该接口适用于低版本公版门锁。

- (void)getSingleRevokeOfflinePasswordWithDevId:(NSString *)devId
                                          pwdId:(NSInteger )pwdId
                                        success:(ThingSuccessID)success
                                        failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
pwdId 密码编号
success 接口成功回调
failure 接口失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)getProSingleRevokeOfflinePasswordWithDevId:(NSString *)devId
                                   unlockBindingId:(NSInteger )unlockBindingId
                                              name:(NSString *)name
                                           success:(ThingSuccessID)success
                                           failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
unlockBindingId 密码的授权编号
name 离线删除密码的名称
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版
[self.bleDevice getSingleRevokeOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                      pwdId:@"pwdId"
                                                    success:^(id result) {
        if (result && [result isKindOfClass:[NSDictionary class]]){
            NSString *pwdName = [result[@"pwdName"] stringValue];
            NSString *pwdValue = [result[@"pwd"] stringValue];
        }} failure:^(NSError *error) {
                        NSLog(@"接口报错");
    }];

//Pro
[self.bleDevice getProSingleRevokeOfflinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                   unlockBindingId:[dicValue[@"unlockBindingId"] integerValue]
                                                              name:@"清空码"
                                                           success:^(id result) {
            if (result && [result isKindOfClass:[NSDictionary class]]){
                NSString *pwdName = [result[@"pwdName"] stringValue];
                NSString *pwdValue = [result[@"pwd"] stringValue];
            }
        }failure:^(NSError *error) {
                        NSLog(@"接口报错");
        }];

获取生效中可以被清空的离线不限次数密码

查询单个清空码,需要选择的密码列表。

接口说明

- (void)getSingleRevokePasswordListWithDevId:(NSString *)devId
                                     success:(ThingSuccessID)success
                                     failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 接口成功回调
failure 接口失败回调

临时在线密码重复校验

接口说明

适用低版本公版门锁。

- (void)validateCustomPasswordWithDevId:(NSString *)devId
                                   name:(NSString *)name
                          effectiveTime:(NSInteger)effectiveTime
                            invalidTime:(NSInteger)invalidTime
                               password:(NSString *)password
                               schedule:(ThingSmartBLELockScheduleList *)schedule
                                success:(ThingSuccessID)success
                                failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
name 密码名称
effectiveTime 生效时间
invalidTime 失效时间
password 密码
schedule 周期
success 接口成功回调
failure 接口失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)validateProCustomPasswordWithDevId:(NSString *)devId
                                      name:(NSString *)name
                           unlockBindingId:(NSInteger)unlockBindingId
                             effectiveTime:(NSInteger)effectiveTime
                               invalidTime:(NSInteger)invalidTime
                                  password:(NSString *)password
                                  schedule:(NSString *)schedule
                                   success:(ThingSuccessID)success
                                   failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
name 密码名称
unlockBindingId 临时密码的编号(更新时必传)
effectiveTime 生效时间
invalidTime 失效时间
password 密码
schedule 周期
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版
    ThingSmartBLELockScheduleList *schedule = [[ThingSmartBLELockScheduleList alloc] init];//schedule 需要塞入自己的周期数据
    NSString *scheduleString = [schedule getJsonStringFromScheduleList];
    [self.lockDeviceService validateCustomPasswordWithDevId:devId
                                                       name:name
                                              effectiveTime:effectiveTime
                                                invalidTime:invalidTime
                                                   password:password
                                                   schedule:scheduleString
                                                    success:^(id result) {
                        NSLog(@"验证成功");
    } failure:^(NSError *error) {
                        NSLog(@"接口报错");
        }];

//Pro
    ThingSmartBLELockScheduleList *schedule = [[ThingSmartBLELockScheduleList alloc] init];//schedule 需要塞入自己的周期数据
    NSString *scheduleString = [schedule getJsonStringFromScheduleList];
    [self.lockDeviceService validateProCustomPasswordWithDevId:devId
                                                          name:name
                                               unlockBindingId:0
                                                 effectiveTime:effectiveTime
                                                   invalidTime:invalidTime
                                                      password:password
                                                      schedule:scheduleString
                                                       success:^(id result) {
                        NSLog(@"验证成功");
    } failure:^(NSError *error) {
                        NSLog(@"接口报错");
        }];

创建临时在线密码

接口说明

适用低版本公版门锁,自定义密码对应低版本公版的周期密码。

- (void)getCustomOnlinePasswordWithDevId:(NSString *)devId
                                    name:(NSString *)name
                           effectiveTime:(NSInteger)effectiveTime
                             invalidTime:(NSInteger)invalidTime
                                password:(NSString *)password
                                schedule:(ThingSmartBLELockScheduleList *)schedule
                               availTime:(NSInteger)availTime
                                      sn:(NSInteger)sn
                                 success:(ThingSuccessID)success
                                 failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
name 密码名称
effectiveTime 生效时间
invalidTime 失效时间
password 密码
schedule 周期
availTime 可用次数。
  • 0:永久
  • 1:一次性
sn 临时密码编号
success 接口成功回调
failure 接口失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)getProCustomOnlinePasswordWithDevId:(NSString *)devId
                                       name:(NSString *)name
                                   password:(NSString *)password
                              effectiveTime:(NSInteger)effectiveTime
                                invalidTime:(NSInteger)invalidTime
                                  availTime:(NSInteger)availTime
                                         sn:(NSInteger)sn
                                   schedule:(ThingSmartBLELockScheduleList *)schedule
                                    success:(ThingSuccessID)success
                                    failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
name 密码名称
password 密码
effectiveTime 生效时间
invalidTime 失效时间
availTime 可用次数
sn 临时密码编号
schedule 周期
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

        //低版本公版一次性密码
        ThingSmartBLELockScheduleList *listModel = [[ThingSmartBLELockScheduleList alloc] init];
    [self.bleDevice getCustomOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                         name:name
                                                effectiveTime:effectiveTime
                                                  invalidTime:invalidTime
                                                     password:password
                                                     schedule:listModel
                                                    availTime:1
                                                           sn:0
                                                      success:^(id result) {
                        NSLog(@"创建成功");
            } failure:^(NSError *error) {
                            NSLog(@"创建失败");
            }];

         //低版本公版周期密码
            ThingSmartBLELockScheduleList *listModel = [self.cycleView getScheduleListModel];
            [self.bleDevice getCustomOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                         name:name
                                                effectiveTime:effectiveTime
                                                  invalidTime:invalidTime
                                                     password:password
                                                     schedule:listModel
                                                    availTime:0
                                                           sn:0
                                                      success:^(id result) {
                        NSLog(@"创建成功");
            } failure:^(NSError *error) {
                                NSLog(@"创建失败");
            }];

//Pro 周期密码
    ThingSmartBLELockScheduleList *listModel = [self.cycleView getScheduleListModel];
            [self.bleDevice getProCustomOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                           name:name
                                                       password:password
                                                  effectiveTime:effectiveTime
                                                    invalidTime:invalidTime
                                                      availTime:0
                                                             sn:0
                                                       schedule:listModel
                                                        success:^(id result) {
                                NSLog(@"创建成功");
            } failure:^(NSError *error) {
                                NSLog(@"创建失败");
            }];

修改临时在线密码的信息或者时效

接口说明

该接口适用于低版本公版门锁。

- (void)updateOnlinePasswordWithDevId:(NSString *)devId
                                 name:(NSString *)name
                             password:(NSString *)password
                                pwdId:(NSInteger )pwdId
                        effectiveTime:(NSInteger)effectiveTime
                          invalidTime:(NSInteger)invalidTime
                             schedule:(ThingSmartBLELockScheduleList *)schedule
                                   sn:(NSInteger)sn
                            availTime:(NSInteger)availTime
                              success:(ThingSuccessID)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 产品 ID
name 密码名称
password 密码
pwdId 密码编号
effectiveTime 生效时间
invalidTime 失效时间
schedule 周期
sn 硬件 ID
availTime 可用次数
success 接口成功回调
failure 接口失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)updateProOnlinePasswordWithDevId:(NSString *)devId
                                    name:(NSString *)name
                                password:(NSString *)password
                         unlockBindingId:(NSInteger )unlockBindingId
                           effectiveTime:(NSInteger)effectiveTime
                             invalidTime:(NSInteger)invalidTime
                                   phase:(NSInteger)phase
                                schedule:(ThingSmartBLELockScheduleList *)schedule
                                      sn:(NSInteger)sn
                                 success:(ThingSuccessID)success
                                 failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
productId 产品 ID
name 密码名称
password 密码
unlockBindingId 临时密码序号
effectiveTime 生效时间
invalidTime 失效时间
phase
  • 2:正常
  • 4:冻结
schedule 周期
sn 硬件 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版
ThingSmartBLELockScheduleList *listModel = [[ThingSmartBLELockScheduleList alloc] init];
            [self.bleDevice updateOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                     name:name
                                                 password:@""
                                                    pwdId:pwdId
                                            effectiveTime:effectiveTime
                                              invalidTime:invalidTime
                                                 schedule:listModel
                                                       sn:sn
                                                availTime:1
                                                  success:^(id result) {
                            NSLog(@"更新成功");
            } failure:^(NSError *error) {
                            NSLog(@"更新失败");
            }];
//Pro
ThingSmartBLELockScheduleList *listModel = [[ThingSmartBLELockScheduleList alloc] init];
            [self.bleDevice updateProOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                        name:name
                                                    password:@""
                                             unlockBindingId:unlockBindingId
                                               effectiveTime:effectiveTime
                                                 invalidTime:invalidTime
                                                       phase:2
                                                    schedule:listModel
                                                          sn:1
                                                     success:^(id result) {
                            NSLog(@"更新成功");
            } failure:^(NSError *error) {
                            NSLog(@"更新失败");
            }];

删除在线临时密码

接口说明

该接口适用于低版本公版门锁。

- (void)deleteOnlinePasswordWithDevId:(NSString *)devId
                                pwdId:(NSInteger )pwdId
                                   sn:(NSInteger)sn
                              success:(ThingSuccessID)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
productId 产品 ID
pwdId 密码编号
sn 硬件 ID
success 接口成功回调
failure 接口失败回调

接口说明

该接口适用于 Pro 门锁。

- (void)deleteProOnlinePasswordWithDevId:(NSString *)devId
                         unlockBindingId:(NSInteger )unlockBindingId
                                      sn:(NSInteger)sn
                                 success:(ThingSuccessID)success
                                 failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
productId 产品 ID
unlockBindingId 临时密码序号
sn 硬件 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版
[self.bleDevice deleteOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                                    pwdId:pwdId
                                                       sn:sn
                                                  success:^(id result) {
                            NSLog(@"删除成功");
        } failure:^(NSError *error) {
                            NSLog(@"删除失败");
        }];
//Pro
[self.bleDevice deleteProOnlinePasswordWithDevId:self.bleDevice.deviceModel.devId
                                             unlockBindingId:unlockBindingId
                                                          sn:sn
                                                     success:^(id result) {
                            NSLog(@"删除成功");
        } failure:^(NSError *error) {
                            NSLog(@"删除失败");
        }];

获取离线密码列表(低版本)

该接口适用于低版本公版。

接口说明

- (void)getOfflinePasswordListWithDevId:(NSString *)devId
                                pwdType:(NSString *)pwdType
                                 status:(NSInteger)status
                                 offset:(NSInteger)offset
                                  limit:(NSInteger)limit
                                success:(ThingSuccessID)success
                                failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
pwdType 密码类型
  • 0:多次使用的密码
  • 1:单次使用的密码
  • 8:删除单个的密码
  • 9:清空码
status 密码状态
  • 1:有效
  • 0:无效
offset 页码
limit 记录数,默认 50 条
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版查询离线一次性密码
[self.bleDevice getOfflinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                    pwdType:@"1"
                                                     status:1
                                                     offset:0
                                                      limit:20
                                                    success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];
//低版本公版查询离线不限次数密码
[self.bleDevice getOfflinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                    pwdType:@"0"
                                                     status:1
                                                     offset:0
                                                      limit:20
                                                    success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];

//低版本公版查询清空码(所有)列表
[self.bleDevice getOfflinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                    pwdType:@"9"
                                                     status:1
                                                     offset:0
                                                      limit:40
                                                    success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];

//低版本公版查询清空码(单个)列表
[self.bleDevice getOfflinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                    pwdType:@"9"
                                                     status:1
                                                     offset:0
                                                      limit:20
                                                    success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];

获取临时在线密码列表(低版本)

该接口适用于低版本公版。

接口说明

- (void)getOnlinePasswordListWithDevId:(NSString *)devId
                             availTime:(NSInteger)availTime
                               success:(ThingSuccessID)success
                               failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
availTime 可用次数
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//低版本公版在线一次性密码列表
[self.bleDevice getOnlinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                 availTime:1
                                                   success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];
//低版本公版在线周期性密码列表
[self.bleDevice getOnlinePasswordListWithDevId:self.bleDevice.deviceModel.devId
                                                 availTime:0
                                                   success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];

获取密码列表

该接口适用于 Pro 门锁。

接口说明

- (void)getProPasswordListWithDevId:(NSString *)devId
                          authTypes:(NSArray *)authTypes
                            success:(ThingSuccessID)success
                            failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
authTypes 授权类型
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

//查询在线自定义密码列表
[self.bleDevice getProPasswordListWithDevId:self.bleDevice.deviceModel.devId
                                              authTypes:@[@"LOCK_TEMP_PWD"]
                                                success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];
//查询离线限时、一次性、清空码密码列表
[self.bleDevice getProPasswordListWithDevId:self.bleDevice.deviceModel.devId
                                              authTypes:@[@"LOCK_OFFLINE_TEMP_PWD"]
                                                success:^(id result) {
            NSLog(@"查询列表成功");
        } failure:^(NSError *error) {
            NSLog(@"查询列表失败");
        }];

创建动态密码

接口说明

- (void)getLockDynamicPasswordWithSuccess:(nullable ThingSuccessString)success
                                  failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
success 接口成功回调,返回结果为对应查询的动态密码
failure 接口失败回调

示例代码

Objective-C:

    ThingSmartBLELockDevice *lock = [ThingSmartBLELockDevice deviceWithDeviceId:@"your_lock_device_id"];
    [lock getLockDynamicPasswordWithSuccess:^(NSString *result) {
        NSLog(@"动态密码查询结果 %@", result);
    } failure:^(NSError *error) {
        NSLog(@"error %@", error);
    }];

Swift:

    let lockDevice = ThingSmartBLELockDevice(deviceId: "your_lock_device_id")
    lockDevice?.getLockDynamicPassword(success: { (pwd) in
        print("动态密码查询结果 \(pwd)")
    }, failure: { (error) in
        if let e = error {
            print("error \(e)")
        }
    })

获取密码进制类型

查询面板配置信息,包含密码进制类型等。

接口说明

- (void)getLockDeviceConfigWithProductId:(NSString *)productId
                                 options:(NSString *)options
                                 success:(ThingSuccessID)success
                                 failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
productId 产品 ID
options 查询项,包括 uiContentcloudDppowerCode
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

   [self.bleDevice getLockDeviceConfigWithProductId:self.bleLockDevice.deviceModel.productId
                                                     options:@"uiContent,cloudDp,powerCode"
                                                     success:^(id result) {
                                    NSLog(@"接口成功");
            } failure:^(NSError *error) {
                                    NSLog(@"接口报错");
            }];

门锁设置

查询远程开门开关

接口说明

- (void)fetchRemoteUnlockTypeWithDevId:(NSString *)devId
                               success:(nullable ThingSuccessID)success
                               failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice fetchRemoteUnlockTypeWithDevId:self.bleDevice.deviceModel.devId
                                           success:^(id result) {
        NSLog(@"查询远程开门开关状态成功 %@", result);
    } failure:^(NSError *error) {
        NSLog(@"查询远程开门开关状态失败 %@", error);
    }];

设置远程开门开关

接口说明

- (void)setRemoteUnlockTypeWithDevId:(NSString *)devId
                             propKvs:(NSString *)propKvs
                             success:(ThingSuccessID)success
                             failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
propKvs 键值对,键(key)为 UNLOCK_PHONE_REMOTE
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

NSString *dataStr = @"{\"UNLOCK_PHONE_REMOTE\":\"true\"}";
if (!value){
    dataStr = @"{\"UNLOCK_PHONE_REMOTE\":\"false\"}";
}
[self.bleDevice setRemoteUnlockTypeWithDevId:self.bleDevice.deviceModel.devId
                                     propKvs:dataStr
                                     success:^(id result) {
    NSLog(@"设置远程开门开关成功 %@", result);
} failure:^(NSError *error) {
    NSLog(@"设置远程开门开关失败 %@", error);
}];

查询谷歌语音密码开关

接口说明

- (void)fetchRemoteVoiceUnlockWithDevId:(NSString *)devId
                                success:(ThingSuccessID)success
                                failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice fetchRemoteVoiceUnlockWithDevId:self.bleDevice.deviceModel.devId
                                        success:^(id result) {
      NSLog(@"查询音箱密码开启状态成功 %@", result);
} failure:^(NSError *error) {
      NSLog(@"查询音箱密码开启状态失败 %@", error);
}];

设置谷歌语音密码

接口说明

- (void)setRemoteVoiceUnlockWithDevId:(NSString *)devId
                                 open:(BOOL)open
                                  pwd:(NSString *)pwd
                              success:(ThingSuccessID)success
                              failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
open 开关状态
pwd 密码
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice setRemoteVoiceUnlockWithDevId:self.bleDevice.deviceModel.devId
                                             open:YES
                                              pwd:pwd
                                          success:^(id result) {
            NSLog(@"谷歌语音密码设置成功 %@", result);
} failure:^(NSError *error) {
            NSLog(@"谷歌语音密码设置失败 %@", error);
}];

下发门锁设置 DP

使用 设备控制 相关方法。

同步数据

同步门锁随机数、配件和记录

App 启动后,设备在线时,执行一次。用于同步离线密码时间、门锁解锁随机数、查询门锁记录等。若未执行,将无法解锁门锁。

接口说明

- (void)publishSyncBatchDataSuccess:(ThingSuccessHandler)success
                            failure:(ThingFailureError)failure;

参数说明

参数 说明
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice publishSyncBatchDataSuccess:^{
    NSLog(@"数据下发成功");
} failure:^(NSError *error) {
    NSLog(@"数据下发失败");
}];

查询同步数据内容

该方法是查询 publishSyncBatchData 调用方法的云端数据内容,并未与设备交互。

接口说明

- (void)getSyncBatchDataWithDevId:(NSString *)devId
                          success:(ThingSuccessID)success
                          failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

[self.bleDevice getSyncBatchDataWithDevId:self.devId
                                  success:^(id result) {
    NSLog(@"数据查询成功");
} failure:^(NSError *error) {
    NSLog(@"数据查询失败");
}];

同步解锁方式

接口说明

- (void)syncDataWithDevId:(NSString *)devId
                    dpIds:(NSArray<NSString *> *)dpIds
                  success:(ThingSuccessID)success
                  failure:(nullable ThingFailureError)failure;

参数说明

参数 说明
devId 设备 ID
dpIds 需要同步的解锁方式类型列表,值为一个数组数字
success 接口成功回调
failure 接口失败回调

示例代码

Objective-C:

  [self.bleDevice syncDataWithDevId:self.bleDevice.deviceModel.devId
                              dpIds:@[@"12",@"13"]
                            success:^(id result) {
        NSLog(@"同步成功");
  } failure:^(NSError *error) {
        NSLog(@"同步失败");
  }];

附录

关锁记录类型

对返回的操作记录进行解析。

类型 说明
HISTORY_LOCK_UNDEFINED 未定义的关锁类型
HISTORY_LOCK_VOICE_REMOTE 远程语音开门
HISTORY_LOCK_APP_REMOTE 远程手机开门
HISTORY_LOCK_AUTO 自动落锁关锁
HISTORY_LOCK_LOCAL_MANUAL 本地手动落锁
HISTORY_LOCK_FITTINGS 配件关锁
HISTORY_LOCK_App App 长按关锁
HISTORY_LOCK_GEO_FENCE 地理围栏关锁

操作记录数据格式

对返回的操作记录 根据不同类型解析不同数据。

功能 数据定义
设备绑定 [<操作人名称>, <门锁名称>]
临时密码 [<临时密码名称>, <生效时间>, <失效时间>, <周期设置(支持多组-公版只有一组)[<是否全天有效>, <生效分钟>, <失效分钟>, <工作日>, <时区>]]
用户时效
(支持多组)
[<"被修改时效的人",是否永久>, <生效时间>, <失效时间>, <周期设置(支持多组-公版只有一组)[是否全天有效>, <生效分钟>, <失效分钟>, <时区]>]
如果非永久,则不包含
解锁方式新增或移除 [<被添加人的用户编号>, <被添加人的用户名称>, <硬件解锁方式名称>, <类型-门卡(标准 DP)>]
通信模组插拔事件 [<模组类型>]1 为低功耗蓝牙搭配 NB-IoT 模组
离线密码获取 [<离线密码名称,生效时间,失效时间,离线密码类型]>],离线密码类型:
  • 0:多次密码
  • 1:单次密码
  • 8:清除单个密码
  • 9:清空所有已使用的密码
离线密码名称修改 [<原始名称>, <修改后的名称>, <密码类型>]
解锁记录 "1",解锁方式 ID

新版日志类型定义

类型 说明
dev_bind 设备绑定
member_schedule_update 成员时效修改
unlock_add 开锁方式增加
unlock_del 开锁方式删除
temp_pwd_create 临时密码增加
temp_pwd_del 临时密码删除
temp_pwd_meta_update 临时密码时效修改
temp_pwd_name_update 临时密码名称修改
offline_pwd_achieve 多次离线密码获取
offline_pwd_clear_achieve 清空所有离线密码获取
offline_pwd_clear_single_achieve 清空单个离线密码获取
offline_pwd_name_update 离线临时密码名称更新
unlock_ble 按键/蓝牙解锁
unlock_password 普通密码解锁
unlock_temporary 临时密码解锁
unlock_dynamic 动态密码解锁
unlock_offline_pd 离线密码解锁
unlock_offline_clear 离线密码清空所有上报
unlock_offline_clear_single 离线密码清空单个上报
unlock_fingerprint 指纹解锁
unlock_card 门卡解锁
unlock_key 机械钥匙解锁
unlock_face 人脸开锁
unlock_eye 虹膜解锁
unlock_hand 掌纹解锁
unlock_finger_vein 指静脉解锁
unlock_double 组合开锁(不带开门人)
unlock_double_kit 组合开锁(带开门人)
alarm_lock 告警
hijack 劫持
lock_record 关锁记录
unlock_record_check 配件记录
unlock_phone_remote 手机远程开门记录
unlock_app 旧版手机开门记录
unlock_voice_remote 音箱开门记录
door_opened 门被打开
open_inside 门从内侧打开
timer_opened 定时器开已执行
timer_closed 定时器关已执行
dev_communication_module_add 门锁插入或拔出模组

门锁本地 DP 设置操作标准 DP

类型 说明
arming_switch 离家布防
unlock_switch 多重验证
automatic_lock 自动落锁
auto_lock_time 落锁延迟时间
verify_lock_switch 上锁校验开关
do_not_disturb 勿扰模式
special_control 特殊控制
special_function 特殊功能
beep_volume 导航音量

错误码

错误码 说明
4000 产品定义错误
4001 用户名错误
4002 时间错误
4003 设备处理超时
4004 设备未连接

Demo 示例

更多信息,参考 Demo 示例