modify varname

This commit is contained in:
ethan.du 2021-05-19 14:59:24 +08:00
parent 68e55a0e7b
commit 84c08a7673
10 changed files with 46 additions and 46 deletions

View File

@ -87,8 +87,8 @@ static int _setup_connect_init_params(MQTTInitParams* initParams)
initParams->product_sn = (char *)IOT_MY_PRODUCT_SN;
initParams->product_secret = (char *)IOT_MY_PRODUCT_SECRET;
initParams->command_timeout = UIOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = UIOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->command_timeout = IOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = IOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->auto_connect_enable = 1;
initParams->event_handler.h_fp = event_handler;

View File

@ -134,8 +134,8 @@ static int _setup_connect_init_params(MQTTInitParams* initParams)
initParams->product_sn = IOT_MY_PRODUCT_SN;
initParams->device_secret = IOT_MY_DEVICE_SECRET;
initParams->command_timeout = UIOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = UIOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->command_timeout = IOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = IOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->auto_connect_enable = 1;
initParams->event_handler.h_fp = event_handler;

View File

@ -23,11 +23,11 @@
#include "uiot_import.h"
#include "uiot_export_ota.h"
#define UIOT_MY_PRODUCT_SN "PRODUCT_SN"
#define IOT_MY_PRODUCT_SN "PRODUCT_SN"
#define UIOT_MY_DEVICE_SN "DEVICE_SN"
#define IOT_MY_DEVICE_SN "DEVICE_SN"
#define UIOT_MY_DEVICE_SECRET "DEVICE_SECRET"
#define IOT_MY_DEVICE_SECRET "DEVICE_SECRET"
#define OTA_BUF_LEN (1024)
@ -78,11 +78,11 @@ static void event_handler(void *pClient, void *handle_context, MQTTEventMsg *msg
static int _setup_connect_init_params(MQTTInitParams* initParams)
{
initParams->device_sn = UIOT_MY_DEVICE_SN;
initParams->product_sn = UIOT_MY_PRODUCT_SN;
initParams->device_secret = UIOT_MY_DEVICE_SECRET;
initParams->command_timeout = UIOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = UIOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->device_sn = IOT_MY_DEVICE_SN;
initParams->product_sn = IOT_MY_PRODUCT_SN;
initParams->device_secret = IOT_MY_DEVICE_SECRET;
initParams->command_timeout = IOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = IOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->auto_connect_enable = 1;
initParams->event_handler.h_fp = event_handler;
@ -107,7 +107,7 @@ int main(int argc, char **argv)
return FAILURE_RET;
}
void *h_ota = IOT_OTA_Init(UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN, client);
void *h_ota = IOT_OTA_Init(IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN, client);
if (NULL == h_ota) {
IOT_MQTT_Destroy(&client);
LOG_ERROR("init OTA failed");

View File

@ -182,8 +182,8 @@ typedef struct Client {
size_t write_buf_size; // 消息发送buffer长度
size_t read_buf_size; // 消息接收buffer长度
unsigned char write_buf[UIOT_MQTT_TX_BUF_LEN]; // MQTT消息发送buffer
unsigned char read_buf[UIOT_MQTT_RX_BUF_LEN]; // MQTT消息接收buffer
unsigned char write_buf[IOT_MQTT_TX_BUF_LEN]; // MQTT消息发送buffer
unsigned char read_buf[IOT_MQTT_RX_BUF_LEN]; // MQTT消息接收buffer
void *lock_generic; // client原子锁
void *lock_write_buf; // 输出流的锁

View File

@ -349,8 +349,8 @@ int IOT_MQTT_Dynamic_Register(MQTTInitParams *pParams)
ret = IOT_MQTT_Yield(client,200);
/* 向topic发送消息请求回复设备密钥 */
char auth_msg[UIOT_MQTT_TX_BUF_LEN];
HAL_Snprintf(auth_msg, UIOT_MQTT_TX_BUF_LEN, "{\"RequestID\":\"%d\"}", 1);
char auth_msg[IOT_MQTT_TX_BUF_LEN];
HAL_Snprintf(auth_msg, IOT_MQTT_TX_BUF_LEN, "{\"RequestID\":\"%d\"}", 1);
PublishParams pub_params = DEFAULT_PUB_PARAMS;
pub_params.qos = QOS1;
@ -387,7 +387,7 @@ int uiot_mqtt_init(UIoT_Client *pClient, MQTTInitParams *pParams) {
memset(pClient, 0x0, sizeof(UIoT_Client));
int size = HAL_Snprintf(s_uiot_host, HOST_STR_LENGTH, "%s", UIOT_MQTT_DIRECT_DOMAIN);
int size = HAL_Snprintf(s_uiot_host, HOST_STR_LENGTH, "%s", IOT_MQTT_DIRECT_DOMAIN);
if (size < 0 || size > HOST_STR_LENGTH - 1) {
return FAILURE_RET;
}
@ -400,8 +400,8 @@ int uiot_mqtt_init(UIoT_Client *pClient, MQTTInitParams *pParams) {
// packet id 初始化时取1
pClient->next_packet_id = 1;
pClient->write_buf_size = UIOT_MQTT_TX_BUF_LEN;
pClient->read_buf_size = UIOT_MQTT_RX_BUF_LEN;
pClient->write_buf_size = IOT_MQTT_TX_BUF_LEN;
pClient->read_buf_size = IOT_MQTT_RX_BUF_LEN;
pClient->event_handler = pParams->event_handler;

View File

@ -582,7 +582,7 @@ static int _read_mqtt_packet(UIoT_Client *pClient, Timer *timer, uint8_t *packet
if (timer_left_ms <= 0) {
timer_left_ms = 1;
}
timer_left_ms += UIOT_MQTT_MAX_REMAIN_WAIT_MS; //确保一包MQTT报文接收完
timer_left_ms += IOT_MQTT_MAX_REMAIN_WAIT_MS; //确保一包MQTT报文接收完
ret = _decode_packet_rem_len_with_net_read(pClient, &rem_len, timer_left_ms);
if (SUCCESS_RET != ret) {
@ -598,7 +598,7 @@ static int _read_mqtt_packet(UIoT_Client *pClient, Timer *timer, uint8_t *packet
if (timer_left_ms <= 0) {
timer_left_ms = 1;
}
timer_left_ms += UIOT_MQTT_MAX_REMAIN_WAIT_MS;
timer_left_ms += IOT_MQTT_MAX_REMAIN_WAIT_MS;
bytes_to_be_read = pClient->read_buf_size;
do {
@ -627,7 +627,7 @@ static int _read_mqtt_packet(UIoT_Client *pClient, Timer *timer, uint8_t *packet
if (timer_left_ms <= 0) {
timer_left_ms = 1;
}
timer_left_ms += UIOT_MQTT_MAX_REMAIN_WAIT_MS;
timer_left_ms += IOT_MQTT_MAX_REMAIN_WAIT_MS;
pClient->network_stack.read(&(pClient->network_stack), pClient->read_buf, rem_len, timer_left_ms);
return ERR_MQTT_BUFFER_TOO_SHORT;
@ -638,7 +638,7 @@ static int _read_mqtt_packet(UIoT_Client *pClient, Timer *timer, uint8_t *packet
if (timer_left_ms <= 0) {
timer_left_ms = 1;
}
timer_left_ms += UIOT_MQTT_MAX_REMAIN_WAIT_MS;
timer_left_ms += IOT_MQTT_MAX_REMAIN_WAIT_MS;
read_len = pClient->network_stack.read(&(pClient->network_stack), pClient->read_buf + len, rem_len, timer_left_ms);
if (read_len < 0) {
return read_len;

View File

@ -35,8 +35,8 @@ static int _read_string_with_len(char **string, uint16_t *stringLen, unsigned ch
if (enddata - (*pptr) > 1) {
*stringLen = mqtt_read_uint16_t(pptr); /* increments pptr to point past length */
if(*stringLen > UIOT_MQTT_RX_BUF_LEN){
LOG_ERROR("stringLen exceed UIOT_MQTT_RX_BUF_LEN");
if(*stringLen > IOT_MQTT_RX_BUF_LEN){
LOG_ERROR("stringLen exceed IOT_MQTT_RX_BUF_LEN");
return FAILURE_RET;
}

View File

@ -21,13 +21,13 @@ extern "C" {
#endif
/* MQTT心跳消息发送周期, 单位:s */
#define UIOT_MQTT_KEEP_ALIVE_INTERNAL (240)
#define IOT_MQTT_KEEP_ALIVE_INTERNAL (240)
/* MQTT 阻塞调用(包括连接, 订阅, 发布等)的超时时间 */
#define UIOT_MQTT_COMMAND_TIMEOUT (5 * 1000)
#define IOT_MQTT_COMMAND_TIMEOUT (5 * 1000)
/* 接收到 MQTT 包头以后,接收剩余长度及剩余包,最大延迟等待时延 */
#define UIOT_MQTT_MAX_REMAIN_WAIT_MS (2000)
#define IOT_MQTT_MAX_REMAIN_WAIT_MS (2000)
/* 产品序列号的最大长度 */
#define MAX_SIZE_OF_PRODUCT_SN (16)
@ -42,10 +42,10 @@ extern "C" {
#define MAX_SIZE_OF_DEVICE_SECRET (16)
/* MQTT消息发送buffer大小, 支持最大256*1024 */
#define UIOT_MQTT_TX_BUF_LEN (2048)
#define IOT_MQTT_TX_BUF_LEN (2048)
/* MQTT消息接收buffer大小, 支持最大256*1024 */
#define UIOT_MQTT_RX_BUF_LEN (2048)
#define IOT_MQTT_RX_BUF_LEN (2048)
/* 重连最大等待时间 */
#define MAX_RECONNECT_WAIT_INTERVAL (60 * 1000)
@ -55,7 +55,7 @@ extern "C" {
#define ENABLE_INFINITE_RECONNECT 1
/* MQTT连接域名 */
#define UIOT_MQTT_DIRECT_DOMAIN "stacktest.iot.ucloud.cn"
#define IOT_MQTT_DIRECT_DOMAIN "stacktest.iot.ucloud.cn"
#include "uiot_export_mqtt.h"

View File

@ -65,7 +65,7 @@ static int _publish_msg(void *client)
{
char topicName[128] = {0};
int num = 18;
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN);
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN);
PublishParams pub_params = DEFAULT_PUB_PARAMS;
@ -82,7 +82,7 @@ static int _publish_msg(void *client)
static int _register_subscribe_topics(void *client)
{
static char topic_name[128] = {0};
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN);
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN);
SubscribeParams sub_params = DEFAULT_SUB_PARAMS;
sub_params.on_message_handler = on_message_callback;
@ -98,12 +98,12 @@ static int _register_subscribe_topics(void *client)
*/
static int _setup_connect_init_params(MQTTInitParams* initParams)
{
initParams->device_sn = (char *)UIOT_MY_DEVICE_SN;
initParams->product_sn = (char *)UIOT_MY_PRODUCT_SN;
initParams->device_sn = (char *)IOT_MY_DEVICE_SN;
initParams->product_sn = (char *)IOT_MY_PRODUCT_SN;
initParams->product_secret = (char *)UIOT_MY_PRODUCT_SECRET;
initParams->command_timeout = UIOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = UIOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->command_timeout = IOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = IOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->auto_connect_enable = 1;
initParams->event_handler.h_fp = event_handler;

View File

@ -123,7 +123,7 @@ static int _publish_msg(void *client)
{
char topicName[128] = {0};
int num = 18;
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN);
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN);
PublishParams pub_params = DEFAULT_PUB_PARAMS;
@ -141,7 +141,7 @@ static int _register_subscribe_topics(void *client)
{
static char topic_name[128] = {0};
//说明:此处订阅的topic是一个可订阅可发布的需要在控制台上新建
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN);
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN);
SubscribeParams sub_params = DEFAULT_SUB_PARAMS;
sub_params.on_message_handler = on_message_callback;
@ -151,7 +151,7 @@ static int _register_subscribe_topics(void *client)
static int _register_unsubscribe_topics(void *client)
{
static char topic_name[128] = {0};
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", UIOT_MY_PRODUCT_SN, UIOT_MY_DEVICE_SN);
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", IOT_MY_PRODUCT_SN, IOT_MY_DEVICE_SN);
return IOT_MQTT_Unsubscribe(client, topic_name);
}
@ -159,12 +159,12 @@ static int _register_unsubscribe_topics(void *client)
static int _setup_connect_init_params(MQTTInitParams* initParams)
{
int ret = 0;
initParams->device_sn = (char *)UIOT_MY_DEVICE_SN;
initParams->product_sn = (char *)UIOT_MY_PRODUCT_SN;
initParams->device_secret = (char *)UIOT_MY_DEVICE_SECRET;
initParams->device_sn = (char *)IOT_MY_DEVICE_SN;
initParams->product_sn = (char *)IOT_MY_PRODUCT_SN;
initParams->device_secret = (char *)IOT_MY_DEVICE_SECRET;
initParams->command_timeout = UIOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = UIOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->command_timeout = IOT_MQTT_COMMAND_TIMEOUT;
initParams->keep_alive_interval = IOT_MQTT_KEEP_ALIVE_INTERNAL;
initParams->auto_connect_enable = 1;
initParams->event_handler.h_fp = event_handler;
initParams->event_handler.context = NULL;