Gyroscope and Visual Robot Vacuums

Last Updated on : 2024-06-26 09:37:57download

Sweeper SDK provides API requests and real-time channels to enable data queries.

  • Historical records and other data can be queried or deleted by API requests.
  • The cleaning data transmitted from and to robot vacuums can be queried by the registration of listeners on real-time channels.

Query the latest cleaning task

API description

Query the latest cleaning task.

void queryLatestCleanRecord(String devId, String start, int size, ITuyaResultCallback<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

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().queryLatestCleanRecord(devId, "", 500, new ITuyaResultCallback<RecordDetaiBean>() {
                    @Override
                    public void onSuccess(RecordDetaiBean result) {

                    }

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

                    }
                });

Query historical data of cleaning tasks

API description

Returns the historical data of cleaning tasks.

void getHistoryCleanRecordList(String devId, int offset, int limit, long startTime, long endTime, ITuyaResultCallback<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

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getHistoryCleanRecordList(devId, 0, 10, 0, 0, new ITuyaResultCallback<HistoryResultBean>() {
                    @Override
                    public void onSuccess(HistoryResultBean result) {

                    }

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

                    }
                });

Query details of a historical cleaning task

API description

Returns details of a historical cleaning task.

 void getCleanRecordDetail(String devId, int subRecordId, String start, int size, ITuyaResultCallback<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.

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
  • The panel displays the timestamp when the record was reported by the MCU.
  • Tap the record to show the map.
No Yes Yes Yes 00300200123
  • The panel displays the timestamp when the record was reported to the cloud.
  • Tap the record to show the map.
Yes Yes Yes No 202003192025003002
  • The panel displays the timestamp when the record was reported by the MCU.
  • Tap the record without showing the map.
No Yes Yes No 003002
  • The panel displays the timestamp when the record was reported to the cloud.
  • Tap the record without showing the map.

Example

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getCleanRecordDetail(devId, subRecordId, "", 2, new ITuyaResultCallback<RecordDetaiBean>() {
                    @Override
                    public void onSuccess(RecordDetaiBean result) {

                    }

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

                    }
                });

Get the ID of the cleaning task

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 = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().getSubRecordId("20200319202500300200123");

Delete one or more historical cleaning tasks

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

TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class).getGyroscopeAndVisualSweeperKit().deleteHistoryCleanRecord(devId, recodIds, new IResultCallback() {
                    @Override
                    public void onError(String code, String error) {

                    }

                    @Override
                    public void onSuccess() {

                    }
                });

Real-time data channels

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: TuyaHomeSdk.getTransferInstance();

Data flow

Gyroscope and Visual Robot Vacuums

Subscribe to map streaming data

API description

void registerTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);

Example

TuyaHomeSdk.getTransferInstance().registerTransferDataListener(new ITuyaDataCallback<TransferDataBean>() {
	@Override
	public void onSuccess(TransferDataBean result) {

	}

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

	}
});

TransferDataBean

Field Type Description
data byte[]
  • Bits 0 to 3 indicate subRecordId of a map.
  • Bits 4 to 12 are not business data and will neither be parsed.
Note that actual map data is indicated starting from Bit 13. Every three bits create a map point, including the x-coordinate, y-coordinate, and point type of the map point.
devId String The device ID.

Unsubscribe from map streaming data

API description

void unRegisterTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);

Example

TuyaHomeSdk.getTransferInstance().unRegisterTransferDataListener(this);