Last Updated on : 2024-06-19 07:59:08download
Sweeper SDK provides API requests and real-time channels to enable data queries.
API description
Query the latest cleaning task.
//Streaming service 1.0
void queryLatestCleanRecord(String devId, String start, int size, IThingResultCallback<RecordDetaiBean> callback);
//Streaming service 2.0
void queryLatestCleanRecordV2(String devId, String start, int size, IThingResultCallback<RecordDetaiBean> callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
start | The start row. The value in the first request is empty. In the follow-up requests, the value of startRow in the last response is required. |
size | The maximum number of entries to be returned in each call. The value is 500 . |
The following table lists the properties of RecordDetaiBean
.
Field | Type | Description |
---|---|---|
devId | String | The device ID. |
startRow | String | The start row. |
dataList | List<String> | The map data. |
subRecordId | int | The ID of the cleaning task. |
hasNext | boolean | Specifies whether to return the next page. |
startTime | long | The start time of the period to be queried. |
endTime | long | The end time of the period to be queried. |
Example
//Streaming service 1.0
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().queryLatestCleanRecord(devId, "", 500, new IThingResultCallback<RecordDetaiBean>() {
@Override
public void onSuccess(RecordDetaiBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//Streaming service 2.0
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().queryLatestCleanRecordV2(devId, "", 500, new IThingResultCallback<RecordDetaiBean>() {
@Override
public void onSuccess(RecordDetaiBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
Returns the historical data of cleaning tasks.
void getHistoryCleanRecordList(String devId, int offset, int limit, long startTime, long endTime, IThingResultCallback<HistoryResultBean> callback);
Parameters
Field | Type | Description |
---|---|---|
devId | String | The device ID. |
offset | int | The number of entries starting from which entries are returned. |
limit | int | The maximum number of entries returned on each page. |
startTime | long | The start time of the period to be queried. |
endTime | long | The end time of the period to be queried. |
The following table lists the properties of HistoryResultBean
.
Field | Type | Description |
---|---|---|
datas | List<RecordListBean> | The list of historical data. |
totalCount | int | The total number of entries. |
The following table lists the properties of RecordListBean
.
Field | Type | Description |
---|---|---|
recordId | String | The map ID. |
gid | long | The home group ID. |
dpId | int | The data point (DP) ID generated for the robot vacuum product on the Tuya Developer Platform. |
gmtCreate | long | The time when the cleaning record was created. |
value | String | The information about the map. The value is used to parse subRecordId . |
uuid | String | The device ID. |
Example
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getHistoryCleanRecordList(devId, 0, 10, 0, 0, new IThingResultCallback<HistoryResultBean>() {
@Override
public void onSuccess(HistoryResultBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
Returns details of a historical cleaning task.
//Streaming service 1.0
void getCleanRecordDetail(String devId, int subRecordId, String start, int size, IThingResultCallback<RecordDetaiBean> callback);
//Streaming service 2.0
void getCleanRecordDetailV2(String devId, int subRecordId, String start, int size, int mapId, int datatype, IThingResultCallback<RecordDetaiBean> callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
subRecordId | The ID of the cleaning task to be queried. Parse the value parameter of the historical cleaning tasks to get the ID. The parsing rules vary depending on different data lengths. The following table describes the rules. |
start | The start row. The value in the first request is empty. In the follow-up requests, the value of startRow in the last response is required. |
size | The maximum number of entries to be returned in each call. The value is 500 . |
mapId | The submap ID for streaming service 2.0 only. |
datatype | The map type for streaming service 2.0 only. |
Protocol for parsing value
Record time 12 digits |
Cleaning time 3 digits |
Cleaning area 3 digits |
subRecordId 5 digits |
Example | Description |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | 20200319202500300200123 |
|
No | Yes | Yes | Yes | 00300200123 |
|
Yes | Yes | Yes | No | 202003192025003002 |
|
No | Yes | Yes | No | 003002 |
|
Example
//Streaming service 1.0
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getCleanRecordDetail(devId, subRecordId, "", 2, new IThingResultCallback<RecordDetaiBean>() {
@Override
public void onSuccess(RecordDetaiBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
//Streaming service 2.0
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getCleanRecordDetailV2(devId, subRecordId, "", 2, 0, 0, new IThingResultCallback<RecordDetaiBean>() {
@Override
public void onSuccess(RecordDetaiBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
API description
The simple method that encapsulates the protocol to parse strings of value
type. You can choose between this method and the protocol for parsing value. Currently, only strings of value type are supported.
int getSubRecordId(String value);
Example
int subId = ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getSubRecordId("20200319202500300200123");
API description
Up to 100 entries can be deleted in each call.
void deleteHistoryCleanRecord(String devId, List<String> recordIds, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
recordIds | The list of cleaning task IDs. You can call getHistoryCleanRecordList to get the IDs. |
Example
ThingOptimusSdk.getManager(IThingSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().deleteHistoryCleanRecord(devId, recodIds, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
Real-time channels can be registered to listen for reported device data streams. Arrays are returned in the response and parsed into required data, such as the x-coordinate, y-coordinate, and color values, using the device protocol.
Access to API: ThingHomeSdk.getTransferInstance();
API description
void registerTransferDataListener(IThingDataCallback<TransferDataBean> callback);
Example
ThingHomeSdk.getTransferInstance().registerTransferDataListener(new IThingDataCallback<TransferDataBean>() {
@Override
public void onSuccess(TransferDataBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TransferDataBean
Field | Type | Description |
---|---|---|
data | byte[] |
|
devId | String | The device ID. |
API description
void unRegisterTransferDataListener(IThingDataCallback<TransferDataBean> callback);
Example
ThingHomeSdk.getTransferInstance().unRegisterTransferDataListener(this);
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback