Last Updated on : 2024-03-04 07:31:43
You can query the recent historical logs of reported data points (DPs). Currently, you can query only the data of the past 7 days.
Query the historical logs of reported DPs, helping you understand the operation history of the device within a certain period of time.
- (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;
Parameter | Type | Description | Mandatory |
---|---|---|---|
dpIds | NSArray | The device functions to be queried, i.e., data point (DP), for example, @[@“1”, @“2”]. | Yes |
offset | NSInteger | Pagination offset. | Yes |
limit | NSInteger | Page size, the number of results to be returned per page. | Yes |
startTime | NSDate | The reporting time of the device, the query start time. | No |
endTime | NSDate | The reporting time of the device, the query end time. | No |
isASC | BOOL | Order by time:
|
No |
success | ThingSuccessID block | The success callback. | Yes |
failure | ThingFailureError block | The failure callback. | Yes |
Objective-C
NSArray *dpIds = @[@"1", @"2"];
NSInteger offset = 0;
NSInteger limit = 10;
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
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)")
})
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback