Merge pull request #184 from jiejieTop/master

fix mqttclient sample compilation error of board-TencentOS_tiny_EVB_MX_Plus ...
This commit is contained in:
Supowang
2020-06-23 10:17:01 +08:00
committed by GitHub
4 changed files with 97 additions and 107 deletions

View File

@@ -16,16 +16,13 @@ void mqtt_set_esp8266_port(hal_uart_port_t port) {
} }
#endif #endif
mqtt_client_t client;
client_init_params_t init_params;
static void tos_topic_handler(void* client, message_data_t* msg) static void tos_topic_handler(void* client, message_data_t* msg)
{ {
(void) client; (void) client;
LOG_I("-----------------------------------------------------------------------------------"); MQTT_LOG_I("-----------------------------------------------------------------------------------");
LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__, MQTT_LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__,
msg->topic_name, msg->message->qos, (char*)msg->message->payload); msg->topic_name, msg->message->qos, (char*)msg->message->payload);
LOG_I("-----------------------------------------------------------------------------------\n"); MQTT_LOG_I("-----------------------------------------------------------------------------------\n");
} }
@@ -35,6 +32,8 @@ void mqttclient_task(void)
char buf[100] = { 0 }; char buf[100] = { 0 };
mqtt_client_t *client = NULL;
mqtt_message_t msg; mqtt_message_t msg;
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
@@ -49,33 +48,24 @@ void mqttclient_task(void)
bc35_28_95_sal_init(HAL_UART_PORT_0); bc35_28_95_sal_init(HAL_UART_PORT_0);
#endif #endif
init_params.read_buf_size = 256; mqtt_log_init();
init_params.write_buf_size = 256;
#ifdef MQTT_NETWORK_TYPE_TLS
init_params.connect_params.network_params.network_ssl_params.ca_crt = test_ca_get();
init_params.connect_params.network_params.port = "8883";
#else
init_params.connect_params.network_params.port = "1883";
#endif
init_params.connect_params.network_params.addr = "111.230.189.156"; //"47.95.164.112";//"jiejie01.top"; //"129.204.201.235"; //"192.168.1.101";
init_params.connect_params.user_name = "RUAP1R610Vsupowang;12010126;80LJ2;1621294860"; // random_string(10); //"jiejietop-acer1"; client = mqtt_lease();
init_params.connect_params.password = "2e90a9f1e604f2f0473355228c3d59276951aa8e6ed4d27f270f05ee8a4d0983;hmacsha256"; //random_string(10); // "123456";
init_params.connect_params.client_id = "RUAP1R610Vsupowang";; //random_string(10); // "clientid-acer1";
init_params.connect_params.clean_session = 1;
log_init();
mqtt_init(&client, &init_params);
error = mqtt_connect(&client);
LOG_D("mqtt connect error is %#x", error); mqtt_set_port(client, "1883");
mqtt_set_host(client, "111.230.189.156");
mqtt_set_client_id(client, "RUAP1R610Vsupowang");
mqtt_set_user_name(client, "RUAP1R610Vsupowang;12010126;80LJ2;1621294860");
mqtt_set_password(client, "2e90a9f1e604f2f0473355228c3d59276951aa8e6ed4d27f270f05ee8a4d0983;hmacsha256");
mqtt_set_clean_session(client, 1);
error = mqtt_connect(client);
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler); MQTT_LOG_D("mqtt connect error is %#x", error);
LOG_D("mqtt subscribe error is %#x", error); mqtt_subscribe(client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
MQTT_LOG_D("mqtt subscribe error is %#x", error);
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
@@ -86,7 +76,7 @@ void mqttclient_task(void)
msg.qos = QOS0; msg.qos = QOS0;
msg.payload = (void *) buf; msg.payload = (void *) buf;
error = mqtt_publish(&client, "RUAP1R610V/supowang/data", &msg); error = mqtt_publish(client, "RUAP1R610V/supowang/data", &msg);
tos_task_delay(4000); tos_task_delay(4000);
} }

View File

@@ -1493,8 +1493,8 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\list.c</PathWithFileName> <PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\random.c</PathWithFileName>
<FilenameWithoutPath>list.c</FilenameWithoutPath> <FilenameWithoutPath>random.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
@@ -1505,8 +1505,8 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\random.c</PathWithFileName> <PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</PathWithFileName>
<FilenameWithoutPath>random.c</FilenameWithoutPath> <FilenameWithoutPath>mqtt_list.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
@@ -1517,8 +1517,8 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\error.h</PathWithFileName> <PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_log.h</PathWithFileName>
<FilenameWithoutPath>error.h</FilenameWithoutPath> <FilenameWithoutPath>mqtt_log.h</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
@@ -1529,8 +1529,8 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log.h</PathWithFileName> <PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_error.h</PathWithFileName>
<FilenameWithoutPath>log.h</FilenameWithoutPath> <FilenameWithoutPath>mqtt_error.h</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
@@ -1554,6 +1554,30 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>98</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\nettype_tls.c</PathWithFileName>
<FilenameWithoutPath>nettype_tls.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>99</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\nettype_tcp.c</PathWithFileName>
<FilenameWithoutPath>nettype_tcp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@@ -1564,7 +1588,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>19</GroupNumber> <GroupNumber>19</GroupNumber>
<FileNumber>98</FileNumber> <FileNumber>100</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1576,7 +1600,7 @@
</File> </File>
<File> <File>
<GroupNumber>19</GroupNumber> <GroupNumber>19</GroupNumber>
<FileNumber>99</FileNumber> <FileNumber>101</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1588,7 +1612,7 @@
</File> </File>
<File> <File>
<GroupNumber>19</GroupNumber> <GroupNumber>19</GroupNumber>
<FileNumber>100</FileNumber> <FileNumber>102</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@@ -1598,30 +1622,6 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>19</GroupNumber>
<FileNumber>101</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tcp.c</PathWithFileName>
<FilenameWithoutPath>platform_nettype_tcp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>19</GroupNumber>
<FileNumber>102</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tls.c</PathWithFileName>
<FilenameWithoutPath>platform_nettype_tls.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File> <File>
<GroupNumber>19</GroupNumber> <GroupNumber>19</GroupNumber>
<FileNumber>103</FileNumber> <FileNumber>103</FileNumber>

View File

@@ -16,7 +16,7 @@
<TargetCommonOption> <TargetCommonOption>
<Device>STM32L431RCTx</Device> <Device>STM32L431RCTx</Device>
<Vendor>STMicroelectronics</Vendor> <Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32L4xx_DFP.2.0.0</PackID> <PackID>Keil.STM32L4xx_DFP.2.2.0</PackID>
<PackURL>http://www.keil.com/pack</PackURL> <PackURL>http://www.keil.com/pack</PackURL>
<Cpu>IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4")</Cpu> <Cpu>IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
<FlashUtilSpec></FlashUtilSpec> <FlashUtilSpec></FlashUtilSpec>
@@ -922,25 +922,25 @@
<Group> <Group>
<GroupName>mqttclient/common</GroupName> <GroupName>mqttclient/common</GroupName>
<Files> <Files>
<File>
<FileName>list.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\list.c</FilePath>
</File>
<File> <File>
<FileName>random.c</FileName> <FileName>random.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath> <FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath>
</File> </File>
<File> <File>
<FileName>error.h</FileName> <FileName>mqtt_list.c</FileName>
<FileType>5</FileType> <FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\error.h</FilePath> <FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</FilePath>
</File> </File>
<File> <File>
<FileName>log.h</FileName> <FileName>mqtt_log.h</FileName>
<FileType>5</FileType> <FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath> <FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_log.h</FilePath>
</File>
<File>
<FileName>mqtt_error.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_error.h</FilePath>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -952,6 +952,16 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\network\network.c</FilePath> <FilePath>..\..\..\..\components\connectivity\mqttclient\network\network.c</FilePath>
</File> </File>
<File>
<FileName>nettype_tls.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\network\nettype_tls.c</FilePath>
</File>
<File>
<FileName>nettype_tcp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\network\nettype_tcp.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@@ -972,16 +982,6 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</FilePath> <FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</FilePath>
</File> </File>
<File>
<FileName>platform_nettype_tcp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tcp.c</FilePath>
</File>
<File>
<FileName>platform_nettype_tls.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tls.c</FilePath>
</File>
<File> <File>
<FileName>platform_thread.c</FileName> <FileName>platform_thread.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>

View File

@@ -1,48 +1,48 @@
/* /*
* @Author: jiejie * @Author: jiejie
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 00:42:16 * @LastEditTime: 2020-06-17 19:31:41
* @LastEditTime: 2020-02-25 09:25:35
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/ */
#ifndef _MQTT_CONFIG_H_ #ifndef _MQTT_CONFIG_H_
#define _MQTT_CONFIG_H_ #define _MQTT_CONFIG_H_
//#define LOG_IS_SALOF //#define MQTT_LOG_IS_SALOF
#define LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL #define MQTT_NETSOCKET_USING_AT
#ifdef LOG_IS_SALOF #define MQTT_LOG_LEVEL MQTT_LOG_DEBUG_LEVEL //MQTT_LOG_WARN_LEVEL MQTT_LOG_DEBUG_LEVEL
#define USE_LOG (1U)
#define USE_SALOF (1U) #ifdef MQTT_LOG_IS_SALOF
#define SALOF_OS USE_TENCENTOS #define SALOF_USING_LOG (1U)
#define USE_IDLE_HOOK (0U) #define SALOF_USING_SALOF (1U)
#define LOG_COLOR (0U) #define SALOF_LOG_LEVEL MQTT_LOG_LEVEL
#define LOG_TS (0U) #define SALOF_OS SALOF_USING_TENCENTOS
#define LOG_TAR (0U) #define SALOF_USING_IDLE_HOOK (0U)
#define SALOF_BUFF_SIZE (512U) #define SALOF_LOG_COLOR (1U)
#define SALOF_FIFO_SIZE (1024U) #define SALOF_LOG_TS (0U)
#define SALOF_TASK_STACK_SIZE (1024U) #define SALOF_LOG_TAR (0U)
#define SALOF_TASK_TICK (50U) #define SALOF_BUFF_SIZE 512
#define SALOF_FIFO_SIZE 4096
#define SALOF_TASK_STACK_SIZE 1024
#define SALOF_TASK_TICK 50
#endif #endif
#define MQTT_MAX_PACKET_ID (0xFFFF - 1) #define MQTT_MAX_PACKET_ID (0xFFFF - 1)
#define MQTT_TOPIC_LEN_MAX 64 #define MQTT_TOPIC_LEN_MAX 64
#define MQTT_ACK_HANDLER_NUM_MAX 64 #define MQTT_ACK_HANDLER_NUM_MAX 64
#define MQTT_DEFAULT_BUF_SIZE 1024 #define MQTT_DEFAULT_BUF_SIZE 1024
#define MQTT_DEFAULT_CMD_TIMEOUT 4000 #define MQTT_DEFAULT_CMD_TIMEOUT 5000
#define MQTT_MAX_CMD_TIMEOUT 20000 #define MQTT_MAX_CMD_TIMEOUT 20000
#define MQTT_MIN_CMD_TIMEOUT 1000 #define MQTT_MIN_CMD_TIMEOUT 1000
#define MQTT_KEEP_ALIVE_INTERVAL 100 // unit: second #define MQTT_KEEP_ALIVE_INTERVAL 50 // unit: second
#define MQTT_VERSION 4 // 4 is mqtt 3.1.1 #define MQTT_VERSION 4 // 4 is mqtt 3.1.1
#define MQTT_RECONNECT_DEFAULT_DURATION 1000 #define MQTT_RECONNECT_DEFAULT_DURATION 1000
#define MQTT_THREAD_STACK_SIZE 2048 #define MQTT_THREAD_STACK_SIZE 2048
#define MQTT_THREAD_PRIO 5 #define MQTT_THREAD_PRIO 5
#define MQTT_THREAD_TICK 50 #define MQTT_THREAD_TICK 50
#define MQTT_NETSOCKET_USE_AT
//#define MQTT_NETWORK_TYPE_TLS #define MQTT_NETWORK_TYPE_NO_TLS
#endif /* _MQTT_CONFIG_H_ */ #endif /* _MQTT_CONFIG_H_ */