未验证 提交 295eb780 编写于 作者: S Supowang 提交者: GitHub

Merge pull request #185 from jiejieTop/master

fix mqttclient sample compilation error on  EVB_LN882x and LTE_DTU_EC20_SIM7600CE board
;********************** COPYRIGHT(c) 2017 STMicroelectronics ******************
;* File Name : startup_stm32l431xx.s
;* Author : MCD Application Team
;* Description : STM32L431xx Ultra Low Power devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the Cortex-M4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;*
;* Redistribution and use in source and binary forms, with or without modification,
;* are permitted provided that the following conditions are met:
;* 1. Redistributions of source code must retain the above copyright notice,
;* this list of conditions and the following disclaimer.
;* 2. Redistributions in binary form must reproduce the above copyright notice,
;* this list of conditions and the following disclaimer in the documentation
;* and/or other materials provided with the distribution.
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
;* may be used to endorse or promote products derived from this software
;* without specific prior written permission.
;*
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*
;*******************************************************************************
;
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x100
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x100
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_PVM_IRQHandler ; PVD/PVM1/PVM2/PVM3/PVM4 through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
DCD ADC1_IRQHandler ; ADC1
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SDMMC1_IRQHandler ; SDMMC1
DCD 0 ; Reserved
DCD SPI3_IRQHandler ; SPI3
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD COMP_IRQHandler ; COMP Interrupt
DCD LPTIM1_IRQHandler ; LP TIM1 interrupt
DCD LPTIM2_IRQHandler ; LP TIM2 interrupt
DCD 0 ; Reserved
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7
DCD LPUART1_IRQHandler ; LP UART1 interrupt
DCD QUADSPI_IRQHandler ; Quad SPI global interrupt
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD SAI1_IRQHandler ; Serial Audio Interface 1 global interrupt
DCD 0 ; Reserved
DCD SWPMI1_IRQHandler ; Serial Wire Interface 1 global interrupt
DCD TSC_IRQHandler ; Touch Sense Controller global interrupt
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD RNG_IRQHandler ; RNG global interrupt
DCD FPU_IRQHandler ; FPU
DCD CRS_IRQHandler ; CRS interrupt
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_PVM_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_IRQHandler [WEAK]
EXPORT DMA1_Channel3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_IRQHandler [WEAK]
EXPORT DMA1_Channel5_IRQHandler [WEAK]
EXPORT DMA1_Channel6_IRQHandler [WEAK]
EXPORT DMA1_Channel7_IRQHandler [WEAK]
EXPORT ADC1_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT SDMMC1_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Channel1_IRQHandler [WEAK]
EXPORT DMA2_Channel2_IRQHandler [WEAK]
EXPORT DMA2_Channel3_IRQHandler [WEAK]
EXPORT DMA2_Channel4_IRQHandler [WEAK]
EXPORT DMA2_Channel5_IRQHandler [WEAK]
EXPORT COMP_IRQHandler [WEAK]
EXPORT LPTIM1_IRQHandler [WEAK]
EXPORT LPTIM2_IRQHandler [WEAK]
EXPORT DMA2_Channel6_IRQHandler [WEAK]
EXPORT DMA2_Channel7_IRQHandler [WEAK]
EXPORT LPUART1_IRQHandler [WEAK]
EXPORT QUADSPI_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT SAI1_IRQHandler [WEAK]
EXPORT SWPMI1_IRQHandler [WEAK]
EXPORT TSC_IRQHandler [WEAK]
EXPORT RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
EXPORT CRS_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_PVM_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM15_IRQHandler
TIM1_UP_TIM16_IRQHandler
TIM1_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
SDMMC1_IRQHandler
SPI3_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Channel1_IRQHandler
DMA2_Channel2_IRQHandler
DMA2_Channel3_IRQHandler
DMA2_Channel4_IRQHandler
DMA2_Channel5_IRQHandler
COMP_IRQHandler
LPTIM1_IRQHandler
LPTIM2_IRQHandler
DMA2_Channel6_IRQHandler
DMA2_Channel7_IRQHandler
LPUART1_IRQHandler
QUADSPI_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
SAI1_IRQHandler
SWPMI1_IRQHandler
TSC_IRQHandler
RNG_IRQHandler
FPU_IRQHandler
CRS_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
/*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @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 MQTT_LOG_IS_SALOF
#define MQTT_NETSOCKET_USING_AT
#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 5000
#define MQTT_MAX_CMD_TIMEOUT 20000
#define MQTT_MIN_CMD_TIMEOUT 1000
#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
#define MQTT_THREAD_PRIO 5
#define MQTT_THREAD_TICK 50
#define MQTT_NETWORK_TYPE_NO_TLS
#endif /* _MQTT_CONFIG_H_ */
......@@ -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);
client = mqtt_lease();
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);
error = mqtt_connect(&client);
error = mqtt_connect(client);
LOG_D("mqtt connect error is %#x", error);
MQTT_LOG_D("mqtt connect error is %#x", error);
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
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,38 +2256,38 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/platform</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>28</GroupNumber>
<GroupNumber>27</GroupNumber>
<FileNumber>150</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</PathWithFileName>
<FilenameWithoutPath>platform_memory.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\nettype_tls.c</PathWithFileName>
<FilenameWithoutPath>nettype_tls.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>28</GroupNumber>
<GroupNumber>27</GroupNumber>
<FileNumber>151</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</PathWithFileName>
<FilenameWithoutPath>platform_mutex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\nettype_tcp.c</PathWithFileName>
<FilenameWithoutPath>nettype_tcp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/platform</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>28</GroupNumber>
<FileNumber>152</FileNumber>
......@@ -2284,8 +2295,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</PathWithFileName>
<FilenameWithoutPath>platform_net_socket.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</PathWithFileName>
<FilenameWithoutPath>platform_memory.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -2296,8 +2307,8 @@
<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>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</PathWithFileName>
<FilenameWithoutPath>platform_mutex.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -2308,8 +2319,8 @@
<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>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</PathWithFileName>
<FilenameWithoutPath>platform_net_socket.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......
......@@ -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>
<FileName>mqtt_list.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</FilePath>
</File>
<File>
<FileName>log.h</FileName>
<FileName>mqtt_log.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_log.h</FilePath>
</File>
<File>
<FileName>list.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\list.c</FilePath>
<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>
......
/*
* @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 LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL
#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_IS_SALOF
//#define MQTT_NETSOCKET_USING_AT
#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_ */
\ No newline at end of file
......@@ -7,16 +7,13 @@
#define USE_EC20
mqtt_client_t client;
client_init_params_t init_params;
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");
}
......@@ -25,6 +22,7 @@ void mqttclient_task(void)
int error;
char buf[100] = { 0 };
mqtt_client_t *client = NULL;
mqtt_message_t msg;
......@@ -37,36 +35,28 @@ void mqttclient_task(void)
#ifdef USE_EC20
ec20_sal_init(HAL_UART_PORT_2);
#endif
mqtt_log_init();
client = mqtt_lease();
init_params.read_buf_size = 256;
init_params.write_buf_size = 256;
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;OQHZL;1626061655");
mqtt_set_password(client, "ed41ae0cdf9100ce2aa5d5874566f8f4f77b1eab80b19ede4d1419eafe92eb54;hmacsha256");
mqtt_set_clean_session(client, 1);
mqtt_set_read_buf_size(client, 256);
mqtt_set_write_buf_size(client, 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;OQHZL;1626061655"; // random_string(10); //"jiejietop-acer1";
init_params.connect_params.password = "ed41ae0cdf9100ce2aa5d5874566f8f4f77b1eab80b19ede4d1419eafe92eb54;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);
error = mqtt_connect(client);
LOG_D("mqtt connect error is %#x", error);
MQTT_LOG_D("mqtt connect error is %#x", error);
//mqtt_set_interceptor_handler(&client,tos_topic_handler);
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
mqtt_subscribe(client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
LOG_D("mqtt subscribe error is %#x", error);
MQTT_LOG_D("mqtt subscribe error is %#x", error);
memset(&msg, 0, sizeof(msg));
......@@ -77,7 +67,7 @@ void mqttclient_task(void)
msg.qos = QOS0;
msg.payload = (void *) buf;
error = mqtt_publish(&client, "RUAP1R610V/supowang/data", &msg);
error = mqtt_publish(client, "RUAP1R610V/supowang/data", &msg);
tos_task_delay(4000);
}
......
......@@ -223,7 +223,7 @@
<Group>
<GroupName>Application/User</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1007,7 +1007,7 @@
<Group>
<GroupName>mqttclient</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1027,7 +1027,7 @@
<Group>
<GroupName>mqttclient/mqtt</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1155,7 +1155,7 @@
<Group>
<GroupName>mqttclient/salof</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1223,7 +1223,7 @@
<Group>
<GroupName>mqttclient/common</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1234,8 +1234,8 @@
<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\random.c</PathWithFileName>
<FilenameWithoutPath>random.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1246,8 +1246,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\random.c</PathWithFileName>
<FilenameWithoutPath>random.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</PathWithFileName>
<FilenameWithoutPath>mqtt_list.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1258,8 +1258,8 @@
<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_error.h</PathWithFileName>
<FilenameWithoutPath>mqtt_error.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1270,8 +1270,8 @@
<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>
......@@ -1279,7 +1279,7 @@
<Group>
<GroupName>mqttclient/network</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......@@ -1295,38 +1295,38 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/platform</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>18</GroupNumber>
<GroupNumber>17</GroupNumber>
<FileNumber>81</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</PathWithFileName>
<FilenameWithoutPath>platform_memory.c</FilenameWithoutPath>
<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>
<GroupNumber>17</GroupNumber>
<FileNumber>82</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</PathWithFileName>
<FilenameWithoutPath>platform_mutex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\nettype_tcp.c</PathWithFileName>
<FilenameWithoutPath>nettype_tcp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/platform</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>83</FileNumber>
......@@ -1334,8 +1334,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</PathWithFileName>
<FilenameWithoutPath>platform_net_socket.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</PathWithFileName>
<FilenameWithoutPath>platform_memory.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1346,8 +1346,8 @@
<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>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</PathWithFileName>
<FilenameWithoutPath>platform_mutex.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1358,8 +1358,8 @@
<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>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</PathWithFileName>
<FilenameWithoutPath>platform_net_socket.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
......@@ -1391,7 +1391,7 @@
<Group>
<GroupName>mqttclient/config</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
......
......@@ -16,7 +16,7 @@
<TargetCommonOption>
<Device>STM32F103RB</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
<PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
<FlashUtilSpec></FlashUtilSpec>
......@@ -833,24 +833,24 @@
<GroupName>mqttclient/common</GroupName>
<Files>
<File>
<FileName>list.c</FileName>
<FileName>random.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\list.c</FilePath>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath>
</File>
<File>
<FileName>random.c</FileName>
<FileName>mqtt_list.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_list.c</FilePath>
</File>
<File>
<FileName>error.h</FileName>
<FileName>mqtt_error.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\error.h</FilePath>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_error.h</FilePath>
</File>
<File>
<FileName>log.h</FileName>
<FileName>mqtt_log.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\mqtt_log.h</FilePath>
</File>
</Files>
</Group>
......@@ -862,6 +862,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>
......@@ -882,16 +892,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>
......
/*
* @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 LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL
#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_IS_SALOF
#define MQTT_NETSOCKET_USING_AT
#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
#define MQTT_THREAD_PRIO 5
#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_ */
#include "tos_k.h"
#include "esp8266.h"
#include "mqttclient.h"
#define USE_ESP8266
static hal_uart_port_t esp8266_port = HAL_UART_PORT_0;
static void tos_topic_handler(void* client, message_data_t* msg)
{
(void) client;
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);
MQTT_LOG_I("-----------------------------------------------------------------------------------\n");
}
void mqtt_demo(void)
{
int error;
char buf[100] = { 0 };
mqtt_message_t msg;
mqtt_client_t *client = NULL;
memset(&msg, 0, sizeof(msg));
printf("\nwelcome to mqttclient test...\n");
#ifdef USE_ESP8266
esp8266_sal_init(esp8266_port);
esp8266_join_ap("wifii", "woshijiejie");
#endif
#ifdef USE_NB_BC35
int bc35_28_95_sal_init(hal_uart_port_t uart_port);
bc35_28_95_sal_init(HAL_UART_PORT_0);
#endif
esp8266_join_ap("wifii", "woshijiejie");
mqtt_log_init();
client = mqtt_lease();
mqtt_set_port(client, "1883");
mqtt_set_host(client, "www.jiejie01.top");
mqtt_set_client_id(client, random_string(10));
mqtt_set_user_name(client, random_string(10));
mqtt_set_password(client, random_string(10));
mqtt_set_clean_session(client, 1);
mqtt_set_read_buf_size(client, 256);
mqtt_set_write_buf_size(client, 256);
error = mqtt_connect(client);
MQTT_LOG_D("mqtt connect error is %#x", error);
error = mqtt_connect(client);
MQTT_LOG_D("mqtt connect error is %#x", error);
mqtt_subscribe(client, "tos-topic", QOS0, tos_topic_handler);
MQTT_LOG_D("mqtt subscribe error is %#x", error);
memset(&msg, 0, sizeof(msg));
for (;;) {
sprintf(buf, "welcome to mqttclient, this is a publish test, a rand number: %d ...", random_number());
msg.qos = QOS0;
msg.payload = (void *) buf;
error = mqtt_publish(client, "tos-topic", &msg);
tos_task_delay(4000);
}
}
void application_entry(void *arg)
{
mqtt_demo();
while (1) {
printf("This is a mqtt demo!\r\n");
tos_task_delay(1000);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册