English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Voice Package Download

Last Updated on : 2022-11-29 02:14:33download

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

Class name Description
TuyaSmartSweeperDevice 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<TuyaSmartFileDownloadModel *> *upgradeFileList))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class name Description
TuyaSmartFileDownloadModel 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<TuyaSmartFileDownloadModel *> * _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<TuyaSmartFileDownloadModel *> *upgradeFileList, NSUInteger totalCount))success failure:(void (^)(NSError * _Nullable error))failure

Parameters

Class name Description
TuyaSmartFileDownloadModel 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<TuyaSmartFileDownloadModel *> * _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 (^)(TuyaSmartFileDownloadRateModel *rateModel))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class name Description
TuyaSmartFileDownloadRateModel 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:^(TuyaSmartFileDownloadRateModel * _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:(TuyaSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadStatus:(TuyaSmartSweeperFileDownloadStatus)status;

Parameters

TuyaSmartSweeperFileDownloadStatus Description
TuyaSmartSweeperFileDownloadUpgrading File downloading
TuyaSmartSweeperFileDownloadFinish File downloaded
TuyaSmartSweeperFileDownloadFailure Download failed
Parameter Description
sweeperDevice The instance object of TuyaSmartSweeperDevice.
type The type of file.
status The download status TuyaSmartSweeperFileDownloadStatus.

Example

ObjC:

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

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

}

Swift:

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

func sweeperDevice(_ sweeperDevice: TuyaSmartSweeperDevice, type: String, downloadStatus status: TuyaSmartSweeperFileDownloadStatus) {

    }

Callback for real-time download progress

API description

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

Parameters

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

Example

ObjC:

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

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

}

Swift:

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

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

    }