Last Updated on : 2024-11-18 11:33:15download
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 Developer 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 versions 3.1.0 to 3.2.3-1, 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.
The real-time data of a laser robot vacuum is processed through the following channels.
The legacy and new SDK versions are accessed in different ways but provide similar functionalities.
Legacy SDK versions are accessed with ITuyaSweeper
:
ITuyaSweeper iTuyaSweeper = TuyaHomeSdk.getSweeperInstance()
New SDK versions are accessed with ITuyaSweeperKit
:
ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);
ITuyaSweeperKit iTuyaSweeperKit = iTuyaSweeperKitSdk.getSweeperInstance()
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) {
}
});
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) {
}
});
For Sweeper SDK versions later than v3.2.4, this feature will be deprecated. We recommend that you use P2P channels to get real-time data.
Get the absolute path of the map file on the server. You can manually download the file to parse it.
After cloud configurations are initialized, real-time data channels can be enabled to get real-time data.
/**
* 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 | The type of data. Valid values:
|
mapPath | String | A file path or map path. |
Example
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperDataChannel(new ITuyaSweeperDataListener() {
@Override
public void onSweeperDataReceived(SweeperDataBean bean) {
}
});
For Sweeper SDK versions later than v3.2.4, this feature will be deprecated. We recommend that you use P2P channels to get real-time data.
After cloud configurations are initialized, real-time data channels can be enabled to get real-time data.
/**
* 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 |
|
data | byte[] | The data content. |
devId | String | The device ID. |
Example
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperByteDataChannel(new ITuyaSweeperByteDataListener() {
@Override
public void onSweeperByteData(SweeperByteData data) {
}
@Override
public void onFailure(int code, String msg) {
}
});
/**
*
* @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");
To get historical data, you can call the following API method to read the file content from the cloud.
/**
* 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) {
}
});
/**
* 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
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getSweeperCurrentPath("devId", new ITuyaResultCallback<SweeperPathBean>() {
@Override
public void onSuccess(SweeperPathBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
/**
*
* @param devId The device ID.
* @param limit The number of returned entries in each call. We recommend that you specify a value of up to 100.
* @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 number of returned entries in each call. We recommend that you specify a value of up to 100.
* @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) {
}
});
Deletes historical data and stored data from the cloud. Up to 100 entries can be deleted in each call.
/**
* @param devId The device ID.
* @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) {
}
});
API description
/**
* Returns historical data of a robot vacuum. Multiple maps are used in this scenario.
* @param devId The device ID.
* @param limit The number of returned entries in each call. We recommend that you specify a value of up to 100.
* @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 number of returned entries in each call. We recommend that you specify a value of up to 100.
* @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) {
}
});
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.
/**
* 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){
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback