查询设备功能历史上报⽇志

更新时间:2024-04-03 06:08:38下载pdf

您可以查询设备功能最近的历史上报⽇志,目前只能查询近 7 天的数据。

查询设备操作日志

查询设备功能的历史上报日志,帮助您了解设备在某段时间内的操作历史。

方法签名

- (void)queryDeviceOperateLogWithDpIds:(NSArray *)dpIds
                                offset:(NSInteger)offset
                                 limit:(NSInteger)limit
                             startTime:(NSDate *)startTime
                               endTime:(NSDate *)endTime
                                 isASC:(BOOL)isASC
                               success:(ThingSuccessID)success
                               failure:(ThingFailureError)failure;

参数说明

参数 类型 描述 是否必填
dpIds NSArray 要查询的设备功能,即 DP(Data Point),例如 @[@“1”, @“2”]
offset NSInteger 分页偏移量
limit NSInteger 分页大小, 指返回结果一页的数据条数
startTime NSDate 设备上报的时间,查询起始时间
endTime NSDate 设备上报的时间,查询截止时间
isASC BOOL 按时间排序方式:
  • YES:升序排列
  • NO:降序排列,默认值
success ThingSuccessID block 成功时的回调
failure ThingFailureError block 失败时的回调

参数中 offsetlimit 取值的总和不能超过 1000。

调用示例

Objective-C

NSArray *dpIds = @[@"1", @"2"];
NSInteger offset = 0;
NSInteger limit = 10; // The sum of the values of offset and limit cannot exceed 1000.
NSDate *startTime = nil; // Use actual date if available
NSDate *endTime = nil; // Use actual date if available
BOOL isASC = NO;

ThingSmartDevice *device = [[ThingSmartDevice alloc] init];
[device queryDeviceOperateLogWithDpIds:dpIds offset:offset limit:limit startTime:startTime endTime:endTime isASC:isASC success:^(id result) {
    NSLog(@"Success: %@", result);
} failure:^(NSError *error) {
    NSLog(@"Error: %@", error);
}];

Swift

let dpIds: [String] = ["1", "2"]
let offset: Int = 0
let limit: Int = 10 // The sum of the values of offset and limit cannot exceed 1000.
let startTime: Date? = nil // Use actual date if available
let endTime: Date? = nil // Use actual date if available
let isASC: Bool = false

let device = ThingSmartDevice()
device.queryDeviceOperateLog(withDpIds: dpIds, offset: offset, limit: limit, startTime: startTime, endTime: endTime, isASC: isASC, success: { result in
    print("Success: \(result)")
}, failure: { error in
    print("Error: \(error)")
})