optimize print log& shadow declaration

This commit is contained in:
ethan.du 2019-11-22 14:09:55 +08:00
parent e39c37ef1e
commit bd01eb4bdd
12 changed files with 155 additions and 187 deletions

View File

@ -139,7 +139,7 @@ int HAL_AT_TCP_Disconnect(utils_network_pt pNetwork)
ret = at_exec_cmd(resp, at_command, 0, "AT+QICLOSE=%d\r\n",pNetwork->handle-1);
if(SUCCESS_RET != ret)
{
HAL_Printf("close TCP link fail!\n");
LOG_ERROR("close TCP link fail!\n");
}
else
{
@ -391,7 +391,7 @@ static int urc_qird_recv_func(const char *data, uint32_t size)
ret |= ring_buff_push_data(&(g_ring_tcp_buff[link_num]), &temp_char, 1);
if(SUCCESS_RET != ret)
{
HAL_Printf("copy data to tcp buff fail\n");
LOG_ERROR("copy data to tcp buff fail\n");
}
}
}
@ -448,7 +448,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "ATE0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("ATE0 set fail!\n");
LOG_ERROR("ATE0 set fail!\n");
goto end;
}
@ -464,7 +464,7 @@ static int ec20_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CPIN?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("please check SIM card status!\n");
LOG_ERROR("please check SIM card status!\n");
continue;
}
@ -473,7 +473,7 @@ static int ec20_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CSQ\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("bad signal!\n");
LOG_ERROR("bad signal!\n");
continue;
}
@ -482,7 +482,7 @@ static int ec20_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CREG?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("not network regist!\n");
LOG_ERROR("not network regist!\n");
continue;
}
@ -491,7 +491,7 @@ static int ec20_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CGREG?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("not Attach GPRS!\n");
LOG_ERROR("not Attach GPRS!\n");
continue;
}
@ -500,7 +500,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CEREG?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("check TCPIP mode fail!\n");
LOG_ERROR("check TCPIP mode fail!\n");
goto end;
}
@ -509,7 +509,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+COPS?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("query current Network Operator fail!\n");
LOG_ERROR("query current Network Operator fail!\n");
goto end;
}
@ -519,7 +519,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QICSGP=1,1,\"UNINET\",\"\",\"\",0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("AT+QICSGP CHN-UNICOM fail!\n");
LOG_ERROR("AT+QICSGP CHN-UNICOM fail!\n");
goto end;
}
}
@ -529,7 +529,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QICSGP=1,1,\"CMNET\",\"\",\"\",0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("AT+QICSGP CHINA MOBILE fail!\n");
LOG_ERROR("AT+QICSGP CHINA MOBILE fail!\n");
goto end;
}
}
@ -539,7 +539,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QICSGP=1,1,\"CTNET\",\"\",\"\",0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("AT+QICSGP CHN-CT fail!\n");
LOG_ERROR("AT+QICSGP CHN-CT fail!\n");
goto end;
}
}
@ -559,7 +559,7 @@ static int ec20_init()
if(retry_time == 10)
{
HAL_Printf("sim800c init fail!\n");
LOG_ERROR("sim800c init fail!\n");
goto end;
}
@ -568,7 +568,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CTZU=3\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("Enable automatic time zone update via NITZ and update LOCAL time to RTC fail!\n");
LOG_ERROR("Enable automatic time zone update via NITZ and update LOCAL time to RTC fail!\n");
goto end;
}
@ -577,7 +577,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIDEACT=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("Deactivate context profile fail!\n");
LOG_ERROR("Deactivate context profile fail!\n");
goto end;
}
@ -586,7 +586,7 @@ static int ec20_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIACT=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("Activate context profile fail!\n");
LOG_ERROR("Activate context profile fail!\n");
goto end;
}
@ -650,7 +650,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
if(SUCCESS_RET != ret)
{
HAL_Printf("build TCP link fail!\n");
LOG_ERROR("build TCP link fail!\n");
goto end;
}
else

View File

@ -129,7 +129,7 @@ int HAL_AT_TCP_Disconnect(utils_network_pt pNetwork)
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPCLOSE=%d\r\n",pNetwork->handle-1);
if(SUCCESS_RET != ret)
{
HAL_Printf("close TCP link fail!\n");
LOG_ERROR("close TCP link fail!\n");
}
else
{
@ -256,43 +256,13 @@ static int urc_recvdata_recv_func(const char *data, uint32_t size)
ret |= ring_buff_push_data(&(g_ring_tcp_buff[link_num]), &temp_char, 1);
if(SUCCESS_RET != ret)
{
HAL_Printf("copy data to tcp buff fail\n");
LOG_ERROR("copy data to tcp buff fail\n");
}
}
}
return SUCCESS_RET;
}
/*
static int urc_recvlen_recv_judge(const char *data, uint32_t size)
{
char temp[13] = {0};
if(size > 12)
{
memcpy(temp, &data[1],12);
temp[12] = '\0';
if(0 == strncmp(temp, "+CIPRECVLEN:", size))
{
return SUCCESS_RET;
}
else
{
return FAILURE_RET;
}
}
else
{
if(0 == strncmp(data, "+CIPRECVLEN:", size))
{
return SUCCESS_RET;
}
else
{
return FAILURE_RET;
}
}
}
*/
static int urc_recvlen_recv_judge(const char *data, uint32_t size)
{
@ -368,7 +338,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+RST\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("AT rst fail!\n");
LOG_ERROR("AT rst fail!\n");
goto end;
}
@ -380,7 +350,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "ATE0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("ATE0 set fail!\n");
LOG_ERROR("ATE0 set fail!\n");
goto end;
}
@ -389,7 +359,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CWMODE=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set Wi-Fi mode to station fail!\n");
LOG_ERROR("set Wi-Fi mode to station fail!\n");
continue;
}
@ -398,7 +368,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CIPMUX=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set mutil link fail!\n");
LOG_ERROR("set mutil link fail!\n");
continue;
}
@ -407,7 +377,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CWJAP=\"ucloud-guest\",\"ucloud.cn\"\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("link Wi-Fi AP fail!\n");
LOG_ERROR("link Wi-Fi AP fail!\n");
continue;
}
@ -416,7 +386,7 @@ static int esp8266_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CIFSR\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("get ip addr fail!\n");
LOG_ERROR("get ip addr fail!\n");
continue;
}
@ -488,7 +458,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPSTART=%d,\"TCP\",\"%s\",%d\r\n", link_num, pNet->pHostAddress, pNet->port);
if(SUCCESS_RET != ret)
{
HAL_Printf("build TCP link fail!\n");
LOG_ERROR("build TCP link fail!\n");
goto end;
}
else
@ -503,7 +473,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPRECVMODE=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set tcp receive data mode fail!\n");
LOG_ERROR("set tcp receive data mode fail!\n");
goto end;
}

View File

@ -92,7 +92,7 @@ int HAL_AT_Read(_IN_ utils_network_pt pNetwork, _OU_ unsigned char *buffer, _IN_
ret |= ring_buff_push_data(&(g_ring_tcp_buff[link_num]), &temp_char, 1);
if(SUCCESS_RET != ret)
{
HAL_Printf("copy data to tcp buff fail\n");
LOG_ERROR("copy data to tcp buff fail\n");
}
}
}
@ -176,7 +176,7 @@ int HAL_AT_TCP_Disconnect(utils_network_pt pNetwork)
ret = at_exec_cmd(resp, at_command, 0, "AT+QICLOSE=%d\r",pNetwork->handle-1);
if(SUCCESS_RET != ret)
{
HAL_Printf("close TCP link fail!\n");
LOG_ERROR("close TCP link fail!\n");
}
else
{
@ -452,7 +452,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "ATE0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("ATE0 set fail!\n");
LOG_ERROR("ATE0 set fail!\n");
goto end;
}
@ -468,7 +468,7 @@ static int m26_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CPIN?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("please check SIM card status!\n");
LOG_ERROR("please check SIM card status!\n");
continue;
}
@ -477,7 +477,7 @@ static int m26_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CSQ\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("bad signal!\n");
LOG_ERROR("bad signal!\n");
continue;
}
@ -486,7 +486,7 @@ static int m26_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CREG?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("not network regist!\n");
LOG_ERROR("not network regist!\n");
continue;
}
@ -495,7 +495,7 @@ static int m26_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CGREG?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("not Attach GPRS!\n");
LOG_ERROR("not Attach GPRS!\n");
continue;
}
@ -504,7 +504,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIMODE?\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("check TCPIP mode fail!\n");
LOG_ERROR("check TCPIP mode fail!\n");
goto end;
}
@ -517,7 +517,7 @@ static int m26_init()
if(retry_time == 10)
{
HAL_Printf("sim800c init fail!\n");
LOG_ERROR("sim800c init fail!\n");
goto end;
}
@ -526,7 +526,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIFGCNT=0\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set foreground fail!\n");
LOG_ERROR("set foreground fail!\n");
goto end;
}
@ -535,7 +535,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QICSGP=1, \"CMNET\"\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set apn fail!\n");
LOG_ERROR("set apn fail!\n");
goto end;
}
@ -544,7 +544,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIDEACT\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("shut down GPRS/CSD PDP fail!\n");
LOG_ERROR("shut down GPRS/CSD PDP fail!\n");
goto end;
}
@ -553,7 +553,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIMUX=1\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set multi link mode fail!\n");
LOG_ERROR("set multi link mode fail!\n");
goto end;
}
@ -562,7 +562,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIREGAPP\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("set APN fail!\n");
LOG_ERROR("set APN fail!\n");
goto end;
}
@ -571,7 +571,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QIACT\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("build wireless link fail!\n");
LOG_ERROR("build wireless link fail!\n");
goto end;
}
@ -580,7 +580,7 @@ static int m26_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+QILOCIP\r\n");
if(SUCCESS_RET != ret)
{
HAL_Printf("fetch local IP address fail!\n");
LOG_ERROR("fetch local IP address fail!\n");
goto end;
}
@ -642,7 +642,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
ret = at_exec_cmd(resp, at_command, 0, "AT+QIDNSGIP=\"%s\"\r", pNet->pHostAddress);
if(SUCCESS_RET != ret)
{
HAL_Printf("build TCP link fail!\n");
LOG_ERROR("build TCP link fail!\n");
goto end;
}
@ -651,7 +651,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
ret = at_exec_cmd(resp, at_command, 0, "AT+QIOPEN=%d,\"TCP\",\"%s\",\"%d\"\r", link_num, domain_ip_addr, pNet->port);
if(SUCCESS_RET != ret)
{
HAL_Printf("build TCP link fail!\n");
LOG_ERROR("build TCP link fail!\n");
goto end;
}
else

View File

@ -93,7 +93,7 @@ int HAL_AT_Read(_IN_ utils_network_pt pNetwork, _OU_ unsigned char *buffer, _IN_
ret |= ring_buff_push_data(&(g_ring_tcp_buff[link_num]), &temp_char, 1);
if(SUCCESS_RET != ret)
{
HAL_Printf("copy data to tcp buff fail\n");
LOG_ERROR("copy data to tcp buff fail\n");
}
}
}
@ -177,7 +177,7 @@ int HAL_AT_TCP_Disconnect(utils_network_pt pNetwork)
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPCLOSE=%d\r",pNetwork->handle-1);
if(SUCCESS_RET != ret)
{
HAL_Printf("close TCP link fail!\n");
LOG_ERROR("close TCP link fail!\n");
}
else
{
@ -406,7 +406,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "ATE0\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("ATE0 set fail!\n");
LOG_ERROR("ATE0 set fail!\n");
goto end;
}
@ -422,7 +422,7 @@ static int sim800c_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CPIN?\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("please check SIM card status!\n");
LOG_ERROR("please check SIM card status!\n");
continue;
}
@ -431,7 +431,7 @@ static int sim800c_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CSQ\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("bad signal!\n");
LOG_ERROR("bad signal!\n");
continue;
}
@ -440,7 +440,7 @@ static int sim800c_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CREG?\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("not network regist!\n");
LOG_ERROR("not network regist!\n");
continue;
}
@ -449,7 +449,7 @@ static int sim800c_init()
ret |= at_exec_cmd(resp, at_command, 0, "AT+CGATT?\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("not Attach GPRS!\n");
LOG_ERROR("not Attach GPRS!\n");
continue;
}
@ -462,7 +462,7 @@ static int sim800c_init()
if(retry_time == 10)
{
HAL_Printf("sim800c init fail!\n");
LOG_ERROR("sim800c init fail!\n");
goto end;
}
@ -471,7 +471,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPMUX=1\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("set multi link mode fail!\n");
LOG_ERROR("set multi link mode fail!\n");
goto end;
}
@ -480,7 +480,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CSTT=\"3GNET\"\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("set APN fail!\n");
LOG_ERROR("set APN fail!\n");
goto end;
}
@ -489,7 +489,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CIICR\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("build wireless link fail!\n");
LOG_ERROR("build wireless link fail!\n");
goto end;
}
@ -498,7 +498,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CIFSR\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("fetch local IP address fail!\n");
LOG_ERROR("fetch local IP address fail!\n");
goto end;
}
@ -507,7 +507,7 @@ static int sim800c_init()
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPQSEND=1\r");
if(SUCCESS_RET != ret)
{
HAL_Printf("fast send mode fail!\n");
LOG_ERROR("fast send mode fail!\n");
goto end;
}
@ -569,7 +569,7 @@ int HAL_AT_TCP_Connect(_IN_ void * pNetwork, _IN_ const char *host, _IN_ uint16_
ret = at_exec_cmd(resp, at_command, 0, "AT+CIPSTART=%d,\"TCP\",\"%s\",\"%d\"\r", link_num, pNet->pHostAddress, pNet->port);
if(SUCCESS_RET != ret)
{
HAL_Printf("build TCP link fail!\n");
LOG_ERROR("build TCP link fail!\n");
goto end;
}
else

View File

@ -29,7 +29,7 @@
#define UIOT_MY_DEVICE_SECRET "DEVICE_SECRET"
#define OTA_BUF_LEN (5000)
#define OTA_BUF_LEN (1024)
static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg)
{

View File

@ -253,7 +253,7 @@ static void on_message_callback_get_device_secret(void *pClient, MQTTMessage *me
HAL_Free(Password);
return;
}
extern char ringBuff[];
int IOT_MQTT_Dynamic_Register(MQTTInitParams *pParams)
{
POINTER_VALID_CHECK(pParams, ERR_PARAM_INVALID);

View File

@ -21,96 +21,8 @@
extern "C" {
#endif
#include "uiot_export_mqtt.h"
#include "mqtt_client.h"
/**
* @brief
*/
typedef enum {
ACK_NONE = -3, // 请求超时
ACK_TIMEOUT = -2, // 请求超时
ACK_REJECTED = -1, // 请求拒绝
ACK_ACCEPTED = 0 // 请求接受
} RequestAck;
/**
* @brief 使
*/
typedef enum {
GET, // 获取云端设备文档
UPDATE, // 更新或创建云端设备文档
UPDATE_AND_RESET_VER, // 更新同时重置版本号
DELETE, // 删除部分云端设备文档
DELETE_ALL, // 删除全部云端设备文档中的属性,不需要一个个添加需要删除的属性
REPLY_CONTROL_UPDATE, // 设备处理完服务端的control消息后回应的update消息
REPLY_CONTROL_DELETE, // 设备处理完服务端的control消息后回应的delete消息
} Method;
/**
* @brief JSON文档中支持的数据类型
*/
typedef enum {
JINT32, // 32位有符号整型
JINT16, // 16位有符号整型
JINT8, // 8位有符号整型
JUINT32, // 32位无符号整型
JUINT16, // 16位无符号整型
JUINT8, // 8位无符号整型
JFLOAT, // 单精度浮点型
JDOUBLE, // 双精度浮点型
JBOOL, // 布尔型
JSTRING, // 字符串
JOBJECT // JSON对象
} JsonDataType;
/**
* @brief , JSON文档节点
*/
typedef struct _JSONNode {
char *key; // 该JSON节点的Key
void *data; // 该JSON节点的Value
JsonDataType type; // 该JSON节点的数据类型
} DeviceProperty;
/**
* @brief
*
* @param pClient ShadowClient对象
* @param method
* @param requestAck
* @param pJsonDocument
* @param userContext
*
*/
typedef void (*OnRequestCallback)(void *pClient, Method method, RequestAck requestAck, const char *pJsonDocument, void *userContext);
/**
* @brief
*/
typedef struct _RequestParam {
Method method; // 文档请求方式: GET, UPDATE, DELETE等
List *property_delta_list; // 该请求需要修改的属性
uint32_t timeout_sec; // 请求超时时间, 单位:s
OnRequestCallback request_callback; // 请求回调方法
void *user_context; // 用户数据, 会通过回调方法OnRequestCallback返回
} RequestParams;
/**
* @brief
*
* @param pClient ShadowClient对象
* @param pParams
* @param pJsonValueBuffer
* @param valueLength
* @param DeviceProperty
*/
typedef void (*OnPropRegCallback)(void *pClient, RequestParams *pParams, char *pJsonValueBuffer, uint32_t valueLength, DeviceProperty *pProperty);
#include "uiot_import.h"
#include "shadow_client.h"
/**
* @brief ShadowClient

View File

@ -23,8 +23,7 @@ extern "C" {
#include <stdbool.h>
#include "mqtt_client.h"
#include "shadow_client_json.h"
#include "uiot_export_shadow.h"
/* 在任意给定时间内, 处于appending状态的请求最大个数 */
#define MAX_APPENDING_REQUEST_AT_ANY_GIVEN_TIME (10)
@ -42,6 +41,93 @@ extern "C" {
#define MAX_WAIT_TIME_SEC 1
#define MAX_WAIT_TIME_MS 1000
/**
* @brief
*/
typedef enum {
ACK_NONE = -3, // 请求超时
ACK_TIMEOUT = -2, // 请求超时
ACK_REJECTED = -1, // 请求拒绝
ACK_ACCEPTED = 0 // 请求接受
} RequestAck;
/**
* @brief 使
*/
typedef enum {
GET, // 获取云端设备文档
UPDATE, // 更新或创建云端设备文档
UPDATE_AND_RESET_VER, // 更新同时重置版本号
DELETE, // 删除部分云端设备文档
DELETE_ALL, // 删除全部云端设备文档中的属性,不需要一个个添加需要删除的属性
REPLY_CONTROL_UPDATE, // 设备处理完服务端的control消息后回应的update消息
REPLY_CONTROL_DELETE, // 设备处理完服务端的control消息后回应的delete消息
} Method;
/**
* @brief JSON文档中支持的数据类型
*/
typedef enum {
JINT32, // 32位有符号整型
JINT16, // 16位有符号整型
JINT8, // 8位有符号整型
JUINT32, // 32位无符号整型
JUINT16, // 16位无符号整型
JUINT8, // 8位无符号整型
JFLOAT, // 单精度浮点型
JDOUBLE, // 双精度浮点型
JBOOL, // 布尔型
JSTRING, // 字符串
JOBJECT // JSON对象
} JsonDataType;
/**
* @brief , JSON文档节点
*/
typedef struct _JSONNode {
char *key; // 该JSON节点的Key
void *data; // 该JSON节点的Value
JsonDataType type; // 该JSON节点的数据类型
} DeviceProperty;
/**
* @brief
*
* @param pClient ShadowClient对象
* @param method
* @param requestAck
* @param pJsonDocument
* @param userContext
*
*/
typedef void (*OnRequestCallback)(void *pClient, Method method, RequestAck requestAck, const char *pJsonDocument, void *userContext);
/**
* @brief
*/
typedef struct _RequestParam {
Method method; // 文档请求方式: GET, UPDATE, DELETE等
List *property_delta_list; // 该请求需要修改的属性
uint32_t timeout_sec; // 请求超时时间, 单位:s
OnRequestCallback request_callback; // 请求回调方法
void *user_context; // 用户数据, 会通过回调方法OnRequestCallback返回
} RequestParams;
/**
* @brief
*
* @param pClient ShadowClient对象
* @param pParams
* @param pJsonValueBuffer
* @param valueLength
* @param DeviceProperty
*/
typedef void (*OnPropRegCallback)(void *pClient, RequestParams *pParams, char *pJsonValueBuffer, uint32_t valueLength, DeviceProperty *pProperty);
/**
* @brief

View File

@ -22,7 +22,6 @@ extern "C" {
#endif
#include "shadow_client.h"
#include "uiot_export_shadow.h"
//设备影子相关topic
#define SHADOW_PUBLISH_REQUEST_TEMPLATE "/$system/%s/%s/shadow/upstream"

View File

@ -26,9 +26,8 @@ extern "C" {
#include <stdarg.h>
#include <stddef.h>
#include "uiot_export.h"
#include "uiot_import.h"
#include "uiot_export_shadow.h"
#include "shadow_client.h"
/* 回复消息中的消息字段 */
#define METHOD_FIELD "Method"

View File

@ -27,6 +27,8 @@ extern "C" {
#include "lite-utils.h"
#include "shadow_client_common.h"
int IOT_Shadow_Request_Add_Delta_Property(void *handle, RequestParams *pParams, DeviceProperty *pProperty);
void* IOT_Shadow_Construct(const char *product_sn, const char *device_sn, void *ch_signal)
{
FUNC_ENTRY;

View File

@ -114,7 +114,7 @@ int shadow_common_update_property(UIoT_Shadow *pShadow, DeviceProperty *pPropert
}
else if((DELETE == method) || (REPLY_CONTROL_DELETE == method))
{
HAL_Printf("delete property\n");
LOG_INFO("delete property\n");
property_bak->data = NULL;
}
else