Last Updated on : 2023-04-19 02:31:12download
This topic describes the Tuya Smart Production Management System (PMS) SDK that enables the communication between production test tools and the Tuya PMS. During the production test process, the production test SDK can get data from or upload data to the Tuya PMS.
You can go to the SDK repository to download the SDK.
└─tuya-cloud-sdk
├─C#
│ │ BouncyCastle.Crypto.dll
│ │ Newtonsoft.Json.dll
│ │ ReleaseNote.txt
│ │ TuyaCloudIfLib.dll
│ │ TuyaCloudIfLib.xml
│ │
│ └─Demo
└─C++
├─Demo
│ Demo(C++).rar
│
└─Lib
BouncyCastle.Crypto.dll
CloudExport.h
CppCloudLib.dll
CppCloudLib.lib
Newtonsoft.Json.dll
Readme.txt
TuyaCloudIfLib.dll
TuyacloudLib\C#
includes the SDK for C#.TuyacloudLib\C++
includes the SDK for C++.Interface | Description |
---|---|
SetUrlSftVer | Set the environment of Tuya software |
UserLogin | Log in with an account |
TokenAuth | Authorize a product with a token |
GetTokenInfo | Get token information |
TokenAuthValidate | Verify an authorization with a token |
AddAuthLog | Add authorization logs |
GetWorkOrderInfo | Query ticket information |
GetCraftLine | Query routes |
QueryMacSN | Query MAC address and IMEI by SN |
StationReset | Reset node status |
Auth | Authorize a product with a ticket |
AuthValidate | Verify a product authorization with a ticket |
StationStatusCommit | Commit node status |
GetShortLink | Get a short URL |
GetSmartConfigQRCode | Get a QR code for pairing by SN and PID |
CheckNodeIsPass | Check the processing status |
Interface | Description |
---|---|
Login | Log in with an account |
CloudAPI | Cloud API operations |
API name
SetUrlSftVer
Functional description
Select the environment of Tuya software and set the name and version of the application that calls the SDK. Based on these settings, the parameters in the call of the network communication SDK automatically include the name and version of the application.
Function prototype
void SetUrlSftVer ( string sftVer, string sftIdentity, _LoginUrlType urlType = _LoginUrlType.Release )
Parameter description
Parameter name | Description |
---|---|
sftVer | The version number of the software that calls the SDK. |
sftIdentity | The name of the software that calls the SDK. |
urlType | The environment of the Tuya software. The online environment is specified by default. |
Return value
Return value | Description |
---|---|
None | None |
urlType
must be set to _LoginUrlType.Release
. Otherwise, the product authorization might be invalid.
API name
UserLogin
Functional description
Enable login with a Tuya software account and implement user authentication. Contact your project manager to get the username and password. You must apply for the username and password for each account. The permissions and application scope vary based on different accounts. Most API operations in the SDK are available only after login with your account.
Function prototype
UserLoginRspParas UserLogin ( UserLoginReqParas ReqParas, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
ReqParas | The parameters in the login request. This is the object of the UserLoginReqParas class. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the UserLoginRspParas class. |
The successful response or the error message that is returned. |
API name
TokenAuth
Functional description
Upload the information about a product to the Tuya PMS. The uploaded information can be the media access control address (MAC address), serial number (SN), and token. After the verification is passed, the authorization key and other information are returned to authorize the specified device. Unauthorized or failed devices might not be able to connect to the Tuya PMS.
Function prototype
TokenAuthRsp TokenAuth ( TokenAuthReq ReqParas, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
ReqParas | The parameters in the authorization request. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the ProdTokenAuthRsp class. |
The successful response, the error message that is returned in a failed call, or authorization information. |
API name
GetTokenInfo
Functional description
Get the information about a token.
Function prototype
GetTokenInfoRspParas GetTokenInfo ( GetTokenInfoReqParas ReqParas, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
ReqParas | The parameters in the authorization request. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the GetTokenInfoRspParas class. |
The information about the token. |
API name
TokenAuthValidate
Functional description
Verify the validity of an authorization. This verification must be passed before a device is authorized.
Function prototype
TokenAuthValidateRsp TokenAuthValidate ( TokenAuthValidateReq ReqParas, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
ReqParas | The parameters in the authorization request. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the TokenAuthValidateRsp class. |
The result of the validity verification. |
API name
AddAuthLog
Functional description
Upload authorization logs to the Tuya PMS after a device is authorized.
Function prototype
AddAuthLogRspParas AddAuthLog(AddAuthLogReqParas ReqParas, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
ReqParas | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the AddAuthLogRspParas class. |
The successful response or the error message that is returned. |
API name
GetWorkOrderInfo
Functional description
Get the information about a ticket.
Function prototype
GetWorkOrderInfoRsp GetWorkOrderInfo ( GetWorkOrderInfoReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the GetWorkOrderInfoRsp class. |
The successful response or the error message that is returned. |
API name
GetCraftLine
Functional description
Query the information about routes.
Function prototype
GetCraftLineRsp GetCraftLine( GetCraftLineReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the GetCraftLineRsp class. |
The successful response or the error message that is returned. |
API name
QueryMacSN
Functional description
Get data such as the MAC address and IMEI by SN. The data has been associated with the specific SN.
Function prototype
QueryMacSNRspParas QueryMacSN ( queryMacSNReqParas Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the QueryMacSNRspParas class. |
The successful response or the error message that is returned. |
API name
StationReset
Functional description
Reset the status of a node and clear the test record and status of the node.
Function prototype
StationResetRsp StationReset( StationResetReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the StationResetRsp class. |
The successful response or the error message that is returned. |
API name
Auth
Functional description
Authorize a product with a ticket.
Function prototype
AuthRsp Auth( AuthReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the AuthRsp class. |
The successful response or the error message that is returned. |
API name
AuthValidate
Functional description
Verify a product authorization with a ticket.
Function prototype
AuthValidateRsp AuthValidate( AuthValidateReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the AuthValidateRsp class. |
The successful response or the error message that is returned. |
API name
StationStatusCommit
Functional description
Commit the status of a node.
Function prototype
StationStatusCommitRsp StationStatusCommit( StationStatusCommitReq Req, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to add authorization logs. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the StationStatusCommitRsp class. |
The successful response or the error message that is returned. |
API name
GetShortLink
Functional description
Get a short URL.
Function prototype
GetShortLinkRsp GetShortLink( GetShortLinkReq, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to get a short URL. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the GetShortLinkRsp class. |
The successful response or the error message that is returned. |
API name
GetSmartConfigQRCode
Functional description
Get a short URL.
Function prototype
GetSmartConfigQRCodeRsp GetSmartConfigQRCode( GetSmartConfigQRCodeReq, string apiVer = "1.0")
Parameter description
Parameter name | Description |
---|---|
Req | The parameters in the request to get the QR code of a short URL. |
apiVer | The API version. Default value: 1.0. |
Return value
Return value | Description |
---|---|
The object of the GetSmartConfigQRCodeRsp class. |
The successful response or the error message that is returned. |
API name
CheckNodeIsPass
Functional description
Check the processing status of a product.
Function prototype
CheckCraftRouteNodeRsp CheckNodeIsPass( CheckCraftRouteNodeReq req, string apiVer = "2.0")
Parameter description
Parameter name | Description |
---|---|
Req | The request to check the processing status of a product. |
apiVer | The API version. Default value: 2.0. |
Return value
Return value | Description |
---|---|
The object of the CheckCraftRouteNodeRsp class. |
The successful response or the error message that is returned. |
enum _LoginUrlType
{
Release = 0, // The online environment is specified by default.
Preview = 1, // The preview environment.
Daily = 2 // The daily environment.
}
public class UserLoginReqParas
{
public string username; // The username, required.
public string password; // The password, required.
public string token; // The token, optional.
}
public class PermissionsData
{
public string permissionCode; // The login permission code.
public string permissionName; // The login permission name.
}
public class UserLoginResult
{
public string sessionId; // The login session ID.
public List<PermissionsData> permissions; // The list of login permissions.
}
public class UserLoginRspParas{
public bool success; // The result of the call. Valid values: true: indicates a successful call. false: indicates a failed call.
public string errorMsg; // The error message that is returned in a failed call.
public string errorCode; // The error code.
public string status; // The operation status, including the specific error message or status.
public long t; // The timestamp when the API operation is called.
public UserLoginResult result; // The result of the call.
}
public class TokenAuthReq
{
public string sn ; // The product SN.
public string tokenId ; // The license.
public string sftVersion ;// The software version number.
public string muid ; // The value of muid for the Espressif chipset. A null string is returned for other chipsets.
public string mac ; // The MAC address of a product.
public string chipId ; // The ID of an encrypted chip. A null string is returned for unencrypted chips.
}
public class TokenAuthResult
{
public string uuid; // The value of uuid of a module.
public string mac; // The authorized MAC address.
public string accessKey; // The authorization key.
}
public class TokenAuthRsp{
public bool success; // The result of the call. Valid values: true: indicates a successful call. false: indicates a failed call.
public string errorMsg; // The error message that is returned in a failed call.
public string errorCode; // The error code.
public string status; // The operation status.
public long t; // The timestamp when the API operation is called.
public TokenAuthResult result; // The authorization result is valid only when the serial port running result is true.
}
public class GetTokenInfoReqParas
{
public string tokenId; // The license.
public string type; // The type of authorization. Set the value to Wi-Fi.
public string sftVersion; // The software version number.
public string softwareName; // The software name.
}
public class TokenInfo
{
public int amount; // The total number of devices that can be authorized with a token.
public string firmwareConfigMd5; // The MD5 hash value of a configuration file.
public string firmwareConfigUrl; // The URL of a configuration file.
public string snPrefix; // The prefix of an SN.
public string firmwareChip; // The firmware chipset.
public string firmwareProtocolType; // The type of firmware protocol.
public string productionFirmwareMd5; // The MD5 hash value of production firmware.
public string productionFirmwareUrl; // The URL of production firmware.
public bool supportFirmwareConfig; // Specifies whether to support original equipment manufacturer (OEM) configurations.
public string productionSubFirmwareUrl; // The URL of sub-firmware.
public string moduleModelChip; // The chipset of a module.
public string productId; // The product ID.
public string type; // The type of license.
public string firmwareKey; // The firmware key.
public string macRule; // Specifies whether a MAC address is assigned by the cloud. Valid values: 0: A MAC address is not assigned. 1: A MAC address is assigned.
public bool oem; // Specifies whether OEM firmware is used.
public string countryCode; // The country code.
public string productionSubFirmwareMd5; // The MD5 hash value of sub-firmware.
public string userareaFirmwareUrl; // The URL of user area firmware.
public string userareaFirmwareMd5; // The MD5 hash value of user area firmware.
public bool refreshUserarea; // Specifies whether to refresh user area firmware.
public long effectiveTime; // The time when the license takes effect.
public int expires; // The validity of the license.
public string id; // The license.
public string productionId; // The production batch number.
public bool test; // Specifies whether a production test is performed.
public int usedAmount; // The number of licenses.
public string wifiHotspotName; // The name of a hotspot.
public string wifiPassword; // The password of a hotspot.
public string desc; // The description of the license.
public string manufacturer; // The manufacturer.
public string productKey; // Reserved.
public string fingerprint; // The name of firmware.
public string firmwareVersion; // The version of firmware.
public int firmwareType; // Reserved.
public bool gpioTest; // Reserved.
public bool wifiTest; // Reserved.
public string baselineVersion; // Reserved.
public string flashRunSize; //The size of flash memory. Unit: Mbit/s.
}
public class TokenAuthRsp
{
public bool success; // The result of the call. Valid values: true: indicates a successful call. false: indicates a failed call.
public string errorMsg; // The error message that is returned in a failed call.
public string errorCode; // The error code.
public string status; // The operation status, including the specific error message or status.
public long t; // The timestamp when the API operation is called.
public ProdTokenAuthResult result; // The result of the call.
}
public class ProdTokenAuthValidateReq {
public string tokenId ; // The license.
public string sn; // The product SN.
public string mac ; // The MAC address of a product.
public string uuid ; // The value of uuid of an authorized product.
public string muid ; // The ID of a product chip.
public string accessKey ; // The authorization key.
public string wifiHotspotName ; // The name of a hotspot.
public string wifiPassword ; // The password of a hotspot.
public string chipId ; // The ID of an encrypted chip.
public string sftVersion ; // The software version number.
}
public class TokenAuthValidateResult
{
public bool result; // The result of authorization verification.
public string failureDepict; // The description of a failure reason.
}
public class TokenAuthValidateRsp : BaseResponse
{
public bool success; // The result of authorization verification.
public string errorMsg; // The error message that is returned in a failed call.
public string errorCode; // The error code.
public string status; // The operation status, including the specific error message or status.
public long t; // The timestamp when the API operation is called.
public ProdTokenAuthValidateResult result; // The result of the call.
}
public class AuthLog
{
public string hid; // The value is a MAC address in the authorization of a Wi-Fi product.
public string uuid; // The value of uuid for an authorization.
public string tokenId; // The license.
public string sn; // The product SN.
public string activeTime; // The timestamp when the authorization takes effect.
public string firmwareInfo; // The firmware fingerprint, including the name and version of the firmware.
public string gpio; // The result of a general-purpose input/output (GPIO) pin test. The result can be successful or failed.
public string rssi; // The result of a Wi-Fi signal strength test.
public int authStatus; // The authorization status. Valid values: 1: indicates a successful authorization. 0: indicates a failed authorization.
public string authDepict; // The description of authorization status. The authorization can be successful or failed.
public string countryCode; // The country code.
}
public class AddAuthLogReqParas
{
public AuthLog log; // The data set of authorization logs.
}
public class AddAuthLogRspParas{
public bool success; // The result of the call.
public string errorMsg; // The error message that is returned in a failed call.
public string errorCode; // The error code.
public string status; // The operation status, including the specific error message or status.
public long t; // The timestamp when the API operation is called.
}
public class GetWorkOrderInfoReq {
public string orderCode;/// The ticket code, required.
}
public class GetWorkOrderInfoRsp{
public WorkOrderInfo result;// The returned result.
public class WorkOrderInfo
{
public string materielCode;// The material code.
public string productSize;/// The product model.
public string pcsNum;/// The number of orders.
public string tokenId;/// The license.
}
}
public class GetCraftLineReq{
public string orderCode;/// The ticket code.
}
public class GetCraftLineRsp{
public CraftLineNodes result;
public class CraftLineNodes {
public string code;/// The route code.
public string name;/// The route name.
public List<Node> nodeList;/// A list of nodes for a route.
public class Node/// The definition of a node for a route.
{
public string code;/// The station code.
public string desc; /// The description of the station.
public string programs;/// The program of the station.
}
}
public class QueryMacSNReqParas{
public string orderCode = "";/// The ticket code.
public string tokenId = "";/// The license.
public string keyType = "";/// The SN and MAC address, optional.
public string key = ""; /// The SN and MAC address, optional. If you set the value, the associated MAC address, SN, and CMEI are returned.
public string printed = "";/// Specifies whether to print the response. Valid values: N means to return unprinted records, and Y means to return printed records. A null string means to return all records.
public int offset = 0;/// The offset.
public int limit = 1;/// The maximum number of records to be returned.
}
public class QueryMacSNRspParas{
public MacSNQueryResult result;
public class MacSNQueryResult {
public int totalCount;/// The total number of records.
public List<MacSNData> datas;/// A group of SN and MAC data.
}
public class MacSNData
{
public string code;/// The code that is used for colored packaging.
public string sn;/// The SN.
public string mac;/// The MAC address.
public string tokenId;/// The license.
public string printed; /// Indicates whether the records are printed. Valid values: Y: printed. N: not printed.
public string packed;/// Indicates the packaging status. Valid values: Y: packaged. N: not packaged.
public string channelType; /// The type of the carrier.
public string channelDeviceId;/// The code of the carrier.
public string psk;/// The pre-shared key (PSK).
public string imei;/// The IMEI number.
public string patchSn;/// The patch SN.
public string jdSecretKey; /// The JD Cloud key.
}
}
public class StationResetReq{
public string orderCode ;/// The ticket code, required.
public string sn; /// The SN, required.
public string stationCode ;/// The node code, required.
}
public class StationResetRsp{
public StationResetResult result;
public class StationResetResult {
public string requestId ;/// The request ID.
public int amount/// The number of nodes to be passed in a process.
}
}
public class AuthReq{
public string requestId ; /// The value is obtained from the response to the station resetting request. Required.
public string tokenId ;/// The license, required.
public string sn;/// The SN, required.
public string muid;/// The chip ID is required only for an Espressif Wi-Fi module.
public string mac;/// The MAC address is required for an Espressif Zigbee module. The value is read from the module and not assigned from the printed code.
public string chipId; /// The security chip ID that is required by a security module.
public string sftVersion;/// The software version of the production test tool, required.
}
public class AuthRsp{
public AuthRspResult result;
public class AuthRspResult {
public string uuid;/// The value of uuid for a module. The value is generated in the cloud based on earlier logic. Specifically, the value varies based on different pairing modes.
public string mac;/// The MAC address.
public string accessKey;/// The authorization key.
public string pskKey ;/// The PSK.
public string certificateContent;/// The security certificate.
public string privateKey; /// The security key.
public int crc32CertificateContent;/// The cyclic redundancy check (CRC) code in a security certificate.
public int crc32PrivateKey ;/// The CRC code for a private key.
}
}
public class AuthValidateReq{
public string requestId;/// The value is obtained from the response of the station resetting request. Required.
public string tokenId; /// The license, required.
public string sn; /// The SN, required.
public string muid;/// The chip ID is required only for an Espressif Wi-Fi module.
public string accessKey;/// The license that is read from the module, required.
public string uuid; /// The value of uuid for a module. The value is required and read from the module.
public string mac;/// The MAC address is required for an Espressif Zigbee module. The value is read from the module and not assigned from the printed code.
public string wifiHotspotName;/// The name of a hotspot. The value is read from the module.
public string wifiPassword; /// The Wi-Fi password that is read from the module.
public string chipId;/// The chip ID.
public string sftVersion; /// The software version for a production test, required.
public string nodeCode;/// The node code.
}
public class AuthValidateRsp{
public AuthValidateResult result;
public class AuthValidateResult {
public bool result;/// The result of authorization verification.
public string failureDepict;/// The description of a failure reason.
}
}
public class StationStatusCommitReq{
public string stationCode;/// The name of a node.
public string requestId ;/// The request ID.
public string orderCode;/// The ticket code.
public string sn;/// The SN.
public int status; /// Valid values: 1: the status is reported. 0: failed to report the status.
}
public class StationStatusCommitRsp{
public int result { get; set; }/// The number of nodes to be passed in a process.
}
public class GetShortLinkReq
{
public string orderCode { get; set; } /// The ticket code, required.
public string sn { get; set; }/// The SN, required.
public string appId { get; set; }/// Optional. Default value: `168`.
}
public class GetShortLinkRsp
{
public class GetShortLinkResult
{
public string sn { get; set; } // The authorized SN. The value might be different from that in the request.
public string shortUrl { get; set; }/// // The short URL.
public string deviceCode { get; set; }/// // The short code.
}
public GetShortLinkResult result;
}
public class GetSmartConfigQRCodeReq
{
public string orderCode { get; set; }/// The ticket code.
public string sn { get; set; }/// The SN.
public string pid { get; set; }/// The PID.
}
public class GetSmartConfigQRCodeRsp
{
public class GetSmartConfigQRCodeResult
{
public string sn { get; set; } /// // The authorized SN. The value might be different from that in the request.
public string shortUrl { get; set; } /// // The short URL.
public string deviceCode { get; set; } /// // The short code.
}
public GetSmartConfigQRCodeResult result;
}
/// <summary>
/// The request parameters to check the process status by SN.
/// </summary>
public class CheckCraftRouteNodeReq : BaseRequest
{
public string sn;
/// <summary>
/// The current node code.
/// </summary>
public string nodeCode;// The current node code.
}
/// <summary>
/// The response parameters to check the process status by SN.
/// </summary>
public class CheckCraftRouteNodeRsp : BaseResponse
{
/// <summary>
/// The status of a station test status. Valid values: true: passed. false: untested or failed.
/// </summary>
public bool result;
}
API name
Login
Functional description
Log in to the Tuya PMS and get information about user permissions.
Function prototype
bool _stdcall Login(char* userName, char* password, char *version = "1.0", char*rsp = "");
Parameter description
Parameter name | Description |
---|---|
userName | The login username. |
password | The login password. |
version | The API version. Default value: 1.0. |
rsp | The login result. |
Return value
Return value | Description |
---|---|
String | The login result returned by rsp in the JSON format. |
API name
CloudAPI
Functional description
Log in to the Tuya PMS and get information about user permissions.
Function prototype
bool _stdcall CloudAPI(char* api, char*data, char* ver,char*result);
Parameter description
Parameter name | Description |
---|---|
api | The name of the API operation to be called. |
data | The string in the JSON format. |
ver | The API version. |
result | The result to be returned in the JSON format. |
Return value
Return value | Description |
---|---|
result | The result to be returned in the JSON format. |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback