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

Laser Robot Vacuum

Last Updated on : 2022-03-04 15:04:07download

The data of a laser robot vacuum is classified into real-time data and historical data. Both types of data include map data and route data, and are stored as files on the Tuya IoT Development Platform.

  • The real-time map data is stored in a different file from the real-time route data.
  • The historical data of maps and routes are stored in the same file. Map data and route data are divided and read based on specific rules.

We recommend that all API methods are called after initCloudConfig is called successfully. The configurations are valid for half an hour. If the initialization failed, updateCloudConfig is called to update the configurations.

Get data of a robot vacuum

The real-time data of a laser robot vacuum is processed through the following channels.

Laser Robot Vacuum

Access legacy and new SDK versions

The legacy and new SDK versions are accessed in different ways but provide similar functionalities. For more information, see Changelog.

  • The legacy versions earlier than SDK v0.1.0 are accessed with ITuyaSweeper:

    ITuyaSweeper  iTuyaSweeper = TuyaHomeSdk.getSweeperInstance()
    
  • SDK v0.1.0 and later are accessed with ITuyaSweeperKit:

    ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);
    
    ITuyaSweeperKit iTuyaSweeperKit = iTuyaSweeperKitSdk.getSweeperInstance()
    

Initialize cloud storage configurations

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

Returns the location where files are stored. bucket indicates the location.

API description

/**
*
* @param devId     The device ID.
* @param callback
*/
void initCloudConfig(String devId, ITuyaCloudConfigCallback callback);

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().initCloudConfig("xxx", new ITuyaCloudConfigCallback() {
    @Override
    public void onConfigSuccess(String bucket) {

    }

    @Override
    public void onConfigError(String errorCode, String errorMessage) {

    }
});

// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().initCloudConfig("xxx", new ITuyaCloudConfigCallback() {
    @Override
    public void onConfigSuccess(String bucket) {

    }

    @Override
    public void onConfigError(String errorCode, String errorMessage) {

    }
});

Update cloud storage configurations

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

Returns the location where files are stored. bucket indicates the location.

The bucket location is valid within a limited period. After it expires, call the following API method to update cloud configurations:

API description

/**
 *
 * @param devId    The device ID.
 * @param callback
 */
void updateCloudConfig(String devId, ITuyaCloudConfigCallback callback);

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().updateCloudConfig(deviceId, new ITuyaCloudConfigCallback() {
    @Override
    public void onConfigSuccess(String bucket) {

    }

    @Override
    public void onConfigError(String errorCode, String errorMsg) {

    }
});
// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().updateCloudConfig("", new ITuyaCloudConfigCallback() {
    @Override
    public void onConfigSuccess(String bucket) {

    }

    @Override
    public void onConfigError(String errorCode, String errorMessage) {

    }
});

Register or disable real-time data channels

Return the relative path

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

After cloud configurations are initialized, real-time data channels can be enabled to get real-time data. The relative path of files is returned.

API description

/**
 * Enables the channel to get data of the robot vacuum and returns the URL where the data is stored.
 *
 * @param listener
 */
void startConnectSweeperDataChannel(ITuyaSweeperDataListener listener);

/**
 * Disables the real-time data channel.
 */
void stopConnectSweeperDataChannel();

Callback data structure of SweeperDataBean

Field Type Description
mapType int
  • 0: map data
  • 1: cleaning route data
mapPath String A file path or map path.

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().startConnectSweeperDataChannel(new ITuyaSweeperDataListener() {
    @Override
    public void onSweeperDataReceived(SweeperDataBean sweeperDataBean) {

    }
});

// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperDataChannel(new ITuyaSweeperDataListener() {
    @Override
    public void onSweeperDataReceived(SweeperDataBean bean) {

    }
});

Return arrays

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

After cloud configurations are initialized, real-time data channels can be enabled to get real-time data. The response is returned as an array of byte[].

API description

/**
 * Enables the channel to get real-time data and returns the array of `byte[]`.
 *
 * @param listener
 */
void startConnectSweeperByteDataChannel(ITuyaSweeperByteDataListener listener);

/**
 * Disables the real-time data channel.
 */
void stopConnectSweeperByteDataChannel();

Callback data structure of SweeperByteData

Field Type Description
type int
  • 0: map data
  • 1: cleaning route data
data byte[] The data content.
devId String The device ID.

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().startConnectSweeperByteDataChannel(new ITuyaSweeperByteDataListener() {
    @Override
    public void onSweeperByteData(SweeperByteData data) {

    }

    @Override
    public void onFailure(int code, String msg) {

    }
});
// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperByteDataChannel(new ITuyaSweeperByteDataListener() {
    @Override
    public void onSweeperByteData(SweeperByteData data) {

    }

    @Override
    public void onFailure(int code, String msg) {

    }
});

Get the absolute URL

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

Get the absolute path of the map file on the server. You can manually download the file to parse it.

API description

/**
 *
 * @param bucket The bucket where the file is stored.
 * @param path   The relative path of the file (`startConnectSweeperDataChannel`).
 */
String getCloudFileUrl(String bucket, String path);

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().getCloudFileUrl("bucket","path");
// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getCloudFileUrl("bucket","path");

Get data content

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

To get historical data, you can call the following API method to read the file content from the cloud.

API description


/**
 * Returns the data content in the format of `byte[]`.
 *
 * @param bucket
 * @param path
 * @param listener
 */
void getSweeperByteData(String bucket, String path, ITuyaByteDataListener listener);

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().getSweeperByteData("bucket", "path", new ITuyaByteDataListener() {
    @Override
    public void onSweeperByteData(byte[] data) {

    }

    @Override
    public void onFailure(int code, String msg) {

    }
});
// New versions.
   TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getSweeperByteData("bucket", "path", new ITuyaByteDataListener() {
    @Override
    public void onSweeperByteData(byte[] data) {

    }

    @Override
    public void onFailure(int code, String msg) {

    }
});

Get data of the current cleaning task

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

API description

/**
	* Returns the path of the map and route that are stored in real time.
	* @param devId    The device ID.
	* @param callback
	*/
	void getSweeperCurrentPath(String devId,ITuyaResultCallback<SweeperPathBean> callback);

Fields of SweeperPathBean

Field Type Description
mapPath String The path of a map.
routePath String The path of a route.

Example

// Legacy versions.
TuyaHomeSdk.getSweeperInstance().getSweeperCurrentPath("devId", new ITuyaResultCallback<SweeperPathBean>() {
    @Override
    public void onSuccess(SweeperPathBean result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getSweeperCurrentPath("devId", new ITuyaResultCallback<SweeperPathBean>() {
    @Override
    public void onSuccess(SweeperPathBean result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

Get historical data of cleaning tasks

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

API description

/**
 *
 * @param devId    The device ID.
 * @param limit    The maximum number of returned entries in each call. `100` is recommended.
 * @param offset   The offset of returned data to display data on pages.
 * @param callback
 */
void getSweeperHistoryData(String devId, int limit, int offset,ITuyaResultCallback<SweeperHistory> callback);

/**
 *
 * @param devId     The device ID.
 * @param limit     The maximum number of returned entries in each call. `100` is recommended.
 * @param offset    The offset of returned data to display data on pages.
 * @param startTime The start timestamp.
 * @param endTime   The end timestamp.
 * @param callback
 */
void getSweeperHistoryData(String devId, int limit, int offset, long startTime, long endTime,ITuyaResultCallback<SweeperHistory> callback);

Callback data structure of SweeperHistory

Field Type Description
datas List The list of historical data.
totalCount int The total number of returned entries in each call.

Fields of SweeperHistoryBean

Field Type Description
id String The map ID.
time long The timestamp when a file is uploaded.
bucket String The bucket where a file is stored.
file String The path of the file.
extend String The extension field.

extend is an extension field whose value can be passed through to the device. Example: {"map_id":123, "layout_size":4589, "route_size":1024}.

  • layout_size represents the data size of the map file.
  • route_size represents the data size of the route file.

When the system reads historical data files, it reads layout_size to get map data and route_size to get route data.

Example

// Legacy versions.
 TuyaHomeSdk.getSweeperInstance().getSweeperHistoryData("devId", 10, 0, new ITuyaResultCallback<SweeperHistory>() {
    @Override
    public void onSuccess(SweeperHistory result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
// New versions.
   TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getSweeperHistoryData("devId", 10, 0, new ITuyaResultCallback<SweeperHistory>() {
    @Override
    public void onSuccess(SweeperHistory result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

Delete historical data of cleaning tasks

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

Deletes historical data and stored data from the cloud.

API description

/**
* @param devId      The ID of the device.
* @param fileIdList The list of IDs in historical data.
* @param callback
*/
void deleteSweeperHistoryData(String devId, List<String> fileIdList, final ITuyaDelHistoryCallback callback);

Example

List<String> list = new ArrayList<>();
list.add("10");
list.add("11");
// Legacy versions.
	TuyaHomeSdk.getSweeperInstance().deleteSweeperHistoryData("devId", list, new 				 	ITuyaDelHistoryCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteSweeperHistoryData("devId", list, new ITuyaDelHistoryCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

Clear historical data of cleaning tasks

  • Versions earlier than SDK v0.1.0: supported
  • SDK v0.1.0 and later: supported

Deletes all historical data.

API description

/**
* Deletes all historical data.
* @param devId     The device ID.
* @param callback
*/
void deleteAllHistoryData(String devId,final ITuyaDelHistoryCallback callback);

Example

// Legacy versions.

TuyaHomeSdk.getSweeperInstance().deleteAllHistoryData("devId", new ITuyaDelHistoryCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

// New versions.
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteAllHistoryData("devId", new ITuyaDelHistoryCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

Get multi-floor map data

  • Versions earlier than SDK v0.1.0: not supported
  • SDK v0.1.0 and later: supported

API description

/**
 * Returns historical data of a robot vacuum. Multiple maps are used in this scenario.
 * @param devId    The device ID.
 * @param limit    The maximum number of returned entries in each call. `100` is recommended.
 * @param offset   The offset of returned data to display data on pages.
 * @param callback
 */
void getSweeperMultiMapHistoryData(String devId, int limit, int offset,
                                   ITuyaResultCallback<SweeperHistory> callback);

/**
 * Returns historical data of a robot vacuum. Multiple maps are used in this scenario.
 * @param devId     The device ID.
 * @param limit     The maximum number of returned entries in each call. `100` is recommended.
 * @param offset    The offset of returned data to display data on pages.
 * @param startTime The start timestamp.
 * @param endTime   The end timestamp.
 * @param callback
 */
void getSweeperMultiMapHistoryData(String devId, int limit, int offset, long startTime, long endTime,
                                   ITuyaResultCallback<SweeperHistory> callback);

Example

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getSweeperMultiMapHistoryData("devId", 20, 0, new ITuyaResultCallback<SweeperHistory>() {
    @Override
    public void onSuccess(SweeperHistory result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

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

    /**
     * Names one of the floor maps in a cleaning task.
     * @param devId The ID of the device.
     * @param id The map ID.
     * @param name The map name.
     * @param callback The callback.
     */
    void sweeperFileNameUpdateWithDevId(String devId, long id, String name,final ITuyaSweeperNameUpdateCallback callback);

Example

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().sweeperFileNameUpdateWithDevId("devId",id,"name", new ITuyaSweeperNameUpdateCallback() {
    @Override
    public void onNameUpdate(boolean result){

    }

    @Override
    public void void onFailure(String code, String msg){

    }
});

Clear multi-floor map data

  • Versions earlier than SDK v0.1.0: not supported
  • SDK v0.1.0 and later: supported

API description

/**
 * Deletes all historical data. Multiple maps are used in this scenario.
 * @param devId
 * @param callback
 */
void deleteAllMultiMapHistoryData(String devId, ITuyaDelHistoryCallback callback);

Example

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteAllMultiMapHistoryData("devId", new ITuyaDelHistoryCallback() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});