Last Updated on : 2024-11-18 11:33:15download
Travel SDK serves your development as an extension of SmartLife App SDK. Before you integrate the Travel SDK, implement the device control feature on top of the SmartLife App SDK.
| Class name | Description | 
|---|---|
| IODDeviceInfo(ODDeviceInfo) | Get smart travel device information, such as HD images and firmware details. | 
| IODDeviceDPManager(ODDeviceDPManager) | Process device data points (DPs). For example, send DP data (advanced programming languages supported) and check whether device DPs are supported. | 
| IODStore(ODStore) | Implement features related to offline stores. For example, get a list of offline stores and search for target ones. | 
| IODTrack(ODTrack) | Implement features related to cycling navigation. For example, get a list of cycling routes and upload cycling routes. | 
SmartLife App SDK supports device thumbnails by default. You can make the following API request to get the HD device image with dimensions of 800 x 800 pixels. This image is configured on the Tuya IoT Development Platform. Device firmware information is also returned in this call.
API description
void getDeviceIcon(String devIds, final ITuyaResultCallback<ProductMap> listener)
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| devIds | String | Yes | “id1,id2,id3” | The array of device ID strings. | 
| listener | ITuyaResultCallback | Yes | - | The callback. | 
Data model of ProductMap
Fields of ProductMap
| Field | Data type | Description | 
|---|---|---|
| productIconVOMap | Map<String, ProductIcon> | The list of image information. | 
Fields of ProductIcon
| Field | Data type | Description | 
|---|---|---|
| icon | String | The HD image of the device. Dimensions: 800 x 800 pixels. | 
| smallIcon | String | The thumbnail of the device. | 
Example
TuyaODSDK.getIODDeviceInfo().getDeviceIcon("id1,id2,id3", new ITuyaResultCallback<ProductMap>() {
                @Override
                public void onSuccess(ProductMap result) {
                }
                @Override
                public void onError(String errorCode, String errorMessage) {
                }
            });
API description
void getDeviceHardwareInfo(String deviceId, ITuyaResultCallback<DeviceHardwareInfo> listener);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| deviceId | String | Yes | - | The device ID. | 
| listener | ITuyaResultCallback | Yes | - | The callback. | 
Data model of DeviceHardwareInfo
Fields of DeviceHardwareInfo
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| deviceInfo | Map<String, Object> | The list of device information. | 
Fields of deviceInfo
| Field | Data type | Description | 
|---|---|---|
| chassisNo | String | The vehicle identification number. | 
| activeTime | String | The time when a device is activated. | 
| productModel | String | The device model. | 
Example
TuyaODSDK.getIODDeviceInfo().getDeviceHardwareInfo(devId, new ITuyaResultCallback<DeviceHardwareInfo>() {
                @Override
                public void onSuccess(DeviceHardwareInfo result) {
                }
                @Override
                public void onError(String errorCode, String errorMessage) {
                }
            });
API description
void publishDP(String deviceId, String dpCode, Object value, ITuyaDevice tuyaDevice, IResultCallback callback)
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| deviceId | String | Yes | - | The device ID. | 
| dpCode | String | Yes | “blelock_switch” | The value of dpCodethat identifies a device DP. | 
| value | Object | Yes | true | The DP value. | 
| tuyaDevice | ITuyaDevice | Yes | TuyaHomeSdk.newDeviceInstance(deviceBean.getDevId()) | - | 
| callback | IResultCallback | Yes | - | The callback. | 
Return parameters
None.
Example
ITuyaDevice tuyaDevice =TuyaHomeSdk.newDeviceInstance(deviceBean.getDevId());
TuyaODSDK.getIODDeviceManagerInstance().publishDP(deviceBean.getDevId(), "blelock_switch", true, tuyaDevice, new IResultCallback() {
                    @Override
                    public void onError(String code, String error) {
                    }
                    @Override
                    public void onSuccess() {
                    }
                });
dpCodeAPI description
<T> T getValueByDPCode(String deviceId, String dpCode, Class<T> valueType);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| deviceId | String | Yes | - | The device ID. | 
| dpCode | String | Yes | “blelock_switch” | The value of dpCodethat identifies a device DP. | 
| valueType | Object | Yes | true | The DP value. | 
Return parameters
| Data type | Example | Description | 
|---|---|---|
| Boolean | true | The DP value. | 
Example
boolean switchValue = TuyaODSDK.getIODDeviceManagerInstance().getValueByDPCode(devId, "blelock_switch", Boolean.class);
API description
SchemaBean getSchemaByDPCode(String deviceId, String dpCode);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| deviceId | String | Yes | - | The device ID. | 
| dpCode | String | Yes | “blelock_switch” | The value of dpCodethat identifies a device DP. | 
Return parameters
SchemaBean
For more information about SchemaBean, see Device Control.
Example
TuyaODSDK.getIODDeviceManagerInstance().getSchemaByDPCode(devId, "blelock_switch");
dpCode-specific featureAPI description
boolean isDPCodeSupport(String deviceId, String dpCode);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| deviceId | String | Yes | - | The device ID. | 
| dpCode | String | Yes | “blelock_switch” | The value of dpCodethat identifies a device DP. | 
Return parameters
| Data type | Example | Description | 
|---|---|---|
| Boolean | true | true: supported.false: not supported. | 
Example
TuyaODSDK.getIODDeviceManagerInstance().isDPCodeSupport(devId, "blelock_switch");
API description
void getStoreList(StoreGetReq storeGetReq, ITuyaResultCallback<List<StoreInfo>> callback);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| storeGetReq | StoreGetReq | Yes | - | - | 
| callback | ITuyaResultCallback<List | Yes | - | The callback. | 
Data model of StoreInfo
| Field | Data type | Description | 
|---|---|---|
| id | String | The store ID. | 
| name | String | The name of the store. | 
| address | String | The address of the store. | 
| lon | Double | The longitude of the store. | 
| lat | Double | The latitude of the store. | 
| source | String | The source of the store information. Valid values: 
 | 
| type | String | The type of points of interest (POI). Example: store_electrocarmeans an electric vehicle store. | 
| coordType | String | The type of coordinate system. Valid values: 
 | 
| distance | Double | The distance from the store to the current location. Unit: meters. | 
| favorite | Boolean | Specifies whether the store is favorited. | 
| info | ExtraInfo | The additional information about the store. | 
Data model of ExtraInfo
| Field | Data type | Description | 
|---|---|---|
| phone | String | The contact phone of the store. | 
| picture | String | The image of the store. | 
Data model of StoreGetReq
| Field | Data type | Description | 
|---|---|---|
| radius | Int | The radius of the geographical scope within which stores are returned. Unit: meters. | 
| max | Int | The maximum number of stores to be returned in this call. | 
| lon | Double | The longitude of the current location. | 
| lat | Double | The latitude of the current location. | 
| coordType | String | The type of coordinate system. Valid values: 
 | 
| source | String | The source of the store information. Valid values: 
 | 
| type | String | The type of points of interest (POI). Example: store_electrocarmeans an electric vehicle store. | 
Example
double longitude = 121.355359;
double latitude = 31.217979;
StoreGetReq storeGetReq = new StoreGetReq().setLon(longitude).setLat(latitude).setRadius(5).setSource(StoreInfoConstants.Source.TUYA.value).setType(StoreInfoConstants.STORE_TYPE.ELECTRONIC.value);
TuyaODSDK.getIODStoreInstance().getStoreList(storeGetReq, new ITuyaResultCallback<List<StoreInfo>>() {
            @Override
            public void onSuccess(List<StoreInfo> result) {
                showToast("success");
            }
            @Override
            public void onError(String errorCode, String errorMessage) {
                showToast(errorMessage);
            }
        });
API description
void searchStoreList(StoreSearchReq storeSearchReq, ITuyaResultCallback<List<StoreInfo>> callback);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| storeGetReq | StoreSearchReq | Yes | - | - | 
| callback | ITuyaResultCallback<List | Yes | - | The callback. | 
Data model of StoreSearchReq
| Field | Data type | Description | 
|---|---|---|
| radius | Int | The radius of the geographical scope within which stores are returned. Unit: meters. | 
| lon | Double | The longitude of the current location. | 
| lat | Double | The latitude of the current location. | 
| coordType | String | The type of coordinate system. Valid values: 
 | 
| source | String | The source of the store information. Valid values: 
 | 
| type | String | The type of POI. Example: store_electrocarmeans an electric vehicle store. | 
| keyword | String | The search keyword. | 
| pageIndex | Int | The requested page number. | 
| pageSize | Int | The maximum number of entries to be returned per page. | 
Example
double longitude = 121.355359;
double latitude = 31.217979;
StoreSearchReq storeSearchReq = new StoreSearchReq().setLon(longitude).setLat(latitude).setRadius(5).setSource(StoreInfoConstants.Source.TUYA.value).setType(StoreInfoConstants.STORE_TYPE.ELECTRONIC.value).setKeyword("car");
TuyaODSDK.getIODStoreInstance().searchStoreList(storeSearchReq, new ITuyaResultCallback<List<StoreInfo>>() {
            @Override
            public void onSuccess(List<StoreInfo> result) {
                showToast("success");
            }
            @Override
            public void onError(String errorCode, String errorMessage) {
                showToast(errorMessage);
            }
        });
Implement features related to cycling navigation. For example, get a list of cycling routes and upload cycling routes.
API description
void getTrackStatistic(TrackStatisticReq trackStatisticReq, ITuyaResultCallback<TrackStatisticInfo> callback);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| trackStatisticReq | TrackStatisticReq | Yes | - | - | 
| callback | ITuyaResultCallback | Yes | - | The callback. | 
Data model of TrackStatisticReq
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| startTime | Long | The start time of the cycling period. | 
| endTime | Long | The end time of the cycling period. | 
Data model of TrackStatisticInfo
Fields of TrackStatisticInfo
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| list | List | The list of segmented routes. | 
Fields of TrackStatistic
| Field | Data type | Description | 
|---|---|---|
| totalTime | Long | The total duration of a segmented route. | 
| startTime | Long | The start time of a segmented route. | 
| averageSpeed | Double | The average speed of a segmented route. | 
| maxSpeed | Double | The maximum speed of a segmented route. | 
| totalMileage | Double | The total distance of a segmented route. | 
| battery | Int | The battery information. | 
Example
TrackStatisticReq trackStatisticReq = new TrackStatisticReq().setDeviceId(deviceId).setStartTime(startTime).setEndTime(endTime);
TuyaODSDK.getIODTrackInstance().getTrackStatistic(trackStatisticReq, new ITuyaResultCallback<TrackStatisticInfo>() {
            @Override
            public void onSuccess(TrackStatisticInfo result) {
                showToast("success");
            }
            @Override
            public void onError(String errorCode, String errorMessage) {
                showToast(errorMessage);
            }
        });
API description
void getTrackSegment(TrackSegmentReq trackSegmentReq, ITuyaResultCallback<TrackSegmentInfo> callback);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| trackSegmentReq | TrackSegmentReq | Yes | - | - | 
| callback | ITuyaResultCallback | Yes | - | The callback. | 
Data model of TrackSegmentReq
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| lastId | Long | The route ID used to query the next array of data. | 
| lessMileage | Double | The minimum distance, used to filter data. | 
| pageSize | Int | The maximum number of entries returned on each page. | 
Data model of TrackSegmentInfo
Fields of TrackSegmentInfo
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| lastIdStr | Long | The route ID used to query the next array of data. | 
| areLastPage | Boolean | Indicates whether the last page is returned. | 
| segmentList | List | The array of route data. | 
Fields of TrackSegment
| Field | Data type | Description | 
|---|---|---|
| duration | Long | The cycling duration of the route. Unit: seconds. | 
| startTime | Long | The start time of the route. Unit: seconds. | 
| endTime | Long | The start time of the route. Unit: seconds. | 
| speed | Double | The cycling speed. Unit: km/h. | 
| mileage | Double | The distance. Unit: km. | 
| battery | Int | The battery Level. | 
Example
TrackSegmentReq trackSegmentReq = new TrackSegmentReq().setDeviceId(deviceId).setLastId(-1).setLessMileage(1).setPageSize(10);
TuyaODSDK.getIODTrackInstance().getTrackSegment(trackSegmentReq, new ITuyaResultCallback<TrackSegmentInfo>() {
            @Override
            public void onSuccess(TrackSegmentInfo result) {
                showToast("success");
            }
            @Override
            public void onError(String errorCode, String errorMessage) {
                showToast(errorMessage);
            }
        });
API description
void reportLocation(ReportLocationReq reportLocationReq, ITuyaResultCallback<Boolean> callback);
Request parameters
| Parameter | Data type | Required | Example | Description | 
|---|---|---|---|---|
| reportLocationReq | ReportLocationReq | Yes | - | - | 
| callback | ITuyaResultCallback | Yes | - | The callback. | 
Data model of ReportLocationReq
Fields of ReportLocationReq
| Field | Data type | Description | 
|---|---|---|
| deviceId | String | The device ID. | 
| productId | String | The product ID. | 
| payLoad | PayLoad | The location information. | 
Fields of PayLoad
| Field | Data type | Description | 
|---|---|---|
| accuracy | Float | The precision of the location information. Unit: meters. | 
| battery | Int | The battery Level. | 
| lat | Double | The latitude of the current location. | 
| lon | Double | The longitude of the current location. | 
| speed | Int | The current value of dpCodeforspeed. | 
| mileage | Int | The current value of dpCodeformileage_once. | 
| start | Boolean | The start or end flag of the route. Valid values: 
 | 
Example
double longitude = 121.355359;
double latitude = 31.217979;
ReportLocationReq.PayLoad payLoad = new ReportLocationReq.PayLoad().setLongitude(longitude).setLatitude(latitude).setBattery(50).setMileage(10).setSpeed(20).setStart(true);
ReportLocationReq reportLocationReq = new ReportLocationReq().setDeviceId(deviceId).setProductId(productId).setPayLoad(payLoad);
TuyaODSDK.getIODTrackInstance().reportLocation(reportLocationReq, new ITuyaResultCallback<Boolean>() {
              @Override
              public void onSuccess(Boolean result) {
                  showToast("success");
              }
              @Override
              public void onError(String errorCode, String errorMessage) {
                  showToast(errorMessage);
              }
          });
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback