Appearance
Data Interaction API
API Overview
Function | Description |
---|---|
Qth_cmdSendTsl() | Sends TSL data to Developer Center. |
Qth_cmdSendTrans() | Sends transparent transmission data to Developer Center. |
Qth_wanSendDevInfo() | Reports device information to Developer Center. |
Qth_wanSendDevStatus() | Reports device status to Developer Center. |
Qth_ntpSetResultCb() | Sets callback function of receiving the NTP result. |
Qth_ntpSendNtpReq() | Sends an NTP request. |
API Description
Qth_cmdSendTsl
This function sends TSL data to Developer Center.
Prototype
c
oprt_ret Qth_cmdSendTsl(Qth_sendMode_e mode, void *ttlvHead, quint16_t *pkgId, Qth_sendCb_f sendCb);
Parameter
Input Parameter
Qth_sendMode_e
mode
: Data sending mode.Value Description QTH_SEND_AT_MOST_ONCE Each message is only sent once with no confirmation or resending required. Data loss or repetition may occur. QTH_SEND_AT_LEAST_ONCE Each message is sent at least once until the device receives the reception confirmation from Developer Center. Data repetition may occur. QTH_SEND_EXACTLY_ONCE Each message is only sent once by Developer Center and only received once by the receiver, with no data loss or repetition. void *
ttlvHead
: TTLV data table.Qth_sendCb_f
sendCb
: Callback function of data sending result. If you do not care about the sending result, set this parameter to NULL.- Prototypec
typedef void (*Qth_sendCb_f)(quint16_t pkgId, qbool result);
- Input Parameter
- quint16_t
pkgId
: PkgID of the data sent. - qbool
result
: Data sending result.
- quint16_t
- Prototype
Output Parameter
quint16_t *
pkgId
: PkgID of the data sent. If you do not care about the sending result, set this parameter to NULL.Return Value
OPRT_OK
: Successful execution- Other values: See Error Code List for details.
Example
c
void *ttlvHead = NULL;
Quos_ttlvAddIdBool(&ttlvHead, 1, TRUE);
Qth_cmdSendTsl(QTH_SEND_AT_MOST_ONCE, ttlvHead, NULL, NULL);
Qth_cmdSendTrans
This function sends transparent transmission data to Developer Center.
Prototype
c
oprt_ret Qth_cmdSendTrans(Qth_sendMode_e mode, quint8_t *value, quint32_t valLen, quint16_t *pkgId, Qth_sendCb_f sendCb);
Parameter
Input Parameter
Qth_sendMode_e
mode
: Data sending mode.Value Description QTH_SEND_AT_MOST_ONCE Each message is only sent once with no confirmation or resending required. Data loss or repetition may occur. QTH_SEND_AT_LEAST_ONCE Each message is sent at least once until the device receives the reception confirmation from Developer Center. Data repetition may occur. QTH_SEND_EXACTLY_ONCE Each message is only sent once by Developer Center and only received once by the receiver, with no data loss or repetition. quint8_t *
value
: Transparent transmission data.quint32_t
valLen
: Length of transparent transmission data.Qth_sendCb_f
sendCb
: Callback function of data sending result. If you do not care about the sending result, set this parameter to NULL.- Prototypec
typedef void (*Qth_sendCb_f)(quint16_t pkgId, qbool result);
- Input Parameter
- quint16_t
pkgId
: PkgID of the data sent. - qbool
result
: Data sending result.
- quint16_t
- Prototype
Output Parameter
quint16_t *
pkgId
: PkgID of the data sent. If you do not care about the sending result, set this parameter to NULL.Return Value
OPRT_OK
: Successful execution- Other values: See Error Code List for details.
Example
c
void sendCb(quint16_t pkgId, qbool result)
{
Quos_logPrintf(LL_DBG, "recv send event, pkgId:%u, result:%d", pkgId, result);
}
quint16_t pkgId = 0;
Qth_cmdSendTrans(QTH_SEND_AT_LEAST_ONCE, "hello world", 11, &pkgId, sendCb);
Qth_ntpSetResultCb
This function sets callback function of receiving the NTP result.
Prototype
c
oprt_ret Qth_ntpSetResultCb(Qth_ntpCb_f callback);
Parameter
Input Parameter
- Qth_ntpCb_f
callback
: Callback function of receiving the NTP result.- Prototype
ctypedef void (*Qth_ntpCb_f)(quint16_t pkgId, Qth_ntpInfo_t *ntpInfo);
- Qth_ntpCb_f
Output Parameter
None
Return Value
OPRT_OK
: Successful execution- Other values: See Error Code List for details.
Example
c
oprt_ret ret = OPRT_OK;
void ntpDataCb(quint16_t pkgId, Qth_ntpInfo_t *ntpInfo)
{
Quos_logPrintf(LL_DBG, "recv ntp info, pkgId:%u", pkgId);
Quos_logPrintf(LL_DBG, "%04d-%02d-%02d %02d:%02d:%02d.%03d, %s, "PRINTF_FORMAT_U64,
ntpInfo->tm.tm_year, ntpInfo->tm.tm_mon, ntpInfo->tm.tm_mday, ntpInfo->tm.tm_hour, ntpInfo->tm.tm_min, ntpInfo->tm.tm_sec, ntpInfo->tm.tm_ms,
ntpInfo->timezone, PRINTF_CONV_U64(ntpInfo->timestamp));
}
ret = Qth_ntpSetResultCb(ntpDataCb);
if (OPRT_OK != ret)
{
Quos_logPrintf(APPS_OPEN, LL_ERR, "set ntp result callback error");
}
Qth_ntpSendNtpReq
This function sends an NTP request.
Prototype
c
oprt_ret Qth_ntpSendNtpReq(quint16_t *pkgId, Qth_sendCb_f sendCb);
Parameter
Input Parameter
- Qth_sendCb_f
sendCb
: Callback function of data reporting result. If you do not care about the sending result, set this parameter to NULL.- Prototype
ctypedef void (*Qth_sendCb_f)(quint16_t pkgId, qbool result);
- Qth_sendCb_f
Output Parameter
quint16_t
pkgId
: PkgID of the data reported. If you do not care about the sending result, set this parameter to NULL.Return Value
OPRT_OK
: Successful execution- Other values: See Error Code List for details.
Example
c
oprt_ret ret = OPRT_OK;
void ntpDataCb(quint16_t pkgId, Qth_ntpInfo_t *ntpInfo)
{
Quos_logPrintf(LL_DBG, "recv ntp info, pkgId:%u", pkgId);
Quos_logPrintf(LL_DBG, "%04d-%02d-%02d %02d:%02d:%02d.%03d, %s, "PRINTF_FORMAT_U64,
ntpInfo->tm.tm_year, ntpInfo->tm.tm_mon, ntpInfo->tm.tm_mday, ntpInfo->tm.tm_hour, ntpInfo->tm.tm_min, ntpInfo->tm.tm_sec, ntpInfo->tm.tm_ms,
ntpInfo->timezone, PRINTF_CONV_U64(ntpInfo->timestamp));
}
Qth_ntpSetResultCb(ntpDataCb);
ret = Qth_ntpSendNtpReq(NULL, NULL);
if (OPRT_OK != ret)
{
Quos_logPrintf(APPS_OPEN, LL_ERR, "send ntp request error");
}
Qth_wanSendDevInfo
This function reports device information to Developer Center.
Prototype
c
void Qth_wanSendDevInfo();
Parameter
Input Parameter
- None
Return Value
- None
Example
c
Qth_wanSendDevInfo();
Qth_wanSendDevStatus
This function reports device status to Developer Center.
Prototype
c
void Qth_wanSendDevStatus();
Parameter
Input Parameter
- None
Return Value
- None
Example
c
Qth_wanSendDevStatus();
Error Code List
Enumeration Value | Hexadecimal | Decimal | Description |
---|---|---|---|
OPRT_OK | -0x0000 | -0 | Successful execution. |
OPRT_COM_ERROR | -0x0001 | -1 | General error. |
OPRT_INVALID_PARM | -0x0002 | -2 | Invalid parameter. |
OPRT_MALLOC_FAILED | -0x0003 | -3 | Memory allocation failed. |
OPRT_NOT_SUPPORTED | -0x0004 | -4 | Not supported. |
OPRT_NOT_FOUND | -0x0005 | -5 | Object not found. |
OPRT_INDEX_OUT_OF_BOUND | -0x0006 | -6 | Index out of bounds. |
OPRT_EXCEED_UPPER_LIMIT | -0x0007 | -7 | Exceed upper limit. |
OPRT_NOT_EXIST | -0x0008 | -8 | Not exist. |
OPRT_QTH_CMD_PKG_FORMAT_INVALID | -0x1200 | -4608 | Data packet format error. |
OPRT_QTH_CMD_PKG_GENERATE_FAILED | -0x1201 | -4609 | Failed to generate the data packet. |
OPRT_QTH_CMD_UNSUPPORTED | -0x1202 | -4610 | Unsupported data command. |
OPRT_QTH_CMD_PKG_SEND_FAILED | -0x1203 | -4611 | Failed to send the data packet. |
OPRT_QTH_WAN_PKG_FORMAT_INVALID | -0x1300 | -4864 | WAN data packet format error. |
OPRT_QTH_WAN_PKG_REPEATED | -0x1301 | -4865 | Duplicate WAN data packet. |
OPRT_QTH_WAN_GET_TOPIC_FAILED | -0x1302 | -4866 | Failed to get the topic over WAN. |
OPRT_QTH_WAN_UNKNOWN_FAILED | -0x1303 | -4867 | WAN connection unknown error. |