Gyroscope and Visual Sweeper

The SDK provides two data acquisition methods: HTTPS interface request and real-time channel. To acquire and delete historical data, you need to request the HTTPS interface. The data transferred during the sweeping of the sweeper can be obtained by monitoring the real-time channel registration.

HTTPS Interface

Interface Description

The HTTPS interface uses TuyaHomeSdk's call through the interface, mainly passing in the interface name, interface version number, and input parameters.

EntranceTuyaHomeSdk.getRequestInstance()

public interface ITuyaSmartRequest {

    /**
     *
     * @param apiName  api name
     * @param version  api version
     * @param postData params to post
     * @param callback 
     * @param object Data structure to receive callback data, such as corresponding javabean     
     */
    <T> void requestWithApiName(String apiName, String version, Map<String, Object> postData, Class<T> object, final ITuyaDataCallback<T> callback);

    <T> void requestWithApiNameWithoutSession(String apiName, String version, Map<String, Object> postData, Class<T> object, final ITuyaDataCallback<T> callback);

    void onDestroy();
}

1.Latest Record

Request parameters:

apiName:tuya.m.device.media.latest

version:2.0

postData:

{
  "devId" : "xxx",
  "start":"",
  "size" : 500
}

Example of Returned Data

 {
    "devId" : "xxx",
    "startRow" : "mtnva58ee6817b605ddcc6_35_1535629239586",
    "dataList" : [ "373702373700", "383702383802373901383901383800"],
    "subRecordId" : 35,
    "hasNext" : true,
    "startTime" : 1535629049,
    "endTime" : 1535629244,
    "status" : 2
}

2.Get Record List

Request parameters:

apiName:m.smart.scale.history.get.list

version:1.0

postData:

{
  "devId" : "xxx",
  "dpIds" : "",
  "offset": 0,
  "limit" : 10
}
Fields Type Description
devId String Device id
dpIds String The dpId of the cleaning record configured on the Tuya platform
offset int Offset value
limit int Number of pages

Example of Returned Data

{
        "datas":[
            {
                "devId":"xxxx",
                "dps":[
                    {
                        "15":"201906171721009007"
                    }
                ],
                "avatar":"https://airtake-public-data.oss-cn-hangzhou.aliyuncs.com/smart/user_res/avatar/scale/no_body_icon.png",
                "userName":"unknow",
                "gmtCreate":1560763848501,
                "uuid":"15607600058B81A6C4A0273FDD61091D0B02403848501",
                "userId":"0",
                "tags":0,
                "status":1
            }
        ],
        "hasNext":false,
        "totalCount":1
    }
Fields Type Description
uuid String UUID used when deleting records
15 String The dpId of the cleaning record configured on the Tuya platform
201906171721009007 String The value reported by the equipment under dpId [June 17, 2019, 17:21, cleaning time 009, cleaning area 007] Specific data and equipment are prepared
total int Total numbers
hasNext boolean Is there a next page

3.Get Record Information Detail

Request parameters:

apiName:tuya.m.device.media.detail

version:2.0

postData:

{
  "devId" : "xxx",
  "subRecordId" : 31,
  "start":"",
  "size" : 500
}
Fields Type Description
devId String Device id
subRecordId int clean record id
start String Pass the empty string for the first time, and fill the startRow value in the return value of the previous page when the next page is taken later
size int Request data size

Example of Returned Data

{
    "devId" : "xxx",
    "startRow" : "mtnva58ee6817b605ddcc6_31_1535622776561",
    "dataList" : ["3e3f02403e013e3f00", "3f3f024040013f3f00"],
    "subRecordId" : 31,
    "hasNext" : true,
    "startTime" : 1535621566,
    "endTime" : 1535623017,
    "status" : 2
  }
Fields Type Description
startRow String Start value passed in next request
subRecordId int clean record id
startTime long start time,timestamp
endTime long end time,timestamp
hasNext boolean Is there a next page

4.Delete Record(up to 100 records)

Request parameters:

apiName:m.smart.scale.history.delete

version:1.0

postData:

{
  "devId" : "xxx",
  "uuid":"15607600058B81A6C4A0273FDD61091D0B02403848501,
  15607600058B81A6C4A0273FDD61091D0B0240384850"、
}

Example of Returned Data

 ture / false

Data Transfer Subscribe

Function Introduction

Register the real-time data channel to monitor the device data stream report, and the returned data is in the form of byte array, which is parsed into available data according to the machine protocol, such as x, y coordinates, color value, etc.

Data Flow

Channel flow chart

EntranceTuyaHomeSdk.getTransferInstance();

Subscribe Map Stream Data

void registerTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);

Sample Code


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

    }

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

    }
});

Unsubscribe Map Stream Data

void unRegisterTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);

代码示例

TuyaHomeSdk.getTransferInstance().unRegisterTransferDataListener(this);

results matching ""

    No results matching ""