Laser Sweeper
- Laser sweeper data is divided into real-time data and historical record data. Both types of data include map data and route data, which are stored on the OSS server in the form of files.
- The maps and paths of real-time data are stored in different files, and the maps and paths of historical data are stored in the same file. The map and path data are split and read according to the specified rules.
- It is recommended that all interfaces be called after the success of
initCloudConfig
, and the validity period of the configuration information will be updated within half an hour afterupdateCloudConfig
Sweeper Data Acquisition
Data Flow
Sweeper new and old version entrance
Different entrances, same functional interface
Old version entrance
ITuyaSweeper
ITuyaSweeper iTuyaSweeper = TuyaHomeSdk.getSweeperInstance()
New version entrance
ITuyaSweeperKit
ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class); ITuyaSweeperKit iTuyaSweeperKit = iTuyaSweeperKitSdk.getSweeperInstance()
Initialize Cloud Configuration
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
Get bucket information from file storage
/**
*
* @param devId device id
* @param callback
*/
void initCloudConfig(String devId, ITuyaCloudConfigCallback callback);
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().initCloudConfig("xxx", new ITuyaCloudConfigCallback() {
@Override
public void onConfigSuccess(String bucket) {
}
@Override
public void onConfigError(String errorCode, String errorMessage) {
}
});
//New version
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 Configuration
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
Get the latest bucket information
Due to the timeliness of the obtained file address, when the file address becomes invalid, you need to call this interface to update the cloud configuration
/**
*
* @param devId device id
* @param callback
*/
void updateCloudConfig(String devId, ITuyaCloudConfigCallback callback);
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().updateCloudConfig(deviceId, new ITuyaCloudConfigCallback() {
@Override
public void onConfigSuccess(String bucket) {
}
@Override
public void onConfigError(String errorCode, String errorMsg) {
}
});
//New version
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().updateCloudConfig("", new ITuyaCloudConfigCallback() {
@Override
public void onConfigSuccess(String bucket) {
}
@Override
public void onConfigError(String errorCode, String errorMessage) {
}
});
Register or Close the Real-time Data Channel (Return File Relative Path)
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
When the cloud configuration is initialized successfully, you can open the real-time data channel to obtain real-time data
void startConnectSweeperDataChannel(ITuyaSweeperDataListener listener);
void stopConnectSweeperDataChannel();
SweeperDataBean data analysis
Fields | Type | Description |
---|---|---|
mapType | int | 0 means map, 1 means path |
mapPath | String | Route path or map path |
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().startConnectSweeperDataChannel(new ITuyaSweeperDataListener() {
@Override
public void onSweeperDataReceived(SweeperDataBean sweeperDataBean) {
}
});
//New version
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperDataChannel(new ITuyaSweeperDataListener() {
@Override
public void onSweeperDataReceived(SweeperDataBean bean) {
}
});
Register or Close the Real-time Data Channel (Return Byte Array)
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
When the cloud configuration is initialized successfully, you can open the real-time data channel to obtain real-time data
/**
*
* @param listener
*/
void startConnectSweeperByteDataChannel(ITuyaSweeperByteDataListener listener);
/**
* Close the real-time data channel
*/
void stopConnectSweeperByteDataChannel();
SweeperByteData data analysis
Fields | Type | Description |
---|---|---|
type | int | 0 means map, 1 means path |
data | byte[] | data content |
devId | String | device id |
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().startConnectSweeperByteDataChannel(new ITuyaSweeperByteDataListener() {
@Override
public void onSweeperByteData(SweeperByteData data) {
}
@Override
public void onFailure(int code, String msg) {
}
});
//New version
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().startConnectSweeperByteDataChannel(new ITuyaSweeperByteDataListener() {
@Override
public void onSweeperByteData(SweeperByteData data) {
}
@Override
public void onFailure(int code, String msg) {
}
});
Get Full File Url
Interface Description
- Old version (version before 0.1.0): support
New version (version after 0.1.0): support
Get the complete path of the map file on the OSS server, you can download and analyze it yourself
/**
*
* @param bucket File storage bucket
* @param path File relative path(startConnectSweeperDataChannel)
*/
String getCloudFileUrl(String bucket, String path);
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().getCloudFileUrl("bucket","path");
//New version
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().getCloudFileUrl("bucket","path");
Get Data Content of Cloud Storage
Interface Description
- Old version (version before 0.1.0): support
New version (version after 0.1.0): support
When obtaining historical data, you can directly call this interface to read the file content in the cloud
/**
*
* @param bucket
* @param path
* @param listener
*/
void getSweeperByteData(String bucket, String path, ITuyaByteDataListener listener);
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().getSweeperByteData("bucket", "path", new ITuyaByteDataListener() {
@Override
public void onSweeperByteData(byte[] data) {
}
@Override
public void onFailure(int code, String msg) {
}
});
//New version
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 Current Cleaning Data
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
/**
* Get real-time map storage path and route storage path
* @param devId device id
* @param callback
*/
void getSweeperCurrentPath(String devId,ITuyaResultCallback<SweeperPathBean> callback);
SweeperPathBean fields information
Fields | Type | Description |
---|---|---|
mapPath | String | map path |
routePath | String | route path |
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().getSweeperCurrentPath("devId", new ITuyaResultCallback<SweeperPathBean>() {
@Override
public void onSuccess(SweeperPathBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//New version
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 History Sweep Records
Interface Description
- Old version (version before 0.1.0): support
- New version (version after 0.1.0): support
/**
*
* @param devId device id
* @param limit The number of data obtained at a time (it is recommended not to exceed 100)
* @param offset Get data offset (for paging)
* @param callback
*/
void getSweeperHistoryData(String devId, int limit, int offset,ITuyaResultCallback<SweeperHistory> callback);
/**
*
* @param devId device id
* @param limit The number of data obtained at a time (it is recommended not to exceed 100)
* @param offset Get data offset (for paging)
* @param startTime Start timestamp
* @param endTime End timestamp
* @param callback
*/
void getSweeperHistoryData(String devId, int limit, int offset, long startTime, long endTime,ITuyaResultCallback<SweeperHistory> callback);
SweeperHistoryFields information
Fields | Type | Description |
---|---|---|
datas | List |
Historical data list |
totalCount | int | total count |
SweeperHistoryBean fields information
Fields | Type | Description |
---|---|---|
id | String | map id |
time | long | File upload timestamp |
bucket | String | File storage bucket |
file | String | file path |
extend | String | Extended fields |
【extend Explanation】
extend is an extension fields can be transparently transmitted with the device (for example: {"map_id": 123, "layout_size": 4589, "route_size": 1024}
layout_size indicates the size of the map file, that is, the size of the map data in the file
route_size indicates the size of the path file, that is, the size of the path data in the file
When reading historical data files, read map data and route data according to layout_size and route_size
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().getSweeperHistoryData("devId", 10, 0, new ITuyaResultCallback<SweeperHistory>() {
@Override
public void onSuccess(SweeperHistory result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//New version
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 History Sweep Records
Interface Description
- Old version (version before 0.1.0): support
New version (version after 0.1.0): support
Delete cloud history and data stored in OSS server
/**
* @param devId device id
* @param fileIdList History id collection
* @param callback
*/
void deleteSweeperHistoryData(String devId, List<String> fileIdList, final ITuyaDelHistoryCallback callback);
Sample code
List<String> list = new ArrayList<>();
list.add("10");
list.add("11");
//Old version TuyaHomeSdk.getSweeperInstance().deleteSweeperHistoryData("devId", list, new ITuyaDelHistoryCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//New version TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteSweeperHistoryData("devId", list, new ITuyaDelHistoryCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
Clear History Sweep Rcords
Interface Description
- Old version (version before 0.1.0): support
New version (version after 0.1.0): support
Delete all history
/**
* @param devId device id
* @param callback
*/
void deleteAllHistoryData(String devId,final ITuyaDelHistoryCallback callback);
Sample code
//Old version
TuyaHomeSdk.getSweeperInstance().deleteAllHistoryData("devId", new ITuyaDelHistoryCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//New version
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteAllHistoryData("devId", new ITuyaDelHistoryCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
Get Historical Sweep Records (multi-maps)
Interface Description
- Old version(Before 0.1.0): Not supported
- New version (version after 0.1.0): support
/**
* Get sweeper history (multi-map)
* @param devId device id
* @param limit The number of data obtained at a time (it is recommended not to exceed 100)
* @param offset Get data offset (for paging)
* @param callback
*/
void getSweeperMultiMapHistoryData(String devId, int limit, int offset,
ITuyaResultCallback<SweeperHistory> callback);
/**
* Get sweeper history (multi-map)
* @param devId device id
* @param limit The number of data obtained at a time (it is recommended not to exceed 100)
* @param offset Get data offset (for paging)
* @param startTime start timestamp
* @param endTime end timestamp
* @param callback
*/
void getSweeperMultiMapHistoryData(String devId, int limit, int offset, long startTime, long endTime,
ITuyaResultCallback<SweeperHistory> callback);
Sample code
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) {
}
});
Clear History Sweep Records (multiple maps)
Interface Description
- Old version(Before 0.1.0): Not supported
- New version (version after 0.1.0): support
/**
* Delete all history (applicable to multiple maps)
* @param devId
* @param callback
*/
void deleteAllMultiMapHistoryData(String devId, ITuyaDelHistoryCallback callback);
Sample code
TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getSweeperInstance().deleteAllMultiMapHistoryData("devId", new ITuyaDelHistoryCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});