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

Laser Robot Vacuum

Last Updated on : 2022-11-18 03:55:05download

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.

    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.

  • 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 can be called to update the configurations.

Initialize cloud storage configurations

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

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

Example

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

Returns the latest 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:

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

Example

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

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

    }
});

Get the absolute URL

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

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getCloudFileUrl("bucket","path");

Get data content

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

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 historical data of cleaning tasks

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

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

Deletes historical data and stored data from the cloud. Up to 100 entries can be deleted in each call.

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");

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

    }

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

    }
});

Get multi-floor map data

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){

    }
});