Gateway Management

Last Updated on : 2024-11-22 02:19:32download

Get the list of added gateways

API description

+ (void)getGatewayDeviceListWithSiteId:(long long)siteId
                              pageSize:(NSInteger)pageSize
                               startId:(NSInteger)startId
                               success:(ThingLockDeviceListSuccess)success
                               failure:(ThingFailureError)failure;

Parameters

Parameter Description
pageNo The page number.
siteId The site ID.
pageSize The number of items returned per page.
startId The pagination cursor. Pass 0 for the first request. On subsequent requests, its value is the lastId returned in the previous response.
success The success callback.
failure The failure callback.

Example

[ThingResidenceSiteManager getGatewayDeviceListWithSiteId:siteId
                                                 pageSize:20
                                                  startId:self.lastIndex
                                                  success:^(NSArray<NSString *> * _Nullable deviceIdList, NSInteger lastIndex) {

} failure:^(NSError *error) {

}];

Get the list of bound sub-devices

API description

+ (void)getSubDeviceListWithGatewayId:(NSString *)gatewayId
                             pageSize:(NSInteger)pageSize
                              startId:(NSInteger)startId
                              success:(ThingLockDeviceListSuccess)success
                              failure:(ThingFailureError)failure;

Parameters

Parameter Description
gatewayId The gateway ID.
pageSize The number of items returned per page.
startId The pagination cursor. Pass 0 for the first request. On subsequent requests, its value is the lastId returned in the previous response.
success The success callback.
failure The failure callback.

Example

[ThingLockGateway getSubDeviceListWithGatewayId:self.devId
                                       pageSize:20
                                        startId:self.lastIndex
                                        success:^(NSArray<NSString *> * _Nullable deviceIdList, NSInteger lastIndex) {

} failure:^(NSError *error) {

}];

Get the list of Bluetooth sub-devices for binding

API description

+ (void)getUnbinedDeviceListWithSiteId:(long long)siteId
                              pageSize:(NSInteger)pageSize
                               startId:(NSInteger)startId
                               success:(ThingLockDeviceListSuccess)success
                               failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
pageSize The number of items returned per page.
startId The pagination cursor. Pass 0 for the first request. On subsequent requests, its value is the lastId returned in the previous response.
success The success callback.
failure The failure callback.

Example

[ThingLockGateway getUnbinedDeviceListWithSiteId:SiteManager.shared.siteId
                                        pageSize:20
                                        startId:self.lastIndex
                                        success:^(NSArray<NSString *> * _Nullable deviceIdList, NSInteger lastIndex) {

} failure:^(NSError *error) {

}];

When the Bluetooth gateway is associating with a sub-device, this method returns the list of Bluetooth locks not yet bound with a gateway in the current site.

Bluetooth gateway binds with a sub-device

API description

+ (void)bindSubDeviceWithGatewayId:(NSString *)gatewayId
                         devIdList:(NSArray<NSString *> *)devIdList
                           success:(ThingSuccessID)success
                           failure:(ThingFailureError)failure;

Parameters

Parameter Description
gatewayId The gateway ID.
devIdList The list of device IDs to bind.
success The success callback.
failure The failure callback.

Example

[ThingLockGateway bindSubDeviceWithGatewayId:self.devId
                                   devIdList:@[devId]
                                     success:^(id result) {

} failure:^(NSError *error) {

}];

Bluetooth gateway unbinds from a sub-device

API description

+ (void)unbindSubDeviceWithGatewayId:(NSString *)gatewayId
                           devIdList:(NSArray<NSString *> *)devIdList
                             success:(ThingSuccessID)success
                             failure:(ThingFailureError)failure;

Parameters

Parameter Description
gatewayId The gateway ID.
devIdList The list of device IDs to unbind.
success The success callback.
failure The failure callback.

Example

[ThingLockGateway unbindSubDeviceWithGatewayId:self.devId
                                     devIdList:@[devId]
                                       success:^(id result) {

} failure:^(NSError *error) {

}];

Rename a gateway

API description

- (void)updateName:(NSString *)name
           success:(nullable ThingSuccessHandler)success
           failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
name The name of the gateway.
success The success callback.
failure The failure callback.

Example

ThingSmartDevice *device = [ThingSmartDevice deviceWithDeviceId:self.devId];
[device updateName:newName success:^{

} failure:^(NSError *error) {

}];