Merge pull request #125 from jiejieTop/master
update mqttclient to version 1.0.2 and add gokit demo...
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
// File: STM32F405_415_407_417_427_437_429_439.dbgconf
|
||||
// Version: 1.0.0
|
||||
// Note: refer to STM32F405/415 STM32F407/417 STM32F427/437 STM32F429/439 reference manual (RM0090)
|
||||
// refer to STM32F40x STM32F41x datasheets
|
||||
// refer to STM32F42x STM32F43x datasheets
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Debug MCU configuration register (DBGMCU_CR)
|
||||
// <o.2> DBG_STANDBY <i> Debug Standby Mode
|
||||
// <o.1> DBG_STOP <i> Debug Stop Mode
|
||||
// <o.0> DBG_SLEEP <i> Debug Sleep Mode
|
||||
// </h>
|
||||
DbgMCU_CR = 0x00000007;
|
||||
|
||||
// <h> Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
|
||||
// <i> Reserved bits must be kept at reset value
|
||||
// <o.26> DBG_CAN2_STOP <i> CAN2 stopped when core is halted
|
||||
// <o.25> DBG_CAN1_STOP <i> CAN2 stopped when core is halted
|
||||
// <o.23> DBG_I2C3_SMBUS_TIMEOUT <i> I2C3 SMBUS timeout mode stopped when core is halted
|
||||
// <o.22> DBG_I2C2_SMBUS_TIMEOUT <i> I2C2 SMBUS timeout mode stopped when core is halted
|
||||
// <o.21> DBG_I2C1_SMBUS_TIMEOUT <i> I2C1 SMBUS timeout mode stopped when core is halted
|
||||
// <o.12> DBG_IWDG_STOP <i> Independent watchdog stopped when core is halted
|
||||
// <o.11> DBG_WWDG_STOP <i> Window watchdog stopped when core is halted
|
||||
// <o.10> DBG_RTC_STOP <i> RTC stopped when core is halted
|
||||
// <o.8> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
|
||||
// <o.7> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted
|
||||
// <o.6> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted
|
||||
// <o.5> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
|
||||
// <o.4> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
|
||||
// <o.3> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted
|
||||
// <o.2> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted
|
||||
// <o.1> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
|
||||
// <o.0> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
|
||||
// </h>
|
||||
DbgMCU_APB1_Fz = 0x00000000;
|
||||
|
||||
// <h> Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
|
||||
// <i> Reserved bits must be kept at reset value
|
||||
// <o.18> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted
|
||||
// <o.17> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted
|
||||
// <o.16> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted
|
||||
// <o.1> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted
|
||||
// <o.0> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
|
||||
// </h>
|
||||
DbgMCU_APB2_Fz = 0x00000000;
|
||||
|
||||
// <<< end of configuration section >>>
|
@@ -1,16 +0,0 @@
|
||||
; *************************************************************
|
||||
; *** Scatter-Loading Description File generated by uVision ***
|
||||
; *************************************************************
|
||||
|
||||
LR_IROM1 0x08000000 0x00100000 { ; load region size_region
|
||||
ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
.ANY (+XO)
|
||||
}
|
||||
RW_IRAM1 0x20000000 0x00030000 { ; RW data
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
|
||||
/*
|
||||
* Auto generated Run-Time-Environment Component Configuration File
|
||||
* *** Do not modify ! ***
|
||||
*
|
||||
* Project: 'TencentOS_tiny'
|
||||
* Target: 'TencentOS_tiny'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "stm32f4xx.h"
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F429IGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.13.0</PackID>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.9.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2002FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
@@ -1,48 +0,0 @@
|
||||
// File: STM32F405_415_407_417_427_437_429_439.dbgconf
|
||||
// Version: 1.0.0
|
||||
// Note: refer to STM32F405/415 STM32F407/417 STM32F427/437 STM32F429/439 reference manual (RM0090)
|
||||
// refer to STM32F40x STM32F41x datasheets
|
||||
// refer to STM32F42x STM32F43x datasheets
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Debug MCU configuration register (DBGMCU_CR)
|
||||
// <o.2> DBG_STANDBY <i> Debug Standby Mode
|
||||
// <o.1> DBG_STOP <i> Debug Stop Mode
|
||||
// <o.0> DBG_SLEEP <i> Debug Sleep Mode
|
||||
// </h>
|
||||
DbgMCU_CR = 0x00000007;
|
||||
|
||||
// <h> Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
|
||||
// <i> Reserved bits must be kept at reset value
|
||||
// <o.26> DBG_CAN2_STOP <i> CAN2 stopped when core is halted
|
||||
// <o.25> DBG_CAN1_STOP <i> CAN2 stopped when core is halted
|
||||
// <o.23> DBG_I2C3_SMBUS_TIMEOUT <i> I2C3 SMBUS timeout mode stopped when core is halted
|
||||
// <o.22> DBG_I2C2_SMBUS_TIMEOUT <i> I2C2 SMBUS timeout mode stopped when core is halted
|
||||
// <o.21> DBG_I2C1_SMBUS_TIMEOUT <i> I2C1 SMBUS timeout mode stopped when core is halted
|
||||
// <o.12> DBG_IWDG_STOP <i> Independent watchdog stopped when core is halted
|
||||
// <o.11> DBG_WWDG_STOP <i> Window watchdog stopped when core is halted
|
||||
// <o.10> DBG_RTC_STOP <i> RTC stopped when core is halted
|
||||
// <o.8> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
|
||||
// <o.7> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted
|
||||
// <o.6> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted
|
||||
// <o.5> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
|
||||
// <o.4> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
|
||||
// <o.3> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted
|
||||
// <o.2> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted
|
||||
// <o.1> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
|
||||
// <o.0> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
|
||||
// </h>
|
||||
DbgMCU_APB1_Fz = 0x00000000;
|
||||
|
||||
// <h> Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
|
||||
// <i> Reserved bits must be kept at reset value
|
||||
// <o.18> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted
|
||||
// <o.17> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted
|
||||
// <o.16> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted
|
||||
// <o.1> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted
|
||||
// <o.0> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
|
||||
// </h>
|
||||
DbgMCU_APB2_Fz = 0x00000000;
|
||||
|
||||
// <<< end of configuration section >>>
|
@@ -1,16 +0,0 @@
|
||||
; *************************************************************
|
||||
; *** Scatter-Loading Description File generated by uVision ***
|
||||
; *************************************************************
|
||||
|
||||
LR_IROM1 0x08000000 0x00100000 { ; load region size_region
|
||||
ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
.ANY (+XO)
|
||||
}
|
||||
RW_IRAM1 0x20000000 0x00030000 { ; RW data
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
|
||||
/*
|
||||
* Auto generated Run-Time-Environment Component Configuration File
|
||||
* *** Do not modify ! ***
|
||||
*
|
||||
* Project: 'TencentOS_tiny'
|
||||
* Target: 'TencentOS_tiny'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "stm32f4xx.h"
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
@@ -2,43 +2,46 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 00:42:16
|
||||
* @LastEditTime : 2020-01-16 00:39:23
|
||||
* @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.
|
||||
*/
|
||||
#ifndef _MQTT_CONFIG_H_
|
||||
#define _MQTT_CONFIG_H_
|
||||
|
||||
#define MQTT_NO 0
|
||||
#define MQTT_YES 1
|
||||
#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)
|
||||
#endif
|
||||
|
||||
|
||||
#define MQTT_MAX_PACKET_ID (0xFFFF - 1)
|
||||
#define MQTT_TOPIC_LEN_MAX 128
|
||||
#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_MAX_CMD_TIMEOUT 20000
|
||||
#define MQTT_MIN_CMD_TIMEOUT 1000
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 20 // unit: second
|
||||
#define MQTT_VERSION 4 // 4 is mqtt 3.1.1
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 100 // 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_TLS MQTT_NO
|
||||
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#define MQTT_TLS_HANDSHAKE_TIMEOUT (5 * 1000)
|
||||
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#endif /* MQTT_NETWORK_TYPE_TLS */
|
||||
//#define MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#endif /* _MQTT_CONFIG_H_ */
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F429IGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.13.0</PackID>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.9.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2002FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
@@ -2,14 +2,30 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 00:42:16
|
||||
* @LastEditTime : 2020-01-16 00:39:23
|
||||
* @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.
|
||||
*/
|
||||
#ifndef _MQTT_CONFIG_H_
|
||||
#define _MQTT_CONFIG_H_
|
||||
|
||||
#define MQTT_NO 0
|
||||
#define MQTT_YES 1
|
||||
#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)
|
||||
#endif
|
||||
|
||||
|
||||
#define MQTT_MAX_PACKET_ID (0xFFFF - 1)
|
||||
#define MQTT_TOPIC_LEN_MAX 64
|
||||
@@ -18,27 +34,14 @@
|
||||
#define MQTT_DEFAULT_CMD_TIMEOUT 4000
|
||||
#define MQTT_MAX_CMD_TIMEOUT 20000
|
||||
#define MQTT_MIN_CMD_TIMEOUT 1000
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 20 // unit: second
|
||||
#define MQTT_VERSION 4 // 4 is mqtt 3.1.1
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 100 // 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_TLS MQTT_YES
|
||||
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#define MQTT_TLS_HANDSHAKE_TIMEOUT (5 * 1000)
|
||||
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#endif /* MQTT_NETWORK_TYPE_TLS */
|
||||
#define MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#endif /* _MQTT_CONFIG_H_ */
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
#define TOS_CFG_MMHEAP_EN 1u
|
||||
|
||||
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x12000
|
||||
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x13000
|
||||
|
||||
#define TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN 1u
|
||||
|
||||
|
52
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_dwt.h
Normal file
52
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_dwt.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-15 20:51:38
|
||||
* @LastEditTime: 2020-02-16 00:07:34
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _BSP_DWT_H
|
||||
#define _BSP_DWT_H
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define USE_DWT_DELAY 1 /* 使用dwt内核精确延时 */
|
||||
|
||||
#if USE_DWT_DELAY
|
||||
#define USE_TICK_DELAY 0 /* 不使用SysTick延时 */
|
||||
#else
|
||||
#define USE_TICK_DELAY 1 /* 使用SysTick延时 */
|
||||
#endif
|
||||
|
||||
#if USE_DWT_DELAY
|
||||
|
||||
/* 获取内核时钟频率 */
|
||||
#define get_cpu_clk_freq() (72000000U)
|
||||
#define system_clk_freq (72000000U)
|
||||
/* 为方便使用,在延时函数内部调用dwt_init函数初始化时间戳寄存器,
|
||||
这样每次调用函数都会初始化一遍。
|
||||
把本宏值设置为0,然后在main函数刚运行时调用dwt_init可避免每次都初始化 */
|
||||
|
||||
#define CPU_TS_INIT_IN_DELAY_FUNCTION 0
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 函数声明
|
||||
******************************************************************************/
|
||||
uint32_t dwt_read(void);
|
||||
void dwt_init(void);
|
||||
|
||||
//使用以下函数前必须先调用dwt_init函数使能计数器,或使能宏CPU_TS_INIT_IN_DELAY_FUNCTION
|
||||
//最大延时值为60秒
|
||||
void dwt_delay_us(uint32_t us);
|
||||
#define dwt_delay_ms(ms) dwt_delay_us(ms*1000)
|
||||
#define dwt_delay_s(s) dwt_delay_ms(s*1000)
|
||||
|
||||
/* 最大延时 60s=2的32次方/72000000 */
|
||||
#define delay_ms(ms) dwt_delay_ms(ms)
|
||||
#define delay_us(us) dwt_delay_us(us)
|
||||
#define delay_s(s) dwt_delay_s(s)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _BSP_DWT_H */
|
23
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_init.h
Normal file
23
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_init.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-14 22:37:23
|
||||
* @LastEditTime : 2020-02-14 23:37:18
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _BSP_INIT_H_
|
||||
#define _BSP_INIT_H_
|
||||
|
||||
#include "stm32f1xx.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "bsp_led.h"
|
||||
#include "bsp_dwt.h"
|
||||
#include "bsp_usart.h"
|
||||
#include "bsp_motor.h"
|
||||
|
||||
void bsp_init(void);
|
||||
void SystemClock_Config(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
34
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_led.h
Normal file
34
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_led.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-15 20:51:38
|
||||
* @LastEditTime : 2020-02-16 00:24:14
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _BSP_LED_H
|
||||
#define _BSP_LED_H
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#define R_MAX 255
|
||||
#define G_MAX 255
|
||||
#define B_MAX 255
|
||||
|
||||
#define RGB_LED_CLK_PIN GPIO_PIN_8
|
||||
#define RGB_LED_CLK_GPIO_PORT GPIOB
|
||||
|
||||
#define RGB_LED_SDA_PIN GPIO_PIN_9
|
||||
#define RGB_LED_SDA_GPIO_PORT GPIOB
|
||||
|
||||
#define RGB_LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
|
||||
#define SCL_LOW HAL_GPIO_WritePin(RGB_LED_CLK_GPIO_PORT, RGB_LED_CLK_PIN, GPIO_PIN_RESET)
|
||||
#define SCL_HIGH HAL_GPIO_WritePin(RGB_LED_CLK_GPIO_PORT, RGB_LED_CLK_PIN, GPIO_PIN_SET)
|
||||
|
||||
#define SDA_LOW HAL_GPIO_WritePin(RGB_LED_SDA_GPIO_PORT, RGB_LED_SDA_PIN, GPIO_PIN_RESET)
|
||||
#define SDA_HIGH HAL_GPIO_WritePin(RGB_LED_SDA_GPIO_PORT, RGB_LED_SDA_PIN, GPIO_PIN_SET)
|
||||
|
||||
void rgb_led_init(void);
|
||||
void rgb_led_control(uint8_t r,uint8_t g,uint8_t b);
|
||||
|
||||
#endif /* _BSP_LED_H */
|
43
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_motor.h
Normal file
43
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_motor.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-16 00:02:40
|
||||
* @LastEditTime : 2020-02-16 00:31:10
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _BSP_MOTOR_H
|
||||
#define _BSP_MOTOR_H
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#define MOTOR_FORWARD_PORT GPIOB
|
||||
#define MOTOR_FORWARD_PIN GPIO_PIN_4
|
||||
#define MOTOR_FORWARD_CHANNEL TIM_CHANNEL_1
|
||||
|
||||
|
||||
#define MOTOR_REVERSE_PORT GPIOB
|
||||
#define MOTOR_REVERSE_PIN GPIO_PIN_5
|
||||
#define MOTOR_REVERSE_CHANNEL TIM_CHANNEL_2
|
||||
|
||||
#define MOTOR_TIM TIM3
|
||||
#define MOTOR_TIM_RCC_CLK_ENABLE() __HAL_RCC_TIM3_CLK_ENABLE()
|
||||
#define MOTOR_TIM_AFIO_REMAP() __HAL_AFIO_REMAP_TIM3_PARTIAL()
|
||||
#define MOTOR_TIM_RCC_CLK_DISABLE() __HAL_RCC_TIM3_CLK_DISABLE()
|
||||
#define MOTOR_TIM_GPIO_RCC_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
//72M/72=1M<31>ļ<EFBFBD><C4BC><EFBFBD>Ƶ<EFBFBD>ʣ<EFBFBD><CAA3>Զ<EFBFBD><D4B6><EFBFBD>װ<EFBFBD><D7B0>Ϊ500<30><30><EFBFBD><EFBFBD>ôPWMƵ<4D><C6B5>Ϊ1M/250=4kHZ
|
||||
#define MOTOR_PRESCALER 71 //<2F><>ʱ<EFBFBD><CAB1>Ԥ<EFBFBD><D4A4>Ƶ
|
||||
#define MOTOR_PERIOD 249 // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ֵ
|
||||
|
||||
#define MOTOR_MAX_DUTY 100 // <20><><EFBFBD><EFBFBD>ռ<EFBFBD>ձ<EFBFBD>
|
||||
|
||||
typedef enum motor_mode {
|
||||
MOTOR_STOP = 0,
|
||||
MOTOR_FORWARD = 1,
|
||||
MOTOR_REVERSE = 2
|
||||
} motor_mode_t;
|
||||
|
||||
void motor_init(void);
|
||||
void motor_set_speed(motor_mode_t s, uint8_t pwm);
|
||||
|
||||
#endif /* _BSP_MOTOR_H */
|
57
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_usart.h
Normal file
57
board/GoKit3_STM32F103C8T6/BSP/Inc/bsp_usart.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __USART_H
|
||||
#define __USART_H
|
||||
|
||||
#include "stm32f1xx.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define DEBUG_USART_BAUDRATE 115200
|
||||
|
||||
//<2F><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
/*******************************************************/
|
||||
#define DEBUG_USART USART1
|
||||
#define DEBUG_USART_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE();
|
||||
|
||||
#define DEBUG_USART_RX_GPIO_PORT GPIOA
|
||||
#define DEBUG_USART_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define DEBUG_USART_RX_PIN GPIO_PIN_10
|
||||
|
||||
#define DEBUG_USART_TX_GPIO_PORT GPIOA
|
||||
#define DEBUG_USART_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define DEBUG_USART_TX_PIN GPIO_PIN_9
|
||||
|
||||
#define DEBUG_USART_IRQHandler USART1_IRQHandler
|
||||
#define DEBUG_USART_IRQ USART1_IRQn
|
||||
/************************************************************/
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define WIFI_USART_BAUDRATE 115200
|
||||
|
||||
//<2F><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
/*******************************************************/
|
||||
#define WIFI_USART USART2
|
||||
#define WIFI_USART_CLK_ENABLE() __HAL_RCC_USART2_CLK_ENABLE();
|
||||
|
||||
#define WIFI_USART_RX_GPIO_PORT GPIOA
|
||||
#define WIFI_USART_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define WIFI_USART_RX_PIN GPIO_PIN_3
|
||||
|
||||
#define WIFI_USART_TX_GPIO_PORT GPIOA
|
||||
#define WIFI_USART_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define WIFI_USART_TX_PIN GPIO_PIN_2
|
||||
|
||||
#define WIFI_USART_IRQHandler USART2_IRQHandler
|
||||
#define WIFI_USART_IRQ USART2_IRQn
|
||||
/************************************************************/
|
||||
|
||||
void wifi_usart_init(void);
|
||||
void debug_usart_init(void);
|
||||
void usart_send_string(UART_HandleTypeDef *huart, uint8_t *str);
|
||||
int fputc(int ch, FILE *f);
|
||||
int fgetc(FILE *f);
|
||||
|
||||
extern UART_HandleTypeDef debug_usart;
|
||||
extern UART_HandleTypeDef wifi_usart;
|
||||
|
||||
#endif /* __USART_H */
|
@@ -63,7 +63,7 @@
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
/*#define HAL_TIM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/*#define HAL_USART_MODULE_ENABLED */
|
||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||
|
460
board/GoKit3_STM32F103C8T6/BSP/Inc/tos_at.h
Normal file
460
board/GoKit3_STM32F103C8T6/BSP/Inc/tos_at.h
Normal file
@@ -0,0 +1,460 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* Tencent is pleased to support the open source community by making TencentOS
|
||||
* available.
|
||||
*
|
||||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* If you have downloaded a copy of the TencentOS binary from Tencent, please
|
||||
* note that the TencentOS binary is licensed under the BSD 3-Clause License.
|
||||
*
|
||||
* If you have downloaded a copy of the TencentOS source code from Tencent,
|
||||
* please note that TencentOS source code is licensed under the BSD 3-Clause
|
||||
* License, except for the third-party components listed below which are
|
||||
* subject to different license terms. Your integration of TencentOS into your
|
||||
* own projects may require compliance with the BSD 3-Clause License, as well
|
||||
* as the other licenses applicable to the third-party components included
|
||||
* within TencentOS.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _TOS_AT_H_
|
||||
#define _TOS_AT_H_
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_at_utils.h"
|
||||
#include "tos_hal.h"
|
||||
|
||||
#define AT_AGENT_ECHO_OK "OK"
|
||||
#define AT_AGENT_ECHO_FAIL "FAIL"
|
||||
#define AT_AGENT_ECHO_ERROR "ERROR"
|
||||
|
||||
#define AT_DATA_CHANNEL_NUM 1
|
||||
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (0 + 1024)
|
||||
|
||||
#define AT_UART_RX_FIFO_BUFFER_SIZE (0 + 1024)
|
||||
#define AT_RECV_CACHE_SIZE 1024
|
||||
|
||||
#define AT_CMD_BUFFER_SIZE 512
|
||||
|
||||
#define AT_PARSER_TASK_STACK_SIZE 1024
|
||||
#define AT_PARSER_TASK_PRIO 2
|
||||
|
||||
typedef enum at_status_en {
|
||||
AT_STATUS_OK,
|
||||
AT_STATUS_ERROR,
|
||||
AT_STATUS_INVALID_ARGS,
|
||||
} at_status_t;
|
||||
|
||||
typedef struct at_cache_st {
|
||||
uint8_t *buffer;
|
||||
size_t buffer_size;
|
||||
size_t recv_len;
|
||||
} at_cache_t;
|
||||
|
||||
typedef enum at_parse_status_en {
|
||||
AT_PARSE_STATUS_NONE,
|
||||
AT_PARSE_STATUS_NEWLINE,
|
||||
AT_PARSE_STATUS_EVENT,
|
||||
AT_PARSE_STATUS_EXPECT,
|
||||
AT_PARSE_STATUS_OVERFLOW,
|
||||
} at_parse_status_t;
|
||||
|
||||
typedef enum at_echo_status_en {
|
||||
AT_ECHO_STATUS_NONE,
|
||||
AT_ECHO_STATUS_OK,
|
||||
AT_ECHO_STATUS_FAIL,
|
||||
AT_ECHO_STATUS_ERROR,
|
||||
AT_ECHO_STATUS_EXPECT,
|
||||
} at_echo_status_t;
|
||||
|
||||
typedef enum at_channel_status_en {
|
||||
AT_CHANNEL_STATUS_NONE, /*< usually means we are try to get a channel status with invalid id */
|
||||
AT_CHANNEL_STATUS_HANGING, /*< channel is not used */
|
||||
AT_CHANNEL_STATUS_WORKING, /*< channel is being using */
|
||||
AT_CHANNEL_STATUS_BROKEN, /*< channel is broken(module link to remote server is broken) */
|
||||
} at_channel_status_t;
|
||||
|
||||
typedef struct at_data_channel_st {
|
||||
uint8_t is_free;
|
||||
k_chr_fifo_t rx_fifo;
|
||||
uint8_t *rx_fifo_buffer;
|
||||
k_mutex_t rx_lock;
|
||||
|
||||
at_channel_status_t status;
|
||||
|
||||
const char *remote_ip;
|
||||
const char *remote_port;
|
||||
} at_data_channel_t;
|
||||
|
||||
typedef struct at_echo_st {
|
||||
char *buffer;
|
||||
size_t buffer_size;
|
||||
char *echo_expect;
|
||||
int line_num;
|
||||
at_echo_status_t status;
|
||||
size_t __w_idx;
|
||||
int __is_expecting;
|
||||
k_sem_t __expect_notify;
|
||||
} at_echo_t;
|
||||
|
||||
typedef void (*at_event_callback_t)(void);
|
||||
|
||||
typedef struct at_event_st {
|
||||
const char *event_header;
|
||||
at_event_callback_t event_callback;
|
||||
} at_event_t;
|
||||
|
||||
typedef struct at_agent_st {
|
||||
at_data_channel_t data_channel[AT_DATA_CHANNEL_NUM];
|
||||
|
||||
at_event_t *event_table;
|
||||
size_t event_table_size;
|
||||
|
||||
at_echo_t *echo;
|
||||
|
||||
k_task_t parser;
|
||||
at_cache_t recv_cache;
|
||||
|
||||
at_timer_t timer;
|
||||
|
||||
k_mutex_t global_lock;
|
||||
|
||||
char *cmd_buf;
|
||||
k_mutex_t cmd_buf_lock;
|
||||
|
||||
hal_uart_t uart;
|
||||
k_mutex_t uart_tx_lock;
|
||||
k_mutex_t uart_rx_lock;
|
||||
k_sem_t uart_rx_sem;
|
||||
k_chr_fifo_t uart_rx_fifo;
|
||||
uint8_t *uart_rx_fifo_buffer;
|
||||
} at_agent_t;
|
||||
|
||||
#define AT_AGENT ((at_agent_t *)(&at_agent))
|
||||
|
||||
/**
|
||||
* @brief Write data to a channel.
|
||||
* Write data to a channel with certain id.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
* @param[in] buffer data buffer to write.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 write failed(error).
|
||||
* @retval none -1 the number of bytes written.
|
||||
*/
|
||||
__API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_len);
|
||||
|
||||
/**
|
||||
* @brief Read data from a channel.
|
||||
* Read data from a channel with a timeout.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
* @param[out] buffer buffer to hold the data read.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
* @param[in] timeout timeout.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 read failed(error).
|
||||
* @retval none -1 the number of bytes read.
|
||||
*/
|
||||
__API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Read data from a channel.
|
||||
* Read data from a channel.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
* @param[out] buffer buffer to hold the data read.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 read failed(error).
|
||||
* @retval none -1 the number of bytes read.
|
||||
*/
|
||||
__API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_len);
|
||||
|
||||
/**
|
||||
* @brief Allocate a channel.
|
||||
* Allocate a channel with certain id.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
* @param[in] ip remote ip of the channel.
|
||||
* @param[in] port remote port of the channel.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 allocate failed(error).
|
||||
* @retval none -1 the id of the channel.
|
||||
*/
|
||||
__API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *port);
|
||||
|
||||
/**
|
||||
* @brief Allocate a channel.
|
||||
* Allocate a channel.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] ip remote ip of the channel.
|
||||
* @param[in] port remote port of the channel.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 allocate failed(error).
|
||||
* @retval none -1 the id of the channel.
|
||||
*/
|
||||
__API__ int tos_at_channel_alloc(const char *ip, const char *port);
|
||||
|
||||
/**
|
||||
* @brief Free a channel.
|
||||
* Free a channel with certain id.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 free failed(error).
|
||||
* @retval 0 free successfully.
|
||||
*/
|
||||
__API__ int tos_at_channel_free(int channel_id);
|
||||
|
||||
/**
|
||||
* @brief Set channel broken.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 set failed(error).
|
||||
* @retval 0 set successfully.
|
||||
*/
|
||||
__API__ int tos_at_channel_set_broken(int channel_id);
|
||||
|
||||
/**
|
||||
* @brief Judge whether channel is working.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
*
|
||||
* @return at channel status(type of at_channel_status_t)
|
||||
*/
|
||||
__API__ int tos_at_channel_is_working(int channel_id);
|
||||
|
||||
/**
|
||||
* @brief Initialize the at framework.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] uart_port port number of the uart thougth which the module connect to the MCU.
|
||||
* @param[in] event_table the listened event table.
|
||||
* @param[in] event_table_size the size of the listened event table.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 initialize failed(error).
|
||||
* @retval 0 initialize successfully.
|
||||
*/
|
||||
__API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size);
|
||||
|
||||
/**
|
||||
* @brief De-initialize the at framework.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @return
|
||||
None
|
||||
*/
|
||||
__API__ void tos_at_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Create a echo struct.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] echo pointer to the echo struct.
|
||||
* @param[out] buffer buffer to hold the received message from the module.
|
||||
* @param[in] buffer_size size of the buffer.
|
||||
* @param[in] echo_expect the expected echo message.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 create failed(error).
|
||||
* @retval 0 create successfully.
|
||||
*/
|
||||
__API__ int tos_at_echo_create(at_echo_t *echo, char *buffer, size_t buffer_size, char *echo_expect);
|
||||
|
||||
/**
|
||||
* @brief Execute an at command.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] echo pointer to the echo struct.
|
||||
* @param[in] timeout command wait timeout .
|
||||
* @param[in] cmd at command.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 execute failed(error).
|
||||
* @retval 0 execute successfully.
|
||||
*/
|
||||
__API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
|
||||
|
||||
/**
|
||||
* @brief Execute an at command.
|
||||
* Execute an at command and wait until the expected echo message received or timeout.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] echo pointer to the echo struct.
|
||||
* @param[in] timeout command wait timeout .
|
||||
* @param[in] cmd at command.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 execute failed(error).
|
||||
* @retval 0 execute successfully.
|
||||
*/
|
||||
__API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
|
||||
|
||||
/**
|
||||
* @brief Send raw data througth uart.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] echo pointer to the echo struct.
|
||||
* @param[in] timeout command wait timeout .
|
||||
* @param[in] buf data to send.
|
||||
* @param[in] size size of the buf.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 execute failed(error).
|
||||
* @retval 0 execute successfully.
|
||||
*/
|
||||
__API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Send raw data througth uart.
|
||||
* Send raw data througth uart and wait until the expected echo message received or timeout.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] echo pointer to the echo struct.
|
||||
* @param[in] timeout command wait timeout .
|
||||
* @param[in] buf data to send.
|
||||
* @param[in] size size of the buf.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 execute failed(error).
|
||||
* @retval 0 execute successfully.
|
||||
*/
|
||||
__API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Write byte to the at uart.
|
||||
* The function called by the uart interrupt, to put the data from the uart to the at framework.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] data uart received data.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
__API__ void tos_at_uart_input_byte(uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief A global lock provided by at framework.
|
||||
* The lock usually used to make a atomic function.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 pend failed(error).
|
||||
* @retval 0 pend successfully.
|
||||
*/
|
||||
__API__ int tos_at_global_lock_pend(void);
|
||||
|
||||
/**
|
||||
* @brief A global lock provided by at framework.
|
||||
* The lock usually used to make a atomic function.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return errcode
|
||||
* @retval -1 post failed(error).
|
||||
* @retval 0 post successfully.
|
||||
*/
|
||||
__API__ int tos_at_global_lock_post(void);
|
||||
|
||||
/**
|
||||
* @brief Read data from the uart.
|
||||
* Read data from the uart, usually called in listened event callback.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[out] buffer buffer to hold the data read from the uart.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
*
|
||||
* @return length of the data read from the uart.
|
||||
*/
|
||||
__API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len);
|
||||
|
||||
/**
|
||||
* @brief Read data from the uart.
|
||||
* Read data from the uart until meet a '\n', usually called in listened event callback.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[out] buffer buffer to hold the data read from the uart.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
*
|
||||
* @return length of the data read from the uart.
|
||||
*/
|
||||
__API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len);
|
||||
|
||||
/**
|
||||
* @brief Read data from the uart.
|
||||
* Read data from the uart until no more incoming data, usually called in listened event callback.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[out] buffer buffer to hold the data read from the uart.
|
||||
* @param[in] buffer_len length of the buffer.
|
||||
*
|
||||
* @return length of the data read from the uart.
|
||||
*/
|
||||
__API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len);
|
||||
|
||||
/**
|
||||
* @brief Get the remote ip of a channel.
|
||||
* Get the remote ip of a channel with certain id.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
*
|
||||
* @return remote ip of the channel.
|
||||
*/
|
||||
__API__ const char *tos_at_agent_channel_ip_get(int channel_id);
|
||||
|
||||
/**
|
||||
* @brief Get the remote port of a channel.
|
||||
* Get the remote port of a channel with certain id.
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @param[in] channel_id id of the channel.
|
||||
*
|
||||
* @return remote port of the channel.
|
||||
*/
|
||||
__API__ const char *tos_at_agent_channel_port_get(int channel_id);
|
||||
|
||||
#endif /* __AT_AGENT_H_ */
|
||||
|
23
board/GoKit3_STM32F103C8T6/BSP/Inc/tos_at_utils.h
Normal file
23
board/GoKit3_STM32F103C8T6/BSP/Inc/tos_at_utils.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _TOS_AT_UTILS_H_
|
||||
#define _TOS_AT_UTILS_H_
|
||||
|
||||
typedef struct at_timer_st {
|
||||
k_tick_t end_time;
|
||||
} at_timer_t;
|
||||
|
||||
void at_delay(k_tick_t tick);
|
||||
|
||||
void at_delay_ms(uint32_t millisec);
|
||||
|
||||
int at_timer_is_expired(at_timer_t *tmr);
|
||||
|
||||
void at_timer_countdown(at_timer_t *tmr, k_tick_t tick);
|
||||
|
||||
void at_timer_countdown_ms(at_timer_t *tmr, uint32_t millisec);
|
||||
|
||||
k_tick_t at_timer_remain(at_timer_t *tmr);
|
||||
|
||||
void at_timer_init(at_timer_t *tmr);
|
||||
|
||||
#endif
|
||||
|
129
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_dwt.c
Normal file
129
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_dwt.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-15 20:51:38
|
||||
* @LastEditTime : 2020-02-16 00:06:40
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
|
||||
#include "bsp_dwt.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
/*
|
||||
**********************************************************************
|
||||
* ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼĴ<D8BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
**********************************************************************
|
||||
*/
|
||||
/*
|
||||
<20><>Cortex-M<><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWT(Data Watchpoint and Trace)<29><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>32λ<32>ļĴ<C4BC><C4B4><EFBFBD><EFBFBD><EFBFBD>CYCCNT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ϵļ<CFB5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>еĸ<D0B5><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD>¼<EFBFBD><C2BC>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA>
|
||||
60s=2<><32>32<33>η<EFBFBD>/72000000
|
||||
(<28><><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ72M<32><4D><EFBFBD>ں<EFBFBD><DABA><EFBFBD>һ<EFBFBD>ε<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1/72M=13.8ns)
|
||||
<20><>CYCCNT<4E><54><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><F3A3ACBB><EFBFBD>0<EFBFBD><30><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
ʹ<><CAB9>CYCCNT<4E><54><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>裺
|
||||
1<><31><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>DWT<57><54><EFBFBD>裬<EFBFBD><E8A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں˵<DABA><CBB5>ԼĴ<D4BC><C4B4><EFBFBD>DEMCR<43><52>λ24<32><34><EFBFBD>ƣ<EFBFBD>д1ʹ<31><CAB9>
|
||||
2<><32>ʹ<EFBFBD><CAB9>CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
3<><33>ʹ<EFBFBD><CAB9>CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWT_CTRL(<28><><EFBFBD><EFBFBD><EFBFBD>Ϻ궨<CFBA><EAB6A8>ΪDWT_CR)<29><>λ0<CEBB><30><EFBFBD>ƣ<EFBFBD>д1ʹ<31><CAB9>
|
||||
*/
|
||||
|
||||
#if USE_DWT_DELAY
|
||||
|
||||
|
||||
#define DWT_CR *(__IO uint32_t *)0xE0001000
|
||||
#define DWT_CYCCNT *(__IO uint32_t *)0xE0001004
|
||||
#define DEM_CR *(__IO uint32_t *)0xE000EDFC
|
||||
|
||||
|
||||
#define DEM_CR_TRCENA (1 << 24)
|
||||
#define DWT_CR_CYCCNTENA (1 << 0)
|
||||
|
||||
|
||||
/**
|
||||
* @brief <20><>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
* @param <20><>
|
||||
* @retval <20><>
|
||||
* @note ʹ<><CAB9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void dwt_init(void)
|
||||
{
|
||||
/* ʹ<><CAB9>DWT<57><54><EFBFBD><EFBFBD> */
|
||||
DEM_CR |= (uint32_t)DEM_CR_TRCENA;
|
||||
|
||||
/* DWT CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0 */
|
||||
DWT_CYCCNT = (uint32_t)0u;
|
||||
|
||||
/* ʹ<><CAB9>Cortex-M DWT CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD> */
|
||||
DWT_CR |= (uint32_t)DWT_CR_CYCCNTENA;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD>
|
||||
* @param <20><>
|
||||
* @retval <20><>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWT_CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
uint32_t dwt_read(void)
|
||||
{
|
||||
return ((uint32_t)DWT_CYCCNT);
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD>
|
||||
// * @param <20><>
|
||||
// * @retval <20><>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWT_CYCCNT<4E>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
// * <09>˴<EFBFBD><CBB4><EFBFBD>HAL<41><4C><EFBFBD>滻HAL_GetTick<63><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>os
|
||||
// */
|
||||
//uint32_t HAL_GetTick(void)
|
||||
//{
|
||||
// //<2F>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||||
// return ((uint32_t)DWT_CYCCNT / system_clk_freq * 1000);
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>CPU<50><55><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>־<EFBFBD>ȷ<EFBFBD><C8B7>ʱ<EFBFBD><CAB1>32λ<32><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param us : <20>ӳٳ<D3B3><D9B3>ȣ<EFBFBD><C8A3><EFBFBD>λ1 us
|
||||
* @retval <20><>
|
||||
* @note ʹ<>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>dwt_init<69><74><EFBFBD><EFBFBD>ʹ<EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>ʹ<EFBFBD>ܺ<EFBFBD>CPU_TS_INIT_IN_DELAY_FUNCTION
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱֵΪ8<CEAA>룬<EFBFBD><EBA3AC>8*1000*1000
|
||||
*/
|
||||
void dwt_delay_us(__IO uint32_t us)
|
||||
{
|
||||
uint32_t ticks;
|
||||
uint32_t told,tnow,tcnt=0;
|
||||
|
||||
/* <20>ں<EFBFBD><DABA><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#if (CPU_TS_INIT_IN_DELAY_FUNCTION)
|
||||
/* <20><>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
dwt_init();
|
||||
#endif
|
||||
|
||||
ticks = us * (get_cpu_clk_freq() / 1000000); /* <20><>Ҫ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
tcnt = 0;
|
||||
told = (uint32_t)dwt_read(); /* <20>ս<EFBFBD><D5BD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
|
||||
while(1)
|
||||
{
|
||||
tnow = (uint32_t)dwt_read();
|
||||
if(tnow != told)
|
||||
{
|
||||
/* 32λ<32><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if(tnow > told)
|
||||
{
|
||||
tcnt += tnow - told;
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD>װ<EFBFBD><D7B0> */
|
||||
else
|
||||
{
|
||||
tcnt += UINT32_MAX - told + tnow;
|
||||
}
|
||||
|
||||
told = tnow;
|
||||
|
||||
/*ʱ<>䳬<EFBFBD><E4B3AC>/<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD>ӳٵ<D3B3>ʱ<EFBFBD><CAB1>,<2C><><EFBFBD>˳<EFBFBD> */
|
||||
if(tcnt >= ticks)break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
56
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_init.c
Normal file
56
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_init.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-15 20:51:14
|
||||
* @LastEditTime: 2020-02-16 00:08:19
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "bsp_init.h"
|
||||
|
||||
static void system_clock_init(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
while(1);
|
||||
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||
while(1);
|
||||
|
||||
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
||||
|
||||
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
||||
|
||||
/* SysTick_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
||||
}
|
||||
|
||||
void bsp_init(void)
|
||||
{
|
||||
HAL_Init();
|
||||
|
||||
system_clock_init();
|
||||
|
||||
dwt_init();
|
||||
|
||||
debug_usart_init();
|
||||
|
||||
rgb_led_init();
|
||||
|
||||
motor_init();
|
||||
|
||||
}
|
||||
|
113
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_led.c
Normal file
113
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_led.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-15 20:51:38
|
||||
* @LastEditTime : 2020-02-16 00:05:59
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "bsp_led.h"
|
||||
#include "bsp_dwt.h"
|
||||
|
||||
|
||||
void clk_produce(void)
|
||||
{
|
||||
SCL_LOW; // SCL=0
|
||||
delay_us(50);
|
||||
|
||||
SCL_HIGH; // SCL=1
|
||||
delay_us(50);
|
||||
}
|
||||
|
||||
|
||||
void send_32bit_zero(void)
|
||||
{
|
||||
unsigned char i;
|
||||
SDA_LOW; // SDA=0
|
||||
for (i=0; i<32; i++)
|
||||
{
|
||||
clk_produce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t take_anti_code(uint8_t dat)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
|
||||
tmp=((~dat) & 0xC0)>>6;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
void send_data(uint32_t dx)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
{
|
||||
if ((dx & 0x80000000) != 0)
|
||||
SDA_HIGH; // SDA=1;
|
||||
else
|
||||
SDA_LOW; // SDA=0;
|
||||
|
||||
dx <<= 1;
|
||||
clk_produce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void data_deal_with_send(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
uint32_t dx = 0;
|
||||
|
||||
dx |= (uint32_t)0x03 << 30; // The front of the two bits 1 is flag bits
|
||||
dx |= (uint32_t)take_anti_code(b) << 28;
|
||||
dx |= (uint32_t)take_anti_code(g) << 26;
|
||||
dx |= (uint32_t)take_anti_code(r) << 24;
|
||||
|
||||
dx |= (uint32_t)b << 16;
|
||||
dx |= (uint32_t)g << 8;
|
||||
dx |= r;
|
||||
|
||||
send_data(dx);
|
||||
}
|
||||
|
||||
void rgb_led_init(void)
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>GPIO_InitTypeDef<65><66><EFBFBD>͵Ľṹ<C4BD><E1B9B9>*/
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
RGB_LED_GPIO_CLK_ENABLE();
|
||||
|
||||
/*ѡ<><D1A1>Ҫ<EFBFBD><D2AA><EFBFBD>Ƶ<EFBFBD>GPIO<49><4F><EFBFBD><EFBFBD>*/
|
||||
GPIO_InitStruct.Pin = RGB_LED_CLK_PIN;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ*/
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> */
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
/*<2A><><EFBFBD>ÿ⺯<C3BF><E2BAAF><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>GPIO_InitStructure<72><65>ʼ<EFBFBD><CABC>GPIO*/
|
||||
HAL_GPIO_Init(RGB_LED_CLK_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
/*ѡ<><D1A1>Ҫ<EFBFBD><D2AA><EFBFBD>Ƶ<EFBFBD>GPIO<49><4F><EFBFBD><EFBFBD>*/
|
||||
GPIO_InitStruct.Pin = RGB_LED_SDA_PIN;
|
||||
HAL_GPIO_Init(RGB_LED_SDA_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
send_32bit_zero();
|
||||
data_deal_with_send(0,0,0);
|
||||
data_deal_with_send(0,0,0);
|
||||
}
|
||||
|
||||
void rgb_led_control(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
send_32bit_zero();
|
||||
data_deal_with_send(r, g, b);
|
||||
data_deal_with_send(r, g, b);
|
||||
}
|
||||
|
||||
/*********************************************END OF FILE**********************/
|
103
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_motor.c
Normal file
103
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_motor.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-16 00:02:40
|
||||
* @LastEditTime : 2020-02-16 00:23:28
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "bsp_motor.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TIM_HandleTypeDef motor_tim;
|
||||
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
||||
{
|
||||
MOTOR_TIM_RCC_CLK_ENABLE();
|
||||
}
|
||||
|
||||
static void motor_control(uint32_t m1, uint32_t m2)
|
||||
{
|
||||
if (m1 >= MOTOR_PERIOD)
|
||||
m1 = MOTOR_PERIOD;
|
||||
|
||||
if (m2 > MOTOR_PERIOD)
|
||||
m2 = MOTOR_PERIOD;
|
||||
|
||||
__HAL_TIM_SET_COMPARE(&motor_tim, MOTOR_FORWARD_CHANNEL, m1);
|
||||
__HAL_TIM_SET_COMPARE(&motor_tim, MOTOR_REVERSE_CHANNEL, m2);
|
||||
}
|
||||
|
||||
void motor_set_speed(motor_mode_t s, uint8_t pwm)
|
||||
{
|
||||
uint32_t pulse;
|
||||
|
||||
if (pwm > MOTOR_MAX_DUTY)
|
||||
pwm = MOTOR_MAX_DUTY;
|
||||
|
||||
pulse = (pwm * MOTOR_PERIOD) / MOTOR_MAX_DUTY;
|
||||
|
||||
if (MOTOR_STOP == s)
|
||||
motor_control(0, 0);
|
||||
else if (MOTOR_FORWARD == s)
|
||||
motor_control(pulse, 0);
|
||||
else
|
||||
motor_control(0, pulse);
|
||||
}
|
||||
|
||||
static void Error_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init;
|
||||
|
||||
if(htim->Instance == MOTOR_TIM) {
|
||||
|
||||
MOTOR_TIM_GPIO_RCC_CLK_ENABLE();
|
||||
MOTOR_TIM_AFIO_REMAP();
|
||||
|
||||
gpio_init.Pin = MOTOR_FORWARD_PIN | MOTOR_REVERSE_PIN;
|
||||
gpio_init.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &gpio_init);
|
||||
}
|
||||
}
|
||||
|
||||
void motor_init(void)
|
||||
{
|
||||
TIM_OC_InitTypeDef oc_init;
|
||||
|
||||
motor_tim.Instance = MOTOR_TIM;
|
||||
motor_tim.Init.Prescaler = MOTOR_PRESCALER;
|
||||
motor_tim.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
motor_tim.Init.Period = MOTOR_PERIOD;
|
||||
motor_tim.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
|
||||
if (HAL_TIM_Base_Init(&motor_tim) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
HAL_TIM_Base_Start(&motor_tim);
|
||||
|
||||
if (HAL_TIM_PWM_Init(&motor_tim) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
HAL_TIM_MspPostInit(&motor_tim);
|
||||
|
||||
oc_init.OCMode = TIM_OCMODE_PWM1;
|
||||
oc_init.Pulse = MOTOR_PERIOD;
|
||||
oc_init.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
|
||||
if (HAL_TIM_PWM_ConfigChannel(&motor_tim, &oc_init, MOTOR_FORWARD_CHANNEL) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
if (HAL_TIM_PWM_ConfigChannel(&motor_tim, &oc_init, MOTOR_REVERSE_CHANNEL) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
HAL_TIM_PWM_Start(&motor_tim, MOTOR_FORWARD_CHANNEL);//<2F><><EFBFBD><EFBFBD>PWMͨ<4D><CDA8>1
|
||||
HAL_TIM_PWM_Start(&motor_tim, MOTOR_REVERSE_CHANNEL);//<2F><><EFBFBD><EFBFBD>PWMͨ<4D><CDA8>2
|
||||
|
||||
motor_set_speed(MOTOR_STOP, 0);
|
||||
}
|
144
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_usart.c
Normal file
144
board/GoKit3_STM32F103C8T6/BSP/Src/bsp_usart.c
Normal file
@@ -0,0 +1,144 @@
|
||||
#include "bsp_usart.h"
|
||||
|
||||
UART_HandleTypeDef debug_usart;
|
||||
UART_HandleTypeDef wifi_usart;
|
||||
|
||||
/**
|
||||
* @brief DEBUG_USART GPIO <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>á<EFBFBD>115200 8-N-1
|
||||
* @param <20><>
|
||||
* @retval <20><>
|
||||
*/
|
||||
void debug_usart_init(void)
|
||||
{
|
||||
|
||||
debug_usart.Instance = DEBUG_USART;
|
||||
|
||||
debug_usart.Init.BaudRate = DEBUG_USART_BAUDRATE;
|
||||
debug_usart.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
debug_usart.Init.StopBits = UART_STOPBITS_1;
|
||||
debug_usart.Init.Parity = UART_PARITY_NONE;
|
||||
debug_usart.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
debug_usart.Init.Mode = UART_MODE_TX_RX;
|
||||
|
||||
HAL_UART_Init(&debug_usart);
|
||||
|
||||
/*ʹ<>ܴ<EFBFBD><DCB4>ڽ<EFBFBD><DABD>ն<EFBFBD> */
|
||||
__HAL_UART_ENABLE_IT(&debug_usart, UART_IT_RXNE);
|
||||
}
|
||||
|
||||
void wifi_usart_init(void)
|
||||
{
|
||||
|
||||
wifi_usart.Instance = WIFI_USART;
|
||||
|
||||
wifi_usart.Init.BaudRate = WIFI_USART_BAUDRATE;
|
||||
wifi_usart.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
wifi_usart.Init.StopBits = UART_STOPBITS_1;
|
||||
wifi_usart.Init.Parity = UART_PARITY_NONE;
|
||||
wifi_usart.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
wifi_usart.Init.Mode = UART_MODE_TX_RX;
|
||||
|
||||
HAL_UART_Init(&wifi_usart);
|
||||
|
||||
/*ʹ<>ܴ<EFBFBD><DCB4>ڽ<EFBFBD><DABD>ն<EFBFBD> */
|
||||
__HAL_UART_ENABLE_IT(&wifi_usart, UART_IT_RXNE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP <20><>ʼ<EFBFBD><CABC>
|
||||
* @param huart: UART handle
|
||||
* @retval <20><>
|
||||
*/
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
if (huart->Instance == DEBUG_USART)
|
||||
{
|
||||
DEBUG_USART_CLK_ENABLE();
|
||||
|
||||
DEBUG_USART_RX_GPIO_CLK_ENABLE();
|
||||
DEBUG_USART_TX_GPIO_CLK_ENABLE();
|
||||
|
||||
/**USART1 GPIO Configuration
|
||||
PA9 ------> USART1_TX
|
||||
PA10 ------> USART1_RX
|
||||
*/
|
||||
/* <20><><EFBFBD><EFBFBD>Tx<54><78><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ù<EFBFBD><C3B9><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = DEBUG_USART_TX_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(DEBUG_USART_TX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Rx<52><78><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ù<EFBFBD><C3B9><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = DEBUG_USART_RX_PIN;
|
||||
GPIO_InitStruct.Mode=GPIO_MODE_AF_INPUT; //ģʽҪ<CABD><D2AA><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>
|
||||
HAL_GPIO_Init(DEBUG_USART_RX_GPIO_PORT, &GPIO_InitStruct);
|
||||
//<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>1
|
||||
HAL_NVIC_SetPriority(DEBUG_USART_IRQ ,6,0);
|
||||
//ʹ<><CAB9>USART1<54>ж<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
HAL_NVIC_EnableIRQ(DEBUG_USART_IRQ );
|
||||
} else if (huart->Instance == WIFI_USART)
|
||||
{
|
||||
WIFI_USART_CLK_ENABLE();
|
||||
|
||||
WIFI_USART_RX_GPIO_CLK_ENABLE();
|
||||
WIFI_USART_TX_GPIO_CLK_ENABLE();
|
||||
|
||||
/**USART1 GPIO Configuration
|
||||
PA9 ------> USART1_TX
|
||||
PA10 ------> USART1_RX
|
||||
*/
|
||||
/* <20><><EFBFBD><EFBFBD>Tx<54><78><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ù<EFBFBD><C3B9><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = WIFI_USART_TX_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(WIFI_USART_TX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Rx<52><78><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ù<EFBFBD><C3B9><EFBFBD> */
|
||||
GPIO_InitStruct.Pin = WIFI_USART_RX_PIN;
|
||||
GPIO_InitStruct.Mode=GPIO_MODE_AF_INPUT; //ģʽҪ<CABD><D2AA><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>
|
||||
HAL_GPIO_Init(WIFI_USART_RX_GPIO_PORT, &GPIO_InitStruct);
|
||||
//<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>1
|
||||
HAL_NVIC_SetPriority(WIFI_USART_IRQ ,2,0);
|
||||
//ʹ<><CAB9>USART1<54>ж<EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
HAL_NVIC_EnableIRQ(WIFI_USART_IRQ );
|
||||
}
|
||||
}
|
||||
|
||||
/***************** <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> **********************/
|
||||
void usart_send_string(UART_HandleTypeDef *huart, uint8_t *str)
|
||||
{
|
||||
unsigned int k=0;
|
||||
do {
|
||||
HAL_UART_Transmit(huart,(uint8_t *)(str + k) ,1,1000);
|
||||
k++;
|
||||
} while(*(str + k)!='\0');
|
||||
|
||||
}
|
||||
//<2F>ض<EFBFBD><D8B6><EFBFBD>c<EFBFBD>⺯<EFBFBD><E2BAAF>printf<74><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DEBUG_USART<52><54><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>printf<74><66><EFBFBD><EFBFBD>
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>DEBUG_USART */
|
||||
HAL_UART_Transmit(&debug_usart, (uint8_t *)&ch, 1, 1);
|
||||
|
||||
return (ch);
|
||||
}
|
||||
|
||||
//<2F>ض<EFBFBD><D8B6><EFBFBD>c<EFBFBD>⺯<EFBFBD><E2BAAF>scanf<6E><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DEBUG_USART<52><54><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>scanf<6E><66>getchar<61>Ⱥ<EFBFBD><C8BA><EFBFBD>
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
int ch;
|
||||
HAL_UART_Receive(&debug_usart, (uint8_t *)&ch, 1, 1);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
int send_buff(char *buf, int len)
|
||||
{
|
||||
usart_send_string(&debug_usart, (uint8_t *)buf);
|
||||
return len;
|
||||
}
|
||||
|
||||
/*********************************************END OF FILE**********************/
|
73
board/GoKit3_STM32F103C8T6/BSP/Src/tos_hal_uart.c
Normal file
73
board/GoKit3_STM32F103C8T6/BSP/Src/tos_hal_uart.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "tos_k.h"
|
||||
#include "tos_hal.h"
|
||||
#include "stm32f1xx.h"
|
||||
#include "bsp_usart.h"
|
||||
|
||||
__API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port)
|
||||
{
|
||||
if (!uart) {
|
||||
return -1;
|
||||
}
|
||||
if (port == HAL_UART_PORT_1) {
|
||||
uart->private_uart = &debug_usart;
|
||||
debug_usart_init();
|
||||
} else if (port == HAL_UART_PORT_2) {
|
||||
uart->private_uart = &wifi_usart;
|
||||
wifi_usart_init();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
__API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status;
|
||||
UART_HandleTypeDef *uart_handle;
|
||||
|
||||
if (!uart || !buf) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!uart->private_uart) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uart_handle = (UART_HandleTypeDef *)uart->private_uart;
|
||||
|
||||
hal_status = HAL_UART_Transmit(uart_handle, (uint8_t *)buf, size, timeout);
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__API__ int tos_hal_uart_read(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
__API__ int tos_hal_uart_deinit(hal_uart_t *uart)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status;
|
||||
UART_HandleTypeDef *uart_handle;
|
||||
|
||||
if (!uart) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!uart->private_uart) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uart_handle = (UART_HandleTypeDef *)uart->private_uart;
|
||||
|
||||
hal_status = HAL_UART_DeInit(uart_handle);
|
||||
HAL_UART_MspDeInit(uart_handle);
|
||||
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,942 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>GoKit3_STM32F103C8T6</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F103C8</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll></FlashDriverDll>
|
||||
<DeviceId></DeviceId>
|
||||
<RegisterFile></RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:STM32F103C8$SVD\STM32F103xx.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>GoKit3_STM32F103C8T6\</OutputDirectory>
|
||||
<OutputName>GoKit3_STM32F103C8T6</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>0</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>0</BrowseInformation>
|
||||
<ListingPath></ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>0</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments>-REMAP</SimDllArguments>
|
||||
<SimDlgDll>DCM.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments></TargetDllArguments>
|
||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4107</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
|
||||
<Flash3></Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M3"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x5000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x5000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>2</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<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>USE_HAL_DRIVER,STM32F103xB</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Inc\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32F1xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS-CONFIG;..\..\BSP\HardWare\OLED;..\..\..\..\components\connectivity\mqttclient\common;..\..\..\..\components\connectivity\mqttclient\common\log;..\..\..\..\components\connectivity\mqttclient\mqtt;..\..\..\..\components\connectivity\mqttclient\mqttclient;..\..\..\..\components\connectivity\mqttclient\network;..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny;..\..\..\..\net\sal_module_wrapper;..\..\..\..\devices\esp8266;..\..\..\..\kernel\hal\include</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x08000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile></ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>Application/MDK-ARM</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_stm32f103xb.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>startup_stm32f103xb.s</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_msp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\stm32f1xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_it.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\stm32f1xx_it.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/Bsp</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>bsp_dwt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\bsp_dwt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_init.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\bsp_init.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_led.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\bsp_led.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_motor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\bsp_motor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bsp_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\bsp_usart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>examples</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>gokit3_mqttclient.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\examples\mqttclient\gokit3_mqttclient.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32F1xx_HAL_Driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_exti.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_gpio_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_pcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_pcd_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/CMSIS</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>system_stm32f1xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\system_stm32f1xx.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/arch</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_cpu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>port_c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc\port_c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>port_s.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc\port_s.S</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/kernel</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_binary_heap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_binary_heap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_char_fifo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_char_fifo.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_completion.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_countdownlatch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_countdownlatch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_event.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_event.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_global.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_global.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmblk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmblk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmheap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmheap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mutex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mutex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_pend.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_pend.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_ring_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_ring_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_robin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_robin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sched.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sched.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sys.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sys.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_task.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_tick.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_tick.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_time.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_time.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_timer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/cmsis</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cmsis_os.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\osal\cmsis_os\cmsis_os.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/at</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_at.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\net\at\src\tos_at.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_at_utils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\net\at\src\tos_at_utils.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/sal</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>sal_module_wrapper.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\net\sal_module_wrapper\sal_module_wrapper.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/hal</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\tos_hal_uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/devices</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>esp8266.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\devices\esp8266\esp8266.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mqttclient.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqttclient\mqttclient.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/mqtt</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>MQTTConnectClient.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTConnectClient.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTConnectServer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTConnectServer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTDeserializePublish.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTDeserializePublish.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTFormat.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTFormat.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTPacket.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTPacket.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTSerializePublish.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSerializePublish.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTSubscribeClient.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSubscribeClient.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTSubscribeServer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSubscribeServer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTUnsubscribeClient.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTUnsubscribeClient.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>MQTTUnsubscribeServer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTUnsubscribeServer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/salof</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>fifo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log\fifo.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>format.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log\format.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>salof.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log\salof.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>arch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log\arch\tencentos-tiny\arch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>salof_config.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log\salof_config.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/common</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>list.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\list.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>random.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\random.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>log.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>error.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\error.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/network</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>network.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\network\network.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/platform</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>platform_memory.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>platform_mutex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>platform_net_socket.c</FileName>
|
||||
<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>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_thread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>platform_timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_timer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>mqttclient/config</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mqtt_config.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\TOS-CONFIG\mqtt_config.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="GoKit3_STM32F103C8T6"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
307
board/GoKit3_STM32F103C8T6/KEIL/mqttclient/startup_stm32f103xb.s
Normal file
307
board/GoKit3_STM32F103C8T6/KEIL/mqttclient/startup_stm32f103xb.s
Normal file
@@ -0,0 +1,307 @@
|
||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f103xb.s
|
||||
;* Author : MCD Application Team
|
||||
;* Description : STM32F103xB 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
|
||||
;* - Configure the clock system
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;******************************************************************************
|
||||
;* @attention
|
||||
;*
|
||||
;* Copyright (c) 2017 STMicroelectronics.
|
||||
;* All rights reserved.
|
||||
;*
|
||||
;* This software component is licensed by ST under BSD 3-Clause license,
|
||||
;* the "License"; You may not use this file except in compliance with the
|
||||
;* License. You may obtain a copy of the License at:
|
||||
;* opensource.org/licenses/BSD-3-Clause
|
||||
;*
|
||||
;******************************************************************************
|
||||
|
||||
; 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 0x400
|
||||
|
||||
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 0x200
|
||||
|
||||
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_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_IRQHandler ; Tamper
|
||||
DCD RTC_IRQHandler ; RTC
|
||||
DCD FLASH_IRQHandler ; Flash
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
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_2_IRQHandler ; ADC1_2
|
||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
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 ; EXTI Line 15..10
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
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_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_IRQHandler [WEAK]
|
||||
EXPORT RTC_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_2_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_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 USBWakeUp_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_IRQHandler
|
||||
RTC_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_2_IRQHandler
|
||||
USB_HP_CAN1_TX_IRQHandler
|
||||
USB_LP_CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_IRQHandler
|
||||
TIM1_UP_IRQHandler
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_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
|
||||
USBWakeUp_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*****
|
211
board/GoKit3_STM32F103C8T6/KEIL/mqttclient/stm32f1xx_it.c
Normal file
211
board/GoKit3_STM32F103C8T6/KEIL/mqttclient/stm32f1xx_it.c
Normal file
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_it.c
|
||||
* @brief Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
*
|
||||
* COPYRIGHT(c) 2016 STMicroelectronics
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stm32f1xx.h"
|
||||
#include "stm32f1xx_it.h"
|
||||
#include "tos_k.h"
|
||||
#include "bsp_usart.h"
|
||||
#include "tos_at.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard fault interrupt.
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END HardFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE BEGIN HardFault_IRQn 1 */
|
||||
|
||||
/* USER CODE END HardFault_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory management fault.
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 1 */
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Prefetch fault, memory access fault.
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END BusFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE BEGIN BusFault_IRQn 1 */
|
||||
|
||||
/* USER CODE END BusFault_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Undefined instruction or illegal state.
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE BEGIN UsageFault_IRQn 1 */
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System service call via SWI instruction.
|
||||
*/
|
||||
void SVC_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 0 */
|
||||
/* USER CODE BEGIN SVCall_IRQn 1 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug monitor.
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System tick timer.
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
HAL_IncTick();
|
||||
|
||||
if (tos_knl_is_running())
|
||||
{
|
||||
tos_knl_irq_enter();
|
||||
tos_tick_handler();
|
||||
tos_knl_irq_leave();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DEBUG_USART_IRQHandler(void)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
tos_knl_irq_enter();
|
||||
|
||||
if(__HAL_UART_GET_FLAG( &debug_usart, UART_FLAG_RXNE ) != RESET)
|
||||
{
|
||||
HAL_UART_Receive(&debug_usart, &data, 1, 1);
|
||||
HAL_UART_Transmit(&debug_usart, &data, 1, 1);
|
||||
}
|
||||
|
||||
tos_knl_irq_leave();
|
||||
}
|
||||
|
||||
void WIFI_USART_IRQHandler(void)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
tos_knl_irq_enter();
|
||||
|
||||
if(__HAL_UART_GET_FLAG( &wifi_usart, UART_FLAG_RXNE ) != RESET)
|
||||
{
|
||||
HAL_UART_Receive(&wifi_usart, &data, 1, 1);
|
||||
tos_at_uart_input_byte(data);
|
||||
}
|
||||
|
||||
tos_knl_irq_leave();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F1xx Peripheral Interrupt Handlers */
|
||||
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||
/* For the available peripheral interrupt handler names, */
|
||||
/* please refer to the startup file (startup_stm32f1xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
48
board/GoKit3_STM32F103C8T6/TOS-CONFIG/mqtt_config.h
Normal file
48
board/GoKit3_STM32F103C8T6/TOS-CONFIG/mqtt_config.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 00:42:16
|
||||
* @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.
|
||||
*/
|
||||
#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)
|
||||
#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_MAX_CMD_TIMEOUT 20000
|
||||
#define MQTT_MIN_CMD_TIMEOUT 1000
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 100 // 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
|
||||
|
||||
#endif /* _MQTT_CONFIG_H_ */
|
@@ -19,7 +19,7 @@
|
||||
|
||||
#define TOS_CFG_MMHEAP_EN 1u
|
||||
|
||||
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x1000
|
||||
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x2C00
|
||||
|
||||
#define TOS_CFG_MUTEX_EN 1u
|
||||
|
||||
|
@@ -1,674 +1,201 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
@@ -1,10 +1,65 @@
|
||||
# mqttclient
|
||||
|
||||
**一个基于socket API之上的跨平台MQTT客户端**
|
||||
|
||||
## 整体框架
|
||||

|
||||
基于socket API的MQTT客户端,拥有非常简洁的API接口,以极少的资源实现QOS2的服务质量,并且无缝衔接了mbedtls加密库。
|
||||
|
||||
> 备注:目前只支持linux及TencentOS tiny系统
|
||||
## 优势:
|
||||
- **基于标准BSD socket之上开发**,只要是兼容BSD socket的系统均可使用。
|
||||
|
||||
- **稳定**:无论是`掉线重连`,`丢包重发`,都是严格`遵循MQTT协议标准`执行,除此之外对**大数据量**的测试无论是收是发,都是非常稳定(一次发送`135K`数据,3秒一次),高频测试也是非常稳定(7个主题同时收发,每秒一次,也就是1秒14个mqtt报文,服务质量QoS0、QoS1、QoS2都有)。因为作者以极少的资源设计了`记录机制`,对采用QoS1服务质量的报文必须保证到达一次,当发布的主题(qos1、qos2都适用)没有被服务器收到时会自动重发,而对QoS2服务质量的报文保证有且只有处理一次(如果不相信它稳定性的同学可以自己去修改源码,专门为QoS2服务质量去做测试,故意不回复`PUBREC`包,让服务器重发QoS2报文,且看看客户端是否有且只有处理一次),而对于掉线重连的稳定性,这种则是**基本操作**了,没啥好说的,在自动重连后还会自动重新订阅主题,保证主题不会丢失,因此在测试中稳定性极好。
|
||||
|
||||
- **轻量级**:整个代码工程极其简单,不使用mbedtls情况下,占用资源极少,作者曾使用esp8266模组与云端通信,整个工程代码消耗的RAM不足15k(包括系统占用的开销,对数据的处理开销,而此次还是未优化的情况下,还依旧完美保留了掉线重连的稳定性,但是对应qos1、qos2服务质量的报文则未做测试,因为STM32F103C8T6芯片资源实在是太少了,折腾不起)。
|
||||
|
||||
- **无缝衔接mbedtls加密传输**,让网络传输更加安全,而且接口层完全不需要用户理会,无论是否加密,mqttclient对用户提供的API接口是**没有变化**的,这就很好的兼容了一套代应用层的码可以加密传输也可以不加密传输。
|
||||
|
||||
- **拥有极简的API接口**,总的来说,mqttclient的配置都有默认值,基本无需配置都能使用的,也可以随意配置,对配置都有健壮性检测,这样子设计的API接口也是非常简单。
|
||||
|
||||
- **有非常好的代码风格与思想**:整个代码采用分层式设计,代码实现采用异步处理的思想,降低耦合,提高性能,具体体现在什么地方呢?很简单,目前市面上很多MQTT客户端发布主题都是要阻塞等待ack,这是非常暴力的行为,阻塞当前线程等待服务器的应答,那如果我想要发送数据怎么办,或者我要重复检测数据怎么办,你可能会说,指定阻塞时间等待,那如果网络延迟,ack迟迟不来,我就白等了吗,对于qos1、qos2的服务质量怎么办,所以说这种还是要异步处理的思想,我发布主题,那我发布出去就好了,不需要等待,对于qos1、qos2服务质量的MQTT报文,如果服务器没收到,那我重发就可以,这种重发也是异步的处理,完全不会阻塞当前线程。
|
||||
|
||||
- **MQTT协议支持主题通配符`“#”、“+”`。**
|
||||
|
||||
- **订阅的主题与消息处理完全分离**,让编程逻辑更加简单易用,用户无需理会错综复杂的逻辑关系。
|
||||
|
||||
- **mqttclient内部已实现保活处理机制**,无需用户过多关心理会,用户只需专心处理应用功能即可。
|
||||
|
||||
- **无缝衔接salof**:它是一个同步异步日志输出框架,在空闲时候输出对应的日志信息,也可以将信息写入flash中保存,方便调试。
|
||||
|
||||
- **不对外产生依赖。**
|
||||
|
||||
## 整体框架
|
||||
|
||||
拥有非常明确的分层框架。
|
||||
|
||||

|
||||
|
||||
**目前已适配了Linux、TencentOS tiny平台,除此之外,TencentOS tiny的AT框架亦可以使用(RAM消耗不足15K),并且稳定性极好!**
|
||||
|
||||
|
||||
| 平台 | 代码位置 |
|
||||
| -------------- | -------- |
|
||||
| Linux | [https://github.com/jiejieTop/mqttclient](https://github.com/jiejieTop/mqttclient) |
|
||||
| TencentOS tiny | [https://github.com/Tencent/TencentOS-tiny/tree/master/board/Fire_STM32F429](https://github.com/Tencent/TencentOS-tiny/tree/master/board/Fire_STM32F429) |
|
||||
| TencentOS tiny AT 框架| [https://github.com/Tencent/TencentOS-tiny/tree/master/board/GoKit3_STM32F103C8T6](https://github.com/Tencent/TencentOS-tiny/tree/master/board/GoKit3_STM32F103C8T6) |
|
||||
|
||||
|
||||
|
||||
## 版本
|
||||
|
||||
| 发布版本 | 描述 |
|
||||
| --- | --- |
|
||||
| [v1.0.0] | 初次发布,完成基本概念及其稳定性验证 |
|
||||
| [v1.0.1] | 修复主动与服务器断开连接时的逻辑 |
|
||||
|
||||
## 问题
|
||||
|
||||
欢迎以 [GitHub Issues](https://github.com/jiejieTop/mqttclient/issues) 的形式提交问题和bug报告
|
||||
|
||||
## 版权和许可
|
||||
|
||||
mqttclient 由 [Apache License v2.0](https://github.com/jiejieTop/mqttclient/blob/master/LICENSE) 许可 提供。
|
||||
|
||||
简单谈谈关于开源协议的描述,[Apache License v2.0](https://github.com/jiejieTop/mqttclient/blob/master/LICENSE) 鼓励代码共享和尊重原作者的著作权,可以自由的使用,修改源代码,也可以将修改后的代码作为开源或者专有软件再发布(作为开源或闭源商业软件),**但本源码必须保留作者版权声明**。
|
||||
|
||||
## linux平台下测试使用
|
||||
### 安装cmake:
|
||||
@@ -17,20 +72,20 @@ sudo apt-get install cmake
|
||||
```c
|
||||
init_params.connect_params.network_params.network_ssl_params.ca_crt = test_ca_get(); /* CA证书 */
|
||||
init_params.connect_params.network_params.addr = "xxxxxxx"; /* 服务器域名 */
|
||||
init_params.connect_params.network_params.port = "8883";
|
||||
init_params.connect_params.network_params.port = "8883"; /* 服务器端口号 */
|
||||
init_params.connect_params.user_name = "xxxxxxx"; /* 用户名 */
|
||||
init_params.connect_params.password = "xxxxxxx"; /* 密码 */
|
||||
init_params.connect_params.client_id = "xxxxxxx"; /* 客户端id */
|
||||
```
|
||||
|
||||
### 打开salof
|
||||
[salof](https://github.com/jiejieTop/salof) 全称是:`Synchronous Asynchronous Log Output Framework`(同步异步日志输出框架)
|
||||
### mbedtls
|
||||
|
||||
默认打开mbedtls。
|
||||
|
||||
[salof](https://github.com/jiejieTop/salof) 全称是:`Synchronous Asynchronous Log Output Framework`(同步异步日志输出框架),它是一个同步异步日志输出框架,在空闲时候输出对应的日志信息,并且该库与mqttclient无缝衔接。
|
||||
|
||||
**配置对应的日志输出级别:**
|
||||
|
||||
它是一个异步日志输出库,在空闲时候输出对应的日志信息,并且该库与mqttclient无缝衔接,如果不需要则将 `LOG_IS_SALOF` 定义为0即可。
|
||||
```c
|
||||
#define LOG_IS_SALOF 0
|
||||
```
|
||||
在`mqttclient/common/log/config.h`配置文件中打开对应的日志输出级别:
|
||||
```c
|
||||
#define BASE_LEVEL (0)
|
||||
#define ASSERT_LEVEL (BASE_LEVEL + 1) /* 日志输出级别:断言级别(非常高优先级) */
|
||||
@@ -39,17 +94,75 @@ sudo apt-get install cmake
|
||||
#define INFO_LEVEL (WARN_LEVEL + 1) /* 日志输出级别:信息级别(低优先级) */
|
||||
#define DEBUG_LEVEL (INFO_LEVEL + 1) /* 日志输出级别:调试级别(更低优先级) */
|
||||
|
||||
#define SALOF_OS USE_LINUX /* 选择对应的平台:Linux/FreeRTOS/TencentOS */
|
||||
#define LOG_LEVEL WARN_LEVEL /* 日志输出级别 */
|
||||
```
|
||||
|
||||
**日志其他选项:**
|
||||
|
||||
- 终端带颜色
|
||||
- 时间戳
|
||||
- 标签
|
||||
|
||||
### mqttclient的配置
|
||||
配置文件是:`mqttclient/mqtt_config.h`,在这里可以根据自身需求配置对应的信息。
|
||||
如是否选择`mbedtls`加密层:
|
||||
|
||||
配置mqtt等待应答列表的最大值,对于qos1 qos2服务质量有要求的可以将其设置大一点,当然也必须资源跟得上,它主要是保证qos1 qos2的mqtt报文能准确到达服务器。
|
||||
|
||||
```c
|
||||
#define MQTT_NETWORK_TYPE_TLS MQTT_YES
|
||||
#define MQTT_ACK_HANDLER_NUM_MAX 64
|
||||
```
|
||||
|
||||
选择MQTT协议的版本,默认为4,表示使用MQTT 3.1.1版本,而3则表示为MQTT 3.1版本。
|
||||
|
||||
```c
|
||||
#define MQTT_VERSION 4 // 4 is mqtt 3.1.1
|
||||
```
|
||||
|
||||
设置默认的保活时间,它主要是保证MQTT客户端与服务器的保持活性连接,单位为 秒 ,比如MQTT客户端与服务器100S没有发送数据了,有没有接收到数据,此时MQTT客户端会发送一个ping包,确认一下这个会话是否存在,如果收到服务器的应答,那么说明这个会话还是存在的,可以随时收发数据,而如果不存在了,就清除会话。
|
||||
|
||||
```c
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 100 // unit: second
|
||||
```
|
||||
|
||||
默认的命令超时,它主要是用于socket读写超时,在MQTT初始化时可以指定:
|
||||
|
||||
```
|
||||
#define MQTT_DEFAULT_CMD_TIMEOUT 4000
|
||||
```
|
||||
|
||||
默认主题的长度,主题是支持通配符的,如果主题太长则会被截断:
|
||||
|
||||
```c
|
||||
#define MQTT_TOPIC_LEN_MAX 64
|
||||
```
|
||||
|
||||
默认的算法数据缓冲区的大小,如果要发送大量数据则修改大一些,在MQTT初始化时可以指定:
|
||||
|
||||
```c
|
||||
#define MQTT_DEFAULT_BUF_SIZE 1024
|
||||
```
|
||||
|
||||
线程相关的配置,如线程栈,线程优先级,线程时间片等:
|
||||
在linux环境下可以是不需要理会这些参数的,而在RTOS平台则需要配置,如果不使用mbedtls,线程栈2048字节已足够,而使用mbedtls加密后,需要配置4096字节以上。
|
||||
```c
|
||||
#define MQTT_THREAD_STACK_SIZE 2048 // 线程栈
|
||||
#define MQTT_THREAD_PRIO 5 // 线程优先级
|
||||
#define MQTT_THREAD_TICK 50 // 线程时间片
|
||||
```
|
||||
|
||||
默认的重连时间间隔,当发生掉线时,会以这个时间间隔尝试重连:
|
||||
```c
|
||||
#define MQTT_RECONNECT_DEFAULT_DURATION 1000
|
||||
```
|
||||
|
||||
其他不需要怎么配置的东西:
|
||||
```c
|
||||
#define MQTT_MAX_PACKET_ID (0xFFFF - 1) // mqtt报文id
|
||||
#define MQTT_MAX_CMD_TIMEOUT 20000 //最大的命令超时参数
|
||||
#define MQTT_MIN_CMD_TIMEOUT 1000 //最小的命令超时参数
|
||||
```
|
||||
|
||||
> ps:以上参数基本不需要怎么配置的,直接用即可~
|
||||
|
||||
### 编译 & 运行
|
||||
```bash
|
||||
./build.sh
|
||||
@@ -60,6 +173,7 @@ sudo apt-get install cmake
|
||||
- 整体采用分层式设计,代码实现采用异步设计方式,降低耦合。
|
||||
- 消息的处理使用回调的方式处理:用户指定`[订阅的主题]`与指定`[消息的处理函数]`
|
||||
- 不对外产生依赖
|
||||
|
||||
## API
|
||||
`mqttclient`拥有非常简洁的`api`接口
|
||||
```c
|
||||
@@ -79,10 +193,10 @@ int mqtt_yield(mqtt_client_t* c, int timeout_ms);
|
||||
```c
|
||||
typedef struct mqtt_client {
|
||||
unsigned short packet_id;
|
||||
unsigned char *read_buf;
|
||||
unsigned char *write_buf;
|
||||
unsigned char ping_outstanding;
|
||||
unsigned char ack_handler_number;
|
||||
unsigned char *read_buf;
|
||||
unsigned char *write_buf;
|
||||
unsigned int cmd_timeout;
|
||||
unsigned int read_buf_size;
|
||||
unsigned int write_buf_size;
|
||||
@@ -97,10 +211,12 @@ typedef struct mqtt_client {
|
||||
network_t *network;
|
||||
platform_thread_t *thread;
|
||||
platform_timer_t reconnect_timer;
|
||||
platform_timer_t ping_timer;
|
||||
platform_timer_t last_sent;
|
||||
platform_timer_t last_received;
|
||||
connect_params_t *connect_params;
|
||||
} mqtt_client_t;
|
||||
```
|
||||
|
||||
该结构主要维护以下内容:
|
||||
1. 读写数据缓冲区`read_buf、write_buf`
|
||||
2. 命令超时时间`cmd_timeout`(主要是读写阻塞时间、等待响应的时间、重连等待时间)
|
||||
@@ -108,82 +224,158 @@ typedef struct mqtt_client {
|
||||
4. 维护消息处理列表`msg_handler_list`,这是`mqtt`协议必须实现的内容,所有来自服务器的`publish`报文都会被处理(前提是订阅了对应的消息)
|
||||
5. 维护一个网卡接口`network`
|
||||
6. 维护一个内部线程`thread`,所有来自服务器的mqtt包都会在这里被处理!
|
||||
7. 两个定时器,分别是掉线重连定时器与保活定时器`reconnect_timer、ping_timer`
|
||||
7. 两个定时器,分别是掉线重连定时器与保活定时器`reconnect_timer、last_sent、last_received`
|
||||
8. 一些连接的参数`connect_params`
|
||||
|
||||
## 初始化
|
||||
|
||||
## mqttclient实现
|
||||
|
||||
以下是整个框架的实现方式,方便大家更容易理解mqttclient的代码与设计思想,让大家能够修改源码与使用,还可以提交pr或者issues,开源的世界期待各位大神的参与,感谢!
|
||||
|
||||
除此之外以下代码的`记录机制`与其`超时处理机制`是非常好的编程思想,大家有兴趣一定要看源代码!
|
||||
|
||||
### 初始化
|
||||
|
||||
```c
|
||||
int mqtt_init(mqtt_client_t* c, client_init_params_t* init)
|
||||
```
|
||||
|
||||
主要是配置`mqtt_client_t`结构的相关信息,如果没有指定初始化参数,则系统会提供默认的参数。
|
||||
但连接部分的参数则必须指定:
|
||||
|
||||
```c
|
||||
init_params.connect_params.network_params.addr = "[你的mqtt服务器IP地址或者是域名]";
|
||||
init_params.connect_params.network_params.port = 1883; //端口号
|
||||
init_params.connect_params.user_name = "jiejietop";
|
||||
init_params.connect_params.password = "123456";
|
||||
init_params.connect_params.client_id = "clientid";
|
||||
|
||||
mqtt_init(&client, &init_params);
|
||||
```
|
||||
|
||||
## 连接服务器
|
||||
### 连接服务器
|
||||
|
||||
```c
|
||||
int mqtt_connect(mqtt_client_t* c);
|
||||
```
|
||||
连接服务器则是使用非异步的方式设计,因为必须等待连接上服务器才能进行下一步操作。
|
||||
过程如下
|
||||
|
||||
参数只有 `mqtt_client_t` 类型的指针,字符串类型的`主题`(支持通配符"#" "+"),主题的`服务质量`,以及收到报文的`处理函数`,如不指定则有默认处理函数。连接服务器则是使用非异步的方式设计,因为必须等待连接上服务器才能进行下一步操作。
|
||||
|
||||
过程如下:
|
||||
1. 调用底层的连接函数连接上服务器:
|
||||
|
||||
```c
|
||||
c->network->connect(c->network);
|
||||
```
|
||||
|
||||
2. 序列化`mqtt`的`CONNECT`报文并且发送
|
||||
|
||||
```c
|
||||
MQTTSerialize_connect(c->write_buf, c->write_buf_size, &connect_data)
|
||||
mqtt_send_packet(c, len, &connect_timer)
|
||||
```
|
||||
|
||||
3. 等待来自服务器的`CONNACK`报文
|
||||
|
||||
```c
|
||||
mqtt_wait_packet(c, CONNACK, &connect_timer)
|
||||
```
|
||||
4. 连接成功后创建一个内部线程`mqtt_yield_thread`
|
||||
|
||||
4. 连接成功后创建一个内部线程`mqtt_yield_thread`,并在合适的时候启动它:
|
||||
|
||||
```c
|
||||
platform_thread_init("mqtt_yield_thread", mqtt_yield_thread, c, MQTT_THREAD_STACK_SIZE, MQTT_THREAD_PRIO, MQTT_THREAD_TICK)
|
||||
|
||||
if (NULL != c->thread) {
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED);
|
||||
platform_thread_startup(c->thread);
|
||||
platform_thread_start(c->thread); /* start run mqtt thread */
|
||||
}
|
||||
```
|
||||
## 订阅报文
|
||||
|
||||
5. 而对于重连来说则不会重新创建线程,直接改变客户端状态为连接状态即可:
|
||||
|
||||
```c
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED);
|
||||
```
|
||||
|
||||
### 订阅报文
|
||||
|
||||
```c
|
||||
int mqtt_subscribe(mqtt_client_t* c, const char* topic_filter, mqtt_qos_t qos, message_handler_t handler)
|
||||
```
|
||||
|
||||
订阅报文使用异步设计来实现的:
|
||||
过程如下:
|
||||
1. 序列化订阅报文并且发送给服务器
|
||||
|
||||
```c
|
||||
MQTTSerialize_subscribe(c->write_buf, c->write_buf_size, 0, mqtt_get_next_packet_id(c), 1, &topic, (int*)&qos)
|
||||
mqtt_send_packet(c, len, &timer)
|
||||
```
|
||||
|
||||
2. 创建对应的消息处理节点,这个消息节点在收到服务器的`SUBACK`订阅应答报文后会挂载到消息处理列表`msg_handler_list`上
|
||||
|
||||
```c
|
||||
mqtt_msg_handler_create(topic_filter, qos, handler)
|
||||
```
|
||||
3. 在发送了报文给服务器那就要等待服务器的响应了,记录这个等待`SUBACK`
|
||||
|
||||
3. 在发送了报文给服务器那就要等待服务器的响应了,先记录这个等待`SUBACK`
|
||||
|
||||
```c
|
||||
mqtt_ack_list_record(c, SUBACK, mqtt_get_next_packet_id(c), len, msg_handler)
|
||||
```
|
||||
## 取消订阅
|
||||
|
||||
### 取消订阅
|
||||
与订阅报文的逻辑基本差不多的~
|
||||
|
||||
## 发布报文
|
||||
1. 序列化订阅报文并且发送给服务器
|
||||
|
||||
```c
|
||||
MQTTSerialize_unsubscribe(c->write_buf, c->write_buf_size, 0, packet_id, 1, &topic)
|
||||
mqtt_send_packet(c, len, &timer)
|
||||
```
|
||||
|
||||
2. 创建对应的消息处理节点,这个消息节点在收到服务器的`UNSUBACK`取消订阅应答报文后将消息处理列表`msg_handler_list`上的已经订阅的主题消息节点销毁
|
||||
|
||||
```c
|
||||
mqtt_msg_handler_create((const char*)topic_filter, QOS0, NULL)
|
||||
```
|
||||
|
||||
3. 在发送了报文给服务器那就要等待服务器的响应了,先记录这个等待`UNSUBACK`
|
||||
|
||||
```c
|
||||
mqtt_ack_list_record(c, UNSUBACK, packet_id, len, msg_handler)
|
||||
```
|
||||
|
||||
### 发布报文
|
||||
|
||||
```c
|
||||
int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg)
|
||||
```
|
||||
|
||||
参数只有 `mqtt_client_t` 类型的指针,字符串类型的`主题`(支持通配符),要发布的消息(包括`服务质量`、`消息主体`)。
|
||||
|
||||
```c
|
||||
mqtt_message_t msg;
|
||||
|
||||
msg.qos = 2;
|
||||
msg.payload = (void *) buf;
|
||||
|
||||
mqtt_publish(&client, "testtopic1", &msg);
|
||||
```
|
||||
|
||||
核心思想都差不多,过程如下:
|
||||
1. 先序列化发布报文,然后发送到服务器
|
||||
|
||||
```c
|
||||
MQTTSerialize_publish(c->write_buf, c->write_buf_size, 0, msg->qos, msg->retained, msg->id,
|
||||
topic, (unsigned char*)msg->payload, msg->payloadlen);
|
||||
mqtt_send_packet(c, len, &timer)
|
||||
```
|
||||
|
||||
2. 对于QOS0的逻辑,不做任何处理,对于QOS1和QOS2的报文则需要记录下来,在没收到服务器应答的时候进行重发
|
||||
|
||||
```c
|
||||
if (QOS1 == msg->qos) {
|
||||
rc = mqtt_ack_list_record(c, PUBACK, mqtt_get_next_packet_id(c), len, NULL);
|
||||
@@ -191,17 +383,29 @@ mqtt_send_packet(c, len, &timer)
|
||||
rc = mqtt_ack_list_record(c, PUBREC, mqtt_get_next_packet_id(c), len, NULL);
|
||||
}
|
||||
```
|
||||
## 内部线程
|
||||
|
||||
3. 还有非常重要的一点,重发报文的MQTT报文头部需要设置DUP标志位,这是MQTT协议的标准,因此,在重发的时候作者直接操作了报文的DUP标志位,因为修改DUP标志位的函数我没有从MQTT库中找到,所以我封装了一个函数,这与LwIP中的交叉存取思想是一个道理,它假设我知道MQTT报文的所有操作,所以我可以操作它,这样子可以提高很多效率:
|
||||
|
||||
```c
|
||||
mqtt_set_publish_dup(c,1); /* may resend this data, set the udp flag in advance */
|
||||
```
|
||||
|
||||
### 内部线程
|
||||
|
||||
```c
|
||||
static void mqtt_yield_thread(void *arg)
|
||||
```
|
||||
|
||||
主要是对`mqtt_yield`函数的返回值做处理,比如在`disconnect`的时候销毁这个线程。
|
||||
|
||||
## 核心的处理函数`mqtt_yield`
|
||||
### 核心的处理函数
|
||||
|
||||
1. 数据包的处理`mqtt_packet_handle`
|
||||
|
||||
```c
|
||||
static int mqtt_packet_handle(mqtt_client_t* c, platform_timer_t* timer)
|
||||
```
|
||||
|
||||
对不同的包使用不一样的处理:
|
||||
|
||||
```c
|
||||
@@ -242,118 +446,184 @@ static int mqtt_packet_handle(mqtt_client_t* c, platform_timer_t* timer)
|
||||
goto exit;
|
||||
}
|
||||
```
|
||||
|
||||
并且做保活的处理:
|
||||
|
||||
```c
|
||||
mqtt_keep_alive(c)
|
||||
```
|
||||
|
||||
当发生超时后
|
||||
|
||||
```c
|
||||
if (platform_timer_is_expired(&c->last_sent) || platform_timer_is_expired(&c->last_received))
|
||||
```
|
||||
|
||||
序列号一个心跳包并且发送给服务器
|
||||
|
||||
```c
|
||||
MQTTSerialize_pingreq(c->write_buf, c->write_buf_size);
|
||||
mqtt_send_packet(c, len, &timer);
|
||||
```
|
||||
|
||||
当再次发生超时后,表示与服务器的连接已断开,需要重连的操作,设置客户端状态为断开连接
|
||||
|
||||
```c
|
||||
mqtt_set_client_state(c, CLIENT_STATE_DISCONNECTED);
|
||||
```
|
||||
|
||||
2. `ack`链表的扫描,当收到服务器的报文时,对ack列表进行扫描操作
|
||||
|
||||
```c
|
||||
mqtt_ack_list_scan(c);
|
||||
```
|
||||
|
||||
当超时后就销毁ack链表节点:
|
||||
|
||||
```c
|
||||
mqtt_ack_handler_destroy(ack_handler);
|
||||
```
|
||||
|
||||
当然下面这几种报文则需要重发操作:(`PUBACK 、PUBREC、 PUBREL 、PUBCOMP`,保证QOS1 QOS2的服务质量)
|
||||
|
||||
```c
|
||||
if ((ack_handler->type == PUBACK) || (ack_handler->type == PUBREC) || (ack_handler->type == PUBREL) || (ack_handler->type == PUBCOMP))
|
||||
mqtt_ack_handler_resend(c, ack_handler);
|
||||
```
|
||||
|
||||
3. 保持活性的时间过去了,可能掉线了,需要重连操作
|
||||
|
||||
```c
|
||||
mqtt_try_reconnect(c);
|
||||
```
|
||||
|
||||
重连成功后尝试重新订阅报文,保证恢复原始状态~
|
||||
|
||||
```c
|
||||
mqtt_try_resubscribe(c)
|
||||
```
|
||||
## `发布应答`与`发布完成`报文的处理
|
||||
|
||||
### 发布应答与发布完成报文的处理
|
||||
|
||||
```c
|
||||
static int mqtt_puback_and_pubcomp_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
```
|
||||
|
||||
1. 反序列化报文
|
||||
|
||||
```c
|
||||
MQTTDeserialize_ack(&packet_type, &dup, &packet_id, c->read_buf, c->read_buf_size)
|
||||
```
|
||||
|
||||
2. 取消对应的ack记录
|
||||
|
||||
```c
|
||||
mqtt_ack_list_unrecord(c, packet_type, packet_id, NULL);
|
||||
```
|
||||
## `订阅应答`报文的处理
|
||||
|
||||
### 订阅应答报文的处理
|
||||
|
||||
```c
|
||||
static int mqtt_suback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
```
|
||||
|
||||
1. 反序列化报文
|
||||
|
||||
```c
|
||||
MQTTDeserialize_suback(&packet_id, 1, &count, (int*)&granted_qos, c->read_buf, c->read_buf_size)
|
||||
```
|
||||
|
||||
2. 取消对应的ack记录
|
||||
|
||||
```c
|
||||
mqtt_ack_list_unrecord(c, packet_type, packet_id, NULL);
|
||||
```
|
||||
|
||||
3. 安装对应的订阅消息处理函数,如果是已存在的则不会安装
|
||||
|
||||
```c
|
||||
mqtt_msg_handlers_install(c, msg_handler);
|
||||
```
|
||||
## `取消订阅应答`报文的处理
|
||||
|
||||
### 取消订阅应答报文的处理
|
||||
|
||||
```c
|
||||
static int mqtt_unsuback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
```
|
||||
|
||||
1. 反序列化报文
|
||||
|
||||
```c
|
||||
MQTTDeserialize_unsuback(&packet_id, c->read_buf, c->read_buf_size)
|
||||
```
|
||||
2. 取消对应的ack记录
|
||||
|
||||
2. 取消对应的ack记录,并且获取到已经订阅的消息处理节点
|
||||
|
||||
```c
|
||||
mqtt_ack_list_unrecord(c, UNSUBACK, packet_id, &msg_handler)
|
||||
```
|
||||
|
||||
3. 销毁对应的订阅消息处理函数
|
||||
|
||||
```c
|
||||
mqtt_msg_handler_destroy(msg_handler);
|
||||
mqtt_msg_handler_destory(msg_handler);
|
||||
```
|
||||
## 来自服务器的`发布`报文的处理
|
||||
|
||||
### 来自服务器的发布报文的处理
|
||||
|
||||
```c
|
||||
static int mqtt_publish_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
```
|
||||
|
||||
1. 反序列化报文
|
||||
|
||||
```c
|
||||
MQTTDeserialize_publish(&msg.dup, &qos, &msg.retained, &msg.id, &topic_name,
|
||||
(unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->read_buf, c->read_buf_size)
|
||||
```
|
||||
|
||||
2. 对于QOS0、QOS1的报文,直接去处理消息
|
||||
|
||||
```c
|
||||
mqtt_deliver_message(c, &topic_name, &msg);
|
||||
```
|
||||
|
||||
3. 对于QOS1的报文,还需要发送一个`PUBACK`应答报文给服务器
|
||||
|
||||
```c
|
||||
MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBACK, 0, msg.id);
|
||||
```
|
||||
|
||||
4. 而对于QOS2的报文则需要发送`PUBREC`报文给服务器,除此之外还需要记录`PUBREL`到ack链表上,等待服务器的发布释放报文,最后再去处理这个消息
|
||||
|
||||
```c
|
||||
MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBREC, 0, msg.id);
|
||||
mqtt_ack_list_record(c, PUBREL, msg.id + 1, len, NULL)
|
||||
mqtt_deliver_message(c, &topic_name, &msg);
|
||||
```
|
||||
|
||||
> 说明:一旦注册到ack列表上的报文,当具有重复的报文是不会重新被注册的,它会通过`mqtt_ack_list_node_is_exist`函数判断这个节点是否存在,主要是依赖等待响应的消息类型与msgid。
|
||||
|
||||
## `发布收到`与`发布释放`报文的处理
|
||||
### 发布收到与发布释放报文的处理
|
||||
|
||||
```c
|
||||
static int mqtt_pubrec_and_pubrel_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
```
|
||||
|
||||
1. 反序列化报文
|
||||
|
||||
```c
|
||||
MQTTDeserialize_ack(&packet_type, &dup, &packet_id, c->read_buf, c->read_buf_size)
|
||||
```
|
||||
|
||||
2. 产生一个对应的应答报文
|
||||
|
||||
```c
|
||||
mqtt_publish_ack_packet(c, packet_id, packet_type);
|
||||
```
|
||||
|
||||
3. 取消对应的ack记录
|
||||
|
||||
```c
|
||||
mqtt_ack_list_unrecord(c, UNSUBACK, packet_id, &msg_handler)
|
||||
```
|
||||
|
||||
## 在后台测试
|
||||
nohup ./mqtt-client > log.out 2>&1 &
|
||||
|
@@ -2,17 +2,18 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 00:42:16
|
||||
* @LastEditTime : 2020-01-10 01:01:26
|
||||
* @LastEditTime: 2020-03-21 16:49:07
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _ERROR_H_
|
||||
#define _ERROR_H_
|
||||
|
||||
typedef enum mqtt_error {
|
||||
MQTT_SSL_CERT_ERROR = -0x001C, /* cetr parse failed */
|
||||
MQTT_SOCKET_FAILED = -0x001B, /* socket fd failed */
|
||||
MQTT_SOCKET_UNKNOWN_HOST = -0x001A, /* socket unknown host ip or domain */
|
||||
MQTT_SET_PUBLISH_DUP_FAILED = -0x0019, /* mqtt publish packet set udp bit failed */
|
||||
MQTT_CLOSE_SESSION_ERROR = -0x0018, /* mqtt close session error */
|
||||
MQTT_CLEAN_SESSION_ERROR = -0x0018, /* mqtt clean session error */
|
||||
MQTT_ACK_NODE_IS_EXIST = -0x0017, /* mqtt ack list is exist ack node */
|
||||
MQTT_ACK_HANDLER_NUM_TOO_MUCH = -0x0016, /* mqtt ack handler number is too much */
|
||||
MQTT_RESUBSCRIBE_ERROR = -0x0015, /* mqtt resubscribe error */
|
||||
|
@@ -2,17 +2,15 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-27 03:25:58
|
||||
* @LastEditTime : 2020-02-20 01:16:25
|
||||
* @LastEditTime: 2020-02-25 05:42:32
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _LOG_H_
|
||||
#define _LOG_H_
|
||||
|
||||
#define LOG_IS_SALOF 1
|
||||
#include "mqtt_defconfig.h"
|
||||
|
||||
#define LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL INFO_LEVEL
|
||||
|
||||
#if LOG_IS_SALOF
|
||||
#ifdef LOG_IS_SALOF
|
||||
#include "salof.h"
|
||||
|
||||
#define LOG_D(fmt, ...) LOG_DEBUG(fmt, ##__VA_ARGS__)
|
||||
|
@@ -2,11 +2,12 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-26 19:11:34
|
||||
* @LastEditTime : 2019-12-28 01:51:38
|
||||
* @LastEditTime: 2020-03-02 01:32:23
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "salof_defconfig.h"
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
void *salof_alloc(unsigned int size)
|
||||
{
|
||||
@@ -119,3 +120,4 @@ char *salof_get_task_name(void)
|
||||
return k_curr_task->name;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#include "fifo.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
static unsigned int _flbs(unsigned int x) /* find last bit set*/
|
||||
{
|
||||
unsigned int r = 32;
|
||||
@@ -131,3 +133,4 @@ unsigned int fifo_write_able(fifo_t fifo)
|
||||
return (fifo->size - fifo_read_able(fifo));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -2,13 +2,15 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-25 23:54:38
|
||||
* @LastEditTime : 2019-12-28 01:04:08
|
||||
* @LastEditTime: 2020-02-25 08:10:01
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _FIFO_H_
|
||||
#define _FIFO_H_
|
||||
|
||||
#include "config.h"
|
||||
#include "salof_defconfig.h"
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
#define FIFO_READ 0
|
||||
#define FIFO_WRITE 1
|
||||
@@ -33,5 +35,7 @@ unsigned int fifo_read(fifo_t fifo, void *buff, unsigned int len, unsigned int t
|
||||
unsigned int fifo_read_able(fifo_t fifo);
|
||||
unsigned int fifo_write_able(fifo_t fifo);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !_FIFO_H_
|
||||
|
||||
|
@@ -2,11 +2,13 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-25 23:54:19
|
||||
* @LastEditTime : 2019-12-28 01:53:41
|
||||
* @LastEditTime: 2020-02-25 08:12:02
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "format.h"
|
||||
#include "salof_defconfig.h"
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
static int _get_atoi(const char **str)
|
||||
{
|
||||
@@ -280,9 +282,6 @@ int format_nstr(char *buf, unsigned int size, const char *fmt, va_list ap)
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -2,13 +2,12 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-25 23:54:38
|
||||
* @LastEditTime : 2019-12-26 20:10:28
|
||||
* @LastEditTime: 2020-02-25 07:18:09
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _FORMAT_H_
|
||||
#define _FORMAT_H_
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define FORMAT_BUF_LEN 12
|
||||
|
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "salof.h"
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
#ifndef SALOF_BUFF_SIZE
|
||||
#define SALOF_BUFF_SIZE (1024U)
|
||||
#endif
|
||||
@@ -104,5 +106,5 @@ void salof_task(void *parm)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#ifndef _SALOF_H_
|
||||
#define _SALOF_H_
|
||||
|
||||
#include "salof_defconfig.h"
|
||||
#include "format.h"
|
||||
#include "fifo.h"
|
||||
#include <stdio.h>
|
||||
@@ -18,21 +19,19 @@ void salof(const char *fmt, ...);
|
||||
#define FC_DARK 36
|
||||
#define FC_WHITE 37
|
||||
|
||||
#if USE_LOG
|
||||
#ifdef USE_LOG
|
||||
|
||||
#if USE_SALOF
|
||||
#define PRINT_LOG salof
|
||||
#define PRINT_LOG salof
|
||||
#else
|
||||
|
||||
#if ((!USE_SALOF)&&(!PRINT_LOG))
|
||||
#define PRINT_LOG printf
|
||||
#define PRINT_LOG printf
|
||||
#endif
|
||||
|
||||
#ifndef PRINT_LOG
|
||||
#error "If the USE_LOG macro definition is turned on, you must define PRINT_LOG as the LOG output, such as #definePRINT_LOG printf"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LOG_TS || LOG_TAR
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,7 +70,7 @@ void salof(const char *fmt, ...);
|
||||
#define DEBUG_LEVEL (INFO_LEVEL + 1)
|
||||
|
||||
#ifndef LOG_LEVEL
|
||||
#define LOG_LEVEL WARN_LEVEL
|
||||
#define LOG_LEVEL DEBUG_LEVEL
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < DEBUG_LEVEL
|
||||
|
14
components/connectivity/mqttclient/common/log/salof_config.h
Normal file
14
components/connectivity/mqttclient/common/log/salof_config.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-25 06:01:24
|
||||
* @LastEditTime: 2020-02-25 09:28:09
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
|
||||
#ifndef _SALOF_CONFIG_H_
|
||||
#define _SALOF_CONFIG_H_
|
||||
|
||||
#include "mqtt_config.h"
|
||||
|
||||
#endif /* _SALOF_CONFIG_H_ */
|
144
components/connectivity/mqttclient/common/log/salof_defconfig.h
Normal file
144
components/connectivity/mqttclient/common/log/salof_defconfig.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-25 23:56:34
|
||||
* @LastEditTime: 2020-03-02 01:32:32
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _SALOF_DEFCONFIG_H_
|
||||
#define _SALOF_DEFCONFIG_H_
|
||||
|
||||
#include "salof_config.h"
|
||||
|
||||
#ifdef USE_LOG
|
||||
|
||||
#define USE_RTT 1
|
||||
#define USE_FREERTOS 2
|
||||
#define USE_TENCENTOS 3
|
||||
#define USE_LINUX 4
|
||||
|
||||
#define BASE_LEVEL (0)
|
||||
#define ASSERT_LEVEL (BASE_LEVEL + 1)
|
||||
#define ERR_LEVEL (ASSERT_LEVEL + 1)
|
||||
#define WARN_LEVEL (ERR_LEVEL + 1)
|
||||
#define INFO_LEVEL (WARN_LEVEL + 1)
|
||||
#define DEBUG_LEVEL (INFO_LEVEL + 1)
|
||||
|
||||
#ifndef USE_SALOF
|
||||
#define USE_SALOF (1U)
|
||||
#endif
|
||||
|
||||
#ifndef USE_IDLE_HOOK
|
||||
#define USE_IDLE_HOOK (0U)
|
||||
#endif
|
||||
|
||||
#ifndef LOG_COLOR
|
||||
#define LOG_COLOR (1U)
|
||||
#endif
|
||||
|
||||
#ifndef LOG_TS
|
||||
#define LOG_TS (1U)
|
||||
#endif
|
||||
|
||||
#ifndef LOG_TAR
|
||||
#define LOG_TAR (0U)
|
||||
#endif
|
||||
|
||||
#ifndef LOG_LEVEL
|
||||
#define LOG_LEVEL DEBUG_LEVEL //WARN_LEVEL DEBUG_LEVEL
|
||||
#endif
|
||||
|
||||
#if USE_SALOF
|
||||
|
||||
#ifndef SALOF_BUFF_SIZE
|
||||
#define SALOF_BUFF_SIZE (512U)
|
||||
#endif
|
||||
|
||||
#ifndef SALOF_FIFO_SIZE
|
||||
#define SALOF_FIFO_SIZE (1024*4U)
|
||||
#endif
|
||||
|
||||
#ifndef SALOF_TASK_STACK_SIZE
|
||||
#define SALOF_TASK_STACK_SIZE (2048U)
|
||||
#endif
|
||||
|
||||
#ifndef SALOF_TASK_TICK
|
||||
#define SALOF_TASK_TICK (20U)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(SALOF_OS)
|
||||
#error "SALOF_OS isn't defined in 'salof_config.h'"
|
||||
#endif
|
||||
|
||||
#if (SALOF_OS == USE_FREERTOS)
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#define salof_mutex SemaphoreHandle_t
|
||||
#define salof_tcb TaskHandle_t
|
||||
#define salof_sem salof_mutex
|
||||
#if USE_IDLE_HOOK
|
||||
#define salof_handler vApplicationIdleHook
|
||||
#endif
|
||||
#define SALOF_TASK_PRIO (0U)
|
||||
|
||||
#elif (SALOF_OS == USE_TENCENTOS)
|
||||
#include "tos_k.h"
|
||||
#define salof_mutex k_mutex_t*
|
||||
#define salof_sem k_sem_t*
|
||||
#define salof_tcb k_task_t*
|
||||
#define SALOF_TASK_PRIO (TOS_CFG_TASK_PRIO_MAX - 2u)
|
||||
#undef USE_IDLE_HOOK
|
||||
|
||||
#elif (SALOF_OS == USE_RTT)
|
||||
#include <rtconfig.h>
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <stdio.h>
|
||||
#define salof_mutex rt_mutex_t
|
||||
#define salof_sem rt_sem_t
|
||||
#define salof_tcb rt_thread_t
|
||||
#define SALOF_TASK_PRIO (RT_THREAD_PRIORITY_MAX - 1)
|
||||
|
||||
#elif (SALOF_OS == USE_LINUX)
|
||||
#include "pthread.h"
|
||||
#include "memory.h"
|
||||
#include <semaphore.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#define salof_mutex pthread_mutex_t*
|
||||
#define salof_sem sem_t*
|
||||
#define salof_tcb pthread_t*
|
||||
#define SALOF_TASK_PRIO (0U)
|
||||
#undef USE_IDLE_HOOK
|
||||
|
||||
#else
|
||||
#error "not supported OS type"
|
||||
#endif
|
||||
|
||||
void *salof_alloc(unsigned int size);
|
||||
void salof_free(void *mem);
|
||||
salof_tcb salof_task_create(const char *name,
|
||||
void (*task_entry)(void *param),
|
||||
void * const param,
|
||||
unsigned int stack_size,
|
||||
unsigned int priority,
|
||||
unsigned int tick);
|
||||
salof_mutex salof_mutex_create(void);
|
||||
void salof_mutex_delete(salof_mutex mutex);
|
||||
int salof_mutex_pend(salof_mutex mutex, unsigned int timeout);
|
||||
int salof_mutex_post(salof_mutex mutex);
|
||||
salof_sem salof_sem_create(void);
|
||||
void salof_sem_delete(salof_sem sem);
|
||||
int salof_sem_pend(salof_sem sem, unsigned int timeout);
|
||||
int salof_sem_post(salof_sem sem);
|
||||
unsigned int salof_get_tick(void);
|
||||
char *salof_get_task_name(void);
|
||||
extern int send_buff(char *buf, int len);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !_SALOF_DEFCONFIG_H_
|
||||
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-02-25 03:36:09
|
||||
* @LastEditTime: 2020-02-25 07:16:43
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
|
||||
#ifndef _DEFCONFIG_H_
|
||||
#define _DEFCONFIG_H_
|
||||
|
||||
#include "mqtt_config.h"
|
||||
|
||||
#ifndef MQTT_MAX_PACKET_ID
|
||||
#define MQTT_MAX_PACKET_ID (0xFFFF - 1)
|
||||
#endif // !MQTT_MAX_PACKET_ID
|
||||
|
||||
#ifndef MQTT_TOPIC_LEN_MAX
|
||||
#define MQTT_TOPIC_LEN_MAX 64
|
||||
#endif // !MQTT_TOPIC_LEN_MAX
|
||||
|
||||
#ifndef MQTT_ACK_HANDLER_NUM_MAX
|
||||
#define MQTT_ACK_HANDLER_NUM_MAX 64
|
||||
#endif // !MQTT_ACK_HANDLER_NUM_MAX
|
||||
|
||||
#ifndef MQTT_DEFAULT_BUF_SIZE
|
||||
#define MQTT_DEFAULT_BUF_SIZE 1024
|
||||
#endif // !MQTT_DEFAULT_BUF_SIZE
|
||||
|
||||
#ifndef MQTT_DEFAULT_CMD_TIMEOUT
|
||||
#define MQTT_DEFAULT_CMD_TIMEOUT 4000
|
||||
#endif // !MQTT_DEFAULT_CMD_TIMEOUT
|
||||
|
||||
#ifndef MQTT_MAX_CMD_TIMEOUT
|
||||
#define MQTT_MAX_CMD_TIMEOUT 20000
|
||||
#endif // !MQTT_MAX_CMD_TIMEOUT
|
||||
|
||||
#ifndef MQTT_MIN_CMD_TIMEOUT
|
||||
#define MQTT_MIN_CMD_TIMEOUT 1000
|
||||
#endif // !MQTT_MIN_CMD_TIMEOUT
|
||||
|
||||
#ifndef MQTT_KEEP_ALIVE_INTERVAL
|
||||
#define MQTT_KEEP_ALIVE_INTERVAL 100 // unit: second
|
||||
#endif // !MQTT_KEEP_ALIVE_INTERVAL
|
||||
|
||||
#ifndef MQTT_VERSION
|
||||
#define MQTT_VERSION 4 // 4 is mqtt 3.1.1
|
||||
#endif // !MQTT_VERSION
|
||||
|
||||
#ifndef MQTT_RECONNECT_DEFAULT_DURATION
|
||||
#define MQTT_RECONNECT_DEFAULT_DURATION 1000
|
||||
#endif // !MQTT_RECONNECT_DEFAULT_DURATION
|
||||
|
||||
#ifndef MQTT_THREAD_STACK_SIZE
|
||||
#define MQTT_THREAD_STACK_SIZE 4096
|
||||
#endif // !MQTT_THREAD_STACK_SIZE
|
||||
|
||||
#ifndef MQTT_THREAD_PRIO
|
||||
#define MQTT_THREAD_PRIO 5
|
||||
#endif // !MQTT_THREAD_PRIO
|
||||
|
||||
#ifndef MQTT_THREAD_TICK
|
||||
#define MQTT_THREAD_TICK 50
|
||||
#endif // !MQTT_THREAD_TICK
|
||||
|
||||
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#ifndef MQTT_TLS_HANDSHAKE_TIMEOUT
|
||||
#define MQTT_TLS_HANDSHAKE_TIMEOUT (5 * 1000)
|
||||
#endif // !MQTT_TLS_HANDSHAKE_TIMEOUT
|
||||
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#endif /* MQTT_NETWORK_TYPE_TLS */
|
||||
|
||||
#endif /* _DEFCONFIG_H_ */
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-09 21:31:25
|
||||
* @LastEditTime : 2020-02-16 02:50:32
|
||||
* @LastEditTime: 2020-03-15 01:33:01
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "mqttclient.h"
|
||||
@@ -28,22 +28,35 @@ static void mqtt_set_client_state(mqtt_client_t* c, client_state_t state)
|
||||
platform_mutex_unlock(&c->global_lock);
|
||||
}
|
||||
|
||||
static int mqtt_is_connected(mqtt_client_t* c)
|
||||
{
|
||||
client_state_t state;
|
||||
|
||||
state = mqtt_get_client_state(c);
|
||||
if (CLIENT_STATE_CLEAN_SESSION == state) {
|
||||
RETURN_ERROR(MQTT_CLEAN_SESSION_ERROR);
|
||||
} else if (CLIENT_STATE_CONNECTED != state) {
|
||||
RETURN_ERROR(MQTT_NOT_CONNECT_ERROR);
|
||||
}
|
||||
RETURN_ERROR(MQTT_SUCCESS_ERROR);
|
||||
}
|
||||
|
||||
static int mqtt_set_publish_dup(mqtt_client_t* c, unsigned char dup)
|
||||
{
|
||||
unsigned char *read_data = c->write_buf;
|
||||
unsigned char *write_data = c->write_buf;
|
||||
MQTTHeader header = {0};
|
||||
MQTTHeader header = {0};
|
||||
|
||||
if (NULL == c->write_buf)
|
||||
RETURN_ERROR(MQTT_SET_PUBLISH_DUP_FAILED);
|
||||
|
||||
header.byte = readChar(&read_data); /* read header */
|
||||
header.byte = readChar(&read_data); /* read header */
|
||||
|
||||
if (header.bits.type != PUBLISH)
|
||||
RETURN_ERROR(MQTT_SET_PUBLISH_DUP_FAILED);
|
||||
|
||||
header.bits.dup = dup;
|
||||
writeChar(&write_data, header.byte); /* write header */
|
||||
header.bits.dup = dup;
|
||||
writeChar(&write_data, header.byte); /* write header */
|
||||
|
||||
RETURN_ERROR(MQTT_SUCCESS_ERROR);
|
||||
}
|
||||
@@ -98,10 +111,10 @@ static int mqtt_decode_packet(mqtt_client_t* c, int* value, int timeout)
|
||||
rc = MQTTPACKET_READ_ERROR; /* bad data */
|
||||
goto exit;
|
||||
}
|
||||
rc = c->network->read(c->network, &i, 1, timeout);
|
||||
rc = c->network->read(c->network, &i, 1, timeout); /* read network data */
|
||||
if (rc != 1)
|
||||
goto exit;
|
||||
*value += (i & 127) * multiplier;
|
||||
*value += (i & 127) * multiplier; /* decode data length according to mqtt protocol */
|
||||
multiplier *= 128;
|
||||
} while ((i & 128) != 0);
|
||||
exit:
|
||||
@@ -128,7 +141,7 @@ static void mqtt_packet_drain(mqtt_client_t* c, platform_timer_t *timer, int pac
|
||||
bytes2read = packet_len - total_bytes_read;
|
||||
}
|
||||
}
|
||||
} while ((total_bytes_read < packet_len) && (0 != read_len));
|
||||
} while ((total_bytes_read < packet_len) && (0 != read_len)); /* read and discard all corrupted data */
|
||||
}
|
||||
|
||||
static int mqtt_read_packet(mqtt_client_t* c, int* packet_type, platform_timer_t* timer)
|
||||
@@ -141,6 +154,9 @@ static int mqtt_read_packet(mqtt_client_t* c, int* packet_type, platform_timer_t
|
||||
if (NULL == packet_type)
|
||||
RETURN_ERROR(MQTT_NULL_VALUE_ERROR);
|
||||
|
||||
platform_timer_init(timer);
|
||||
platform_timer_cutdown(timer, c->cmd_timeout);
|
||||
|
||||
/* 1. read the header byte. This has the packet type in it */
|
||||
rc = c->network->read(c->network, c->read_buf, len, platform_timer_remain(timer));
|
||||
if (rc != len)
|
||||
@@ -153,8 +169,11 @@ static int mqtt_read_packet(mqtt_client_t* c, int* packet_type, platform_timer_t
|
||||
len += MQTTPacket_encode(c->read_buf + len, remain_len);
|
||||
|
||||
if ((len + remain_len) > c->read_buf_size) {
|
||||
|
||||
/* mqtt buffer is too short, read and discard all corrupted data */
|
||||
mqtt_packet_drain(c, timer, remain_len);
|
||||
RETURN_ERROR(MQTT_BUFFER_TOO_SHORT_ERROR);
|
||||
|
||||
RETURN_ERROR(MQTT_BUFFER_TOO_SHORT_ERROR);
|
||||
}
|
||||
|
||||
/* 3. read the rest of the buffer using a callback to supply the rest of the data */
|
||||
@@ -174,9 +193,13 @@ static int mqtt_send_packet(mqtt_client_t* c, int length, platform_timer_t* time
|
||||
int len = 0;
|
||||
int sent = 0;
|
||||
|
||||
platform_timer_init(timer);
|
||||
platform_timer_cutdown(timer, c->cmd_timeout);
|
||||
|
||||
/* send mqtt packet in a blocking manner or exit when it timer is expired */
|
||||
while ((sent < length) && (!platform_timer_is_expired(timer))) {
|
||||
len = c->network->write(c->network, &c->write_buf[sent], length, platform_timer_remain(timer));
|
||||
if (len < 0) // there was an error writing the data
|
||||
if (len <= 0) // there was an error writing the data
|
||||
break;
|
||||
sent += len;
|
||||
}
|
||||
@@ -215,8 +238,11 @@ static char mqtt_topic_is_matched(char* topic_filter, MQTTString* topic_name)
|
||||
{
|
||||
if (*curn == '/' && *curf != '/')
|
||||
break;
|
||||
if (*curf != '+' && *curf != '#' && *curf != *curn)
|
||||
|
||||
/* support wildcards for MQTT topics, such as '#' '+' */
|
||||
if (*curf != '+' && *curf != '#' && *curf != *curn)
|
||||
break;
|
||||
|
||||
if (*curf == '+') {
|
||||
char* nextpos = curn + 1;
|
||||
while (nextpos < curn_end && *nextpos != '/')
|
||||
@@ -236,7 +262,7 @@ static void mqtt_new_message_data(message_data_t* md, MQTTString* topic_name, mq
|
||||
int len;
|
||||
len = (topic_name->lenstring.len < MQTT_TOPIC_LEN_MAX - 1) ? topic_name->lenstring.len : MQTT_TOPIC_LEN_MAX - 1;
|
||||
memcpy(md->topic_name, topic_name->lenstring.data, len);
|
||||
md->topic_name[len] = '\0';
|
||||
md->topic_name[len] = '\0'; /* the topic name is too long and will be truncated */
|
||||
md->message = message;
|
||||
}
|
||||
|
||||
@@ -245,9 +271,11 @@ static message_handlers_t *mqtt_get_msg_handler(mqtt_client_t* c, MQTTString* to
|
||||
list_t *curr, *next;
|
||||
message_handlers_t *msg_handler;
|
||||
|
||||
/* traverse the msg_handler_list to find the matching message handler */
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->msg_handler_list) {
|
||||
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
|
||||
|
||||
/* judge topic is equal or match, support wildcard, such as '#' '+' */
|
||||
if ((NULL != msg_handler->topic_filter) && ((MQTTPacket_equals(topic_name, (char*)msg_handler->topic_filter)) ||
|
||||
(mqtt_topic_is_matched((char*)msg_handler->topic_filter, topic_name)))) {
|
||||
return msg_handler;
|
||||
@@ -261,12 +289,13 @@ static int mqtt_deliver_message(mqtt_client_t* c, MQTTString* topic_name, mqtt_m
|
||||
int rc = MQTT_FAILED_ERROR;
|
||||
message_handlers_t *msg_handler;
|
||||
|
||||
/* get mqtt message handler */
|
||||
msg_handler = mqtt_get_msg_handler(c, topic_name);
|
||||
|
||||
if (NULL != msg_handler) {
|
||||
message_data_t md;
|
||||
mqtt_new_message_data(&md, topic_name, message);
|
||||
msg_handler->handler(c, &md);
|
||||
mqtt_new_message_data(&md, topic_name, message); /* make a message data */
|
||||
msg_handler->handler(c, &md); /* deliver the message */
|
||||
rc = MQTT_SUCCESS_ERROR;
|
||||
} else
|
||||
goto exit;
|
||||
@@ -288,14 +317,14 @@ static ack_handlers_t *mqtt_ack_handler_create(mqtt_client_t* c, int type, unsig
|
||||
|
||||
list_init(&ack_handler->list);
|
||||
platform_timer_init(&ack_handler->timer);
|
||||
platform_timer_cutdown(&ack_handler->timer, c->cmd_timeout);
|
||||
platform_timer_cutdown(&ack_handler->timer, c->cmd_timeout); /* No response within timeout will be destroyed or resent */
|
||||
|
||||
ack_handler->type = type;
|
||||
ack_handler->packet_id = packet_id;
|
||||
ack_handler->payload_len = payload_len;
|
||||
ack_handler->payload = (unsigned char *)ack_handler + sizeof(ack_handlers_t);
|
||||
ack_handler->handler = handler;
|
||||
memcpy(ack_handler->payload, c->write_buf, payload_len);
|
||||
memcpy(ack_handler->payload, c->write_buf, payload_len); /* save the data in ack handler*/
|
||||
|
||||
return ack_handler;
|
||||
}
|
||||
@@ -304,7 +333,7 @@ static void mqtt_ack_handler_destroy(ack_handlers_t* ack_handler)
|
||||
{
|
||||
if (NULL != &ack_handler->list) {
|
||||
list_del(&ack_handler->list);
|
||||
platform_memory_free(ack_handler);
|
||||
platform_memory_free(ack_handler); /* delete ack handler from the list, and free memory */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,13 +342,13 @@ static void mqtt_ack_handler_resend(mqtt_client_t* c, ack_handlers_t* ack_handle
|
||||
platform_timer_t timer;
|
||||
platform_timer_init(&timer);
|
||||
platform_timer_cutdown(&timer, c->cmd_timeout);
|
||||
platform_timer_cutdown(&ack_handler->timer, c->cmd_timeout);
|
||||
platform_timer_cutdown(&ack_handler->timer, c->cmd_timeout); /* timeout, recutdown */
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
memcpy(c->write_buf, ack_handler->payload, ack_handler->payload_len);
|
||||
memcpy(c->write_buf, ack_handler->payload, ack_handler->payload_len); /* copy data to write buf form ack handler */
|
||||
|
||||
mqtt_send_packet(c, ack_handler->payload_len, &timer);
|
||||
LOG_E("%s:%d %s()... resend %d package, packet_id is %d ", __FILE__, __LINE__, __FUNCTION__, ack_handler->type, ack_handler->packet_id);
|
||||
mqtt_send_packet(c, ack_handler->payload_len, &timer); /* resend data */
|
||||
LOG_W("%s:%d %s()... resend %d package, packet_id is %d ", __FILE__, __LINE__, __FUNCTION__, ack_handler->type, ack_handler->packet_id);
|
||||
platform_mutex_unlock(&c->write_lock);
|
||||
}
|
||||
|
||||
@@ -334,7 +363,9 @@ static int mqtt_ack_list_node_is_exist(mqtt_client_t* c, int type, unsigned shor
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->ack_handler_list) {
|
||||
ack_handler = LIST_ENTRY(curr, ack_handlers_t, list);
|
||||
|
||||
if ((packet_id == ack_handler->packet_id) && (type == ack_handler->type))
|
||||
/* For mqtt packets of qos1 and qos2, you can use the packet id and type as the unique
|
||||
identifier to determine whether the node already exists and avoid repeated addition. */
|
||||
if ((packet_id == ack_handler->packet_id) && (type == ack_handler->type))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -346,9 +377,11 @@ static int mqtt_ack_list_record(mqtt_client_t* c, int type, unsigned short packe
|
||||
int rc = MQTT_SUCCESS_ERROR;
|
||||
ack_handlers_t *ack_handler = NULL;
|
||||
|
||||
/* Determine if the node already exists */
|
||||
if (mqtt_ack_list_node_is_exist(c, type, packet_id))
|
||||
RETURN_ERROR(MQTT_ACK_NODE_IS_EXIST);
|
||||
|
||||
/* create a ack handler node */
|
||||
ack_handler = mqtt_ack_handler_create(c, type, packet_id, payload_len, handler);
|
||||
if (NULL == ack_handler)
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
@@ -377,6 +410,7 @@ static int mqtt_ack_list_unrecord(mqtt_client_t* c, int type, unsigned short pac
|
||||
if (handler)
|
||||
*handler = ack_handler->handler;
|
||||
|
||||
/* destroy a ack handler node */
|
||||
mqtt_ack_handler_destroy(ack_handler);
|
||||
mqtt_subtract_ack_handler_num(c);
|
||||
}
|
||||
@@ -395,13 +429,13 @@ static message_handlers_t *mqtt_msg_handler_create(const char* topic_filter, mqt
|
||||
list_init(&msg_handler->list);
|
||||
|
||||
msg_handler->qos = qos;
|
||||
msg_handler->handler = handler;
|
||||
msg_handler->handler = handler; /* register callback handler */
|
||||
msg_handler->topic_filter = topic_filter;
|
||||
|
||||
return msg_handler;
|
||||
}
|
||||
|
||||
static void mqtt_msg_handler_destroy(message_handlers_t *msg_handler)
|
||||
static void mqtt_msg_handler_destory(message_handlers_t *msg_handler)
|
||||
{
|
||||
if (NULL != &msg_handler->list) {
|
||||
list_del(&msg_handler->list);
|
||||
@@ -423,6 +457,7 @@ static int mqtt_msg_handler_is_exist(mqtt_client_t* c, message_handlers_t *handl
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->msg_handler_list) {
|
||||
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
|
||||
|
||||
/* determine whether a node already exists by mqtt topic, but wildcards are not supported */
|
||||
if ((NULL != msg_handler->topic_filter) && (mqtt_is_topic_equals(msg_handler->topic_filter, handler->topic_filter))) {
|
||||
LOG_W("%s:%d %s()...msg_handler->topic_filter: %s, handler->topic_filter: %s", __FILE__, __LINE__, __FUNCTION__, msg_handler->topic_filter, handler->topic_filter);
|
||||
return 1;
|
||||
@@ -435,10 +470,11 @@ static int mqtt_msg_handler_is_exist(mqtt_client_t* c, message_handlers_t *handl
|
||||
static int mqtt_msg_handlers_install(mqtt_client_t* c, message_handlers_t *handler)
|
||||
{
|
||||
if (mqtt_msg_handler_is_exist(c, handler)) {
|
||||
mqtt_msg_handler_destroy(handler);
|
||||
mqtt_msg_handler_destory(handler);
|
||||
RETURN_ERROR(MQTT_SUCCESS_ERROR);
|
||||
}
|
||||
|
||||
/* install to msg_handler_list*/
|
||||
list_add_tail(&handler->list, &c->msg_handler_list);
|
||||
|
||||
RETURN_ERROR(MQTT_SUCCESS_ERROR);
|
||||
@@ -451,6 +487,7 @@ static void mqtt_clean_session(mqtt_client_t* c)
|
||||
ack_handlers_t *ack_handler;
|
||||
message_handlers_t *msg_handler;
|
||||
|
||||
/* release all ack_handler_list memory */
|
||||
if (!(list_is_empty(&c->ack_handler_list))) {
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->ack_handler_list) {
|
||||
ack_handler = LIST_ENTRY(curr, ack_handlers_t, list);
|
||||
@@ -459,6 +496,7 @@ static void mqtt_clean_session(mqtt_client_t* c)
|
||||
list_del_init(&c->ack_handler_list);
|
||||
}
|
||||
|
||||
/* release all msg_handler_list memory */
|
||||
if (!(list_is_empty(&c->msg_handler_list))) {
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->msg_handler_list) {
|
||||
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
|
||||
@@ -467,6 +505,8 @@ static void mqtt_clean_session(mqtt_client_t* c)
|
||||
}
|
||||
list_del_init(&c->msg_handler_list);
|
||||
}
|
||||
|
||||
mqtt_set_client_state(c, CLIENT_STATE_INVALID);
|
||||
}
|
||||
|
||||
static void mqtt_ack_list_scan(mqtt_client_t* c)
|
||||
@@ -484,6 +524,8 @@ static void mqtt_ack_list_scan(mqtt_client_t* c)
|
||||
continue;
|
||||
|
||||
if ((ack_handler->type == PUBACK) || (ack_handler->type == PUBREC) || (ack_handler->type == PUBREL) || (ack_handler->type == PUBCOMP)) {
|
||||
|
||||
/* timeout has occurred. for qos1 and qos2 packets, you need to resend them. */
|
||||
mqtt_ack_handler_resend(c, ack_handler);
|
||||
continue;
|
||||
}
|
||||
@@ -505,6 +547,7 @@ static int mqtt_try_resubscribe(mqtt_client_t* c)
|
||||
LIST_FOR_EACH_SAFE(curr, next, &c->msg_handler_list) {
|
||||
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
|
||||
|
||||
/* resubscribe topic */
|
||||
if ((rc = mqtt_subscribe(c, msg_handler->topic_filter, msg_handler->qos, msg_handler->handler)) == MQTT_ACK_HANDLER_NUM_TOO_MUCH)
|
||||
LOG_W("%s:%d %s()... mqtt ack handler num too much ...", __FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
@@ -518,10 +561,10 @@ static int mqtt_try_do_reconnect(mqtt_client_t* c)
|
||||
int rc = MQTT_CONNECT_FAILED_ERROR;
|
||||
|
||||
if (CLIENT_STATE_CONNECTED != mqtt_get_client_state(c))
|
||||
rc = mqtt_connect(c);
|
||||
rc = mqtt_connect(c); /* reconnect */
|
||||
|
||||
if (MQTT_SUCCESS_ERROR == rc) {
|
||||
rc = mqtt_try_resubscribe(c);
|
||||
rc = mqtt_try_resubscribe(c); /* resubscribe */
|
||||
}
|
||||
|
||||
LOG_I("%s:%d %s()... mqtt try connect result is %#x", __FILE__, __LINE__, __FUNCTION__, rc);
|
||||
@@ -556,15 +599,15 @@ static int mqtt_publish_ack_packet(mqtt_client_t *c, unsigned short packet_id, i
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
switch (packet_type) {
|
||||
case PUBREC:
|
||||
len = MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBREL, 0, packet_id);
|
||||
rc = mqtt_ack_list_record(c, PUBCOMP, packet_id, len, NULL);
|
||||
case PUBREC:
|
||||
len = MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBREL, 0, packet_id); /* make a PUBREL ack packet */
|
||||
rc = mqtt_ack_list_record(c, PUBCOMP, packet_id, len, NULL); /* record ack, expect to receive PUBCOMP*/
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
goto exit;
|
||||
break;
|
||||
|
||||
case PUBREL:
|
||||
len = MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBCOMP, 0, packet_id);
|
||||
len = MQTTSerialize_ack(c->write_buf, c->write_buf_size, PUBCOMP, 0, packet_id); /* make a PUBCOMP ack packet */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -591,11 +634,15 @@ static int mqtt_puback_and_pubcomp_packet_handle(mqtt_client_t *c, platform_time
|
||||
unsigned short packet_id;
|
||||
unsigned char dup, packet_type;
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
if (MQTTDeserialize_ack(&packet_type, &dup, &packet_id, c->read_buf, c->read_buf_size) != 1)
|
||||
rc = MQTT_PUBREC_PACKET_ERROR;
|
||||
|
||||
(void) dup;
|
||||
rc = mqtt_ack_list_unrecord(c, packet_type, packet_id, NULL);
|
||||
rc = mqtt_ack_list_unrecord(c, packet_type, packet_id, NULL); /* unrecord ack handler */
|
||||
|
||||
RETURN_ERROR(rc);
|
||||
}
|
||||
@@ -608,7 +655,12 @@ static int mqtt_suback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
unsigned short packet_id;
|
||||
int is_nack = 0;
|
||||
message_handlers_t *msg_handler = NULL;
|
||||
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
/* deserialize subscribe ack packet */
|
||||
if (MQTTDeserialize_suback(&packet_id, 1, &count, (int*)&granted_qos, c->read_buf, c->read_buf_size) != 1)
|
||||
RETURN_ERROR(MQTT_SUBSCRIBE_ACK_PACKET_ERROR);
|
||||
|
||||
@@ -620,7 +672,7 @@ static int mqtt_suback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
|
||||
if (is_nack) {
|
||||
mqtt_msg_handler_destroy(msg_handler);
|
||||
mqtt_msg_handler_destory(msg_handler); /* subscribe topic failed, destory message handler */
|
||||
RETURN_ERROR(MQTT_SUBSCRIBE_NOT_ACK_ERROR);
|
||||
}
|
||||
|
||||
@@ -634,16 +686,20 @@ static int mqtt_unsuback_packet_handle(mqtt_client_t *c, platform_timer_t *timer
|
||||
int rc = MQTT_FAILED_ERROR;
|
||||
message_handlers_t *msg_handler;
|
||||
unsigned short packet_id = 0;
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
if (MQTTDeserialize_unsuback(&packet_id, c->read_buf, c->read_buf_size) != 1)
|
||||
RETURN_ERROR(MQTT_UNSUBSCRIBE_ACK_PACKET_ERROR);
|
||||
|
||||
rc = mqtt_ack_list_unrecord(c, UNSUBACK, packet_id, &msg_handler);
|
||||
rc = mqtt_ack_list_unrecord(c, UNSUBACK, packet_id, &msg_handler); /* unrecord ack handler, and get message handler */
|
||||
|
||||
if (!msg_handler)
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
|
||||
mqtt_msg_handler_destroy(msg_handler);
|
||||
mqtt_msg_handler_destory(msg_handler); /* destory message handler */
|
||||
|
||||
RETURN_ERROR(rc);
|
||||
}
|
||||
@@ -655,6 +711,10 @@ static int mqtt_publish_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
mqtt_message_t msg;
|
||||
int qos;
|
||||
msg.payloadlen = 0;
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
if (MQTTDeserialize_publish(&msg.dup, &qos, &msg.retained, &msg.id, &topic_name,
|
||||
(unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->read_buf, c->read_buf_size) != 1)
|
||||
@@ -662,6 +722,7 @@ static int mqtt_publish_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
|
||||
msg.qos = (mqtt_qos_t)qos;
|
||||
|
||||
/* for qos1 and qos2, you need to send a ack packet */
|
||||
if (msg.qos != QOS0) {
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
@@ -684,6 +745,7 @@ static int mqtt_publish_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
|
||||
if (msg.qos != QOS2)
|
||||
mqtt_deliver_message(c, &topic_name, &msg);
|
||||
else {
|
||||
/* record the received of a qos2 message and only processes it when the qos2 message is received for the first time */
|
||||
if ((rc = mqtt_ack_list_record(c, PUBREL, msg.id, len, NULL)) != MQTT_ACK_NODE_IS_EXIST)
|
||||
mqtt_deliver_message(c, &topic_name, &msg);
|
||||
}
|
||||
@@ -697,12 +759,16 @@ static int mqtt_pubrec_and_pubrel_packet_handle(mqtt_client_t *c, platform_timer
|
||||
int rc = MQTT_FAILED_ERROR;
|
||||
unsigned short packet_id;
|
||||
unsigned char dup, packet_type;
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
if (MQTTDeserialize_ack(&packet_type, &dup, &packet_id, c->read_buf, c->read_buf_size) != 1)
|
||||
RETURN_ERROR(MQTT_PUBREC_PACKET_ERROR);
|
||||
|
||||
(void) dup;
|
||||
rc = mqtt_publish_ack_packet(c, packet_id, packet_type);
|
||||
rc = mqtt_publish_ack_packet(c, packet_id, packet_type); /* make a ack packet and send it */
|
||||
rc = mqtt_ack_list_unrecord(c, packet_type, packet_id, NULL);
|
||||
|
||||
RETURN_ERROR(rc);
|
||||
@@ -710,21 +776,17 @@ static int mqtt_pubrec_and_pubrel_packet_handle(mqtt_client_t *c, platform_timer
|
||||
|
||||
static int mqtt_packet_handle(mqtt_client_t* c, platform_timer_t* timer)
|
||||
{
|
||||
|
||||
int rc = MQTT_SUCCESS_ERROR;
|
||||
int packet_type = 0;
|
||||
|
||||
rc = mqtt_read_packet(c, &packet_type, timer);
|
||||
|
||||
platform_timer_init(timer);
|
||||
platform_timer_cutdown(timer, c->cmd_timeout);
|
||||
|
||||
switch (packet_type) {
|
||||
case 0: /* timed out reading packet */
|
||||
break;
|
||||
|
||||
case CONNACK:
|
||||
break;
|
||||
case CONNACK: /* has been processed */
|
||||
goto exit;
|
||||
|
||||
case PUBACK:
|
||||
case PUBCOMP:
|
||||
@@ -749,19 +811,15 @@ static int mqtt_packet_handle(mqtt_client_t* c, platform_timer_t* timer)
|
||||
break;
|
||||
|
||||
case PINGRESP:
|
||||
c->ping_outstanding = 0;
|
||||
c->ping_outstanding = 0; /* keep alive ping success */
|
||||
break;
|
||||
|
||||
default:
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (mqtt_keep_alive(c) != MQTT_SUCCESS_ERROR) {
|
||||
mqtt_set_client_state(c, CLIENT_STATE_DISCONNECTED);
|
||||
rc = MQTT_NOT_CONNECT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
rc = mqtt_keep_alive(c);
|
||||
|
||||
exit:
|
||||
if (rc == MQTT_SUCCESS_ERROR)
|
||||
rc = packet_type;
|
||||
@@ -785,11 +843,19 @@ static int mqtt_wait_packet(mqtt_client_t* c, int packet_type, platform_timer_t*
|
||||
static void mqtt_yield_thread(void *arg)
|
||||
{
|
||||
int rc;
|
||||
client_state_t state;
|
||||
mqtt_client_t *c = (mqtt_client_t *)arg;
|
||||
|
||||
state = mqtt_get_client_state(c);
|
||||
if (CLIENT_STATE_CONNECTED != state) {
|
||||
LOG_W("%s:%d %s()..., mqtt is not connected to the server...", __FILE__, __LINE__, __FUNCTION__);
|
||||
platform_thread_stop(c->thread); /* mqtt is not connected to the server, stop thread */
|
||||
}
|
||||
|
||||
while (1) {
|
||||
rc = mqtt_yield(c, c->cmd_timeout);
|
||||
if (MQTT_CLOSE_SESSION_ERROR == rc) {
|
||||
LOG_E("%s:%d %s()..., mqtt close session....", __FILE__, __LINE__, __FUNCTION__);
|
||||
if (MQTT_CLEAN_SESSION_ERROR == rc) {
|
||||
LOG_E("%s:%d %s()..., mqtt clean session....", __FILE__, __LINE__, __FUNCTION__);
|
||||
c->network->disconnect(c->network);
|
||||
mqtt_clean_session(c);
|
||||
goto exit;
|
||||
@@ -836,8 +902,11 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
/* serialize connect packet */
|
||||
if ((len = MQTTSerialize_connect(c->write_buf, c->write_buf_size, &connect_data)) <= 0)
|
||||
goto exit;
|
||||
|
||||
/* send connect packet */
|
||||
if ((rc = mqtt_send_packet(c, len, &connect_timer)) != MQTT_SUCCESS_ERROR)
|
||||
goto exit;
|
||||
|
||||
@@ -851,12 +920,24 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
|
||||
|
||||
exit:
|
||||
if (rc == MQTT_SUCCESS_ERROR) {
|
||||
if(NULL ==c->thread)
|
||||
if(NULL == c->thread) {
|
||||
|
||||
/* connect success, and need init mqtt thread */
|
||||
c->thread= platform_thread_init("mqtt_yield_thread", mqtt_yield_thread, c, MQTT_THREAD_STACK_SIZE, MQTT_THREAD_PRIO, MQTT_THREAD_TICK);
|
||||
c->ping_outstanding = 0;
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED);
|
||||
|
||||
if (NULL != c->thread) {
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED);
|
||||
platform_thread_startup(c->thread);
|
||||
platform_thread_start(c->thread); /* start run mqtt thread */
|
||||
}
|
||||
} else {
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED); /* reconnect, mqtt thread is already exists */
|
||||
}
|
||||
|
||||
c->ping_outstanding = 0; /* reset ping outstanding */
|
||||
|
||||
} else {
|
||||
mqtt_set_client_state(c, CLIENT_STATE_INITIALIZED);
|
||||
mqtt_set_client_state(c, CLIENT_STATE_INITIALIZED); /* connect failed */
|
||||
}
|
||||
|
||||
platform_mutex_unlock(&c->write_lock);
|
||||
@@ -869,15 +950,18 @@ exit:
|
||||
int mqtt_keep_alive(mqtt_client_t* c)
|
||||
{
|
||||
int rc = MQTT_SUCCESS_ERROR;
|
||||
|
||||
rc = mqtt_is_connected(c);
|
||||
if (MQTT_SUCCESS_ERROR != rc)
|
||||
RETURN_ERROR(rc);
|
||||
|
||||
if (platform_timer_is_expired(&c->last_sent) || platform_timer_is_expired(&c->last_received)) {
|
||||
if (c->ping_outstanding) {
|
||||
LOG_W("%s:%d %s()... ping outstanding", __FILE__, __LINE__, __FUNCTION__);
|
||||
rc = MQTT_FAILED_ERROR; /* PINGRESP not received in keepalive interval */
|
||||
mqtt_set_client_state(c, CLIENT_STATE_DISCONNECTED);
|
||||
rc = MQTT_NOT_CONNECT_ERROR; /* PINGRESP not received in keepalive interval */
|
||||
} else {
|
||||
platform_timer_t timer;
|
||||
platform_timer_init(&timer);
|
||||
platform_timer_cutdown(&timer, c->cmd_timeout);
|
||||
int len = MQTTSerialize_pingreq(c->write_buf, c->write_buf_size);
|
||||
if (len > 0 && (rc = mqtt_send_packet(c, len, &timer)) == MQTT_SUCCESS_ERROR) // send the ping packet
|
||||
c->ping_outstanding++;
|
||||
@@ -903,14 +987,15 @@ int mqtt_init(mqtt_client_t* c, client_init_params_t* init)
|
||||
}
|
||||
memset(c->network, 0, sizeof(network_t));
|
||||
|
||||
if ((MQTT_MIN_PAYLOAD_SIZE <= init->read_buf_size) || (MQTT_MAX_PAYLOAD_SIZE >= init->read_buf_size))
|
||||
if ((MQTT_MIN_PAYLOAD_SIZE >= init->read_buf_size) || (MQTT_MAX_PAYLOAD_SIZE <= init->read_buf_size))
|
||||
init->read_buf_size = MQTT_DEFAULT_BUF_SIZE;
|
||||
if ((MQTT_MIN_PAYLOAD_SIZE <= init->write_buf_size) || (MQTT_MAX_PAYLOAD_SIZE >= init->read_buf_size))
|
||||
if ((MQTT_MIN_PAYLOAD_SIZE >= init->write_buf_size) || (MQTT_MAX_PAYLOAD_SIZE <= init->read_buf_size))
|
||||
init->write_buf_size = MQTT_DEFAULT_BUF_SIZE;
|
||||
|
||||
c->read_buf = (unsigned char*) platform_memory_alloc(init->read_buf_size);
|
||||
c->write_buf = (unsigned char*) platform_memory_alloc(init->write_buf_size);
|
||||
if ((NULL == c->read_buf) || (NULL == c->write_buf)){
|
||||
|
||||
if ((NULL == c->read_buf) || (NULL == c->write_buf)) {
|
||||
LOG_E("%s:%d %s()... malloc buf failed...", __FILE__, __LINE__, __FUNCTION__);
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
}
|
||||
@@ -930,8 +1015,10 @@ int mqtt_init(mqtt_client_t* c, client_init_params_t* init)
|
||||
|
||||
if (0 == init->connect_params.keep_alive_interval)
|
||||
init->connect_params.keep_alive_interval = MQTT_KEEP_ALIVE_INTERVAL;
|
||||
|
||||
if (0 == init->connect_params.mqtt_version)
|
||||
init->connect_params.mqtt_version = MQTT_VERSION;
|
||||
|
||||
if (0 == init->reconnect_try_duration)
|
||||
init->reconnect_try_duration = MQTT_RECONNECT_DEFAULT_DURATION;
|
||||
|
||||
@@ -968,8 +1055,9 @@ int mqtt_release(mqtt_client_t* c)
|
||||
if (NULL == c)
|
||||
RETURN_ERROR(MQTT_NULL_VALUE_ERROR);
|
||||
|
||||
while (CLIENT_STATE_INVALID != mqtt_get_client_state(c)); /* wait for the clean session to complete */
|
||||
|
||||
if (NULL != c->network) {
|
||||
network_release(c->network);
|
||||
platform_memory_free(c->network);
|
||||
c->network = NULL;
|
||||
}
|
||||
@@ -984,8 +1072,6 @@ int mqtt_release(mqtt_client_t* c)
|
||||
c->read_buf = NULL;
|
||||
}
|
||||
|
||||
mqtt_clean_session(c);
|
||||
|
||||
memset(c, 0, sizeof(mqtt_client_t));
|
||||
|
||||
RETURN_ERROR(MQTT_SUCCESS_ERROR);
|
||||
@@ -993,6 +1079,7 @@ int mqtt_release(mqtt_client_t* c)
|
||||
|
||||
int mqtt_connect(mqtt_client_t* c)
|
||||
{
|
||||
/* connect server in blocking mode and wait for connection result */
|
||||
return mqtt_connect_with_results(c);
|
||||
}
|
||||
|
||||
@@ -1007,13 +1094,14 @@ int mqtt_disconnect(mqtt_client_t* c)
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
len = MQTTSerialize_disconnect(c->write_buf, c->write_buf_size);
|
||||
/* serialize disconnect packet and send it */
|
||||
len = MQTTSerialize_disconnect(c->write_buf, c->write_buf_size);
|
||||
if (len > 0)
|
||||
rc = mqtt_send_packet(c, len, &timer);
|
||||
|
||||
platform_mutex_unlock(&c->write_lock);
|
||||
|
||||
mqtt_set_client_state(c, CLIENT_STATE_INVALID);
|
||||
mqtt_set_client_state(c, CLIENT_STATE_CLEAN_SESSION);
|
||||
|
||||
RETURN_ERROR(rc);
|
||||
}
|
||||
@@ -1031,22 +1119,22 @@ int mqtt_subscribe(mqtt_client_t* c, const char* topic_filter, mqtt_qos_t qos, m
|
||||
if (CLIENT_STATE_CONNECTED != mqtt_get_client_state(c))
|
||||
RETURN_ERROR(MQTT_NOT_CONNECT_ERROR);
|
||||
|
||||
platform_timer_init(&timer);
|
||||
platform_timer_cutdown(&timer, c->cmd_timeout);
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
packet_id = mqtt_get_next_packet_id(c);
|
||||
|
||||
/* serialize subscribe packet and send it */
|
||||
len = MQTTSerialize_subscribe(c->write_buf, c->write_buf_size, 0, packet_id, 1, &topic, (int*)&qos);
|
||||
if (len <= 0)
|
||||
goto exit;
|
||||
|
||||
if ((rc = mqtt_send_packet(c, len, &timer)) != MQTT_SUCCESS_ERROR)
|
||||
goto exit;
|
||||
|
||||
if (NULL == handler)
|
||||
handler = default_msg_handler;
|
||||
handler = default_msg_handler; /* if handler is not specified, the default handler is used */
|
||||
|
||||
/* create a message and record it */
|
||||
msg_handler = mqtt_msg_handler_create(topic_filter, qos, handler);
|
||||
if (NULL == msg_handler)
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
@@ -1073,18 +1161,17 @@ int mqtt_unsubscribe(mqtt_client_t* c, const char* topic_filter)
|
||||
if (CLIENT_STATE_CONNECTED != mqtt_get_client_state(c))
|
||||
RETURN_ERROR(MQTT_NOT_CONNECT_ERROR);
|
||||
|
||||
platform_timer_init(&timer);
|
||||
platform_timer_cutdown(&timer, c->cmd_timeout);
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
packet_id = mqtt_get_next_packet_id(c);
|
||||
|
||||
|
||||
/* serialize unsubscribe packet and send it */
|
||||
if ((len = MQTTSerialize_unsubscribe(c->write_buf, c->write_buf_size, 0, packet_id, 1, &topic)) <= 0)
|
||||
goto exit;
|
||||
if ((rc = mqtt_send_packet(c, len, &timer)) != MQTT_SUCCESS_ERROR)
|
||||
goto exit;
|
||||
|
||||
/* create a message and record it */
|
||||
msg_handler = mqtt_msg_handler_create((const char*)topic_filter, QOS0, NULL);
|
||||
if (NULL == msg_handler)
|
||||
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
|
||||
@@ -1114,19 +1201,17 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
|
||||
if ((NULL != msg->payload) && (0 == msg->payloadlen))
|
||||
msg->payloadlen = strlen((char*)msg->payload);
|
||||
|
||||
platform_timer_init(&timer);
|
||||
platform_timer_cutdown(&timer, c->cmd_timeout);
|
||||
|
||||
platform_mutex_lock(&c->write_lock);
|
||||
|
||||
if (msg->qos == QOS1 || msg->qos == QOS2) {
|
||||
if (mqtt_ack_handler_is_maximum(c)) {
|
||||
rc = MQTT_ACK_HANDLER_NUM_TOO_MUCH;
|
||||
rc = MQTT_ACK_HANDLER_NUM_TOO_MUCH; /* the recorded ack handler has reached the maximum */
|
||||
goto exit;
|
||||
}
|
||||
msg->id = mqtt_get_next_packet_id(c);
|
||||
}
|
||||
|
||||
/* serialize publish packet and send it */
|
||||
len = MQTTSerialize_publish(c->write_buf, c->write_buf_size, 0, msg->qos, msg->retained, msg->id,
|
||||
topic, (unsigned char*)msg->payload, msg->payloadlen);
|
||||
if (len <= 0)
|
||||
@@ -1136,12 +1221,15 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
|
||||
goto exit;
|
||||
|
||||
if (QOS0 != msg->qos) {
|
||||
mqtt_set_publish_dup(c,1);
|
||||
mqtt_set_publish_dup(c,1); /* may resend this data, set the udp flag in advance */
|
||||
|
||||
if (QOS1 == msg->qos) {
|
||||
rc = mqtt_ack_list_record(c, PUBACK, msg->id, len, NULL);
|
||||
/* expect to receive PUBACK, otherwise data will be resent */
|
||||
rc = mqtt_ack_list_record(c, PUBACK, msg->id, len, NULL);
|
||||
|
||||
} else if (QOS2 == msg->qos) {
|
||||
rc = mqtt_ack_list_record(c, PUBREC, msg->id, len, NULL);
|
||||
/* expect to receive PUBREC, otherwise data will be resent */
|
||||
rc = mqtt_ack_list_record(c, PUBREC, msg->id, len, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,26 +1257,33 @@ int mqtt_yield(mqtt_client_t* c, int timeout_ms)
|
||||
|
||||
while (!platform_timer_is_expired(&timer)) {
|
||||
state = mqtt_get_client_state(c);
|
||||
if (CLIENT_STATE_INVALID == state) {
|
||||
RETURN_ERROR(MQTT_CLOSE_SESSION_ERROR);
|
||||
if (CLIENT_STATE_CLEAN_SESSION == state) {
|
||||
RETURN_ERROR(MQTT_CLEAN_SESSION_ERROR);
|
||||
} else if (CLIENT_STATE_CONNECTED != state) {
|
||||
/* mqtt not connect, need reconnect */
|
||||
rc = mqtt_try_reconnect(c);
|
||||
|
||||
if (MQTT_RECONNECT_TIMEOUT_ERROR == rc)
|
||||
RETURN_ERROR(rc);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* mqtt connected, handle mqtt packet */
|
||||
rc = mqtt_packet_handle(c, &timer);
|
||||
|
||||
if (rc >= 0) {
|
||||
/* scan ack list, destroy ack handler that have timed out or resend them */
|
||||
mqtt_ack_list_scan(c);
|
||||
|
||||
} else if (MQTT_NOT_CONNECT_ERROR == rc) {
|
||||
LOG_E("%s:%d %s()... mqtt not connect", __FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/* reconnect timer cutdown */
|
||||
platform_timer_cutdown(&c->reconnect_timer, c->reconnect_try_duration);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RETURN_ERROR(rc);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-09 21:31:25
|
||||
* @LastEditTime : 2020-01-11 20:11:47
|
||||
* @LastEditTime: 2020-03-15 01:12:28
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _MQTTCLIENT_H_
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "platform_memory.h"
|
||||
#include "platform_mutex.h"
|
||||
#include "platform_thread.h"
|
||||
#include "mqtt_config.h"
|
||||
#include "mqtt_defconfig.h"
|
||||
#include "network.h"
|
||||
#include "random.h"
|
||||
#include "error.h"
|
||||
@@ -35,6 +35,7 @@ typedef enum client_state {
|
||||
CLIENT_STATE_INITIALIZED = 0,
|
||||
CLIENT_STATE_CONNECTED = 1,
|
||||
CLIENT_STATE_DISCONNECTED = 2,
|
||||
CLIENT_STATE_CLEAN_SESSION = 3
|
||||
}client_state_t;
|
||||
|
||||
typedef struct mqtt_connack_data {
|
||||
@@ -93,10 +94,10 @@ typedef struct connect_params {
|
||||
|
||||
typedef struct mqtt_client {
|
||||
unsigned short packet_id;
|
||||
unsigned char *read_buf;
|
||||
unsigned char *write_buf;
|
||||
unsigned char ping_outstanding;
|
||||
unsigned char ack_handler_number;
|
||||
unsigned char *read_buf;
|
||||
unsigned char *write_buf;
|
||||
unsigned int cmd_timeout;
|
||||
unsigned int read_buf_size;
|
||||
unsigned int write_buf_size;
|
||||
|
@@ -2,19 +2,19 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-09 21:30:54
|
||||
* @LastEditTime : 2020-01-14 03:38:15
|
||||
* @LastEditTime: 2020-02-25 03:49:43
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "platform_timer.h"
|
||||
#include "platform_nettype_tcp.h"
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
#include "platform_nettype_tls.h"
|
||||
#endif
|
||||
|
||||
int network_read(network_t *n, unsigned char *buf, int len, int timeout)
|
||||
{
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
return platform_nettype_tls_read(n, buf, len, timeout);
|
||||
#else
|
||||
return platform_nettype_tcp_read(n, buf, len, timeout);
|
||||
@@ -23,7 +23,7 @@ int network_read(network_t *n, unsigned char *buf, int len, int timeout)
|
||||
|
||||
int network_write(network_t *n, unsigned char *buf, int len, int timeout)
|
||||
{
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
return platform_nettype_tls_write(n, buf, len, timeout);
|
||||
#else
|
||||
return platform_nettype_tcp_write(n, buf, len, timeout);
|
||||
@@ -32,7 +32,7 @@ int network_write(network_t *n, unsigned char *buf, int len, int timeout)
|
||||
|
||||
int network_connect(network_t *n)
|
||||
{
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
return platform_nettype_tls_connect(n);
|
||||
#else
|
||||
return platform_nettype_tcp_connect(n);
|
||||
@@ -41,7 +41,7 @@ int network_connect(network_t *n)
|
||||
|
||||
void network_disconnect(network_t *n)
|
||||
{
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
platform_nettype_tls_disconnect(n);
|
||||
#else
|
||||
platform_nettype_tcp_disconnect(n);
|
||||
@@ -61,7 +61,7 @@ int network_init(network_t* n, network_params_t* network_params)
|
||||
n->network_params.addr = network_params->addr;
|
||||
n->network_params.port = network_params->port;
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
n->network_params.network_ssl_params.ca_crt = network_params->network_ssl_params.ca_crt;
|
||||
n->network_params.network_ssl_params.ca_crt_len = strlen(n->network_params.network_ssl_params.ca_crt);
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
|
@@ -2,15 +2,15 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-09 21:31:02
|
||||
* @LastEditTime : 2020-01-14 03:38:32
|
||||
* @LastEditTime: 2020-02-25 03:49:11
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _NETWORK_H_
|
||||
#define _NETWORK_H_
|
||||
|
||||
#include "mqtt_config.h"
|
||||
#include "mqtt_defconfig.h"
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
typedef struct network_ssl_params {
|
||||
const char *ca_crt;
|
||||
size_t ca_crt_len;
|
||||
@@ -31,7 +31,7 @@ typedef struct network_ssl_params {
|
||||
typedef struct network_params {
|
||||
char *addr;
|
||||
char *port;
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
network_ssl_params_t network_ssl_params;
|
||||
void *nettype_tls_params;
|
||||
#endif /* MQTT_NETWORK_TYPE_TLS */
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-14 22:02:07
|
||||
* @LastEditTime : 2019-12-20 20:43:38
|
||||
* @LastEditTime: 2020-02-19 23:53:50
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "tos_k.h"
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-14 22:06:35
|
||||
* @LastEditTime : 2019-12-20 20:57:32
|
||||
* @LastEditTime: 2020-02-19 23:54:02
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _PLATFORM_MEMORY_H_
|
||||
|
@@ -10,6 +10,17 @@
|
||||
int platform_net_socket_connect(const char *host, const char *port, int proto)
|
||||
{
|
||||
int fd, ret = MQTT_SOCKET_UNKNOWN_HOST;
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
|
||||
fd = tos_sal_module_connect(host, port, TOS_SAL_PROTO_TCP);
|
||||
|
||||
if (fd < 0) {
|
||||
return MQTT_CONNECT_FAILED_ERROR;
|
||||
}
|
||||
ret = fd;
|
||||
|
||||
#else
|
||||
|
||||
struct addrinfo hints, *addr_list, *cur;
|
||||
|
||||
/* Do name resolution with both IPv6 and IPv4 */
|
||||
@@ -39,16 +50,25 @@ int platform_net_socket_connect(const char *host, const char *port, int proto)
|
||||
}
|
||||
|
||||
freeaddrinfo(addr_list);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int platform_net_socket_recv(int fd, void *buf, size_t len, int flags)
|
||||
{
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
return tos_sal_module_recv(fd, buf, len);
|
||||
#else
|
||||
return recv(fd, buf, len, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int timeout)
|
||||
{
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
return tos_sal_module_recv_timeout(fd, buf, len, timeout);
|
||||
#else
|
||||
int rc;
|
||||
int bytes = 0;
|
||||
struct timeval tv = {
|
||||
@@ -73,15 +93,23 @@ int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int ti
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
int platform_net_socket_write(int fd, void *buf, size_t len)
|
||||
{
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
return tos_sal_module_send(fd, buf, len);
|
||||
#else
|
||||
return write(fd, buf, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout)
|
||||
{
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
return tos_sal_module_send(fd, buf, len);
|
||||
#else
|
||||
struct timeval tv = {
|
||||
timeout / 1000,
|
||||
(timeout % 1000) * 1000
|
||||
@@ -92,16 +120,23 @@ int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int t
|
||||
tv.tv_usec = 100;
|
||||
}
|
||||
|
||||
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval));
|
||||
platform_net_socket_setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval));
|
||||
|
||||
return write(fd, buf, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
int platform_net_socket_close(int fd)
|
||||
{
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
return tos_sal_module_close(fd);
|
||||
#else
|
||||
return close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef MQTT_NETSOCKET_USE_AT
|
||||
|
||||
int platform_net_socket_set_block(int fd)
|
||||
{
|
||||
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, F_GETFL) & ~O_NONBLOCK);
|
||||
@@ -117,3 +152,4 @@ int platform_net_socket_setsockopt(int fd, int level, int optname, const void *o
|
||||
return setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -2,20 +2,28 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2019-12-15 13:39:00
|
||||
* @LastEditTime : 2020-01-12 00:22:22
|
||||
* @LastEditTime: 2020-02-19 01:02:51
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#ifndef _PLATFORM_NET_SOCKET_H_
|
||||
#define _PLATFORM_NET_SOCKET_H_
|
||||
|
||||
#include "network.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifdef MQTT_NETSOCKET_USE_AT
|
||||
|
||||
#include "sal_module_wrapper.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/api.h"
|
||||
#include <lwip/sockets.h>
|
||||
#include "lwip/netdb.h"
|
||||
|
||||
#include "network.h"
|
||||
#include "error.h"
|
||||
#endif
|
||||
|
||||
#define PLATFORM_NET_PROTO_TCP 0 /**< The TCP transport protocol */
|
||||
#define PLATFORM_NET_PROTO_UDP 1 /**< The UDP transport protocol */
|
||||
@@ -26,8 +34,11 @@ int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int ti
|
||||
int platform_net_socket_write(int fd, void *buf, size_t len);
|
||||
int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout);
|
||||
int platform_net_socket_close(int fd);
|
||||
|
||||
#ifndef MQTT_NETSOCKET_USE_AT
|
||||
int platform_net_socket_set_block(int fd);
|
||||
int platform_net_socket_set_nonblock(int fd);
|
||||
int platform_net_socket_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
|
||||
#endif
|
||||
|
||||
#endif /* _PLATFORM_NET_SOCKET_H_ */
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-01-11 19:45:35
|
||||
* @LastEditTime : 2020-01-16 00:17:56
|
||||
* @LastEditTime: 2020-03-05 23:52:30
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
#include "platform_nettype_tls.h"
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "platform_timer.h"
|
||||
#include "random.h"
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls\x509_crt.h"
|
||||
#include "mbedtls\pk.h"
|
||||
|
||||
#if !defined(MBEDTLS_FS_IO)
|
||||
static const int ciphersuites[] = { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, 0 };
|
||||
@@ -28,7 +30,8 @@ static const int ciphersuites[] = { MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, MBEDTL
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
static int server_certificate_verify(void *hostname, mbedtls_x509_crt *crt, int depth, uint32_t *flags)
|
||||
{
|
||||
LOG_I("%s:%d %s()... server_certificate_verify failed returned 0x%04x\n", __FILE__, __LINE__, __FUNCTION__, *flags);
|
||||
if (0 != *flags)
|
||||
LOG_E("%s:%d %s()... server_certificate_verify failed returned 0x%04x\n", __FILE__, __LINE__, __FUNCTION__, *flags);
|
||||
return *flags;
|
||||
}
|
||||
#endif
|
||||
@@ -110,12 +113,12 @@ static int platform_nettype_tls_init(network_t* n, nettype_tls_params_t* nettype
|
||||
if (n->network_params.network_ssl_params.cert_file != NULL && n->network_params.network_ssl_params.key_file != NULL) {
|
||||
if ((rc = mbedtls_x509_crt_parse_file(&(nettype_tls_params->client_cert), n->network_params.network_ssl_params.cert_file)) != 0) {
|
||||
LOG_E("%s:%d %s()... load client cert file failed returned 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
return PLATFORM_ERR_SSL_CERT;
|
||||
return MQTT_SSL_CERT_ERROR;
|
||||
}
|
||||
|
||||
if ((rc = mbedtls_pk_parse_keyfile(&(nettype_tls_params->private_key), n->network_params.network_ssl_params.key_file, "")) != 0) {
|
||||
LOG_E("%s:%d %s()... load client key file failed returned 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
return PLATFORM_ERR_SSL_CERT;
|
||||
return MQTT_SSL_CERT_ERROR;
|
||||
}
|
||||
} else {
|
||||
LOG_I("%s:%d %s()... cert_file/key_file is empty! | cert_file = %s | key_file = %s", __FILE__, __LINE__, __FUNCTION__,
|
||||
@@ -129,12 +132,13 @@ static int platform_nettype_tls_init(network_t* n, nettype_tls_params_t* nettype
|
||||
n->network_params.network_ssl_params.psk_length, (const unsigned char *) psk_id, strlen( psk_id ));
|
||||
|
||||
mbedtls_ssl_conf_ciphersuites(&(nettype_tls_params->ssl_conf), ciphersuites);
|
||||
|
||||
if (0 != rc) {
|
||||
LOG_E("%s:%d %s()... mbedtls_ssl_conf_psk fail: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != rc) {
|
||||
LOG_E("%s:%d %s()... mbedtls_ssl_conf_psk fail: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -277,7 +281,7 @@ int platform_nettype_tls_read(network_t *n, unsigned char *buf, int len, int tim
|
||||
if (rc > 0) {
|
||||
read_len += rc;
|
||||
} else if ((rc == 0) || ((rc != MBEDTLS_ERR_SSL_WANT_WRITE) && (rc != MBEDTLS_ERR_SSL_WANT_READ) && (rc != MBEDTLS_ERR_SSL_TIMEOUT))) {
|
||||
LOG_E("%s:%d %s()... mbedtls_ssl_read failed: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
// LOG_E("%s:%d %s()... mbedtls_ssl_read failed: 0x%04x", __FILE__, __LINE__, __FUNCTION__, (rc < 0 )? -rc : rc);
|
||||
break;
|
||||
}
|
||||
} while((!platform_timer_is_expired(&timer)) && (read_len < len));
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: jiejie
|
||||
* @Github: https://github.com/jiejieTop
|
||||
* @Date: 2020-01-11 19:45:44
|
||||
* @LastEditTime : 2020-01-13 07:26:26
|
||||
* @LastEditTime: 2020-02-25 03:51:37
|
||||
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
|
||||
*/
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#define _PLATFORM_NETTYPE_TLS_H_
|
||||
|
||||
#include "platform_net_socket.h"
|
||||
#include "mqtt_config.h"
|
||||
#include "mqtt_defconfig.h"
|
||||
#include "network.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
|
||||
#if MQTT_NETWORK_TYPE_TLS
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
|
||||
typedef struct nettype_tls_params {
|
||||
mbedtls_net_context socket_fd; /**< mbed TLS network context. */
|
||||
|
@@ -38,6 +38,23 @@ platform_thread_t *platform_thread_init( const char *name,
|
||||
return thread;
|
||||
}
|
||||
|
||||
void platform_thread_startup(platform_thread_t* thread)
|
||||
{
|
||||
(void)thread;
|
||||
}
|
||||
|
||||
|
||||
void platform_thread_stop(platform_thread_t* thread)
|
||||
{
|
||||
tos_task_suspend(&(thread->thread));
|
||||
}
|
||||
|
||||
void platform_thread_start(platform_thread_t* thread)
|
||||
{
|
||||
tos_task_resume(&(thread->thread));
|
||||
}
|
||||
|
||||
|
||||
void platform_thread_destroy(platform_thread_t* thread)
|
||||
{
|
||||
if (NULL != thread)
|
||||
|
@@ -20,6 +20,9 @@ platform_thread_t *platform_thread_init( const char *name,
|
||||
unsigned int stack_size,
|
||||
unsigned int priority,
|
||||
unsigned int tick);
|
||||
void platform_thread_startup(platform_thread_t* thread);
|
||||
void platform_thread_stop(platform_thread_t* thread);
|
||||
void platform_thread_start(platform_thread_t* thread);
|
||||
void platform_thread_destroy(platform_thread_t* thread);
|
||||
|
||||
#endif
|
||||
|
105
examples/mqttclient/gokit3_mqttclient.c
Normal file
105
examples/mqttclient/gokit3_mqttclient.c
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "bsp_init.h"
|
||||
#include "tos_k.h"
|
||||
#include "esp8266.h"
|
||||
#include "mqttclient.h"
|
||||
|
||||
k_task_t task;
|
||||
k_stack_t task_stack[2048];
|
||||
|
||||
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__,
|
||||
msg->topic_name, msg->message->qos, (char*)msg->message->payload);
|
||||
LOG_I("-----------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||
void mqttclient_task(void *Parameter)
|
||||
{
|
||||
int error;
|
||||
|
||||
char buf[100] = { 0 };
|
||||
|
||||
mqtt_message_t msg;
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
||||
esp8266_sal_init(HAL_UART_PORT_2);
|
||||
esp8266_join_ap("wifii", "woshijiejie");
|
||||
|
||||
init_params.read_buf_size = 256;
|
||||
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 = "www.jiejie01.top"; //"47.95.164.112";//"jiejie01.top"; //"129.204.201.235"; //"192.168.1.101";
|
||||
|
||||
init_params.connect_params.user_name = random_string(10); // random_string(10); //"jiejietop-acer1";
|
||||
init_params.connect_params.password = random_string(10);; //random_string(10); // "123456";
|
||||
init_params.connect_params.client_id = random_string(10);; //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_subscribe(&client, "tos-topic", QOS0, tos_topic_handler);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
k_err_t err;
|
||||
|
||||
bsp_init();
|
||||
|
||||
printf("Welcome to TencentOS tiny\r\n");
|
||||
|
||||
tos_knl_init(); // TOS Tiny kernel initialize
|
||||
|
||||
printf("create mqttclient task\r\n");
|
||||
err = tos_task_create(&task,
|
||||
"mqttclient-task",
|
||||
mqttclient_task,
|
||||
NULL,
|
||||
3,
|
||||
task_stack,
|
||||
1024,
|
||||
20);
|
||||
if(err != K_ERR_NONE)
|
||||
printf("TencentOS Create mqttclient task fail! code : %d \r\n",err);
|
||||
|
||||
tos_knl_start(); // Start TOS Tiny
|
||||
|
||||
}
|
@@ -46,9 +46,15 @@ void application_entry(void *arg)
|
||||
|
||||
init_params.read_buf_size = 1024;
|
||||
init_params.write_buf_size = 1024;
|
||||
|
||||
#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.addr = "www.jiejie01.top";
|
||||
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 = "www.jiejie01.top"; //"47.95.164.112";//"jiejie01.top"; //"129.204.201.235"; //"192.168.1.101";
|
||||
|
||||
init_params.connect_params.user_name = random_string(10);
|
||||
init_params.connect_params.password = random_string(10);
|
||||
init_params.connect_params.client_id = random_string(10);
|
||||
@@ -63,11 +69,15 @@ void application_entry(void *arg)
|
||||
LOG_D("mqtt connect error is %#x", error);
|
||||
|
||||
mqtt_subscribe(&client, "tos-topic", QOS0, tos_topic_handler);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
@@ -7,36 +7,37 @@
|
||||
*/
|
||||
static const char *test_ca_crt = {
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIIFlzCCBH+gAwIBAgIQBf0c/dicZUkWCJnzWyxOuDANBgkqhkiG9w0BAQsFADBy\r\n"
|
||||
"MIIFrTCCBJWgAwIBAgIQDApSGhCHMtFicAaXgcO0vjANBgkqhkiG9w0BAQsFADBy\r\n"
|
||||
"MQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywg\r\n"
|
||||
"SW5jLjEdMBsGA1UECxMURG9tYWluIFZhbGlkYXRlZCBTU0wxHTAbBgNVBAMTFFRy\r\n"
|
||||
"dXN0QXNpYSBUTFMgUlNBIENBMB4XDTE5MDMyOTAwMDAwMFoXDTIwMDMyODEyMDAw\r\n"
|
||||
"dXN0QXNpYSBUTFMgUlNBIENBMB4XDTIwMDEyOTAwMDAwMFoXDTIxMDQyODEyMDAw\r\n"
|
||||
"MFowGzEZMBcGA1UEAxMQd3d3LmppZWppZTAxLnRvcDCCASIwDQYJKoZIhvcNAQEB\r\n"
|
||||
"BQADggEPADCCAQoCggEBAKV5ot0wC7L2sa2ABzLDaYYmxbX61FpHYscY8R1R8nUQ\r\n"
|
||||
"pRfbj8eCNcg6DZf85OX/sSmtqRnk2Z+Nu9ML5KO5sSvVCr/eL0bW8jqlQ39FuyoR\r\n"
|
||||
"vsLkUP8iXIkHyEulPagYK8yFNCf0eR0c/SQO0U+UI4JrVOtwFHV/y8IbZ9pEboBH\r\n"
|
||||
"2II2OYC8azavFoUQXVn+niQiYJb9KGN6Jz4mCgVeGXfoKjW5qtQuCtj0rdpDx+UX\r\n"
|
||||
"JWP5ktLCCfV5Ke+Vb0Ovahr8kASremR/XSh+K8pP+94uxrMp79wc4YVEiMbKEb8j\r\n"
|
||||
"PVnOJwF7d7bjOU2M0baq5ouxE1xl8c2xIc8zABIrUuMCAwEAAaOCAn4wggJ6MB8G\r\n"
|
||||
"A1UdIwQYMBaAFH/TmfOgRw4xAFZWIo63zJ7dygGKMB0GA1UdDgQWBBS4EllqeVPA\r\n"
|
||||
"jt5ZiROEesnBWP5vDTApBgNVHREEIjAgghB3d3cuamllamllMDEudG9wggxqaWVq\r\n"
|
||||
"BQADggEPADCCAQoCggEBAKIDMo45w085LaCMG1LWY5b8V94zDqdt+weVhKolgsLZ\r\n"
|
||||
"htAQTDrafBx1sNJtOpa8ADeQkFbWOTEy3tgViOBvBr+8Qhl6vYsESJrg7DXeCVRm\r\n"
|
||||
"04pk+cFrdWYRE70AUz8RXRuaWLv1Fu2L+qlymrnZB/WBJFnETINh6yzqY8FNETUV\r\n"
|
||||
"EL08eE0LoXt/4b7iAJYEFRYTyBKjLpkr04e92SQIuL/l42j92lYNOjYfYOlpWZUC\r\n"
|
||||
"cp4WHXEDd1YXdTMmXpfsU3VlYS3RTusOFsgXpLFET9xGRvtDSu5qw6rPGf/y/PhT\r\n"
|
||||
"1LFB/xlL2E6Rpo/6VWuQ8A5rA+H3D1I/fIBB97orMYUCAwEAAaOCApQwggKQMB8G\r\n"
|
||||
"A1UdIwQYMBaAFH/TmfOgRw4xAFZWIo63zJ7dygGKMB0GA1UdDgQWBBQyzyOTN1l5\r\n"
|
||||
"Rg1Ih1tQ0TPYMqfw+jApBgNVHREEIjAgghB3d3cuamllamllMDEudG9wggxqaWVq\r\n"
|
||||
"aWUwMS50b3AwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr\r\n"
|
||||
"BgEFBQcDAjBMBgNVHSAERTBDMDcGCWCGSAGG/WwBAjAqMCgGCCsGAQUFBwIBFhxo\r\n"
|
||||
"dHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMAgGBmeBDAECATB9BggrBgEFBQcB\r\n"
|
||||
"AQRxMG8wIQYIKwYBBQUHMAGGFWh0dHA6Ly9vY3NwLmRjb2NzcC5jbjBKBggrBgEF\r\n"
|
||||
"BQcwAoY+aHR0cDovL2NhY2VydHMuZGlnaXRhbGNlcnR2YWxpZGF0aW9uLmNvbS9U\r\n"
|
||||
"cnVzdEFzaWFUTFNSU0FDQS5jcnQwCQYDVR0TBAIwADCCAQQGCisGAQQB1nkCBAIE\r\n"
|
||||
"gfUEgfIA8AB2ALvZ37wfinG1k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABacpL\r\n"
|
||||
"x9kAAAQDAEcwRQIgbNEvEkLAgPDhqZGrXqV3rmByWiQ5CgTUnRo8vRKYH7ICIQDS\r\n"
|
||||
"V+bNpM7cOoPADyZsmRDxdu+kUfkhD3csdkALmMyobAB2AId1v+dZfPiMQ5lfvfNu\r\n"
|
||||
"/1aNR1Y2/0q1YMG06v9eoIMPAAABacpLyO0AAAQDAEcwRQIgP69W3D/iVIaVFVc/\r\n"
|
||||
"+I98YB083woBDWfquBpZq2dXA5ECIQDtP465d8Q0UuNK1gRYCZOe1Daexdndkt2g\r\n"
|
||||
"8zServG3HjANBgkqhkiG9w0BAQsFAAOCAQEADgP0Q4vUgYAR6e98x/tP12Rpsqkt\r\n"
|
||||
"l0Mbpr12lqSDmH2QfmoWRIRmyRrbpR2fkPKikrib3ezTmSJI70saELY8ceLZiaQu\r\n"
|
||||
"Vq6zT/8xXDUcWJbeRgUVo8J3b20oxJLLsf8QmmEMdycKsUJv0iybQq9CCqay8Tq3\r\n"
|
||||
"mGJ2bc6zAqWUjcugLSvh/c6QPp9d8UGyVre/UJFbGVpk8swkhXFTypUVcm+TNqzW\r\n"
|
||||
"A3kKC3k5Sk+l1CTNHgQTO7+T+/9anzLuyf/FNTO3WLav/J/FobMbXycqbwYemisk\r\n"
|
||||
"kS9xodt6dEDc5wf8nWlUOHzU/n0WCjr4Cgl1gRdTRFwy+cLEhLMZOu4vjQ==\r\n"
|
||||
"dHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMAgGBmeBDAECATCBkgYIKwYBBQUH\r\n"
|
||||
"AQEEgYUwgYIwNAYIKwYBBQUHMAGGKGh0dHA6Ly9zdGF0dXNlLmRpZ2l0YWxjZXJ0\r\n"
|
||||
"dmFsaWRhdGlvbi5jb20wSgYIKwYBBQUHMAKGPmh0dHA6Ly9jYWNlcnRzLmRpZ2l0\r\n"
|
||||
"YWxjZXJ0dmFsaWRhdGlvbi5jb20vVHJ1c3RBc2lhVExTUlNBQ0EuY3J0MAkGA1Ud\r\n"
|
||||
"EwQCMAAwggEEBgorBgEEAdZ5AgQCBIH1BIHyAPAAdQB9PvL4j/+IVWgkwsDKnlKJ\r\n"
|
||||
"eSvFDngJfy5ql2iZfiLw1wAAAW/wKSTgAAAEAwBGMEQCIGFq0FdvZfXf4lV20Am1\r\n"
|
||||
"HRP6F7wxzkesK0r1566sNqvxAiBp5W3iTLWEgeJa/PfH5hX/d+K5CIyXScLa4qqa\r\n"
|
||||
"MCLHwwB3AFzcQ5L+5qtFRLFemtRW5hA3+9X6R9yhc5SyXub2xw7KAAABb/ApJJIA\r\n"
|
||||
"AAQDAEgwRgIhANEsjShyRf0GGpwJ6ZTQKBHo933rlSpaNIvor7cG8RBQAiEAkeDf\r\n"
|
||||
"7+n+zyEGZUMOYI0E0R2chjPBJGvtw1yD12sxekowDQYJKoZIhvcNAQELBQADggEB\r\n"
|
||||
"AIzaZ5X1So+xVe2JWkMfmJA8IQhdp9WghCDLRORcIggcY9BtYxFSBdusxIa1bhdt\r\n"
|
||||
"rCY6RoepCwTrhV9PotwMgZtSOu8szHHRlqX8zNUhIh628yzPSTDDZ4xgeJvlGAkT\r\n"
|
||||
"Zlv0XrezkDLRZkKN9R6KX1ccaPNbn9PD6SMtpHPbE7UEZYfrV3wAJhFzsyhp2JF4\r\n"
|
||||
"KLLNPaeDgDM3Lu6tUm/bznDEyxi7/ZoR+7fSQAMF5Jo1ysKUAOC00I9Ne+7eSbTh\r\n"
|
||||
"flV//8NBN+Z2ShCV0uFedf6ugDUMOuOUCtp0c7N+sM1IVE5MOhLRDAGRIUyi7/43\r\n"
|
||||
"dJ0Okust1fXo4UTDGJtyp30=\r\n"
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIIErjCCA5agAwIBAgIQBYAmfwbylVM0jhwYWl7uLjANBgkqhkiG9w0BAQsFADBh\r\n"
|
||||
|
Reference in New Issue
Block a user