Laser Robot Vacuum

Last Updated on : 2023-05-22 06:38:30

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.

Functional description

All robot vacuum features are implemented with the class TuyaSmartSweepDevice that must be initialized with the device ID. An incorrect device ID might cause failed initialization. In this case, nil will be returned.

For Sweeper SDK v3.1.0 and later, real-time data transfers through Object Storage Service (OSS) are deprecated. Instead, use peer-to-peer (P2P) channels to get real-time data.

Class name Description
TuyaSmartSweepDevice The class of Powered by Tuya (PBT) robot vacuums.

Get cloud storage configurations

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

Objc:

[self.sweeperDevice initCloudConfigWithSuccess:^(NSString * _Nonnull bucket) {

} failure:^(NSError * _Nullable error) {

}];

Swift:

sweeperDevice?.initCloudConfig(success: { (bucket) in

}, failure: { (error) in

})

Get the absolute URL

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

ObjC:

NSString *url = [self.sweeperDevice getCloudFileDownloadURLWithBucket:<#bucket#> path:<#path#>];

Swift:

let url = sweeperDevice?.getCloudFileDownloadURL(withBucket: "", path: "")

Get data content

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

ObjC:

[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

})

Get historical data of cleaning tasks

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<TuyaSmartSweeperHistoryModel *> *datas, NSUInteger totalCount))success
                               failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class name Description
TuyaSmartSweeperHistoryModel 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 maximum number of entries to be returned in each call. 100 is recommended.
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

ObjC:

[self.sweeperDevice getSweeperHistoryDataWithLimit:50 offset:0 startTime:-1 endTime:-1 success:^(NSArray<TuyaSmartSweeperHistoryModel *> * _Nonnull datas, NSUInteger totalCount) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getSweeperHistoryData(withLimit: 50, offset: 0, success: { (datas, count) in

        }, failure: { (error) in

        })

Delete historical data of cleaning tasks

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

ObjC:

[self.sweeperDevice removeSweeperHistoryDataWithFileIds:<#fileIds#> success:^{

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.removeSweeperHistoryData(withFileIds: [""], success: {

        }, failure: { (error) in

        })

Get multi-floor map data

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<TuyaSmartSweeperHistoryModel *> *datas, NSUInteger totalCount))success
                                    failure:(void(^)(NSError * _Nullable error))failure;

Parameters

Parameter Description
limit The maximum number of entries to be returned in each call. 100 is recommended.
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

ObjC:

[self.sweeperDevice getSweeperMultiHistoryDataWithLimit:50 offset:0 startTime:-1 endTime:-1 success:^(NSArray<TuyaSmartSweeperHistoryModel *> * _Nonnull datas, NSUInteger totalCount) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getSweeperMultiHistoryData(withLimit: 50, offset: 0, success: { (datas, count) in

        }, failure: { (error) in

        })

Name multiple floor maps

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

ObjC:

[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

        })