fix mqttclient sample compilation error on board-EVB_LN882x ...
This commit is contained in:
@@ -9,45 +9,43 @@
|
||||
static void tos_topic_handler(void* client, message_data_t* msg)
|
||||
{
|
||||
(void) client;
|
||||
LOG_I("-----------------------------------------------------------------------------------");
|
||||
LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__,
|
||||
MQTT_LOG_I("-----------------------------------------------------------------------------------");
|
||||
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);
|
||||
LOG_I("-----------------------------------------------------------------------------------\n");
|
||||
MQTT_LOG_I("-----------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||
mqtt_client_t client;
|
||||
client_init_params_t init_params;
|
||||
|
||||
extern void TCPIP_Init(void);
|
||||
|
||||
void mqtt_iothub(void)
|
||||
{
|
||||
int error;
|
||||
char buf[80] = { 0 };
|
||||
|
||||
mqtt_client_t *client = NULL;
|
||||
|
||||
mqtt_message_t msg;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
||||
sprintf(buf, "welcome to mqttclient, this is a publish test...");
|
||||
|
||||
init_params.read_buf_size = 1024;
|
||||
init_params.write_buf_size = 1024;
|
||||
init_params.connect_params.network_params.addr = "iotcloud-mqtt.gz.tencentdevices.com";
|
||||
init_params.connect_params.network_params.port = "1883";
|
||||
init_params.connect_params.user_name = "RUAP1R610Vsupowang;12010126;FTDC9;1623108655";
|
||||
init_params.connect_params.password = "29e68d809ac4ac0e41bf30cc77cd377d30e7af03f3c76b0c50fa27a2c59e174b;hmacsha256";
|
||||
init_params.connect_params.client_id = "RUAP1R610Vsupowang";
|
||||
init_params.connect_params.clean_session = 1;
|
||||
mqtt_log_init();
|
||||
|
||||
log_init();
|
||||
|
||||
mqtt_init(&client, &init_params);
|
||||
|
||||
error = mqtt_connect(&client);
|
||||
client = mqtt_lease();
|
||||
|
||||
LOG_D("mqtt connect error is %#x", error);
|
||||
mqtt_set_port(client, "1883");
|
||||
mqtt_set_host(client, "iotcloud-mqtt.gz.tencentdevices.com");
|
||||
mqtt_set_client_id(client, "RUAP1R610Vsupowang");
|
||||
mqtt_set_user_name(client, "RUAP1R610Vsupowang;12010126;FTDC9;1623108655");
|
||||
mqtt_set_password(client, "29e68d809ac4ac0e41bf30cc77cd377d30e7af03f3c76b0c50fa27a2c59e174b;hmacsha256");
|
||||
mqtt_set_clean_session(client, 1);
|
||||
|
||||
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
|
||||
|
||||
error = mqtt_connect(client);
|
||||
|
||||
MQTT_LOG_D("mqtt connect error is %#x", error);
|
||||
|
||||
mqtt_subscribe(client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
||||
@@ -56,7 +54,7 @@ void mqtt_iothub(void)
|
||||
msg.qos = QOS0;
|
||||
msg.payload = (void *) buf;
|
||||
|
||||
mqtt_publish(&client, "RUAP1R610V/supowang/data", &msg);
|
||||
mqtt_publish(client, "RUAP1R610V/supowang/data", &msg);
|
||||
|
||||
tos_task_delay(4000);
|
||||
}
|
||||
|
@@ -100,7 +100,10 @@
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<nTsel>6</nTsel>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>4</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
@@ -231,11 +234,19 @@
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<Lin2Executable></Lin2Executable>
|
||||
<Lin2ConfigFile></Lin2ConfigFile>
|
||||
<bLin2Auto>0</bLin2Auto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
@@ -2192,12 +2203,12 @@
|
||||
<File>
|
||||
<GroupNumber>26</GroupNumber>
|
||||
<FileNumber>146</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\error.h</PathWithFileName>
|
||||
<FilenameWithoutPath>error.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mqtt_list.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
@@ -2208,20 +2219,20 @@
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log.h</PathWithFileName>
|
||||
<FilenameWithoutPath>log.h</FilenameWithoutPath>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_log.h</PathWithFileName>
|
||||
<FilenameWithoutPath>mqtt_log.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>26</GroupNumber>
|
||||
<FileNumber>148</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\list.c</PathWithFileName>
|
||||
<FilenameWithoutPath>list.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_error.h</PathWithFileName>
|
||||
<FilenameWithoutPath>mqtt_error.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
@@ -2245,6 +2256,30 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>27</GroupNumber>
|
||||
<FileNumber>150</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>27</GroupNumber>
|
||||
<FileNumber>151</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>
|
||||
@@ -2255,7 +2290,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>28</GroupNumber>
|
||||
<FileNumber>150</FileNumber>
|
||||
<FileNumber>152</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -2267,7 +2302,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>28</GroupNumber>
|
||||
<FileNumber>151</FileNumber>
|
||||
<FileNumber>153</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -2279,7 +2314,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>28</GroupNumber>
|
||||
<FileNumber>152</FileNumber>
|
||||
<FileNumber>154</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -2289,30 +2324,6 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>28</GroupNumber>
|
||||
<FileNumber>153</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>28</GroupNumber>
|
||||
<FileNumber>154</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>
|
||||
<GroupNumber>28</GroupNumber>
|
||||
<FileNumber>155</FileNumber>
|
||||
|
@@ -10,7 +10,8 @@
|
||||
<TargetName>TencentOS_tiny</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060061::V5.06 update 1 (build 61)::ARMCC</pCCUsed>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM4_FP</Device>
|
||||
@@ -183,6 +184,7 @@
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@@ -323,11 +325,15 @@
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>LN882x,ARM_MATH_CM4</Define>
|
||||
@@ -345,6 +351,7 @@
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -497,11 +504,15 @@
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -994,11 +1005,15 @@
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
@@ -1320,19 +1335,19 @@
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>error.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\error.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>log.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>list.c</FileName>
|
||||
<FileName>mqtt_list.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\list.c</FilePath>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mqtt_log.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<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>
|
||||
</Files>
|
||||
</Group>
|
||||
@@ -1344,6 +1359,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\network\network.c</FilePath>
|
||||
</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>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -1364,16 +1389,6 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</FilePath>
|
||||
</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>
|
||||
<FileName>platform_thread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@@ -1,40 +1,41 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 00:42:16
|
||||
* @LastEditTime: 2020-02-25 09:25:35
|
||||
* @LastEditTime: 2020-06-17 19:31:41
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _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 USE_LOG (1U)
|
||||
#define USE_SALOF (1U)
|
||||
#define SALOF_OS USE_TENCENTOS
|
||||
#define USE_IDLE_HOOK (0U)
|
||||
#define LOG_COLOR (0U)
|
||||
#define LOG_TS (0U)
|
||||
#define LOG_TAR (0U)
|
||||
#define SALOF_BUFF_SIZE (512U)
|
||||
#define SALOF_FIFO_SIZE (1024U)
|
||||
#define SALOF_TASK_STACK_SIZE (1024U)
|
||||
#define SALOF_TASK_TICK (50U)
|
||||
#define MQTT_LOG_LEVEL MQTT_LOG_DEBUG_LEVEL //MQTT_LOG_WARN_LEVEL MQTT_LOG_DEBUG_LEVEL
|
||||
|
||||
#ifdef MQTT_LOG_IS_SALOF
|
||||
#define SALOF_USING_LOG (1U)
|
||||
#define SALOF_USING_SALOF (1U)
|
||||
#define SALOF_LOG_LEVEL MQTT_LOG_LEVEL
|
||||
#define SALOF_OS SALOF_USING_TENCENTOS
|
||||
#define SALOF_USING_IDLE_HOOK (0U)
|
||||
#define SALOF_LOG_COLOR (1U)
|
||||
#define SALOF_LOG_TS (0U)
|
||||
#define SALOF_LOG_TAR (0U)
|
||||
#define SALOF_BUFF_SIZE 512
|
||||
#define SALOF_FIFO_SIZE 4096
|
||||
#define SALOF_TASK_STACK_SIZE 1024
|
||||
#define SALOF_TASK_TICK 50
|
||||
#endif
|
||||
|
||||
|
||||
#define MQTT_MAX_PACKET_ID (0xFFFF - 1)
|
||||
#define MQTT_TOPIC_LEN_MAX 64
|
||||
#define MQTT_ACK_HANDLER_NUM_MAX 64
|
||||
#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_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_RECONNECT_DEFAULT_DURATION 1000
|
||||
#define MQTT_THREAD_STACK_SIZE 2048
|
||||
@@ -42,6 +43,6 @@
|
||||
#define MQTT_THREAD_TICK 50
|
||||
|
||||
|
||||
//#define MQTT_NETWORK_TYPE_TLS
|
||||
#define MQTT_NETWORK_TYPE_NO_TLS
|
||||
|
||||
#endif /* _MQTT_CONFIG_H_ */
|
||||
#endif /* _MQTT_CONFIG_H_ */
|
Reference in New Issue
Block a user