Voice Package Download

Last Updated on : 2024-03-04 08:35:03

Sweeper SDK supports downloading voice packages. The delegate protocol ThingSmartSweeperDeviceDelegate can be implemented to execute the callback for the status changes and progress of downloading a voice package.

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

Data flow

Voice Package Download

Query a list of voice packages

API description

Return a list of voice packages available for the current robot vacuum.

- (void)getFileDownloadInfoWithSuccess:(void (^)(NSArray<ThingSmartFileDownloadModel *> *upgradeFileList))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class name Description
ThingSmartFileDownloadModel The data class of the voice package.
Property Type Description
fileId NSString The voice package ID.
productId NSString The product ID.
name NSString The name of the voice package.
desc NSString The description of the voice package.
auditionUrl NSString The URL for downloading the audition version of the voice package.
officialUrl NSString The URL for downloading the official version of the voice package.
imgUrl NSString The URL of the voice package icon.
region NSArray The country or region code.
Parameter Description
success The callback. A list of available voice packages upgradeFileList is returned.
failure The failure callback.

Example

ObjC:

[self.sweeperDevice getFileDownloadInfoWithSuccess:^(NSArray<ThingSmartFileDownloadModel *> * _Nonnull upgradeFileList) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadInfo(success: { (upgradeFileList) in

        }, failure: { (error) in

        })

Query a list of voice files on pages

API description

Returns a list of voice packages available for the current robot vacuum. The result is displayed on pages.

- (void)getFileDownloadInfoWithLimit:(NSUInteger)limit offset:(NSUInteger)offset success:(void (^)(NSArray<ThingSmartFileDownloadModel *> *upgradeFileList, NSUInteger totalCount))success failure:(void (^)(NSError * _Nullable error))failure

Parameters

Class name Description
ThingSmartFileDownloadModel The data class of the voice package.
Property Type Description
fileId NSString The voice package ID.
productId NSString The product ID.
name NSString The name of the voice package.
desc NSString The description of the voice package.
auditionUrl NSString The URL for downloading the audition version of the voice package.
officialUrl NSString The URL for downloading the official version of the voice package.
imgUrl NSString The URL of the voice package icon.
region NSArray The country or region code.
extendField NSDictionary The field of Raw type.
Parameter Description
limit The maximum number of entries to be returned in each call.
offset The number of the entry starting from which entries are returned.
success The callback. A list of available voice packages upgradeFileList is returned.
failure The failure callback.

Example

ObjC:

[self.sweeper getFileDownloadInfoWithLimit:50 offset:0 success:^(NSArray<ThingSmartFileDownloadModel *> * _Nonnull upgradeFileList, NSUInteger totalCount) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadInfo(withLimit: 50, offset: 0, success: { (list, count) in

        }, failure: { (error) in

        })

Confirm voice package downloading

API description

- (void)downloadFileWithFileId:(NSString *)fileId
                       success:(void (^)(id result))success
                       failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Parameter Description
fileId The ID of the voice package to be downloaded.
success The success callback.
failure The failure callback.

Example

ObjC:

[self.sweeperDevice downloadFileWithFileId:<#fileId#> success:^(id  _Nonnull result) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.downloadFile(withFileId: "", success: { (result) in

        }, failure: { (error) in

        })

Query file download progress

API description

Returns the data model for the progress at which a voice package is downloaded.

- (void)getFileDownloadRateWithSuccess:(void (^)(ThingSmartFileDownloadRateModel *rateModel))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class name Description
ThingSmartFileDownloadRateModel The information about the progress at which the file is downloaded.
Property Type Description
fileId NSString The voice package ID.
deviceId NSString The device ID.
status NSInteger The download status.
rate int The download progress.
Parameter Description
success The success callback. The download progress data rateModel is returned.
failure The failure callback.

Example

ObjC:

[self.sweeperDevice getFileDownloadRateWithSuccess:^(ThingSmartFileDownloadRateModel * _Nonnull rateModel) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadRate(success: { (rateModel) in

        }, failure: { (error) in

        })

Callback for voice package download

Callback for real-time download status

API description

- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadStatus:(ThingSmartSweeperFileDownloadStatus)status;

Parameters

ThingSmartSweeperFileDownloadStatus Description
ThingSmartSweeperFileDownloadUpgrading File downloading
ThingSmartSweeperFileDownloadFinish File downloaded
ThingSmartSweeperFileDownloadFailure Download failed
Parameter Description
sweeperDevice The instance object of ThingSmartSweeperDevice.
type The type of file.
status The download status ThingSmartSweeperFileDownloadStatus.

Example

ObjC:

self.sweeperDevice = [ThingSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;

// Implements the delegate method.
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadStatus:(ThingSmartSweeperFileDownloadStatus)status {

}

Swift:

sweeperDevice = ThingSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self

func sweeperDevice(_ sweeperDevice: ThingSmartSweeperDevice, type: String, downloadStatus status: ThingSmartSweeperFileDownloadStatus) {

    }

Callback for real-time download progress

API description

- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadProgress:(int)progress;

Parameters

Parameter Description
sweeperDevice The instance object of ThingSmartSweeperDevice.
type The type of file.
progress The file download progress.

Example

ObjC:

self.sweeperDevice = [ThingSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;

// Implements the delegate method.
- (void)sweeperDevice:(ThingSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadProgress:(int)progress {

}

Swift:

sweeperDevice = ThingSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self

func sweeperDevice(_ sweeperDevice: ThingSmartSweeperDevice, type: String, downloadProgress progress: Int32) {

    }