add socket wrapper for at framework
you can use at framework to send/recv data in socket API example: see examples\tcp_through_module_based_at_socket project: see board\TencentOS_tiny_EVB_MX_Plus\KEIL\tcp_through_module_based_at_socket
This commit is contained in:
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 1u
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(ARMCC_V5) && !defined(__TARGET_FPU_SOFTVFP)) || \
|
||||
(defined(ARMCC_V6) && defined(__ARM_PCS_VFP))
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 1u
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#ifndef __ARMVFP__
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(ARMCC_V5) && !defined(__TARGET_FPU_SOFTVFP)) || \
|
||||
(defined(ARMCC_V6) && defined(__ARM_PCS_VFP))
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 1u
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#ifndef __ARMVFP__
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -18,13 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,12 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_64
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_64
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_64
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_64
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 1u
|
||||
|
@@ -21,17 +21,17 @@
|
||||
/* The stack type changes depending on the data model. */
|
||||
#if( __DATA_MODEL__ == __DATA_MODEL_SMALL__ )
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_16
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_16
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_16
|
||||
#else
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#endif
|
||||
|
||||
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
// #define TOS_CFG_CPU_HRTIMER_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -9,5 +9,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,10 +18,12 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -26,5 +26,8 @@
|
||||
#define CPU_STK_GROWTH_ASCENDING 1
|
||||
#define CPU_STK_GROWTH_DESCENDING 2
|
||||
|
||||
#define CPU_BYTE_ORDER_LITTLE_ENDIAN 1
|
||||
#define CPU_BYTE_ORDER_BIG_ENDIAN 2
|
||||
|
||||
#endif /* _TOS_CPU_DEF_H_ */
|
||||
|
||||
|
@@ -18,13 +18,13 @@
|
||||
#ifndef _PORT_CONFIG_H_
|
||||
#define _PORT_CONFIG_H_
|
||||
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_08
|
||||
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
|
||||
#define TOS_CFG_CPU_HRTIMER_EN 0u
|
||||
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
|
||||
#define TOS_CFG_CPU_ARM_FPU_EN 0u
|
||||
#define TOS_CFG_CPU_BYTE_ORDER CPU_BYTE_ORDER_LITTLE_ENDIAN
|
||||
|
||||
#endif /* _PORT_CONFIG_H_ */
|
||||
|
||||
|
@@ -0,0 +1,77 @@
|
||||
#include "esp8266.h"
|
||||
#include "mcu_init.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "tos_at_socket.h"
|
||||
|
||||
#define TCP_TEST_TASK_STK_SIZE 4096
|
||||
void tcp_test(void);
|
||||
osThreadDef(tcp_test, osPriorityNormal, 1, TCP_TEST_TASK_STK_SIZE);
|
||||
|
||||
#define RECV_LEN 1024
|
||||
uint8_t recv_data[RECV_LEN];
|
||||
|
||||
void tcp_test(void)
|
||||
{
|
||||
int recv_len = -1;
|
||||
int fd, rc, cnt = 0;
|
||||
|
||||
struct sockaddr_in addr;
|
||||
|
||||
bzero(&addr, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = inet_addr("39.108.190.129");
|
||||
addr.sin_port = htons(8080);
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
printf("socket failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
|
||||
if (rc < 0) {
|
||||
printf("connect failed\n");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
send(fd, (const void*)"This is TCP Test!\r\n", strlen("This is TCP Test!\r\n"), 0);
|
||||
|
||||
recv_len = recv(fd, recv_data, sizeof(recv_data), 0);
|
||||
if (recv_len < 0) {
|
||||
printf("task receive error\n");
|
||||
} else if (recv_len == 0) {
|
||||
printf("task receive none\n");
|
||||
} else {
|
||||
recv_data[recv_len] = 0;
|
||||
printf("task: receive len: %d\nmsg from remote: %s\n", recv_len, recv_data);
|
||||
}
|
||||
|
||||
if (++cnt >= 20) {
|
||||
break;
|
||||
}
|
||||
|
||||
tos_sleep_ms(2000);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
#define USE_ESP8266
|
||||
|
||||
void application_entry(void *arg)
|
||||
{
|
||||
#ifdef USE_ESP8266
|
||||
esp8266_sal_init(HAL_UART_PORT_0);
|
||||
esp8266_join_ap("SheldonDai", "srnr6x9xbhmb0");
|
||||
#endif
|
||||
|
||||
#ifdef USE_SIM800A
|
||||
sim800a_power_on();
|
||||
sim800a_sal_init(HAL_UART_PORT_2);
|
||||
#endif
|
||||
|
||||
osThreadCreate(osThread(tcp_test), NULL);
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@
|
||||
#define MQTT_PRODUCT_ID "RUAP1R610V"
|
||||
#define MQTT_DEV_NAME "supowang"
|
||||
#define MQTT_CLIENT_ID "RUAP1R610Vsupowang"
|
||||
#define MQTT_USR_NAME "RUAP1R610Vsupowang;21010406;12365;4294967295"
|
||||
#define MQTT_PASSWORD "1371ae55cd1036f088bd7e39d230712bc3c32c40;hmacsha1"
|
||||
#define MQTT_USR_NAME "RUAP1R610Vsupowang;12010126;LQUY4;1620700055"
|
||||
#define MQTT_PASSWORD "98398cb32f7cb9d73da51fea84bf400c7f17a3303548624731d76fa8db3b43ff;hmacsha256"
|
||||
#define MQTT_SUBSCRIBE_TOPIC "RUAP1R610V/supowang/data"
|
||||
#define MQTT_PUBLISH_TOPIC "RUAP1R610V/supowang/data"
|
||||
|
||||
|
@@ -67,9 +67,9 @@
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_HRTIMER_EN
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_HRTIMER_EN should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_HRTIMER_EN should be declared in 'port_config.h'"
|
||||
#elif (TOS_CFG_CPU_HRTIMER_EN > 0u) && !defined(TOS_CFG_CPU_HRTIMER_SIZE)
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_HRTIMER_SIZE should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_HRTIMER_SIZE should be declared in 'port_config.h'"
|
||||
#elif (TOS_CFG_CPU_HRTIMER_EN > 0u) && ((TOS_CFG_CPU_HRTIMER_SIZE != CPU_WORD_SIZE_08) && \
|
||||
(TOS_CFG_CPU_HRTIMER_SIZE != CPU_WORD_SIZE_16) && \
|
||||
(TOS_CFG_CPU_HRTIMER_SIZE != CPU_WORD_SIZE_32) && \
|
||||
@@ -78,18 +78,22 @@
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT, should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT, should be declared in 'port_config.h'"
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_BYTE_ORDER
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_BYTE_ORDER, should be declared in 'port_config.h'"
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_STK_GROWTH
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_STK_GROWTH, should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_STK_GROWTH, should be declared in 'port_config.h'"
|
||||
#elif ((TOS_CFG_CPU_STK_GROWTH != CPU_STK_GROWTH_ASCENDING) && \
|
||||
(TOS_CFG_CPU_STK_GROWTH != CPU_STK_GROWTH_DESCENDING))
|
||||
#error "INVALID config, TOS_CFG_CPU_STK_GROWTH"
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_ADDR_SIZE
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_ADDR_SIZE, should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_ADDR_SIZE, should be declared in 'port_config.h'"
|
||||
#elif ((TOS_CFG_CPU_ADDR_SIZE != CPU_WORD_SIZE_08) && \
|
||||
(TOS_CFG_CPU_ADDR_SIZE != CPU_WORD_SIZE_16) && \
|
||||
(TOS_CFG_CPU_ADDR_SIZE != CPU_WORD_SIZE_32) && \
|
||||
@@ -98,7 +102,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_CPU_DATA_SIZE
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_DATA_SIZE, should be declared in 'port.h'"
|
||||
#error "UNDECLARED config, TOS_CFG_CPU_DATA_SIZE, should be declared in 'port_config.h'"
|
||||
#elif ((TOS_CFG_CPU_DATA_SIZE != CPU_WORD_SIZE_08) && \
|
||||
(TOS_CFG_CPU_DATA_SIZE != CPU_WORD_SIZE_16) && \
|
||||
(TOS_CFG_CPU_DATA_SIZE != CPU_WORD_SIZE_32) && \
|
||||
|
@@ -99,14 +99,6 @@
|
||||
/////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// disable default
|
||||
#ifndef TOS_CFG_MMBLK_EN
|
||||
#define TOS_CFG_MMBLK_EN 0u
|
||||
#endif
|
||||
/////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// disable default
|
||||
#ifndef TOS_CFG_FAULT_BACKTRACE_EN
|
||||
@@ -232,10 +224,6 @@
|
||||
#define TOS_CFG_TASK_PRIO_MAX 8u
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_MMBLK_EN
|
||||
#define TOS_CFG_MMBLK_EN 0u
|
||||
#endif
|
||||
|
||||
#ifndef TOS_CFG_MMHEAP_EN
|
||||
#define TOS_CFG_MMHEAP_EN 0u
|
||||
#endif
|
||||
|
@@ -23,8 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TOS_MACRO_BEGIN do {
|
||||
#define TOS_MACRO_END } while (0)
|
||||
#define __MACRO_BEGIN do {
|
||||
#define __MACRO_END } while (0)
|
||||
|
||||
#define TOS_OFFSET_OF_FIELD(type, field) \
|
||||
((uint32_t)&(((type *)0)->field))
|
||||
@@ -34,59 +34,59 @@
|
||||
|
||||
#define TOS_COUNT_OF(array) (sizeof(array) / sizeof(array[0]))
|
||||
|
||||
#define TOS_PTR_SANITY_CHECK(ptr) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (unlikely(!(ptr))) { \
|
||||
return K_ERR_OBJ_PTR_NULL; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_PTR_SANITY_CHECK(ptr) \
|
||||
__MACRO_BEGIN \
|
||||
if (unlikely(!(ptr))) { \
|
||||
return K_ERR_OBJ_PTR_NULL; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#define TOS_PTR_SANITY_CHECK_RC(ptr, return_code) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (unlikely(!(ptr))) { \
|
||||
return return_code; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_PTR_SANITY_CHECK_RC(ptr, return_code) \
|
||||
__MACRO_BEGIN \
|
||||
if (unlikely(!(ptr))) { \
|
||||
return return_code; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#define TOS_IN_IRQ_CHECK() \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (unlikely(knl_is_inirq())) { \
|
||||
return K_ERR_IN_IRQ; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_IN_IRQ_CHECK() \
|
||||
__MACRO_BEGIN \
|
||||
if (unlikely(knl_is_inirq())) { \
|
||||
return K_ERR_IN_IRQ; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#if TOS_CFG_OBJECT_VERIFY_EN > 0u
|
||||
|
||||
#define TOS_OBJ_INIT(obj, obj_type) knl_object_init(&obj->knl_obj, obj_type)
|
||||
#define TOS_OBJ_DEINIT(obj) knl_object_deinit(&obj->knl_obj)
|
||||
|
||||
#define TOS_OBJ_VERIFY(obj, obj_type) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (!knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return K_ERR_OBJ_INVALID; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_OBJ_VERIFY(obj, obj_type) \
|
||||
__MACRO_BEGIN \
|
||||
if (!knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return K_ERR_OBJ_INVALID; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (!knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return return_code; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) \
|
||||
__MACRO_BEGIN \
|
||||
if (!knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return return_code; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#define TOS_OBJ_TEST(obj, obj_type) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return K_ERR_OBJ_INVALID; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_OBJ_TEST(obj, obj_type) \
|
||||
__MACRO_BEGIN \
|
||||
if (knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return K_ERR_OBJ_INVALID; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#define TOS_OBJ_TEST_RC(obj, obj_type, return_code) \
|
||||
TOS_MACRO_BEGIN \
|
||||
if (knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return return_code; \
|
||||
} \
|
||||
TOS_MACRO_END
|
||||
#define TOS_OBJ_TEST_RC(obj, obj_type, return_code) \
|
||||
__MACRO_BEGIN \
|
||||
if (knl_object_verify(&obj->knl_obj, obj_type)) { \
|
||||
return return_code; \
|
||||
} \
|
||||
__MACRO_END
|
||||
|
||||
#else
|
||||
|
||||
|
@@ -20,8 +20,6 @@
|
||||
|
||||
__CDECLS_BEGIN
|
||||
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
|
||||
#define K_MMBLK_NEXT_BLK(blk_curr, blk_size) ((void *)((cpu_addr_t)blk_curr + blk_size))
|
||||
#define K_MMBLK_ALIGN_MASK (sizeof(void *) - 1u)
|
||||
|
||||
@@ -107,5 +105,3 @@ __API__ k_err_t tos_mmblk_free(k_mmblk_pool_t *mbp, void *blk);
|
||||
|
||||
__CDECLS_END
|
||||
|
||||
#endif /* _TOS_MMBLK_H_ */
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* within TencentOS.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_k.h"
|
||||
|
||||
#if TOS_CFG_MESSAGE_QUEUE_EN > 0u
|
||||
|
||||
|
@@ -17,13 +17,10 @@
|
||||
|
||||
#include "tos_k.h"
|
||||
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
|
||||
__API__ k_err_t tos_mmblk_pool_create(k_mmblk_pool_t *mbp, void *pool_start, size_t blk_num, size_t blk_size)
|
||||
{
|
||||
uint32_t i;
|
||||
void *blk_curr;
|
||||
void *blk_next;
|
||||
void *blk_curr, *blk_next;
|
||||
|
||||
TOS_IN_IRQ_CHECK();
|
||||
TOS_PTR_SANITY_CHECK(pool_start);
|
||||
@@ -106,6 +103,7 @@ __API__ k_err_t tos_mmblk_free(k_mmblk_pool_t *mbp, void *blk)
|
||||
TOS_CPU_INT_ENABLE();
|
||||
return K_ERR_MMBLK_POOL_FULL;
|
||||
}
|
||||
|
||||
*(void **)blk = mbp->free_list;
|
||||
mbp->free_list = blk;
|
||||
++mbp->blk_free;
|
||||
@@ -113,5 +111,3 @@ __API__ k_err_t tos_mmblk_free(k_mmblk_pool_t *mbp, void *blk)
|
||||
return K_ERR_NONE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* within TencentOS.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_k.h"
|
||||
|
||||
#if TOS_CFG_PRIORITY_MESSAGE_QUEUE_EN > 0u
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
__API__ k_err_t tos_rwlock_create(k_rwlock_t *rwlock)
|
||||
{
|
||||
k_err_t err;
|
||||
|
||||
TOS_PTR_SANITY_CHECK(rwlock);
|
||||
|
||||
err = tos_sem_create(&rwlock->signal, 0u);
|
||||
|
@@ -93,7 +93,7 @@ typedef struct at_echo_st {
|
||||
size_t __w_idx;
|
||||
int __is_expecting;
|
||||
k_sem_t __expect_notify;
|
||||
int fuzzy_matching;
|
||||
int __is_fuzzy_match;
|
||||
} at_echo_t;
|
||||
|
||||
typedef void (*at_event_callback_t)(void);
|
||||
@@ -269,7 +269,7 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size
|
||||
*
|
||||
* @attention None
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
None
|
||||
*/
|
||||
__API__ void tos_at_deinit(void);
|
||||
|
@@ -1,3 +1,20 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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_UTILS_H_
|
||||
#define _TOS_AT_UTILS_H_
|
||||
|
||||
|
@@ -1,3 +1,20 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_at.h"
|
||||
|
||||
__STATIC__ at_agent_t at_agent;
|
||||
@@ -161,18 +178,16 @@ __STATIC__ int at_is_echo_expect(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(at_echo->fuzzy_matching){
|
||||
if(strstr(recv_buffer, expect)!=NULL){
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
if (at_echo->__is_fuzzy_match) {
|
||||
if (strstr(recv_buffer, expect) != NULL) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (strncmp(expect, recv_buffer, expect_len) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -346,7 +361,7 @@ __API__ int tos_at_echo_create(at_echo_t *echo, char *buffer, size_t buffer_size
|
||||
echo->status = AT_ECHO_STATUS_NONE;
|
||||
echo->__w_idx = 0;
|
||||
echo->__is_expecting = K_FALSE;
|
||||
echo->fuzzy_matching = K_FALSE;
|
||||
echo->__is_fuzzy_match = K_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -367,7 +382,7 @@ __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, siz
|
||||
echo->status = AT_ECHO_STATUS_NONE;
|
||||
echo->__w_idx = 0;
|
||||
echo->__is_expecting = K_FALSE;
|
||||
echo->fuzzy_matching = K_TRUE;
|
||||
echo->__is_fuzzy_match = K_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,20 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_at.h"
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum sal_proto_en {
|
||||
typedef enum sal_protocol_en {
|
||||
TOS_SAL_PROTO_TCP,
|
||||
TOS_SAL_PROTO_UDP,
|
||||
} sal_proto_t;
|
||||
|
66
net/socket_wrapper/include/tos_at_socket.h
Normal file
66
net/socket_wrapper/include/tos_at_socket.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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_SOCKET_H_
|
||||
#define _TOS_AT_SOCKET_H_
|
||||
|
||||
#include "tos_at_socket_lib.h"
|
||||
#include "tos_at_socket_types.h"
|
||||
|
||||
#define AF_INET 0
|
||||
|
||||
#define AF_INET6 1
|
||||
|
||||
#define AF_UNIX 2
|
||||
|
||||
/* Provides sequenced, reliable, bidirectional, connection-mode byte streams, and may provide a transmission mechanism for out-of-band data. */
|
||||
#define SOCK_STREAM 0
|
||||
|
||||
/* Provides datagrams, which are connectionless-mode, unreliable messages of fixed maximum length. */
|
||||
#define SOCK_DGRAM 1
|
||||
|
||||
/* Peeks at an incoming message. The data is treated as unread and the next recv() or similar function shall still return this data. */
|
||||
#define MSG_PEEK 0x01
|
||||
|
||||
/* Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific. */
|
||||
#define MSG_OOB 0x02
|
||||
|
||||
/* On SOCK_STREAM sockets this requests that the function block until the full amount of data can be returned. The function may return the smaller amount of data if the socket is a message-based socket, if a signal is caught, if the connection is terminated, if MSG_PEEK was specified, or if an error is pending for the socket. */
|
||||
#define MSG_WAITALL 0x04
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
|
||||
int connect(int socket, const struct sockaddr *address, socklen_t address_len);
|
||||
|
||||
int recv(int socket, void *buffer, size_t length, int flags);
|
||||
|
||||
int recvfrom(int socket, void * buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
|
||||
|
||||
int send(int socket, const void *buffer, size_t length, int flags);
|
||||
|
||||
int sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len);
|
||||
|
||||
int shutdown(int socket, int how);
|
||||
|
||||
int read(int socket, void *buffer, size_t length);
|
||||
|
||||
int close(int socket);
|
||||
|
||||
int write(int socket, const void *buffer, size_t length);
|
||||
|
||||
#endif /* _TOS_AT_SOCKET_H_ */
|
||||
|
78
net/socket_wrapper/include/tos_at_socket_lib.h
Normal file
78
net/socket_wrapper/include/tos_at_socket_lib.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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_SOCKET_LIB_H_
|
||||
#define _TOS_AT_SOCKET_LIB_H_
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_at_socket_types.h"
|
||||
|
||||
#if (TOS_CFG_CPU_BYTE_ORDER == CPU_BYTE_ORDER_BIG_ENDIAN)
|
||||
#ifndef htons
|
||||
#define htons(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef ntohs
|
||||
#define ntohs(x) (x)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef htonl
|
||||
#define htonl(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef ntohl
|
||||
#define ntohl(x) (x)
|
||||
#endif
|
||||
|
||||
#elif (TOS_CFG_CPU_BYTE_ORDER == CPU_BYTE_ORDER_LITTLE_ENDIAN)
|
||||
#ifndef htons
|
||||
#define htons(x) ((u16_t)((((x) & (u16_t)0x00ffU) << 8) | (((x) & (u16_t)0xff00U) >> 8)))
|
||||
#endif
|
||||
|
||||
#ifndef ntohs
|
||||
#define ntohs(x) htons(x)
|
||||
#endif
|
||||
|
||||
#ifndef htonl
|
||||
#define htonl(x) ((((x) & (u32_t)0x000000ffUL) << 24) | \
|
||||
(((x) & (u32_t)0x0000ff00UL) << 8) | \
|
||||
(((x) & (u32_t)0x00ff0000UL) >> 8) | \
|
||||
(((x) & (u32_t)0xff000000UL) >> 24))
|
||||
#endif
|
||||
|
||||
#ifndef ntohl
|
||||
#define ntohl(x) htonl(x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define bzero(s, n) memset(s, 0, n)
|
||||
|
||||
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
|
||||
|
||||
#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
|
||||
#define isascii(c) in_range(c, 0x20, 0x7f)
|
||||
#define isdigit(c) in_range(c, '0', '9')
|
||||
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
|
||||
#define islower(c) in_range(c, 'a', 'z')
|
||||
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
|
||||
|
||||
u32_t inet_addr(const char *cp);
|
||||
|
||||
#endif /* _TOS_AT_SOCKET_LIB_H_ */
|
||||
|
60
net/socket_wrapper/include/tos_at_socket_prv.h
Normal file
60
net/socket_wrapper/include/tos_at_socket_prv.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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_SOCKET_PRV_H_
|
||||
#define _TOS_AT_SOCKET_PRV_H_
|
||||
|
||||
#include "sal_module_wrapper.h"
|
||||
|
||||
#define SOCKET_CTL_MAX 6 /* should consistent with AT_DATA_CHANNEL_NUM */
|
||||
|
||||
typedef struct socket_control_st {
|
||||
int fd; /* the real channel id allocated by at framework.
|
||||
for some module like NBIot(bc35), you only know the channel id until you really do the
|
||||
connect to the server */
|
||||
int is_taken; /* is this control usable?(if is_taken is FALSE then it's not usable) */
|
||||
|
||||
sal_proto_t protocol;
|
||||
} socket_ctl_t;
|
||||
|
||||
int socket_id_sanity_check(int id);
|
||||
|
||||
int socket_id_set_sanity_check(int id);
|
||||
|
||||
int socket_id_alloc(void);
|
||||
|
||||
void socket_id_free(int id);
|
||||
|
||||
void socket_set_protocol(int id, sal_proto_t protocol);
|
||||
|
||||
sal_proto_t socket_get_protocol(int id);
|
||||
|
||||
void socket_set_fd(int id, int fd);
|
||||
|
||||
int socket_get_fd(int id);
|
||||
|
||||
#define SOCKET_ID_SANITY_CHECK(id) \
|
||||
if (!socket_id_sanity_check(id)) { \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define SOCKET_ID_SET_SANITY_CHECK(id) \
|
||||
if (!socket_id_set_sanity_check(id)) { \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#endif /* _TOS_AT_SOCKET_PRV_H_ */
|
58
net/socket_wrapper/include/tos_at_socket_types.h
Normal file
58
net/socket_wrapper/include/tos_at_socket_types.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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_SOCKET_TYPES_H_
|
||||
#define _TOS_AT_SOCKET_TYPES_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
typedef uint8_t u8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef uint32_t u32_t;
|
||||
|
||||
typedef int8_t s8_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
#if !defined(in_addr_t)
|
||||
typedef u32_t in_addr_t;
|
||||
#endif
|
||||
|
||||
struct in_addr {
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
struct sockaddr_in {
|
||||
u8_t sin_len;
|
||||
u8_t sin_family;
|
||||
u16_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr {
|
||||
u8_t sa_len;
|
||||
u8_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
#ifndef socklen_t
|
||||
# define socklen_t int
|
||||
#endif
|
||||
|
||||
#endif /* _TOS_AT_SOCKET_TYPES_H_ */
|
||||
|
217
net/socket_wrapper/tos_at_socket.c
Normal file
217
net/socket_wrapper/tos_at_socket.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_at_socket.h"
|
||||
#include "tos_at_socket_prv.h"
|
||||
#include "sal_module_wrapper.h"
|
||||
|
||||
int socket(int domain, int type, int protocol)
|
||||
{
|
||||
int pub_fd;
|
||||
sal_proto_t proto;
|
||||
|
||||
protocol = protocol;
|
||||
|
||||
if (domain != AF_INET) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (type == SOCK_STREAM) {
|
||||
proto = TOS_SAL_PROTO_TCP;
|
||||
} else if (type == SOCK_DGRAM) {
|
||||
proto = TOS_SAL_PROTO_UDP;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pub_fd = socket_id_alloc();
|
||||
if (pub_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
socket_set_protocol(pub_fd, proto);
|
||||
|
||||
return pub_fd;
|
||||
}
|
||||
|
||||
static int sockaddr2ip(const struct sockaddr_in *addr_in, char ip[], int ip_len)
|
||||
{
|
||||
snprintf(ip, 16, "%u.%u.%u.%u", ((uint8_t *)(&addr_in->sin_addr.s_addr))[0],
|
||||
((uint8_t *)(&addr_in->sin_addr.s_addr))[1],
|
||||
((uint8_t *)(&addr_in->sin_addr.s_addr))[2],
|
||||
((uint8_t *)(&addr_in->sin_addr.s_addr))[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sockaddr2port(const struct sockaddr_in *addr_in, char port[], int port_len)
|
||||
{
|
||||
snprintf(port, port_len, "%d", htons(addr_in->sin_port));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int connect(int socket, const struct sockaddr *address, socklen_t address_len)
|
||||
{
|
||||
int prv_fd;
|
||||
char ip[16], port[8];
|
||||
const struct sockaddr_in *addr_in = (const struct sockaddr_in *)address;
|
||||
|
||||
SOCKET_ID_SANITY_CHECK(socket);
|
||||
|
||||
if (sockaddr2ip(addr_in, ip, sizeof(ip)) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sockaddr2port(addr_in, port, sizeof(port)) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
prv_fd = tos_sal_module_connect(ip, port, socket_get_protocol(socket));
|
||||
if (prv_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
socket_set_fd(socket, prv_fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int recv(int socket, void *buffer, size_t length, int flags)
|
||||
{
|
||||
int total_len = 0, remain_len = length, recv_len;
|
||||
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
if (!(flags & MSG_WAITALL)) {
|
||||
return tos_sal_module_recv(socket_get_fd(socket), buffer, length);
|
||||
}
|
||||
|
||||
while (total_len < length) {
|
||||
recv_len = tos_sal_module_recv(socket_get_fd(socket),
|
||||
(uint8_t *)buffer + total_len,
|
||||
remain_len);
|
||||
|
||||
if (recv_len <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
remain_len -= recv_len;
|
||||
total_len += recv_len;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
|
||||
{
|
||||
int total_len = 0, remain_len = length, recv_len;
|
||||
|
||||
(void)address;
|
||||
(void)address_len;
|
||||
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
if (!(flags & MSG_WAITALL)) {
|
||||
return tos_sal_module_recvfrom(socket_get_fd(socket), buffer, length);
|
||||
}
|
||||
|
||||
while (total_len < length) {
|
||||
recv_len = tos_sal_module_recvfrom(socket_get_fd(socket),
|
||||
(uint8_t *)buffer + total_len,
|
||||
remain_len);
|
||||
|
||||
if (recv_len <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
remain_len -= recv_len;
|
||||
total_len += recv_len;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int send(int socket, const void *buffer, size_t length, int flags)
|
||||
{
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
return tos_sal_module_send(socket_get_fd(socket), buffer, length);
|
||||
}
|
||||
|
||||
int sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
|
||||
{
|
||||
(void)dest_addr;
|
||||
(void)dest_len;
|
||||
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
return tos_sal_module_send(socket_get_fd(socket), message, length);
|
||||
}
|
||||
|
||||
int shutdown(int socket, int how)
|
||||
{
|
||||
int rc;
|
||||
|
||||
how = how;
|
||||
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
if (socket_id_set_sanity_check(socket)) {
|
||||
rc = tos_sal_module_close(socket_get_fd(socket));
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
socket_id_free(socket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read(int socket, void *buffer, size_t length)
|
||||
{
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
return tos_sal_module_recv(socket_get_fd(socket), buffer, length);
|
||||
}
|
||||
|
||||
int close(int socket)
|
||||
{
|
||||
int rc;
|
||||
|
||||
SOCKET_ID_SANITY_CHECK(socket);
|
||||
|
||||
if (socket_id_set_sanity_check(socket)) {
|
||||
rc = tos_sal_module_close(socket_get_fd(socket));
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
socket_id_free(socket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write(int socket, const void *buffer, size_t length)
|
||||
{
|
||||
SOCKET_ID_SET_SANITY_CHECK(socket);
|
||||
|
||||
return tos_sal_module_send(socket_get_fd(socket), buffer, length);
|
||||
}
|
||||
|
122
net/socket_wrapper/tos_at_socket_lib.c
Normal file
122
net/socket_wrapper/tos_at_socket_lib.c
Normal file
@@ -0,0 +1,122 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_at_socket_lib.h"
|
||||
|
||||
s8_t
|
||||
inet_aton(const char *cp, struct in_addr *addr)
|
||||
{
|
||||
u32_t val;
|
||||
s32_t base, n;
|
||||
char c;
|
||||
u32_t parts[4];
|
||||
u32_t* pp = parts;
|
||||
|
||||
c = *cp;
|
||||
for (;;) {
|
||||
/*
|
||||
* Collect number up to ``.''.
|
||||
* Values are specified as for C:
|
||||
* 0x=hex, 0=octal, isdigit=decimal.
|
||||
*/
|
||||
if (!isdigit(c))
|
||||
return (0);
|
||||
val = 0; base = 10;
|
||||
if (c == '0') {
|
||||
c = *++cp;
|
||||
if (c == 'x' || c == 'X')
|
||||
base = 16, c = *++cp;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
for (;;) {
|
||||
if (isdigit(c)) {
|
||||
val = (val * base) + (s16_t)(c - '0');
|
||||
c = *++cp;
|
||||
} else if (base == 16 && isxdigit(c)) {
|
||||
val = (val << 4) |
|
||||
(s16_t)(c + 10 - (islower(c) ? 'a' : 'A'));
|
||||
c = *++cp;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (c == '.') {
|
||||
/*
|
||||
* Internet format:
|
||||
* a.b.c.d
|
||||
* a.b.c (with c treated as 16 bits)
|
||||
* a.b (with b treated as 24 bits)
|
||||
*/
|
||||
if (pp >= parts + 3)
|
||||
return (0);
|
||||
*pp++ = val;
|
||||
c = *++cp;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Check for trailing characters.
|
||||
*/
|
||||
if (c != '\0' && (!isascii(c) || !isspace(c)))
|
||||
return (0);
|
||||
/*
|
||||
* Concoct the address according to
|
||||
* the number of parts specified.
|
||||
*/
|
||||
n = pp - parts + 1;
|
||||
switch (n) {
|
||||
|
||||
case 0:
|
||||
return (0); /* initial nondigit */
|
||||
|
||||
case 1: /* a -- 32 bits */
|
||||
break;
|
||||
|
||||
case 2: /* a.b -- 8.24 bits */
|
||||
if (val > 0xffffff)
|
||||
return (0);
|
||||
val |= parts[0] << 24;
|
||||
break;
|
||||
|
||||
case 3: /* a.b.c -- 8.8.16 bits */
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16);
|
||||
break;
|
||||
|
||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
||||
if (val > 0xff)
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||
break;
|
||||
}
|
||||
if (addr)
|
||||
addr->s_addr = htonl(val);
|
||||
return (1);
|
||||
}
|
||||
|
||||
u32_t inet_addr(const char *cp)
|
||||
{
|
||||
struct in_addr val;
|
||||
|
||||
if (inet_aton(cp, &val)) {
|
||||
return (val.s_addr);
|
||||
}
|
||||
|
||||
return INADDR_NONE;
|
||||
}
|
||||
|
90
net/socket_wrapper/tos_at_socket_prv.c
Normal file
90
net/socket_wrapper/tos_at_socket_prv.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tos_k.h"
|
||||
#include "tos_at_socket_prv.h"
|
||||
#include "sal_module_wrapper.h"
|
||||
|
||||
static socket_ctl_t socket_ctl_table[SOCKET_CTL_MAX] = { 0 };
|
||||
|
||||
int socket_id_sanity_check(int id)
|
||||
{
|
||||
if (id < 0 ||
|
||||
id >= TOS_COUNT_OF(socket_ctl_table) ||
|
||||
!socket_ctl_table[id].is_taken) {
|
||||
return K_FALSE;
|
||||
}
|
||||
|
||||
return K_TRUE;
|
||||
}
|
||||
|
||||
int socket_id_set_sanity_check(int id)
|
||||
{
|
||||
if (!socket_id_sanity_check(id)) {
|
||||
return K_FALSE;
|
||||
}
|
||||
|
||||
if (socket_ctl_table[id].fd == -1) {
|
||||
return K_FALSE;
|
||||
}
|
||||
|
||||
return K_TRUE;
|
||||
}
|
||||
|
||||
int socket_id_alloc(void)
|
||||
{
|
||||
int i = 0;
|
||||
socket_ctl_t *the_ctl;
|
||||
|
||||
for (i = 0; i < TOS_COUNT_OF(socket_ctl_table); ++i) {
|
||||
the_ctl = &socket_ctl_table[i];
|
||||
if (!the_ctl->is_taken) {
|
||||
the_ctl->is_taken = K_TRUE;
|
||||
the_ctl->fd = -1;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void socket_id_free(int id)
|
||||
{
|
||||
socket_ctl_table[id].is_taken = K_FALSE;
|
||||
socket_ctl_table[id].fd = -1;
|
||||
}
|
||||
|
||||
void socket_set_protocol(int id, sal_proto_t protocol)
|
||||
{
|
||||
socket_ctl_table[id].protocol = protocol;
|
||||
}
|
||||
|
||||
sal_proto_t socket_get_protocol(int id)
|
||||
{
|
||||
return socket_ctl_table[id].protocol;
|
||||
}
|
||||
|
||||
void socket_set_fd(int id, int fd)
|
||||
{
|
||||
socket_ctl_table[id].fd = fd;
|
||||
}
|
||||
|
||||
int socket_get_fd(int id)
|
||||
{
|
||||
return socket_ctl_table[id].fd;
|
||||
}
|
||||
|
@@ -356,7 +356,6 @@ osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
|
||||
|
||||
#endif // TOS_CFG_SEM_EN
|
||||
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
// ==== Memory Pool Management Functions ====
|
||||
|
||||
#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
|
||||
@@ -424,7 +423,6 @@ osStatus osPoolFree(osPoolId pool_id, void *block)
|
||||
}
|
||||
|
||||
#endif // Memory Pool Management available
|
||||
#endif // TOS_CFG_MMBLK_EN
|
||||
|
||||
#if TOS_CFG_MESSAGE_QUEUE_EN > 0u
|
||||
// ==== Message Queue Management Functions ====
|
||||
|
@@ -239,9 +239,7 @@ typedef k_sem_t *osSemaphoreId;
|
||||
|
||||
/// Pool ID identifies the memory pool (pointer to a memory pool control block).
|
||||
/// \note CAN BE CHANGED: \b os_pool_cb is implementation specific in every CMSIS-RTOS.
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
typedef k_mmblk_pool_t *osPoolId;
|
||||
#endif
|
||||
|
||||
/// Message ID identifies the message queue (pointer to a message queue control block).
|
||||
/// \note CAN BE CHANGED: \b os_messageQ_cb is implementation specific in every CMSIS-RTOS.
|
||||
@@ -297,14 +295,12 @@ typedef struct os_semaphore_def {
|
||||
|
||||
/// Definition structure for memory block allocation.
|
||||
/// \note CAN BE CHANGED: \b os_pool_def is implementation specific in every CMSIS-RTOS.
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
typedef struct os_pool_def {
|
||||
uint32_t pool_sz; ///< number of items (elements) in the pool
|
||||
uint32_t item_sz; ///< size of an item
|
||||
void *pool; ///< pointer to memory for pool
|
||||
k_mmblk_pool_t *mmblk_pool; ///< memory blk pool handler
|
||||
} osPoolDef_t;
|
||||
#endif
|
||||
|
||||
/// Definition structure for message queue.
|
||||
/// \note CAN BE CHANGED: \b os_messageQ_def is implementation specific in every CMSIS-RTOS.
|
||||
@@ -660,7 +656,6 @@ osStatus osSemaphoreDelete(osSemaphoreId semaphore_id);
|
||||
#endif // Semaphore available
|
||||
#endif // TOS_CFG_SEM_EN
|
||||
|
||||
#if TOS_CFG_MMBLK_EN > 0u
|
||||
// ==== Memory Pool Management Functions ====
|
||||
|
||||
#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
|
||||
@@ -715,7 +710,6 @@ void *osPoolCAlloc(osPoolId pool_id);
|
||||
osStatus osPoolFree(osPoolId pool_id, void *block);
|
||||
|
||||
#endif // Memory Pool Management available
|
||||
#endif // TOS_CFG_MMBLK_EN
|
||||
|
||||
#if TOS_CFG_MESSAGE_QUEUE_EN > 0u
|
||||
// ==== Message Queue Management Functions ====
|
||||
|
@@ -46,6 +46,23 @@ __API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size
|
||||
|
||||
__API__ int tos_hal_uart_read(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_Receive(uart_handle, (uint8_t *)buf, size, timeout);
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -41,6 +41,23 @@ __API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size
|
||||
|
||||
__API__ int tos_hal_uart_read(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_Receive(uart_handle, (uint8_t *)buf, size, timeout);
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,23 @@ __API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size
|
||||
|
||||
__API__ int tos_hal_uart_read(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_Receive(uart_handle, (uint8_t *)buf, size, timeout);
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -49,6 +49,23 @@ __API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size
|
||||
|
||||
__API__ int tos_hal_uart_read(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_Receive(uart_handle, (uint8_t *)buf, size, timeout);
|
||||
if (hal_status != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user