更新时间:2024-03-28 01:35:03下载pdf
ThingLightingArea 定义了一个具体区域的属性和方法,提供诸如区域群控和设备分区等功能。
需要查询区域层级结构时调用该接口。
接口说明
- (void)getAreaLevelsWithNeedUnassignedArea:(BOOL)needUnassignedArea
                             needPublicArea:(BOOL)needPublicArea
                                    success:(nullable void(^)(NSArray <ThingLightingAreaModel *> *areas, NSInteger totalRoomDeviceCount))success
                                    failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| needUnassignedArea | 是否需要未分区区域信息 | 
| needPublicArea | 是否需要公共区域信息 | 
| success | 成功回调,可选 | 
| failure | 失败回调,可选 | 
示例代码
Objective-C:
ThingLightingProject *project = [ThingLightingProject projectWithProjectId:currentProjectId];
[project getAreaLevelsWithNeedUnassignedArea:YES
                              needPublicArea:YES
                                     success:^(NSArray <ThingLightingAreaModel *> *areas, NSInteger totalRoomDeviceCount) {
  NSLog(@"success");
} failure:^(NSError *error) {
  NSLog(@"failure");
}];
需要查询一级区域时调用该接口。
接口说明
- (void)getAreaListWithSuccess:(nullable void(^)(NSArray <ThingLightingAreaModel *> *areas))success
                       failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调,可选 | 
| failure | 失败回调,可选 | 
示例代码
Objective-C:
ThingLightingProject *project = [ThingLightingProject projectWithProjectId:currentProjectId];
[project getAreaListWithSuccess:^(NSArray <ThingLightingAreaModel *> *areas) {
  NSLog(@"success");
} failure:^(NSError *error) {
  NSLog(@"failure");
}];
室内项目和停车场项目创建子区域时,需要调用该接口。
接口说明
+ (void)createAreaWithProjectId:(long long)projectId
                  currentAreaId:(long long)currentAreaId
                           name:(NSString *)name
                      roomLevel:(NSInteger)roomLevel
                        success:(nullable ThingSuccessID)success
                        failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| projectId | 项目 ID,必填 | 
| currentAreaId | 当前区域的 ID。若没有,可自定义 ID 为新区域的父级区域,必填 | 
| name | 区域名称,必填 | 
| roomLevel | 区域层级,可以通过 ThingLightingProjectManager类的getSpaceAttributesWithProjectId方法查询,必填 | 
| success | 成功回调,可选 | 
| failure | 失败回调,可选 | 
示例代码
Objective-C:
[ThingLightingAreaManager createAreaWithProjectId:123
                                   currentAreaId:456
                                            name:@"area name"
                                       roomLevel:1
                                         success:^(id result) {
        NSLog(@"success");
    } failure:^(NSError *error) {
        NSLog(@"failure");
    }];
户外项目创建子区域时,需要调用该接口。
接口说明
不同于创建室内区域方法,可以保存区域的地理位置。
+ (void)createAreaWithProjectId:(long long)projectId
                  currentAreaId:(long long)currentAreaId
                           name:(NSString *)name
                      roomLevel:(NSInteger)roomLevel
                      longitude:(double)longitude
                       latitude:(double)latitude
                        address:(nullable NSString *)address
                        success:(nullable ThingSuccessID)success
                        failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| projectId | 项目 ID,必填 | 
| currentAreaId | 当前区域的 ID。若没有,可自定义 ID 为新区域的父级区域,必填 | 
| name | 区域名称,必填 | 
| roomLevel | 区域层级,可以通过 ThingLightingProjectManager类的getSpaceAttributesWithProjectId方法查询,必填 | 
| longitude | 经度,可选 | 
| latitude | 纬度,可选 | 
| address | 区域地址,可选 | 
| success | 成功回调,可选 | 
| failure | 失败回调,可选 | 
示例代码
Objective-C:
[ThingLightingAreaManager createAreaWithProjectId:123
                                   currentAreaId:456
                                            name:@"area name"
                                       roomLevel:1
                                       longitude:-1
                                        latitude:-1
                                         address:@""
                                         success:^(id result) {
        NSLog(@"success");
    } failure:^(NSError *error) {
        NSLog(@"failure");
    }];
从云端查询子区域列表,包含区域信息和区域下的群组列表信息。
接口说明
- (void)getSubAreaListWithSuccess:(void(^)(NSArray <ThingLightingAreaModel *> *areas))success
                          failure:(ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调,并返回子区域的列表 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area getSubAreaListWithSuccess:^(NSArray<ThingLightingAreaModel *> * _Nonnull areas) {
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
从云端查询当前区域信息,包含子区域列表信息。
接口说明
- (void)getAreaInfoWithSuccess:(void(^)(ThingLightingAreaModel *))success
                       failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调,并返回当前区域的 areaModel | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area getAreaInfoWithSuccess:^(ThingLightingAreaModel * _Nonnull areaModel) {
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
接口说明
@property (nonatomic, assign) long long gId;
示例代码
Objective-C:
    ThingLightingArea *area = [ThingLightingArea areaWithAreaId:0 projectId:0];
    long long gid = area.areaModel.gId;
接口说明
- (void)getParentAreaWithSuccess:(nullable void(^)(ThingLightingAreaModel * _Nullable parentAreaModel))success
                         failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area getParentAreaWithSuccess:^(ThingLightingAreaModel * _Nullable parentAreaModel) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
接口说明
- (void)updateAreaInfoWithName:(NSString *)name
                       success:(nullable ThingSuccessHandler)success
                       failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| name | 区域名称 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area updateAreaInfoWithName:@"area name" success:^{
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
接口说明
- (void)updateAreaInfoWithName:(NSString *)name
                     longitude:(double)longitude
                      latitude:(double)latitude
                       address:(nullable NSString *)address
                       success:(nullable ThingSuccessHandler)success
                       failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| name | 区域名称 | 
| longitude | 经度 | 
| latitude | 纬度 | 
| address | 区域地址 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area updateAreaInfoWithName:@"area name" longitude:-1 latitude:-1 address:@"" success:^{
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
接口说明
- (void)deleteWithSuccess:(ThingSuccessHandler)success
                  failure:(ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area deleteWithSuccess:^{
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
接口说明
具体流程:
首先筛选出本地直连设备。如果有本地直连设备,先进行本地直连设备的操作。
如果还剩下非直接设备,请求云端将设备分配到区域。
- (void)transferDevicesWithDeviceIds:(NSArray<NSString *> *)devIds
                            success:(void (^ _Nullable)(NSArray<NSString *> * successDevIds, NSArray<NSString *> * failedDevIds))success
                            failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 需要添加的设备 ID 列表 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area transferDevicesWithDeviceIds:deviceIds success:^(NSArray<NSString *> * _Nonnull successDevIds, NSArray<NSString *> * _Nonnull failedDevIds) {
    NSLog(@"success");
} failure:^(NSError *error) {
    NSLog(@"failure");
}];
具体流程:
接口说明
- (void)joinGroupWithDeviceIds:(NSArray<NSString *> *)devIds
                       success:(nullable void(^)(NSArray<NSString *> *successDevIds, NSArray<NSString *> *failedDevIds))success
                       failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 设备 ID 数组 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area joinGroupWithDeviceIds:@[id] success:^(NSArray<NSString *> * _Nonnull successDevIds, NSArray<NSString *> * _Nonnull failedDevIds) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
具体流程:
接口说明
- (void)removeDeviceWithDeviceIds:(NSArray<NSString *> *)devIds
                          success:(nullable void(^)(NSArray<NSString *> *successDevIds, NSArray<NSString *> *failedDevIds))success
                          failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 设备 ID 数组 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area removeDeviceWithDeviceIds:@[id] success:^(NSArray<NSString *> * _Nonnull successDevIds, NSArray<NSString *> * _Nonnull failedDevIds){
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
如果暂时无需将设备分区,可以先将设备分配到未分区中。
接口说明
+ (void)addDeviceToUnassignedZone:(NSArray<NSString *> *)devIds
                        projectId:(long long)projectId
                          success:(nullable ThingSuccessID)success
                          failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 设备 ID 数组 | 
| projectId | 项目 ID | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area addDeviceToUnassignedZone:@[id] projectId:projectId success:^(id result) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
从云端查询区域设备分类信息,用于查询设备列表时进行筛选。
接口说明
- (void)fetchSummaryWithSuccess:(nullable void (^)(NSArray<ThingLightingDeviceSummaryModel *> *summaryList))success
                        failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area fetchSummaryWithSuccess:@[id] projectId:projectId success:^(NSArray<ThingLightingDeviceSummaryModel *> * _Nonnull summaryList) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
接口说明
- (void)updateSummaryWithSuccess:(nullable ThingSuccessList)success
                         failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area updateSummaryWithSuccess:^(NSArray *list) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
该接口只是将设备加入区域,设备并未进入群组。
接口说明
- (void)addLocalMeshWithDeviceIds:(NSArray<NSString *> *)devIds
                          success:(nullable ThingSuccessHandler)success
                          failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 设备 ID 数组 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area addLocalMeshWithDeviceIds@[devId] success:^(void) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
接口说明
查询当前区域下的设备列表,支持分页。
- (void)getDeviceListWithOffsetKey:(NSString *)offsetKey
                               tag:(NSString *)tag
                           success:(nullable void(^)(NSArray<ThingSmartDeviceModel *> *devices, NSString *nextOffsetKey, BOOL end))success
                           failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| offsetKey | 分页页码 | 
| tag | 设备分类 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area getDeviceListWithOffsetKey:@"1" tag:@"summary" success:^(NSArray<ThingSmartDeviceModel *> *devices, NSString *nextOffsetKey, BOOL end) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
接口说明
- (void)fetchLocalMeshDeviceListWithDevIds:(NSArray<NSString *> *)devIds
                                   success:(nullable void(^)(NSArray<ThingSmartDeviceAssignedModel *> *array))success
                                   failure:(nullable ThingFailureError)failure;
参数说明
| 参数 | 说明 | 
|---|---|
| devIds | 设备 ID 数组 | 
| success | 成功回调 | 
| failure | 失败回调 | 
示例代码
Objective-C:
[self.area fetchLocalMeshDeviceListWithDevIds:@[devId] success:^(NSArray<ThingSmartDeviceAssignedModel *> *array) {
    NSLog(@"success");
} failure:^(NSError *error){
    NSLog(@"failure");
}];
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈