Last Updated on : 2024-06-03 08:14:45download
A laser robot vacuum transfers cloud-stored data over Message Queuing Telemetry Transport (MQTT). Maps and cleaning routes are stored as files in the cloud. Multiple cloud storage features are supported: get cloud storage configurations, receive real-time notifications of finished file uploading, and download files.
We recommend that you use peer-to-peer (P2P) capabilities of robot vacuums to get real-time notifications of finished file uploading.
All robot vacuum features are implemented with the class ThingSmartSweeperDevice
that must be initialized with the device ID. An incorrect device ID might cause failed initialization. In this case, nil
will be returned.
Class name | Description |
---|---|
ThingSmartSweeperDevice | The class of Tuya-enabled robot vacuums. |
Returns cloud storage configurations from the cloud.
- (void)initCloudConfigWithSuccess:(void (^)(NSString *bucket))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Class name | Description |
---|---|
success | The success callback. The bucket where a file is stored is returned. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice initCloudConfigWithSuccess:^(NSString * _Nonnull bucket) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.initCloudConfig(success: { (bucket) in
}, failure: { (error) in
})
The bucket location is valid within a limited period. After it expires, call the following API method to update cloud configurations:
- (void)updateCloudConfigWithSuccess:(void (^)(NSString *bucket))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Class name | Description |
---|---|
success | The success callback. The bucket where a file is stored is returned. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice updateCloudConfigWithSuccess:^(NSString * _Nonnull bucket) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.updateCloudConfig(success: { (bucket) in
}, failure: { (error) in
})
Returns the absolute path in which a map file is stored on the cloud storage server. You can manually download the file to parse it.
API description
- (nullable NSString *)getCloudFileDownloadURLWithBucket:(NSString *)bucket path:(NSString *)path;
Parameters
Parameter | Description |
---|---|
bucket | The file storage space. |
path | The relative path of a file that contains map or cleaning route data. |
Example
Objective-C:
NSString *url = [self.sweeperDevice getCloudFileDownloadURLWithBucket:<#bucket#> path:<#path#>];
Swift:
let url = sweeperDevice?.getCloudFileDownloadURL(withBucket: "", path: "")
Download files stored in a relative path in the cloud. These files contain data such as maps and cleaning routes.
API description
- (void)getSweeperDataWithBucket:(NSString *)bucket
path:(NSString *)path
success:(void (^)(NSData *data))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Parameter | Description |
---|---|
bucket | The file storage space. |
path | The relative path of a file that contains map or cleaning route data. |
success | The success callback. The file data is returned. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice getSweeperDataWithBucket:<#bucket#> path:<#path#> success:^(NSData * _Nonnull data) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.getSweeperData(withBucket: "", path: "", success: { (data) in
}, failure: { (error) in
})
Returns the relative path in which files of map and cleaning route data for the current cleaning task are stored in the cloud.
- (void)getSweeperCurrentPathWithSuccess:(void (^)(NSString *bucket, NSDictionary<ThingSmartSweeperCurrentPathKey, NSString *> *paths))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
ThingSmartSweeperCurrentPathKey | Description |
---|---|
ThingSmartSweepCurrentMapPathKey | The key of the relative path for the current map. |
ThingSmartSweepCurrentRoutePathKey | The key of the relative path for the current cleaning route. |
Parameter | Description |
---|---|
success | The success callback.
|
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice getSweeperCurrentPathWithSuccess:^(NSString * _Nonnull bucket, NSDictionary<ThingSmartSweeperCurrentPathKey,NSString *> * _Nonnull paths) {
NSString *mapPath = paths[ThingSmartSweepCurrentMapPathKey];
NSString *routePath = paths[ThingSmartSweepCurrentRoutePathKey];
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.getSweeperCurrentPath(success: { (bucket, paths) in
let mapPath = paths[ThingSmartSweepCurrentMapPathKey]
let routePath = paths[ThingSmartSweepCurrentRoutePathKey]
}, failure: { (error) in
})
Returns historical data of cleaning tasks from the cloud.
API description
- (void)getSweeperHistoryDataWithLimit:(NSUInteger)limit
offset:(NSUInteger)offset
startTime:(long)startTime
endTime:(long)endTime
success:(void (^)(NSArray<ThingSmartSweeperHistoryModel *> *datas, NSUInteger totalCount))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Class name | Description |
---|---|
ThingSmartSweeperHistoryModel | The historical data of cleaning tasks |
Property | Type | Description |
---|---|---|
fileId | NSString | The ID of the cleaning task file. |
time | long | The timestamp of the cleaning task file. |
extend | NSString | The rules to split and read cleaning tasks. |
bucket | NSString | The storage space of the cleaning task file. |
file | NSString | The relative path of the cleaning task file. |
Parameter | Description |
---|---|
limit | The number of returned entries in each call. We recommend that you specify a value of up to 100. |
offset | The offset of returned data to display data on pages. |
startTime | The start timestamp. It is not set by default. |
endTime | The end timestamp. It is not set by default. |
success | The success callback. The cleaning task array datas and the total number of historical cleaning tasks totalCount are returned. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice getSweeperHistoryDataWithLimit:50 offset:0 startTime:-1 endTime:-1 success:^(NSArray<ThingSmartSweeperHistoryModel *> * _Nonnull datas, NSUInteger totalCount) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.getSweeperHistoryData(withLimit: 50, offset: 0, success: { (datas, count) in
}, failure: { (error) in
})
Deletes specified historical data of cleaning tasks from the current laser robot vacuum. Up to 100 entries can be deleted in each call.
API description
- (void)removeSweeperHistoryDataWithFileIds:(NSArray<NSString *> *)fileIds
success:(void (^)(void))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Parameter | Description |
---|---|
fileIds | The array of cleaning task file IDs. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice removeSweeperHistoryDataWithFileIds:<#fileIds#> success:^{
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.removeSweeperHistoryData(withFileIds: [""], success: {
}, failure: { (error) in
})
When the laser robot vacuum processes multiple maps in a cleaning task, you can call the following API method to get the historical cleaning tasks for the floor maps.
API description
- (void)getSweeperMultiHistoryDataWithLimit:(NSUInteger)limit
offset:(NSUInteger)offset
startTime:(long)startTime
endTime:(long)endTime
success:(void(^)(NSArray<ThingSmartSweeperHistoryModel *> *datas, NSUInteger totalCount))success
failure:(void(^)(NSError * _Nullable error))failure;
Parameters
Parameter | Description |
---|---|
limit | The number of returned entries in each call. We recommend that you specify a value of up to 100. |
offset | The offset of returned data to display data on pages. |
startTime | The start timestamp. It is not set by default. |
endTime | The end timestamp. It is not set by default. |
success | The success callback. The cleaning task array datas and the total number of historical cleaning tasks totalCount are returned. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice getSweeperMultiHistoryDataWithLimit:50 offset:0 startTime:-1 endTime:-1 success:^(NSArray<ThingSmartSweeperHistoryModel *> * _Nonnull datas, NSUInteger totalCount) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.getSweeperMultiHistoryData(withLimit: 50, offset: 0, success: { (datas, count) in
}, failure: { (error) in
})
When the laser robot vacuum processes multiple maps in a cleaning task, you can call the following API method to name one of the floor maps.
API description
- (void)sweeperFileNameUpdateWithFileId:(NSNumber *)fileId
fileName:(NSString *)fileName
success:(void (^)(id result))success
failure:(void (^)(NSError * _Nullable error))failure;
Parameters
Parameter | Description |
---|---|
fileId | The map ID. |
fileName | The name of the map. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.sweeperDevice sweeperFileNameUpdateWithFileId:@1 fileName:@"" success:^(id _Nonnull result) {
} failure:^(NSError * _Nullable error) {
}];
Swift:
sweeperDevice?.sweeperFileNameUpdate(withFileId: 1, fileName: "", success: { (success) in
}, failure: { (error) in
})
Starting from Sweeper SDK v2.2.1, this feature is deprecated. We recommend that you use P2P channels to get real-time data if needed.
Executes the callback that returns a notification when the laser robot vacuum finishes uploading real-time maps or cleaning routes to the cloud during a cleaning task. You can set the delegate protocol ThingSmartSweeperDeviceDelegate
to listen for the real-time notification callback.
Data model of MQTT notification
Class name | Description |
---|---|
ThingSmartSweeperMQTTMessage | The MQTT notification that is sent when a robot vacuum finishes file uploading. |
Property | Type | Description |
---|---|---|
mapId | NSString | The ID of the map or cleaning route file. |
mapType | ThingSmartSweeperMQTTMessageType | The type of file. Valid values:
|
mapPath | NSString | The relative path of a file that contains map or cleaning route data. |
Callback for file upload notifications
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice didReceiveMessage:(ThingSmartSweeperMQTTMessage *)message;
Parameters
Parameter | Description |
---|---|
sweeperDevice | The robot vacuum instance. |
message | The notification that is sent over MQTT when the robot vacuum finishes file uploading. |
Example
Objective-C:
self.sweeperDevice = [ThingSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;
// Implements the delegate method.
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice didReceiveMessage:(ThingSmartSweeperMQTTMessage *)message {
}
Swift:
sweeperDevice = ThingSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self
func sweeperDevice(_ sweeperDevice: ThingSmartSweeperDevice, didReceive message: ThingSmartSweeperMQTTMessage) {
}
Starting from Sweeper SDK v2.2.1, this feature is deprecated. We recommend that you use P2P channels to get real-time data if needed.
The notification callback is invoked when the robot vacuum finishes uploading files. You can set shouldAutoDownloadData
to YES
to automatically download the files in the callback.
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice didReceiveMessage:(ThingSmartSweeperMQTTMessage *)message downloadData:(nullable NSData *)data downloadError:(nullable NSError *)error;
Parameters
Parameter | Description |
---|---|
sweeperDevice | The robot vacuum instance. |
message | The notification that is sent over MQTT when the robot vacuum finishes file uploading. |
data | The downloaded file content of NSData type. |
error | The error message that is returned when the files failed to be downloaded. |
Example
Objective-C:
self.sweeperDevice = [ThingSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;
// Implements the delegate method.
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice didReceiveMessage:(ThingSmartSweeperMQTTMessage *)message downloadData:(nullable NSData *)data downloadError:(nullable NSError *)error {
}
Swift:
sweeperDevice = ThingSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self
func sweeperDevice(_ sweeperDevice: ThingSmartSweeperDevice, didReceive message: ThingSmartSweeperMQTTMessage, downloadData data: Data?, downloadError error: Error?) {
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback