Merge pull request #7 from Tencent/master

merge
This commit is contained in:
Mculover666
2020-06-05 18:09:09 +08:00
committed by GitHub
531 changed files with 131027 additions and 7814 deletions

View File

@@ -15,9 +15,10 @@
## 1、TencentOS tiny整体架构
![](./doc/image/introduction/TencentOS_tiny_Architecture.png)
TencentOS tiny 主体架构图,从下到上主要包括:
**CPU 库** TencentOS tiny 支持的 CPU IP 核架构,当前主要支持 ARM Cortex M0/3/4/7。
**CPU 库** TencentOS tiny 支持的 CPU IP 核架构,当前主要支持 ARM Cortex M0/3/4/7Cortex A7RISC-V、MSP430、AVR、STM8等
**驱动管理层** 包括板级支持包BSP主要由 MCU 芯片厂家开发与维护、硬件抽象HAL主要由 TencentOS tiny提供方便不同芯片的适配与移植、设备驱动Drivers例如 Wi-Fi、GPRS、LoRa 等模块的驱动程序)。
@@ -60,7 +61,9 @@ TencentOS tiny 主体架构图,从下到上主要包括:
![](./doc/image/introduction/Partners.png)
TencentOS tiny目前支持STM32、NXP、华大半导体、国民技术、GD32、Nordic、TI等主流MCU。当前已完成两套官方定制开发板设计支持全系列STM32 NUCLEO官方评估板内核移植。TencentOS tiny 将携手合作伙伴为物联网终端厂家提供更优质的IoT终端软件解决方案方便各种物联网设备快速接入腾讯云共同扩展IoT生态更好地支撑智慧城市、智能水表、智能家居、智能穿戴、车联网等多种行业应用。
TencentOS tiny自开源发布以来也在努力发展合作伙伴期待合作共赢共同扩展IoT应用生态。目前已经与多家MCU/IP核厂家达成了合作包括意法半导体、恩智浦半导体、兆易半导体、ARM、华大半导体、芯来科技等也与无线SOC和模组厂家达成了广泛的合作关系包括瑞兴恒方、国民技术、Nordic蓝牙、亮牛半导体、有人物联网等
除了MCU和模组外TencentOS tiny也积极推进终端产品及项目的落地目前已经形成了AI智慧农业、智能货柜、智慧会议室等方案并且在腾讯内部与AI 平台部、腾讯微瓴、QQ family达成内部合作共同扩展行业生态同时也开始积极发展外部客户目前与深圳光合显示科技的墨水屏零售标签、鑫悦购充电桩等达成业务合作。TencentOS tiny 将携手合作伙伴为物联网终端厂家提供更优质的IoT终端软件解决方案方便各种物联网设备快速接入腾讯云共同扩展IoT生态更好地支撑智慧城市、智能水表、智能家居、智能穿戴、车联网等多种行业应用。
欢迎IoT相关项目合作有合作需求的请邮件联系TencentOS tiny官方工作人员邮箱地址 supowang@tencent.com

View File

@@ -78,7 +78,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
}
/*------------------ RealView Compiler -----------------*/
@@ -90,10 +90,16 @@ __PORT__ __ASM__ void HardFault_Handler(void)
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
MOVS r1, #0x04
TST r0, r1
BEQ _LD_MSP
MRS r1, PSP
B _EXIT
_LD_MSP
MRS r1, MSP
_EXIT
BL fault_backtrace
}
@@ -104,10 +110,14 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
"MOV r0, lr\n\t"
"TST lr, #0x04\n\t"
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"MOVS r1, #0x04\n\t"
"TST r0, r1\n\t"
"BEQ _LD_MSP\n\t"
"MRS r1, PSP\n\t"
"B _EXIT\n\t"
"_LD_MSP:\n\t"
"MRS r1, MSP\n\t"
"_EXIT:\n\t"
"BL fault_backtrace\n\t"
);
}

View File

@@ -78,7 +78,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
}
/*------------------ RealView Compiler -----------------*/

View File

@@ -76,43 +76,28 @@ __PORT__ void port_standby_mode_enter(void)
#endif
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0\n");
}
/*------------------ RealView Compiler -----------------*/
/* V5 */
#if defined(__CC_ARM)
__PORT__ __ASM__ void HardFault_Handler(void)
{
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
BL fault_backtrace
}
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
"MOV r0, lr\n\t"
"TST lr, #0x04\n\t"
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"BL fault_backtrace\n\t"
"MOVS r1, #0x04\n\t"
"TST r0, r1\n\t"
"BEQ _LD_MSP\n\t"
"MRS r1, PSP\n\t"
"B _EXIT\n"
"_LD_MSP:\n\t"
"MRS r1, MSP\n"
"_EXIT:\n\t"
"LDR r2, =fault_backtrace\n\t"
"BX r2\n\t"
);
}
#endif /* ARMCC VERSION */
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -92,7 +92,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
// k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
// k_fault_log_writer("fault diagnosis is not supported in CORTEX a7\n");
}
#if 0

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
}
/*------------------ RealView Compiler -----------------*/
@@ -107,10 +107,16 @@ __PORT__ __ASM__ void HardFault_Handler(void)
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
MOVS r1, #0x04
TST r0, r1
BEQ _LD_MSP
MRS r1, PSP
B _EXIT
_LD_MSP
MRS r1, MSP
_EXIT
BL fault_backtrace
}
@@ -121,10 +127,14 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
"MOV r0, lr\n\t"
"TST lr, #0x04\n\t"
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"MOVS r1, #0x04\n\t"
"TST r0, r1\n\t"
"BEQ _LD_MSP\n\t"
"MRS r1, PSP\n\t"
"B _EXIT\n\t"
"_LD_MSP:\n\t"
"MRS r1, MSP\n\t"
"_EXIT:\n\t"
"BL fault_backtrace\n\t"
);
}

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
}
/*------------------ RealView Compiler -----------------*/

View File

@@ -93,43 +93,28 @@ __PORT__ void port_standby_mode_enter(void)
#endif
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M0+\n");
}
/*------------------ RealView Compiler -----------------*/
/* V5 */
#if defined(__CC_ARM)
__PORT__ __ASM__ void HardFault_Handler(void)
{
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
BL fault_backtrace
}
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
"MOV r0, lr\n\t"
"TST lr, #0x04\n\t"
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"BL fault_backtrace\n\t"
"MOVS r1, #0x04\n\t"
"TST r0, r1\n\t"
"BEQ _LD_MSP\n\t"
"MRS r1, PSP\n\t"
"B _EXIT\n"
"_LD_MSP:\n\t"
"MRS r1, MSP\n"
"_EXIT:\n\t"
"LDR r2, =fault_backtrace\n\t"
"BX r2\n\t"
);
}
#endif /* ARMCC VERSION */
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -244,25 +244,6 @@ __PORT__ void port_fault_diagnosis(void)
port_fault_do_diagnosis(&regs);
}
/*------------------ RealView Compiler -----------------*/
/* V5 */
#if defined(__CC_ARM)
__PORT__ __ASM__ void HardFault_Handler(void)
{
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
BL fault_backtrace
}
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
@@ -271,11 +252,10 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"BL fault_backtrace\n\t"
"LDR r2, =fault_backtrace\n\t"
"BX r2\n\t"
);
}
#endif /* ARMCC VERSION */
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -227,25 +227,6 @@ __PORT__ void port_fault_diagnosis(void)
port_fault_do_diagnosis(&regs);
}
/*------------------ RealView Compiler -----------------*/
/* V5 */
#if defined(__CC_ARM)
__PORT__ __ASM__ void HardFault_Handler(void)
{
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
BL fault_backtrace
}
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
@@ -254,11 +235,10 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"BL fault_backtrace\n\t"
"LDR r2, =fault_backtrace\n\t"
"BX r2\n\t"
);
}
#endif /* ARMCC VERSION */
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
}
/*------------------ RealView Compiler -----------------*/

View File

@@ -16,7 +16,7 @@
*---------------------------------------------------------------------------*/
#include "tos_k.h"
#include "core_cm0plus.h"
#include "core_cm23.h"
__PORT__ void port_cpu_reset(void)
{
@@ -95,7 +95,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
}
/*------------------ RealView Compiler -----------------*/

View File

@@ -16,7 +16,7 @@
*---------------------------------------------------------------------------*/
#include "tos_k.h"
#include "core_cm0plus.h"
#include "core_cm23.h"
__PORT__ void port_cpu_reset(void)
{
@@ -93,30 +93,12 @@ __PORT__ void port_standby_mode_enter(void)
#endif
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in CORTEX M0\n");
k_fault_log_writer("fault diagnosis is not supported in CORTEX M23\n");
}
/*------------------ RealView Compiler -----------------*/
/* V5 */
#if defined(__CC_ARM)
__PORT__ __ASM__ void HardFault_Handler(void)
{
IMPORT fault_backtrace
MOV r0, lr
TST lr, #0x04
ITE EQ
MRSEQ r1, MSP
MRSNE r1, PSP
BL fault_backtrace
}
/*------------------ ARM Compiler V6 -------------------*/
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__PORT__ void __NAKED__ HardFault_Handler(void)
{
__ASM__ __VOLATILE__ (
@@ -125,11 +107,10 @@ __PORT__ void __NAKED__ HardFault_Handler(void)
"ITE EQ\n\t"
"MRSEQ r1, MSP\n\t"
"MRSNE r1, PSP\n\t"
"BL fault_backtrace\n\t"
"LDR r2, =fault_backtrace\n\t"
"BX r2\n\t"
);
}
#endif /* ARMCC VERSION */
#endif /* TOS_CFG_FAULT_BACKTRACE_EN */

View File

@@ -103,7 +103,7 @@ __PORT__ void port_standby_mode_enter(void)
#if TOS_CFG_FAULT_BACKTRACE_EN > 0u
__PORT__ void port_fault_diagnosis(void)
{
k_fault_log_writer("fault diagnosis does not supported in MSP430\n");
k_fault_log_writer("fault diagnosis is not supported in MSP430\n");
}

View File

@@ -61,7 +61,7 @@ void NMI_Handler(void)
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
void xHardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */

View File

@@ -1169,6 +1169,9 @@
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_fault.c</name>
</file>
</group>
<group>
<name>kernel</name>

View File

@@ -29,8 +29,6 @@
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 80u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u
@@ -39,5 +37,7 @@
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_FAULT_BACKTRACE_EN 1u
#endif

View File

@@ -39,8 +39,6 @@
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 80u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u

View File

@@ -39,8 +39,6 @@
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 80u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u

View File

@@ -39,8 +39,6 @@
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 80u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u

View File

@@ -62,8 +62,6 @@
// 配置是否将TIMER配置成函数模式
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_MMBLK_EN 1u

View File

@@ -52,9 +52,7 @@
// 配置是否将TIMER配置成函数模式
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_MMBLK_EN 1u
#endif /* INC_TOS_CONFIG_H_ */

View File

@@ -52,9 +52,7 @@
// 配置是否将TIMER配置成函数模式
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_MMBLK_EN 1u
#endif /* INC_TOS_CONFIG_H_ */

View File

@@ -1,7 +1,7 @@
#include "mcu_init.h"
#include "cmsis_os.h"
#define APPLICATION_TASK_STK_SIZE 512
#define APPLICATION_TASK_STK_SIZE 1024
extern void application_entry(void *arg);
osThreadDef(application_entry, osPriorityNormal, 1, APPLICATION_TASK_STK_SIZE);

View File

@@ -0,0 +1,94 @@
#include "ec20.h"
#include "mcu_init.h"
#include "tos_k.h"
#include "mqttclient.h"
//#define USE_SIM7600CE
#define USE_EC20
mqtt_client_t client;
client_init_params_t init_params;
static void tos_topic_handler(void* client, message_data_t* msg)
{
(void) client;
LOG_I("-----------------------------------------------------------------------------------");
LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__,
msg->topic_name, msg->message->qos, (char*)msg->message->payload);
LOG_I("-----------------------------------------------------------------------------------\n");
}
void mqttclient_task(void)
{
int error;
char buf[100] = { 0 };
mqtt_message_t msg;
memset(&msg, 0, sizeof(msg));
#ifdef USE_SIM7600CE
sim7600ce_sal_init(HAL_UART_PORT_2);
#endif
#ifdef USE_EC20
ec20_sal_init(HAL_UART_PORT_2);
#endif
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 = "111.230.189.156"; //"47.95.164.112";//"jiejie01.top"; //"129.204.201.235"; //"192.168.1.101";
init_params.connect_params.user_name = "RUAP1R610Vsupowang;12010126;OQHZL;1626061655"; // random_string(10); //"jiejietop-acer1";
init_params.connect_params.password = "ed41ae0cdf9100ce2aa5d5874566f8f4f77b1eab80b19ede4d1419eafe92eb54;hmacsha256"; //random_string(10); // "123456";
init_params.connect_params.client_id = "RUAP1R610Vsupowang";; //random_string(10); // "clientid-acer1";
init_params.connect_params.clean_session = 1;
log_init();
mqtt_init(&client, &init_params);
error = mqtt_connect(&client);
LOG_D("mqtt connect error is %#x", error);
//mqtt_set_interceptor_handler(&client,tos_topic_handler);
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
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, "RUAP1R610V/supowang/data", &msg);
tos_task_delay(4000);
}
}
void application_entry(void *arg)
{
mqttclient_task();
while (1) {
printf("This is a mqtt demo!\r\n");
tos_task_delay(1000);
}
}

View File

@@ -22,7 +22,7 @@
</DaveTm>
<Target>
<TargetName>LTE_DTU_SIM7600</TargetName>
<TargetName>LTE_DTU</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
@@ -45,7 +45,7 @@
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath></ListingPath>
<ListingPath>.\List\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
@@ -117,6 +117,26 @@
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
@@ -125,7 +145,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U303030303030303030303031 -O2254 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
<Name>-U303030303030303030303031 -O2254 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
@@ -135,12 +155,12 @@
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>0</aLwin>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>0</viewmode>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
@@ -274,8 +294,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\stm32f1xx_it.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_it.c</FilenameWithoutPath>
<PathWithFileName>..\..\BSP\Src\usart.c</PathWithFileName>
<FilenameWithoutPath>usart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -286,8 +306,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\usart.c</PathWithFileName>
<FilenameWithoutPath>usart.c</FilenameWithoutPath>
<PathWithFileName>..\..\BSP\Src\stm32f1xx_it_module.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_it_module.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -839,6 +859,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>52</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_stopwatch.c</PathWithFileName>
<FilenameWithoutPath>tos_stopwatch.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@@ -849,7 +881,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>52</FileNumber>
<FileNumber>53</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -869,13 +901,509 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>8</GroupNumber>
<FileNumber>53</FileNumber>
<FileNumber>54</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\examples\hello_world\hello_world.c</PathWithFileName>
<FilenameWithoutPath>hello_world.c</FilenameWithoutPath>
<PathWithFileName>..\..\BSP\Src\mqtt_client.c</PathWithFileName>
<FilenameWithoutPath>mqtt_client.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>at_framwork</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>9</GroupNumber>
<FileNumber>55</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\net\at\src\tos_at.c</PathWithFileName>
<FilenameWithoutPath>tos_at.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>devices</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>10</GroupNumber>
<FileNumber>56</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\devices\sim7600ce\sim7600ce.c</PathWithFileName>
<FilenameWithoutPath>sim7600ce.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>10</GroupNumber>
<FileNumber>57</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\devices\ec20\ec20.c</PathWithFileName>
<FilenameWithoutPath>ec20.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>sal_module_wrapper</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>58</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\net\sal_module_wrapper\sal_module_wrapper.c</PathWithFileName>
<FilenameWithoutPath>sal_module_wrapper.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>hal</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>12</GroupNumber>
<FileNumber>59</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\hal\st\stm32f1xx\src\tos_hal_uart.c</PathWithFileName>
<FilenameWithoutPath>tos_hal_uart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>60</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqttclient\mqttclient.c</PathWithFileName>
<FilenameWithoutPath>mqttclient.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/mqtt</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>61</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTConnectClient.c</PathWithFileName>
<FilenameWithoutPath>MQTTConnectClient.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>62</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTConnectServer.c</PathWithFileName>
<FilenameWithoutPath>MQTTConnectServer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>63</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTDeserializePublish.c</PathWithFileName>
<FilenameWithoutPath>MQTTDeserializePublish.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>64</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTFormat.c</PathWithFileName>
<FilenameWithoutPath>MQTTFormat.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>65</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTPacket.c</PathWithFileName>
<FilenameWithoutPath>MQTTPacket.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>66</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSerializePublish.c</PathWithFileName>
<FilenameWithoutPath>MQTTSerializePublish.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>67</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSubscribeClient.c</PathWithFileName>
<FilenameWithoutPath>MQTTSubscribeClient.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>68</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTSubscribeServer.c</PathWithFileName>
<FilenameWithoutPath>MQTTSubscribeServer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>69</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTUnsubscribeClient.c</PathWithFileName>
<FilenameWithoutPath>MQTTUnsubscribeClient.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>70</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\mqtt\MQTTUnsubscribeServer.c</PathWithFileName>
<FilenameWithoutPath>MQTTUnsubscribeServer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/salof</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>71</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log\fifo.c</PathWithFileName>
<FilenameWithoutPath>fifo.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>72</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log\format.c</PathWithFileName>
<FilenameWithoutPath>format.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>73</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log\salof.c</PathWithFileName>
<FilenameWithoutPath>salof.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>74</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log\arch\tencentos-tiny\arch.c</PathWithFileName>
<FilenameWithoutPath>arch.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>75</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log\salof_config.h</PathWithFileName>
<FilenameWithoutPath>salof_config.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/common</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>76</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\list.c</PathWithFileName>
<FilenameWithoutPath>list.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>77</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\random.c</PathWithFileName>
<FilenameWithoutPath>random.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>78</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\error.h</PathWithFileName>
<FilenameWithoutPath>error.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>79</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\common\log.h</PathWithFileName>
<FilenameWithoutPath>log.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/network</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>17</GroupNumber>
<FileNumber>80</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\network\network.c</PathWithFileName>
<FilenameWithoutPath>network.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/platform</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>81</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_memory.c</PathWithFileName>
<FilenameWithoutPath>platform_memory.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>82</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_mutex.c</PathWithFileName>
<FilenameWithoutPath>platform_mutex.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>83</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_net_socket.c</PathWithFileName>
<FilenameWithoutPath>platform_net_socket.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>84</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tcp.c</PathWithFileName>
<FilenameWithoutPath>platform_nettype_tcp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>85</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_nettype_tls.c</PathWithFileName>
<FilenameWithoutPath>platform_nettype_tls.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>86</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_thread.c</PathWithFileName>
<FilenameWithoutPath>platform_thread.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>18</GroupNumber>
<FileNumber>87</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny\platform_timer.c</PathWithFileName>
<FilenameWithoutPath>platform_timer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>mqttclient/config</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>19</GroupNumber>
<FileNumber>88</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\TOS_CONFIG\mqtt_config.h</PathWithFileName>
<FilenameWithoutPath>mqtt_config.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>

View File

@@ -7,7 +7,7 @@
<Targets>
<Target>
<TargetName>LTE_DTU_SIM7600</TargetName>
<TargetName>LTE_DTU</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
@@ -48,14 +48,14 @@
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>LTE_DTU_SIM7600\</OutputDirectory>
<OutputName>LTE_DTU_SIM7600</OutputName>
<OutputDirectory>.\OBJ\</OutputDirectory>
<OutputName>TencentOS_Tiny</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>0</BrowseInformation>
<ListingPath></ListingPath>
<ListingPath>.\List\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
@@ -338,7 +338,7 @@
<MiscControls></MiscControls>
<Define>USE_HAL_DRIVER,STM32F103xB,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\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\hal\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\..\..\devices\sim7600ce;..\..\..\..\net\sal_module_wrapper</IncludePath>
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\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\hal\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\..\..\devices\sim7600ce;..\..\..\..\net\sal_module_wrapper;..\..\..\..\net\at\include;..\..\..\..\devices\ec20;..\..\..\..\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</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -683,9 +683,9 @@
<GroupName>examples</GroupName>
<Files>
<File>
<FileName>tcp_test.c</FileName>
<FileName>mqtt_client.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\tcp_test.c</FilePath>
<FilePath>..\..\BSP\Src\mqtt_client.c</FilePath>
</File>
</Files>
</Group>
@@ -707,6 +707,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\devices\sim7600ce\sim7600ce.c</FilePath>
</File>
<File>
<FileName>ec20.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\devices\ec20\ec20.c</FilePath>
</File>
</Files>
</Group>
<Group>
@@ -729,6 +734,186 @@
</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>error.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\error.h</FilePath>
</File>
<File>
<FileName>log.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\components\connectivity\mqttclient\common\log.h</FilePath>
</File>
</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>
@@ -742,7 +927,7 @@
<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="LTE_DTU_SIM7600"/>
<targetInfo name="LTE_DTU"/>
</targetInfos>
</component>
</components>

View 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_ */

View File

@@ -1,460 +0,0 @@
/*----------------------------------------------------------------------------
* 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 6
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (1024)
#define AT_UART_RX_FIFO_BUFFER_SIZE (1024)
#define AT_RECV_CACHE_SIZE 1024
#define AT_CMD_BUFFER_SIZE 256
#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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
const char *tos_at_agent_channel_port_get(int channel_id);
#endif /* __AT_AGENT_H_ */

View File

@@ -1,23 +0,0 @@
#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

View File

@@ -1,85 +0,0 @@
#include "sim7600ce.h"
#include "mcu_init.h"
#include "sal_module_wrapper.h"
#include "cmsis_os.h"
#define TCP_TEST_TASK0_STK_SIZE 512
void tcp_test0(void);
osThreadDef(tcp_test0, osPriorityNormal, 1, TCP_TEST_TASK0_STK_SIZE);
#define TCP_TEST_TASK1_STK_SIZE 512
void tcp_test1(void);
osThreadDef(tcp_test1, osPriorityNormal, 1, TCP_TEST_TASK1_STK_SIZE);
int socket_id_0 = -1;
int socket_id_1 = -1;
#define RECV_LEN 1024
uint8_t recv_data_0[RECV_LEN];
uint8_t recv_data_1[RECV_LEN];
void tcp_test0(void)
{
int recv_len = -1;
while (1) {
tos_sal_module_send(socket_id_0, (const void*)"This is TCP Test!\r\n", strlen("This is TCP Test!\r\n"));
recv_len = tos_sal_module_recv_timeout(socket_id_0, recv_data_0, sizeof(recv_data_0), 8000);
if (recv_len < 0) {
printf("task0 receive error\n");
} else if (recv_len == 0) {
printf("task0 receive none\n");
} else {
recv_data_0[recv_len] = 0;
printf("task0: receive len: %d\nmsg from remote: %s\n", recv_len, recv_data_0);
}
tos_sleep_ms(2000);
}
}
void tcp_test1(void)
{
int recv_len = -1;
while (1) {
tos_sal_module_send(socket_id_1, (const void *)"Hello Tencent!\r\n", strlen("Hello Tencent!\r\n"));
recv_len = tos_sal_module_recv_timeout(socket_id_1, recv_data_1, sizeof(recv_data_1), 8000);
if (recv_len < 0) {
printf("task1 receive error\n\r");
} else if (recv_len == 0) {
printf("task1 receive none\n");
} else {
recv_data_1[recv_len] = 0;
printf("task1: receive len: %d\nmsg from remote: %s\n", recv_len, recv_data_1);
}
tos_sleep_ms(2000);
}
}
void application_entry(void *arg)
{
sim7600ce_sal_init(HAL_UART_PORT_2);
socket_id_0 = tos_sal_module_connect("39.108.190.129", "8080", TOS_SAL_PROTO_TCP);
if (socket_id_0 == -1) {
printf("TCP0 connect failed\r\n");
} else {
printf("TCP0 connect success! fd: %d\n", socket_id_0);
}
// socket_id_1 = tos_sal_module_connect("39.108.190.129", "8001", TOS_SAL_PROTO_TCP);
// if (socket_id_1 == -1) {
// printf("TCP1 connect failed\r\n");
// } else {
// printf("TCP1 connect success! fd: %d\n", socket_id_1);
// }
osThreadCreate(osThread(tcp_test0), NULL);
//osThreadCreate(osThread(tcp_test1), NULL);
}

View File

@@ -0,0 +1,94 @@
/*****************************************************************************
* Copyright (c) 2019, Nations Technologies Inc.
*
* All rights reserved.
* ****************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Nations' name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
* ****************************************************************************/
/**
* @file log.h
* @author Nations Solution Team
* @version v1.0.0
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#ifndef __LOG_H__
#define __LOG_H__
#ifndef LOG_ENABLE
#define LOG_ENABLE 1
#endif
#if LOG_ENABLE
#include <stdio.h>
#define LOG_NONE 0
#define LOG_ERROR 10
#define LOG_WARNING 20
#define LOG_INFO 30
#define LOG_DEBUG 40
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_DEBUG
#endif
#if LOG_LEVEL >= LOG_INFO
#define log_info(...) printf(__VA_ARGS__)
#else
#define log_info(...)
#endif
#if LOG_LEVEL >= LOG_ERROR
#define log_error(...) printf(__VA_ARGS__)
#else
#define log_error(...)
#endif
#if LOG_LEVEL >= LOG_WARNING
#define log_warning(...) printf(__VA_ARGS__)
#else
#define log_warning(...)
#endif
#if LOG_LEVEL >= LOG_DEBUG
#define log_debug(...) printf(__VA_ARGS__)
#else
#define log_debug(...)
#endif
void log_init(void);
#else /* !LOG_ENABLE */
#define log_info(...)
#define log_warning(...)
#define log_error(...)
#define log_debug(...)
#define log_init()
#endif
#define log_func() log_debug("call %s\r\n", __FUNCTION__)
#endif /* __LOG_H__ */

View File

@@ -0,0 +1,49 @@
/*****************************************************************************
* Copyright (c) 2019, Nations Technologies Inc.
*
* All rights reserved.
* ****************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Nations' name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
* ****************************************************************************/
/**
* @file main.h
* @author Nations Solution Team
* @version v1.0.0
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#ifndef __MAIN_H__
#define __MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "n32g45x.h"
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H__ */

View File

@@ -0,0 +1,17 @@
#ifndef __MCU_INIT_H
#define __MCU_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "main.h"
#include "log.h"
#include "tos_k.h"
void board_init(void);
#ifdef __cplusplus
}
#endif
#endif /*__ __MCU_INIT_H */

View File

@@ -0,0 +1,69 @@
/*****************************************************************************
* Copyright (c) 2019, Nations Technologies Inc.
*
* All rights reserved.
* ****************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Nations' name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
* ****************************************************************************/
/**
* @file n32g45x_it.h
* @author Nations Solution Team
* @version v1.0.0
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#ifndef __N32G45X_IT_H__
#define __N32G45X_IT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "n32g45x.h"
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __N32G45X_IT_H__ */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View File

@@ -0,0 +1,139 @@
/*****************************************************************************
* Copyright (c) 2019, Nations Technologies Inc.
*
* All rights reserved.
* ****************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Nations' name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
* ****************************************************************************/
/**
* @file log.c
* @author Nations Solution Team
* @version v1.0.0
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#include "log.h"
#if LOG_ENABLE
#include "n32g45x.h"
#include "n32g45x_gpio.h"
#include "n32g45x_usart.h"
#include "n32g45x_rcc.h"
#define LOG_USARTx USART2
#define LOG_PERIPH RCC_APB1_PERIPH_USART2
#define LOG_GPIO GPIOB
#define LOG_PERIPH_GPIO RCC_APB2_PERIPH_GPIOB
#define LOG_REMAP GPIO_RMP3_USART2
#define LOG_TX_PIN GPIO_PIN_4
#define LOG_RX_PIN GPIO_PIN_5
void log_init(void)
{
GPIO_InitType GPIO_InitStructure;
USART_InitType USART_InitStructure;
// close JTAG
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_AFIO | LOG_PERIPH_GPIO, ENABLE);
if (LOG_REMAP)
{
if (LOG_REMAP == GPIO_RMP3_USART2)
{
// release PB4
GPIO_ConfigPinRemap(GPIO_RMP_SW_JTAG_NO_NJTRST, ENABLE);
}
GPIO_ConfigPinRemap(LOG_REMAP, ENABLE);
}
RCC_EnableAPB1PeriphClk(LOG_PERIPH, ENABLE);
GPIO_InitStructure.Pin = LOG_TX_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitPeripheral(LOG_GPIO, &GPIO_InitStructure);
//GPIO_InitStructure.Pin = LOG_RX_PIN;
//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
//GPIO_InitPeripheral(LOG_GPIO, &GPIO_InitStructure);
USART_InitStructure.BaudRate = 115200;
USART_InitStructure.WordLength = USART_WL_8B;
USART_InitStructure.StopBits = USART_STPB_1;
USART_InitStructure.Parity = USART_PE_NO;
USART_InitStructure.HardwareFlowControl = USART_HFCTRL_NONE;
USART_InitStructure.Mode = USART_MODE_TX;
// init uart
USART_Init(USART2, &USART_InitStructure);
// enable uart
USART_Enable(USART2, ENABLE);
}
static int is_lr_sent = 0;
int fputc(int ch, FILE* f)
{
if (ch == '\r')
{
is_lr_sent = 1;
}
else if (ch == '\n')
{
if (!is_lr_sent)
{
USART_SendData(LOG_USARTx, (uint8_t)'\r');
/* Loop until the end of transmission */
while (USART_GetFlagStatus(LOG_USARTx, USART_FLAG_TXC) == RESET)
{
}
}
is_lr_sent = 0;
}
else
{
is_lr_sent = 0;
}
USART_SendData(LOG_USARTx, (uint8_t)ch);
/* Loop until the end of transmission */
while (USART_GetFlagStatus(LOG_USARTx, USART_FLAG_TXC) == RESET)
{
}
return ch;
}
#ifdef USE_FULL_ASSERT
__WEAK void assert_failed(const uint8_t* expr, const uint8_t* file, uint32_t line)
{
log_error("assertion failed: `%s` at %s:%d", expr, file, line);
while (1)
{
}
}
#endif // USE_FULL_ASSERT
#endif // LOG_ENABLE

View File

@@ -0,0 +1,56 @@
#include "mcu_init.h"
k_task_t task1;
k_stack_t task1_stack[1024];
k_task_t task2;
k_stack_t task2_stack[1024];
void task1_fun(void *arg)
{
int count = 0;
while (1) {
printf("###I am task1,count is %d \r\n",count++);
tos_task_delay(1000);
}
}
void task2_fun(void *arg)
{
int count = 0;
while (1) {
printf("***I am task2,count is %d \r\n",count++);
tos_task_delay(2000);
}
}
int main(void)
{
k_err_t err;
board_init();
printf(" Welcome to TencentOS Tiny!\r\n");
tos_knl_init(); // TencentOS Tiny kernel initialize
err = tos_task_create(&task1,
"task1",
task1_fun,
NULL,
3,
task1_stack,
1024,
20);
if(err != K_ERR_NONE)
printf("TencentOS Create task1 fail! code : %d \r\n",err);
err = tos_task_create(&task2,
"task2",
task2_fun,
NULL,
4,
task2_stack,
1024,
20);
if(err != K_ERR_NONE)
printf("TencentOS Create task2 fail! code : %d \r\n",err);
tos_knl_start(); // Start TencentOS Tiny
}

View File

@@ -0,0 +1,35 @@
#include "mcu_init.h"
void board_init(void)
{
log_init();
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file pointer to the source file name
* @param line assert_param error line source number
*/
void assert_failed(const uint8_t* expr, const uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/

View File

@@ -0,0 +1,141 @@
/*****************************************************************************
* Copyright (c) 2019, Nations Technologies Inc.
*
* All rights reserved.
* ****************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Nations' name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
* ****************************************************************************/
/**
* @file n32g45x_it.c
* @author Nations Solution Team
* @version v1.0.0
*
* @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
*/
#include "n32g45x_it.h"
#include "tos_k.h"
/** @addtogroup N32G45X_StdPeriph_Template
* @{
*/
extern __IO uint32_t CurrDataCounterEnd;
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
*/
void SysTick_Handler(void)
{
if (tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
}
/******************************************************************************/
/* N32G45X Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_n32g45x.s). */
/******************************************************************************/
/**
* @brief This function handles PPP interrupt request.
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/

View File

@@ -22,11 +22,11 @@
</DaveTm>
<Target>
<TargetName>LTE_DTU_SIM7600</TargetName>
<TargetName>TencentOS_Tiny</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>72000000</CLKADS>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
@@ -45,7 +45,7 @@
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath></ListingPath>
<ListingPath>.\Listings\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
@@ -77,7 +77,7 @@
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<CpuCode>255</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
@@ -93,7 +93,7 @@
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>1</tRfunc>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
@@ -103,7 +103,7 @@
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>6</nTsel>
<nTsel>3</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@@ -114,7 +114,7 @@
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
<pMon>BIN\CMSIS_AGDI.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
@@ -135,43 +135,26 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0N32G45x.FLM -FS08000000 -FL080000 -FP0($$Device:N32G457MEL7$Flash\N32G45x.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U303030303030303030303031 -O2254 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
<Name>UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0N32G45x -FL080000 -FS08000000 -FP0($$Device:N32G457MEL7$Flash\N32G45x.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>686</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134235520</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\..\..\..\net\at\src\tos_at.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\LTE_DTU_SIM7600\../../../../net/at/src/tos_at.c\686</Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<periodic>0</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
@@ -208,18 +191,11 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>1</EnableFlashSeq>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
<DbgClock>10000000</DbgClock>
</DebugDescription>
</TargetOption>
</Target>
<Group>
<GroupName>Application/MDK-ARM</GroupName>
<GroupName>STARTUP</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
@@ -231,15 +207,15 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>startup_stm32f103xb.s</PathWithFileName>
<FilenameWithoutPath>startup_stm32f103xb.s</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\device\startup\startup_n32g45x.s</PathWithFileName>
<FilenameWithoutPath>startup_n32g45x.s</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>Application/User</GroupName>
<GroupName>CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
@@ -251,91 +227,91 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\gpio.c</PathWithFileName>
<FilenameWithoutPath>gpio.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\i2c.c</PathWithFileName>
<FilenameWithoutPath>i2c.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\mcu_init.c</PathWithFileName>
<FilenameWithoutPath>mcu_init.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\stm32f1xx_hal_msp.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_msp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\usart.c</PathWithFileName>
<FilenameWithoutPath>usart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\stm32f1xx_it_module.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_it_module.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\device\system_n32g45x.c</PathWithFileName>
<FilenameWithoutPath>system_n32g45x.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>Drivers/STM32F1xx_HAL_Driver</GroupName>
<GroupName>FWLB</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\misc.c</PathWithFileName>
<FilenameWithoutPath>misc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_adc.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_adc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_bkp.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_bkp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_can.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_can.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_crc.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_crc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dac.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_dac.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>9</FileNumber>
@@ -343,8 +319,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dbg.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_dbg.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -355,8 +331,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_cortex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dma.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_dma.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -367,8 +343,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_dma.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dvp.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_dvp.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -379,8 +355,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_exti.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_exti.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_exti.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -391,8 +367,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_flash.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_flash.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_flash.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -403,8 +379,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_flash_ex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_gpio.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_gpio.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -415,8 +391,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_gpio.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_i2c.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_i2c.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -427,8 +403,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_gpio_ex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_iwdg.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_iwdg.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -439,8 +415,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_i2c.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_pwr.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_pwr.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -451,8 +427,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_pwr.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_qspi.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_qspi.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -463,8 +439,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_rcc.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_rcc.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_rcc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -475,8 +451,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_rcc_ex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_rtc.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_rtc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -487,8 +463,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_tim.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_sdio.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_sdio.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -499,8 +475,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_tim_ex.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_spi.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_spi.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -511,28 +487,100 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_hal_uart.c</FilenameWithoutPath>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_tim.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_tim.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_usart.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_usart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>25</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_wwdg.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_wwdg.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>26</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_xfmc.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_xfmc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>Drivers/CMSIS</GroupName>
<GroupName>USER</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>24</FileNumber>
<FileNumber>27</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\system_stm32f1xx.c</PathWithFileName>
<FilenameWithoutPath>system_stm32f1xx.c</FilenameWithoutPath>
<PathWithFileName>..\..\BSP\Src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\n32g45x_it.c</PathWithFileName>
<FilenameWithoutPath>n32g45x_it.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>29</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\log.c</PathWithFileName>
<FilenameWithoutPath>log.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>30</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\mcu_init.c</PathWithFileName>
<FilenameWithoutPath>mcu_init.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@@ -546,7 +594,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>25</FileNumber>
<FileNumber>31</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -558,24 +606,24 @@
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>26</FileNumber>
<FileNumber>32</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc\port_c.c</PathWithFileName>
<PathWithFileName>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c</PathWithFileName>
<FilenameWithoutPath>port_c.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>27</FileNumber>
<FileNumber>33</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc\port_s.S</PathWithFileName>
<PathWithFileName>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S</PathWithFileName>
<FilenameWithoutPath>port_s.S</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
@@ -590,7 +638,19 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>28</FileNumber>
<FileNumber>34</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_barrier.c</PathWithFileName>
<FilenameWithoutPath>tos_barrier.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>35</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -602,7 +662,19 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>29</FileNumber>
<FileNumber>36</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_bitmap.c</PathWithFileName>
<FilenameWithoutPath>tos_bitmap.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>37</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -614,7 +686,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>30</FileNumber>
<FileNumber>38</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -626,7 +698,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>31</FileNumber>
<FileNumber>39</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -638,7 +710,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>32</FileNumber>
<FileNumber>40</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -650,7 +722,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>33</FileNumber>
<FileNumber>41</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -662,7 +734,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>34</FileNumber>
<FileNumber>42</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -674,7 +746,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>35</FileNumber>
<FileNumber>43</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -686,7 +758,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>36</FileNumber>
<FileNumber>44</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -698,7 +770,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>37</FileNumber>
<FileNumber>45</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -710,7 +782,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>38</FileNumber>
<FileNumber>46</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -722,7 +794,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>39</FileNumber>
<FileNumber>47</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -734,7 +806,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>40</FileNumber>
<FileNumber>48</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -746,7 +818,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>41</FileNumber>
<FileNumber>49</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -758,7 +830,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>42</FileNumber>
<FileNumber>50</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -770,7 +842,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>43</FileNumber>
<FileNumber>51</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -782,7 +854,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>44</FileNumber>
<FileNumber>52</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -794,7 +866,19 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>45</FileNumber>
<FileNumber>53</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_rwlock.c</PathWithFileName>
<FilenameWithoutPath>tos_rwlock.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>54</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -806,7 +890,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>46</FileNumber>
<FileNumber>55</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -818,7 +902,19 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>47</FileNumber>
<FileNumber>56</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_stopwatch.c</PathWithFileName>
<FilenameWithoutPath>tos_stopwatch.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>57</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -830,7 +926,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>48</FileNumber>
<FileNumber>58</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -842,7 +938,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>49</FileNumber>
<FileNumber>59</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -854,7 +950,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>50</FileNumber>
<FileNumber>60</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -866,7 +962,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>51</FileNumber>
<FileNumber>61</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -876,146 +972,6 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>52</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\kernel\core\tos_stopwatch.c</PathWithFileName>
<FilenameWithoutPath>tos_stopwatch.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>tos/cmsis</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>53</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\osal\cmsis_os\cmsis_os.c</PathWithFileName>
<FilenameWithoutPath>cmsis_os.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>examples</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>8</GroupNumber>
<FileNumber>54</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\tcp_test.c</PathWithFileName>
<FilenameWithoutPath>tcp_test.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>at_framwork</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>9</GroupNumber>
<FileNumber>55</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\net\at\src\tos_at.c</PathWithFileName>
<FilenameWithoutPath>tos_at.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>devices</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>10</GroupNumber>
<FileNumber>56</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\devices\sim7600ce\sim7600ce.c</PathWithFileName>
<FilenameWithoutPath>sim7600ce.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>sal_module_wrapper</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>57</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\net\sal_module_wrapper\sal_module_wrapper.c</PathWithFileName>
<FilenameWithoutPath>sal_module_wrapper.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>hal</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>12</GroupNumber>
<FileNumber>58</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\..\platform\hal\st\stm32f1xx\src\tos_hal_uart.c</PathWithFileName>
<FilenameWithoutPath>tos_hal_uart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</ProjectOpt>

View File

@@ -7,23 +7,23 @@
<Targets>
<Target>
<TargetName>LTE_DTU_SIM7600</TargetName>
<TargetName>TencentOS_Tiny</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STM32F103RB</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
<Device>N32G457MEL7</Device>
<Vendor>Nationstech</Vendor>
<PackID>Nationstech.N32G45x_DFP.0.4.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
<Cpu>IRAM(0x20000000,0x24000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll></FlashDriverDll>
<DeviceId></DeviceId>
<RegisterFile></RegisterFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0N32G45x -FS08000000 -FL080000 -FP0($$Device:N32G457MEL7$Flash\N32G45x.FLM))</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:N32G457MEL7$firmware\CMSIS\device\n32g45x.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
@@ -33,7 +33,7 @@
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:STM32F103RB$SVD\STM32F103xx.svd</SFDFile>
<SFDFile>$$Device:N32G457MEL7$svd\N32G457.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
@@ -48,14 +48,14 @@
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>LTE_DTU_SIM7600\</OutputDirectory>
<OutputName>LTE_DTU_SIM7600</OutputName>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>TencentOS_Tiny</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>0</BrowseInformation>
<ListingPath></ListingPath>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\Listings\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
@@ -106,17 +106,17 @@
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>0</ComprImg>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments>-REMAP</SimDllArguments>
<SimDllArguments> -REMAP</SimDllArguments>
<SimDlgDll>DCM.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments></TargetDllArguments>
<TargetDlgDll>TCM.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
@@ -134,10 +134,10 @@
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4107</DriverSelection>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3></Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
@@ -174,7 +174,7 @@
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M3"</AdsCpuType>
<AdsCpuType>"Cortex-M4"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
@@ -183,7 +183,7 @@
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsVP>2</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
@@ -245,12 +245,12 @@
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x5000</Size>
<Size>0x24000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x8000000</StartAddress>
<Size>0x20000</Size>
<Size>0x80000</Size>
</IROM>
<XRAM>
<Type>0</Type>
@@ -275,7 +275,7 @@
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x8000000</StartAddress>
<Size>0x20000</Size>
<Size>0x80000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
@@ -300,7 +300,7 @@
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x5000</Size>
<Size>0x24000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
@@ -312,10 +312,10 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>4</Optim>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<OneElfS>0</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
@@ -336,9 +336,9 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define>USE_HAL_DRIVER,STM32F103xB,USE_HAL_DRIVER,STM32F103xB</Define>
<Define>N32G45X, USE_STDPERIPH_DRIVER</Define>
<Undefine></Undefine>
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\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</IncludePath>
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\core;..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\device;..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\inc;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\hal\include;..\..\TOS_CONFIG</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -366,7 +366,7 @@
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x08000000</TextAddressRange>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
@@ -380,143 +380,173 @@
</TargetOption>
<Groups>
<Group>
<GroupName>Application/MDK-ARM</GroupName>
<GroupName>STARTUP</GroupName>
<Files>
<File>
<FileName>startup_stm32f103xb.s</FileName>
<FileName>startup_n32g45x.s</FileName>
<FileType>2</FileType>
<FilePath>startup_stm32f103xb.s</FilePath>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\device\startup\startup_n32g45x.s</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Application/User</GroupName>
<GroupName>CMSIS</GroupName>
<Files>
<File>
<FileName>gpio.c</FileName>
<FileName>system_n32g45x.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\gpio.c</FilePath>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\CMSIS\device\system_n32g45x.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>FWLB</GroupName>
<Files>
<File>
<FileName>misc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\misc.c</FilePath>
</File>
<File>
<FileName>i2c.c</FileName>
<FileName>n32g45x_adc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\i2c.c</FilePath>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_adc.c</FilePath>
</File>
<File>
<FileName>n32g45x_bkp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_bkp.c</FilePath>
</File>
<File>
<FileName>n32g45x_can.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_can.c</FilePath>
</File>
<File>
<FileName>n32g45x_crc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_crc.c</FilePath>
</File>
<File>
<FileName>n32g45x_dac.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dac.c</FilePath>
</File>
<File>
<FileName>n32g45x_dbg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dbg.c</FilePath>
</File>
<File>
<FileName>n32g45x_dma.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dma.c</FilePath>
</File>
<File>
<FileName>n32g45x_dvp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_dvp.c</FilePath>
</File>
<File>
<FileName>n32g45x_exti.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_exti.c</FilePath>
</File>
<File>
<FileName>n32g45x_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_flash.c</FilePath>
</File>
<File>
<FileName>n32g45x_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_gpio.c</FilePath>
</File>
<File>
<FileName>n32g45x_i2c.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_i2c.c</FilePath>
</File>
<File>
<FileName>n32g45x_iwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_iwdg.c</FilePath>
</File>
<File>
<FileName>n32g45x_pwr.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_pwr.c</FilePath>
</File>
<File>
<FileName>n32g45x_qspi.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_qspi.c</FilePath>
</File>
<File>
<FileName>n32g45x_rcc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_rcc.c</FilePath>
</File>
<File>
<FileName>n32g45x_rtc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_rtc.c</FilePath>
</File>
<File>
<FileName>n32g45x_sdio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_sdio.c</FilePath>
</File>
<File>
<FileName>n32g45x_spi.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_spi.c</FilePath>
</File>
<File>
<FileName>n32g45x_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_tim.c</FilePath>
</File>
<File>
<FileName>n32g45x_usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_usart.c</FilePath>
</File>
<File>
<FileName>n32g45x_wwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_wwdg.c</FilePath>
</File>
<File>
<FileName>n32g45x_xfmc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\nationz\Nationstech.N32G45x_Library.0.4.0\n32g45x_std_periph_driver\src\n32g45x_xfmc.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>USER</GroupName>
<Files>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\main.c</FilePath>
</File>
<File>
<FileName>n32g45x_it.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\n32g45x_it.c</FilePath>
</File>
<File>
<FileName>log.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\log.c</FilePath>
</File>
<File>
<FileName>mcu_init.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\mcu_init.c</FilePath>
</File>
<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>..\..\BSP\Src\stm32f1xx_it.c</FilePath>
</File>
<File>
<FileName>usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\usart.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_i2c.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.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>
@@ -530,23 +560,33 @@
<File>
<FileName>port_c.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m3\armcc\port_c.c</FilePath>
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\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>
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>tos/kernel</GroupName>
<Files>
<File>
<FileName>tos_barrier.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_barrier.c</FilePath>
</File>
<File>
<FileName>tos_binary_heap.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_binary_heap.c</FilePath>
</File>
<File>
<FileName>tos_bitmap.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_bitmap.c</FilePath>
</File>
<File>
<FileName>tos_char_fifo.c</FileName>
<FileType>1</FileType>
@@ -627,6 +667,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_robin.c</FilePath>
</File>
<File>
<FileName>tos_rwlock.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_rwlock.c</FilePath>
</File>
<File>
<FileName>tos_sched.c</FileName>
<FileType>1</FileType>
@@ -637,6 +682,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_sem.c</FilePath>
</File>
<File>
<FileName>tos_stopwatch.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\kernel\core\tos_stopwatch.c</FilePath>
</File>
<File>
<FileName>tos_sys.c</FileName>
<FileType>1</FileType>
@@ -664,43 +714,13 @@
</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>examples</GroupName>
<Files>
<File>
<FileName>hello_world.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\examples\hello_world\hello_world.c</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="LTE_DTU_SIM7600"/>
</targetInfos>
</component>
</components>
<components/>
<files/>
</RTE>

View File

@@ -0,0 +1,37 @@
#ifndef _TOS_CONFIG_H_
#define _TOS_CONFIG_H_
#include "n32g45x.h"
#define TOS_CFG_TASK_PRIO_MAX 10u
#define TOS_CFG_ROUND_ROBIN_EN 1u
#define TOS_CFG_OBJECT_VERIFY_EN 0u
#define TOS_CFG_TASK_DYNAMIC_CREATE_EN 0u
#define TOS_CFG_EVENT_EN 1u
#define TOS_CFG_MMBLK_EN 1u
#define TOS_CFG_MMHEAP_EN 1u
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x100
#define TOS_CFG_MUTEX_EN 1u
#define TOS_CFG_TIMER_EN 1u
#define TOS_CFG_SEM_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 128u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u
#define TOS_CFG_CPU_CLOCK (SystemCoreClock)
#define TOS_CFG_TIMER_AS_PROC 1u
#endif

View File

@@ -37,8 +37,6 @@
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_VFS_EN 0u
#define TOS_CFG_IDLE_TASK_STK_SIZE 128u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u

View File

@@ -82,7 +82,7 @@ void NMI_Handler(void)
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
void HardFault_Handlerx(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */

View File

@@ -66,7 +66,7 @@
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>8.30.1.17146</state>
<state>8.32.1.18618</state>
</option>
<option>
<name>GeneralEnableMisra</name>
@@ -215,12 +215,12 @@
<name>ICCARM</name>
<archiveVersion>2</archiveVersion>
<data>
<version>34</version>
<version>35</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CCDefines</name>
<state></state>
<state>STM32L073xx</state>
</option>
<option>
<name>CCPreprocFile</name>
@@ -329,7 +329,7 @@
</option>
<option>
<name>OutputFile</name>
<state></state>
<state>$FILE_BNAME$.o</state>
</option>
<option>
<name>CCLibConfigHeader</name>
@@ -345,7 +345,15 @@
</option>
<option>
<name>CCIncludePath2</name>
<state></state>
<state>$PROJ_DIR$\..\..\BSP\Inc</state>
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\include</state>
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\cortex-m0+\iccarm</state>
<state>$PROJ_DIR$\..\..\..\..\kernel\core\include</state>
<state>$PROJ_DIR$\..\..\..\..\osal\cmsis_os</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L0xx\Include</state>
<state>$PROJ_DIR$\..\..\TOS_CONFIG</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\STM32L0xx_HAL_Driver\Inc</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Core\Include</state>
</option>
<option>
<name>CCStdIncCheck</name>
@@ -463,6 +471,10 @@
<name>IccRTTI2</name>
<state>0</state>
</option>
<option>
<name>OICompilerExtraOption</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@@ -519,7 +531,7 @@
</option>
<option>
<name>ADefines</name>
<state></state>
<state>STM32L073xx</state>
</option>
<option>
<name>AList</name>
@@ -611,7 +623,16 @@
</option>
<option>
<name>AUserIncludes</name>
<state></state>
<state>$PROJ_DIR$\..\..\TOS_CONFIG</state>
<state>$PROJ_DIR$\..\..\BSP\Inc</state>
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\include</state>
<state>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\cortex-m0+\iccarm</state>
<state>$PROJ_DIR$\..\..\..\..\kernel\core\include</state>
<state>$PROJ_DIR$\..\..\..\..\osal\cmsis_os</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L0xx\Include</state>
<state>$PROJ_DIR$\..\..\TOS_CONFIG</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\STM32L0xx_HAL_Driver\Inc</state>
<state>$PROJ_DIR$\..\..\..\..\platform\vendor_bsp\st\CMSIS\Core\Include</state>
</option>
<option>
<name>AExtraOptionsCheckV2</name>
@@ -683,7 +704,7 @@
<name>ILINK</name>
<archiveVersion>0</archiveVersion>
<data>
<version>21</version>
<version>22</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@@ -764,7 +785,7 @@
</option>
<option>
<name>IlinkIcfFile</name>
<state>lnk0t.icf</state>
<state>$TOOLKIT_DIR$\config\linker\ST\stm32l073xZ.icf</state>
</option>
<option>
<name>IlinkIcfFileSlave</name>
@@ -824,7 +845,7 @@
</option>
<option>
<name>IlinkProgramEntryLabel</name>
<state></state>
<state>__iar_program_start</state>
</option>
<option>
<name>DoFill</name>
@@ -997,7 +1018,11 @@
</option>
<option>
<name>IlinkTrustzoneImportLibraryOut</name>
<state>###Unitialized###</state>
<state>TencentOS_tiny_import_lib.o</state>
</option>
<option>
<name>OILinkExtraOption</name>
<state>1</state>
</option>
</data>
</settings>
@@ -1141,6 +1166,9 @@
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_fault.c</name>
</file>
</group>
<group>
<name>tos/cmsis-os</name>

View File

@@ -1298,6 +1298,9 @@
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\arch\arm\arm-v7m\common\tos_fault.c</name>
</file>
</group>
<group>
<name>tos/cmsis-os</name>

View File

@@ -33,5 +33,7 @@
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_FAULT_BACKTRACE_EN 1u // 配置TencentOS tiny是否开启异常栈回溯功能
#endif

View File

@@ -31,10 +31,9 @@
#define TOS_CFG_TIMER_AS_PROC 1u // 配置是否将TIMER配置成函数模式
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_MMBLK_EN 1u
#define TOS_CFG_IRQ_STK_SIZE 128u
#endif /* INC_TOS_CONFIG_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -403,14 +403,9 @@
<FilePath>..\apps\common\NvmCtxMgmt.c</FilePath>
</File>
<File>
<FileName>LoRaApi.c</FileName>
<FileName>LoRaDemo.c</FileName>
<FileType>1</FileType>
<FilePath>..\apps\classA\LoRaApi.c</FilePath>
</File>
<File>
<FileName>at_parser.c</FileName>
<FileType>1</FileType>
<FilePath>..\apps\classA\at_parser.c</FilePath>
<FilePath>..\apps\classA\LoRaDemo.c</FilePath>
</File>
</Files>
</Group>
@@ -722,11 +717,6 @@
<FileType>1</FileType>
<FilePath>..\Src\sysIrqHandlers.c</FilePath>
</File>
<File>
<FileName>atcmd-board.c</FileName>
<FileType>1</FileType>
<FilePath>..\Src\atcmd-board.c</FilePath>
</File>
</Files>
</Group>
<Group>
@@ -762,11 +752,6 @@
<FileType>1</FileType>
<FilePath>..\..\..\components\connectivity\LoraWAN\mac\LoRaMacCrypto.c</FilePath>
</File>
<File>
<FileName>LoRaMacFCntHandler.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\components\connectivity\LoraWAN\mac\LoRaMacFCntHandler.c</FilePath>
</File>
<File>
<FileName>LoRaMacParser.c</FileName>
<FileType>1</FileType>
@@ -792,6 +777,11 @@
<FileType>1</FileType>
<FilePath>..\..\..\components\connectivity\LoraWAN\peripherals\soft-se\soft-se.c</FilePath>
</File>
<File>
<FileName>soft-se-hal.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\components\connectivity\LoraWAN\peripherals\soft-se\soft-se-hal.c</FilePath>
</File>
</Files>
</Group>
<Group>

View File

@@ -0,0 +1,84 @@
##
## ______ _
## / _____) _ | |
## ( (____ _____ ____ _| |_ _____ ____| |__
## \____ \| ___ | (_ _) ___ |/ ___) _ \
## _____) ) ____| | | || |_| ____( (___| | | |
## (______/|_____)_|_|_| \__)_____)\____)_| |_|
## (C)2013-2017 Semtech
## ___ _____ _ ___ _ _____ ___ ___ ___ ___
## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
## embedded.connectivity.solutions.==============
##
## License: Revised BSD License, see LICENSE.TXT file included in the project
## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech)
##
project(B-L072Z-LRWAN1)
cmake_minimum_required(VERSION 3.6)
enable_language(ASM)
#---------------------------------------------------------------------------------------
# Target
#---------------------------------------------------------------------------------------
list(APPEND ${PROJECT_NAME}_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/adc-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/delay-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/eeprom-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/gpio-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/lpm-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/rtc-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/spi-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/sx1276-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/uart-board.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/sysIrqHandlers.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/utilities.c"
"${CMAKE_CURRENT_SOURCE_DIR}/cmsis/arm-gcc/startup_stm32l072xx.s"
"${CMAKE_CURRENT_SOURCE_DIR}/cmsis/system_stm32l0xx.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_adc.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_adc_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_cortex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_dma.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_gpio.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rtc.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rtc_ex.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_spi.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c"
)
add_library(${PROJECT_NAME} OBJECT EXCLUDE_FROM_ALL ${${PROJECT_NAME}_SOURCES})
target_compile_definitions(${PROJECT_NAME} PUBLIC -DUSE_HAL_DRIVER -DSTM32L072xx)
# Add define if debbuger support is enabled
target_compile_definitions(${PROJECT_NAME} PUBLIC $<$<BOOL:${USE_DEBUGGER}>:USE_DEBUGGER>)
# Add define if radio debug pins support is enabled
target_compile_definitions(${PROJECT_NAME} PUBLIC $<$<BOOL:${USE_RADIO_DEBUG}>:USE_RADIO_DEBUG>)
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cmsis
${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32
${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/cmsis
${CMAKE_CURRENT_SOURCE_DIR}/../mcu/stm32/STM32L0xx_HAL_Driver/Inc
$<TARGET_PROPERTY:board,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:radio,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:peripherals,INTERFACE_INCLUDE_DIRECTORIES>
)
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)

View File

@@ -20,6 +20,8 @@
*
* \author Gregory Cristian ( Semtech )
*/
#include <stdint.h>
#include <stdbool.h>
#include "stm32l0xx.h"
#include "board-config.h"
#include "adc-board.h"
@@ -70,6 +72,8 @@ uint16_t AdcMcuReadChannel( Adc_t *obj, uint32_t channel )
{
ADC_ChannelConfTypeDef adcConf = { 0 };
uint16_t adcData = 0;
uint32_t tickStart = 0;
bool isAdcReady = true;
// Enable HSI
__HAL_RCC_HSI_ENABLE( );
@@ -83,18 +87,31 @@ uint16_t AdcMcuReadChannel( Adc_t *obj, uint32_t channel )
adcConf.Channel = channel;
adcConf.Rank = ADC_RANK_CHANNEL_NUMBER;
HAL_ADC_ConfigChannel( &AdcHandle, &adcConf );
// Enable ADC1
__HAL_ADC_ENABLE( &AdcHandle );
// Start ADC Software Conversion
HAL_ADC_Start( &AdcHandle );
// Wait for ADC to effectively be enabled
tickStart = HAL_GetTick( );
while( __HAL_ADC_GET_FLAG( &AdcHandle, ADC_FLAG_RDY ) == RESET )
{
if( ( HAL_GetTick( ) - tickStart ) > ADC_ENABLE_TIMEOUT )
{
isAdcReady = false;
break;
}
}
HAL_ADC_PollForConversion( &AdcHandle, HAL_MAX_DELAY );
if( isAdcReady != false )
{
// Start ADC Software Conversion
HAL_ADC_Start( &AdcHandle );
adcData = HAL_ADC_GetValue( &AdcHandle );
HAL_ADC_PollForConversion( &AdcHandle, HAL_MAX_DELAY );
adcData = HAL_ADC_GetValue( &AdcHandle );
}
__HAL_ADC_DISABLE( &AdcHandle );

View File

@@ -185,8 +185,8 @@ void RtcInit( void )
time.Seconds = 0;
time.SubSeconds = 0;
time.TimeFormat = 0;
time.StoreOperation = RTC_DAYLIGHTSAVING_NONE;
time.DayLightSaving = RTC_STOREOPERATION_RESET;
time.StoreOperation = RTC_STOREOPERATION_RESET;
time.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
HAL_RTC_SetTime( &RtcHandle, &time, RTC_FORMAT_BIN );
// Enable Direct Read of the calendar registers (not through Shadow registers)
@@ -469,7 +469,7 @@ void RtcSetMcuWakeUpTime( void )
mcuWakeUpTime = ( int16_t )( ( now - hit ) );
McuWakeUpTimeCal += mcuWakeUpTime;
//PRINTF( 3, "Cal=%d, %d\n\r", McuWakeUpTimeCal, mcuWakeUpTime);
//PRINTF( 3, "Cal=%d, %d\n", McuWakeUpTimeCal, mcuWakeUpTime);
}
}
@@ -485,16 +485,13 @@ static uint64_t RtcGetCalendarValue( RTC_DateTypeDef* date, RTC_TimeTypeDef* tim
uint32_t correction;
uint32_t seconds;
// Get Time and Date
HAL_RTC_GetTime( &RtcHandle, time, RTC_FORMAT_BIN );
// Make sure it is correct due to asynchronus nature of RTC
do
{
firstRead = time->SubSeconds;
firstRead = RTC->SSR;
HAL_RTC_GetDate( &RtcHandle, date, RTC_FORMAT_BIN );
HAL_RTC_GetTime( &RtcHandle, time, RTC_FORMAT_BIN );
}while( firstRead != time->SubSeconds );
}while( firstRead != RTC->SSR );
// Calculte amount of elapsed days since 01/01/2000
seconds = DIVC( ( DAYS_IN_YEAR * 3 + DAYS_IN_LEAP_YEAR ) * date->Year , 4 );
@@ -525,7 +522,7 @@ uint32_t RtcGetCalendarTime( uint16_t *milliseconds )
uint64_t calendarValue = RtcGetCalendarValue( &date, &time );
uint32_t seconds = ( uint32_t )calendarValue >> N_PREDIV_S;
uint32_t seconds = ( uint32_t )( calendarValue >> N_PREDIV_S );
ticks = ( uint32_t )calendarValue & PREDIV_S;
@@ -594,10 +591,10 @@ TimerTime_t RtcTempCompensation( TimerTime_t period, float temperature )
float kDev = RTC_TEMP_DEV_COEFFICIENT;
float t = RTC_TEMP_TURNOVER;
float tDev = RTC_TEMP_DEV_TURNOVER;
float interim = 0.0;
float ppm = 0.0;
float interim = 0.0f;
float ppm = 0.0f;
if( k < 0.0 )
if( k < 0.0f )
{
ppm = ( k - kDev );
}
@@ -609,12 +606,12 @@ TimerTime_t RtcTempCompensation( TimerTime_t period, float temperature )
ppm *= interim * interim;
// Calculate the drift in time
interim = ( ( float ) period * ppm ) / 1e6;
interim = ( ( float ) period * ppm ) / 1000000.0f;
// Calculate the resulting time period
interim += period;
interim = floor( interim );
if( interim < 0.0 )
if( interim < 0.0f )
{
interim = ( float )period;
}

View File

@@ -140,12 +140,24 @@ void SX1276IoDeInit( void )
GpioInit( &SX1276.DIO5, RADIO_DIO_5, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
}
void SX1276IoDbgInit( void )
{
#if defined( USE_RADIO_DEBUG )
GpioInit( &DbgPinTx, RADIO_DBG_PIN_TX, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &DbgPinRx, RADIO_DBG_PIN_RX, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
#endif
}
void SX1276IoTcxoInit( void )
{
GpioInit( &TcxoPower, RADIO_TCXO_POWER, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
}
/*!
* \brief Enables/disables the TCXO if available on board design.
*
* \param [IN] state TCXO enabled when true and disabled when false.
*/
static void SX1276SetBoardTcxo( uint8_t state )
void SX1276SetBoardTcxo( uint8_t state )
{
if( state == true )
{

View File

@@ -0,0 +1,63 @@
/*!
* \file Commissioning.h
*
* \brief End-device commissioning parameters
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2020 Semtech
*
* \endcode
*/
#ifndef __COMMISSIONING_H__
#define __COMMISSIONING_H__
/*!
******************************************************************************
********************************** WARNING ***********************************
******************************************************************************
The LoRaWAN AES128 keys are stored and provisionned on secure-elements.
This project providdes a software emulated secure-element.
The LoRaWAN AES128 keys SHALL be updated under
src/peripherals/<secure-element name>-se\se-identity.h file.
******************************************************************************
******************************************************************************
******************************************************************************
*/
#include "se-identity.h"
/*!
* When set to 1 the application uses the Over-the-Air activation procedure
* When set to 0 the application uses the Personalization activation procedure
*/
#define OVER_THE_AIR_ACTIVATION 1
/*!
* When using ABP activation the MAC layer must know in advance to which server
* version it will be connected.
*/
#define ABP_ACTIVATION_LRWAN_VERSION_V10x 0x01000300 // 1.0.3.0
#define ABP_ACTIVATION_LRWAN_VERSION ABP_ACTIVATION_LRWAN_VERSION_V10x
/*!
* Indicates if the end-device is to be connected to a private or public network
*/
#define LORAWAN_PUBLIC_NETWORK true
/*!
* Current network ID
*/
#define LORAWAN_NETWORK_ID ( uint32_t )0
#endif // __COMMISSIONING_H__

View File

@@ -1,431 +0,0 @@
#include "LoRaApi.h"
#if( OVER_THE_AIR_ACTIVATION == 0 )
uint8_t DevEui[] = { 0x38, 0x37, 0x37, 0x37, 0x71, 0x37, 0x68, 0x07 };
uint8_t JoinEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t AppKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t NwkKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint32_t DevAddr = 0x008B6CCB;
uint8_t FNwkSIntKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t SNwkSIntKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t NwkSEncKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t AppSKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
#else
uint8_t DevEui[] = { 0x47, 0x9B, 0x41, 0xF2, 0x00, 0x45, 0x00, 0x28 };
uint8_t JoinEui[] = { 0x52, 0x69, 0x73, 0x69, 0x6E, 0x67, 0x48, 0x46 };
uint8_t AppKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t NwkKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint32_t DevAddr = 0x00ADE921;
uint8_t FNwkSIntKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t SNwkSIntKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t NwkSEncKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
uint8_t AppSKey[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
#endif
bool NextTx = true;
uint8_t IsTxConfirmed = false;
TimerEvent_t TxNextPacketTimer;
uint8_t AppPort = 2;
uint8_t AppDataSize = 13;
uint8_t AppDataBuffer[LORAWAN_APP_DATA_MAX_SIZE];
LoRaMacPrimitives_t LoRaMacPrimitives;
LoRaMacCallback_t LoRaMacCallbacks;
MibRequestConfirm_t mibReq;
LoRaMacStatus_t status;
LoRaMacStatus_t SendFrame( void )
{
McpsReq_t mcpsReq;
LoRaMacTxInfo_t txInfo;
if( LoRaMacQueryTxPossible( AppDataSize, &txInfo ) != LORAMAC_STATUS_OK )
{
// Send empty frame in order to flush MAC commands
mcpsReq.Type = MCPS_UNCONFIRMED;
mcpsReq.Req.Unconfirmed.fBuffer = NULL;
mcpsReq.Req.Unconfirmed.fBufferSize = 0;
mcpsReq.Req.Unconfirmed.Datarate = LORAWAN_DEFAULT_DATARATE;
}
else
{
if( IsTxConfirmed == false )
{
mcpsReq.Type = MCPS_UNCONFIRMED;
mcpsReq.Req.Unconfirmed.fPort = AppPort;
mcpsReq.Req.Unconfirmed.fBuffer = AppDataBuffer;
mcpsReq.Req.Unconfirmed.fBufferSize = AppDataSize;
mcpsReq.Req.Unconfirmed.Datarate = LORAWAN_DEFAULT_DATARATE;
}
else
{
mcpsReq.Type = MCPS_CONFIRMED;
mcpsReq.Req.Confirmed.fPort = AppPort;
mcpsReq.Req.Confirmed.fBuffer = AppDataBuffer;
mcpsReq.Req.Confirmed.fBufferSize = AppDataSize;
mcpsReq.Req.Confirmed.NbTrials = 8;
mcpsReq.Req.Confirmed.Datarate = LORAWAN_DEFAULT_DATARATE;
}
}
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
return LoRaMacMcpsRequest( &mcpsReq);
}
static void McpsConfirm( McpsConfirm_t *mcpsConfirm )
{
if( mcpsConfirm->Status == LORAMAC_EVENT_INFO_STATUS_OK )
{
switch( mcpsConfirm->McpsRequest )
{
case MCPS_UNCONFIRMED:
{
break;
}
case MCPS_CONFIRMED:
{
break;
}
case MCPS_PROPRIETARY:
{
break;
}
default:
break;
}
}
}
static void OnTxNextPacketTimerEvent( void* context)
{
MibRequestConfirm_t mibReq;
LoRaMacStatus_t status;
TimerStop( &TxNextPacketTimer );
mibReq.Type = MIB_NETWORK_ACTIVATION;
status = LoRaMacMibGetRequestConfirm( &mibReq );
if( status == LORAMAC_STATUS_OK )
{
if( mibReq.Param.NetworkActivation == ACTIVATION_TYPE_NONE )
{
// Network not joined yet. Try to join again
LoRa_JoinNetwork(1);
}
else
{
NextTx = true;
}
}
NextTx = true;
}
static void McpsIndication( McpsIndication_t *mcpsIndication )
{
if( mcpsIndication->Status != LORAMAC_EVENT_INFO_STATUS_OK )
{
return;
}
switch( mcpsIndication->McpsIndication )
{
case MCPS_UNCONFIRMED:
{
break;
}
case MCPS_CONFIRMED:
{
break;
}
case MCPS_PROPRIETARY:
{
break;
}
case MCPS_MULTICAST:
{
break;
}
default:
break;
}
if( mcpsIndication->FramePending == true )
{
// The server signals that it has pending data to be sent.
// We schedule an uplink as soon as possible to flush the server.
OnTxNextPacketTimerEvent( NULL );
}
if( mcpsIndication->RxData == true )
{
}
}
static void MlmeConfirm( MlmeConfirm_t *mlmeConfirm )
{
switch( mlmeConfirm->MlmeRequest )
{
case MLME_JOIN:
{
if( mlmeConfirm->Status == LORAMAC_EVENT_INFO_STATUS_OK )
{
MibRequestConfirm_t mibGet;
printf( "###### ===== JOINED ==== ######\r\n" );
printf( "\r\nOTAA\r\n\r\n" );
mibGet.Type = MIB_DEV_ADDR;
LoRaMacMibGetRequestConfirm( &mibGet );
printf( "DevAddr : %08X\r\n", mibGet.Param.DevAddr );
printf( "\n\r\n" );
mibGet.Type = MIB_CHANNELS_DATARATE;
LoRaMacMibGetRequestConfirm( &mibGet );
printf( "DATA RATE : DR_%d\r\n", mibGet.Param.ChannelsDatarate );
printf( "\r\n" );
// Status is OK, node has joined the network
NextTx = true;
}
else
{
// Join was not successful. Try to join again
LoRa_JoinNetwork(1);
}
break;
}
case MLME_LINK_CHECK:
{
break;
}
default:
break;
}
}
/*!
* \brief MLME-Indication event function
*
* \param [IN] mlmeIndication - Pointer to the indication structure.
*/
static void MlmeIndication( MlmeIndication_t *mlmeIndication )
{
if( mlmeIndication->Status != LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED )
{
printf( "\r\n###### ===== MLME-Indication ==== ######\r\n" );
}
if( mlmeIndication->Status != LORAMAC_EVENT_INFO_STATUS_OK )
{
}
switch( mlmeIndication->MlmeIndication )
{
case MLME_SCHEDULE_UPLINK:
{// The MAC signals that we shall provide an uplink as soon as possible
OnTxNextPacketTimerEvent( NULL );
break;
}
default:
break;
}
}
void OnMacProcessNotify( void )
{
}
void LoRa_Init(void)
{
LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm;
LoRaMacPrimitives.MacMcpsIndication = McpsIndication;
LoRaMacPrimitives.MacMlmeConfirm = MlmeConfirm;
LoRaMacPrimitives.MacMlmeIndication = MlmeIndication;
LoRaMacCallbacks.GetBatteryLevel = BoardGetBatteryLevel;
LoRaMacCallbacks.GetTemperatureLevel = NULL;
LoRaMacCallbacks.NvmContextChange = NvmCtxMgmtEvent;
LoRaMacCallbacks.MacProcessNotify = OnMacProcessNotify;
LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks, ACTIVE_REGION );
mibReq.Type = MIB_APP_KEY;
mibReq.Param.AppKey = AppKey;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_NWK_KEY;
mibReq.Param.NwkKey = NwkKey;
LoRaMacMibSetRequestConfirm( &mibReq );
#if( OVER_THE_AIR_ACTIVATION == 0 )
mibReq.Type = MIB_NET_ID;
mibReq.Param.NetID = LORAWAN_NETWORK_ID;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_DEV_ADDR;
mibReq.Param.DevAddr = DevAddr;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_F_NWK_S_INT_KEY;
mibReq.Param.FNwkSIntKey = FNwkSIntKey;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_S_NWK_S_INT_KEY;
mibReq.Param.SNwkSIntKey = SNwkSIntKey;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_NWK_S_ENC_KEY;
mibReq.Param.NwkSEncKey = NwkSEncKey;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_APP_S_KEY;
mibReq.Param.AppSKey = AppSKey;
LoRaMacMibSetRequestConfirm( &mibReq );
#endif
LoRaMacStart( );
mibReq.Type = MIB_NETWORK_ACTIVATION;
status = LoRaMacMibGetRequestConfirm( &mibReq );
if( status == LORAMAC_STATUS_OK )
{
if( mibReq.Param.NetworkActivation != ACTIVATION_TYPE_NONE )
{
NextTx = true;
}
}
#if 0
#if( OVER_THE_AIR_ACTIVATION == 0 )
LoRa_JoinNetwork(0);
#else
LoRa_JoinNetwork(1);
#endif
TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent );
printf_device_info();
while( 1 )
{
char *data = "Welcome to Tos Tiny!";
LoRaMacProcess( );
Lora_Send(0,2,(uint8_t *)data,strlen(data));
//PrepareTxFrame();
//SendFrame();
NextTx = false;
TimerSetValue( &TxNextPacketTimer, 15000 );
TimerStart( &TxNextPacketTimer );
while(!NextTx);
//tos_sleep_hmsm(0,0,1,400); //<2F><>ʱ1.4s
}
#endif
}
/*lorawan<61><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
void LoRa_JoinNetwork(uint8_t jointype)
{
/*OTAAģʽ*/
if(jointype > 0)
{
MlmeReq_t mlmeReq;
mlmeReq.Type = MLME_JOIN;
mlmeReq.Req.Join.DevEui = DevEui;
mlmeReq.Req.Join.JoinEui = JoinEui;
mlmeReq.Req.Join.Datarate = LORAWAN_DEFAULT_DATARATE;
LoRaMacMlmeRequest( &mlmeReq );
}
else
{
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬*/
MibRequestConfirm_t mibReq;
mibReq.Type = MIB_ABP_LORAWAN_VERSION;
mibReq.Param.AbpLrWanVersion.Value = ABP_ACTIVATION_LRWAN_VERSION;
LoRaMacMibSetRequestConfirm( &mibReq );
mibReq.Type = MIB_NETWORK_ACTIVATION;
mibReq.Param.NetworkActivation = ACTIVATION_TYPE_ABP;
LoRaMacMibSetRequestConfirm( &mibReq );
}
}
/*lorawan<61><6E><EFBFBD><EFBFBD>*/
uint8_t Lora_Send(uint8_t type,uint8_t port, uint8_t * psrc, uint16_t len)
{
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if(type == 1)
{
IsTxConfirmed = true;
}
else
{
IsTxConfirmed = false;
}
/*<2A><>ȡ<EFBFBD>˿<EFBFBD>*/
if(port <1 && port > 233)
{
return 1;
}
else
{
/*<2A><><EFBFBD>¶˿<C2B6>*/
AppPort = port;
}
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>*/
if(len > LORAWAN_APP_DATA_MAX_SIZE)
{
return 1;
}
memcpy1(AppDataBuffer, psrc, len);
AppDataSize = len;
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
//printf("begin to send data\r\n");
LoRaMacStatus_t res = SendFrame( );
if(res == LORAMAC_STATUS_OK)
{
printf("SEND OK\r\n");
return 0;
}
else if(res == LORAMAC_STATUS_NO_NETWORK_JOINED)
{
printf("NO NETWORK JOINED\r\n");
return 2;
}
else if(res == LORAMAC_STATUS_BUSY)
{
printf("LORAMAC STATUS BUSY\r\n");
return 3;
}
else
{
return 1;
}
}
void printf_device_info(void)
{
printf( "DevEui : %02X", DevEui[0] );
for( int i = 1; i < 8; i++ )
{
printf( "-%02X", DevEui[i] );
}
printf( "\r\n" );
printf( "AppEui : %02X", JoinEui[0] );
for( int i = 1; i < 8; i++ )
{
printf( "-%02X", JoinEui[i] );
}
printf( "\r\n" );
printf( "AppKey : %02X", NwkKey[0] );
for( int i = 1; i < 16; i++ )
{
printf( " %02X", NwkKey[i] );
}
printf( "\n\r\n" );
#if( OVER_THE_AIR_ACTIVATION == 0 )
printf( "###### ===== JOINED ==== ######\r\n" );
printf( "\r\nABP\r\n\r\n" );
printf( "DevAddr : %08X\r\n", DevAddr );
printf( "NwkSKey : %02X", FNwkSIntKey[0] );
for( int i = 1; i < 16; i++ )
{
printf( " %02X", FNwkSIntKey[i] );
}
printf( "\r\n" );
printf( "AppSKey : %02X", AppSKey[0] );
for( int i = 1; i < 16; i++ )
{
printf( " %02X", AppSKey[i] );
}
printf( "\n\r\n" );
#endif
}

View File

@@ -1,42 +0,0 @@
#ifndef __LORAAPI_H__
#define __LORAAPI_H__
#include "stdio.h"
#include "string.h"
#include "utilities.h"
#include "board.h"
#include "gpio.h"
#include "LoRaMac.h"
#include "NvmCtxMgmt.h"
#define OVER_THE_AIR_ACTIVATION 0
#define ABP_ACTIVATION_LRWAN_VERSION_V10x 0x01000300 // 1.0.3.0
#define ABP_ACTIVATION_LRWAN_VERSION ABP_ACTIVATION_LRWAN_VERSION_V10x
#define LORAWAN_PUBLIC_NETWORK true
#define LORAWAN_NETWORK_ID ( uint32_t )0
#define ACTIVE_REGION LORAMAC_REGION_CN470
#define LORAWAN_APP_DATA_MAX_SIZE 64
#define LORAWAN_DEFAULT_DATARATE DR_0
#define LORAWAN_ADR_ON 1
#define LORAWAN_DUTYCYCLE_ON false
extern bool NextTx;
extern TimerEvent_t TxNextPacketTimer;
void LoRa_Init(void);
void LoRa_JoinNetwork(uint8_t jointype);
uint8_t Lora_Send(uint8_t type,uint8_t port, uint8_t * psrc, uint16_t len);
void printf_device_info(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +0,0 @@
#include "at_parser.h"
#include "uart-board.h"
#ifndef AT_CMD_BUF_LEN
#define AT_CMD_BUF_LEN 512
#endif
#ifndef UART_RECV_TIMEOUT
#define UART_RECV_TIMEOUT 15000
#endif
static at_uart_ops_t *uart_ops;
static at_table_t *cmd_table;
int at_parser_init(at_uart_ops_t *ops, at_table_t *table)
{
if (ops && table)
{
uart_ops = ops;
cmd_table = table;
if(ops->init)
return ops->init();
else
return 0;
}
else
return -1;
}
int at_cmd_handle(void)
{
uint8_t tmp_buf[AT_CMD_BUF_LEN];
uint16_t len = 0, i;
uint32_t n = 0;
uint16_t cmd_len = 0;
if(!uart_ops || !cmd_table)
return -1;
/*<2A>յ<EFBFBD>\r\n<><6E><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
while(n++ < UART_RECV_TIMEOUT)
{
if(uart_ops->recv(tmp_buf+len, 1) == 1)
{
len++;
n = 0;
}
}
/*ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־*/
if(tmp_buf[len-2] == 0x0D/*'\r'*/ && tmp_buf[len-1] == 0x0A/*'\n'*/)
{
/*<2A><><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD><EFBFBD>\r\n*/
len -= 2;
}
/*<2A><>ѯATָ<54><EFBFBD><EEA3AC>ִ<EFBFBD><D6B4>*/
for(i = 0; cmd_table[i].cmd; i++)
{
cmd_len = strlen(cmd_table[i].cmd);
if(len >= cmd_len)
{
#ifdef AT_IGNORE_CASE
if(strncasecmp((const char*)cmd_table[i].cmd, (const char*)tmp_buf, cmd_len) == 0)
#else
if(memcmp((const char*)cmd_table[i].cmd, (const char*)tmp_buf, cmd_len) == 0)
#endif
{
/*<2A><>=<3D><><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
return cmd_table[i].func(tmp_buf + cmd_len, len - cmd_len);
}
}
}
return -1;
}

View File

@@ -1,56 +0,0 @@
#ifndef __AT_PARSER_H__
#define __AT_PARSER_H__
#include <stdint.h>
#include <string.h>
#define AT_CMD_END NULL
//#define AT_IGNORE_CASE
/*
* Please declare and register command table as follow before call
* at_cmd_handle.
* NOTE. Add AT_CMD_END as last member to mark the end of command.
* All receive text behind command text would be treated as data text
* pass to func.
*
* at_table_t cmd_table[] = {
* {"AT+VERSION=", ver_handle},
* {"AT+RESET", reset_handle},
* ...
* {AT_CMD_END, NULL},
* };
*/
typedef struct
{
const char *cmd; /* <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD> */
uint8_t (*func)(uint8_t *, uint16_t size); /* <20><><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
} at_table_t;
/*
* Please declare and register uart operations so that AT parser is
* able to receive text from uart.
*
* at_uart_ops_t uart_ops = {
* .init = NULL,
* .deinit = NULL,
* .send = NULL,
* .recv = UartReceive,
* .recv_timeout = UartReceive,
* };
*/
typedef struct
{
uint8_t (*init)(void);
uint8_t (*deinit)(void);
uint16_t (*send)(uint8_t *buf, uint16_t size);
uint16_t (*recv)(uint8_t *buf, uint16_t buf_len);
uint16_t (*recv_timeout)(uint8_t *buf, uint16_t buf_len);
}at_uart_ops_t;
int at_parser_init(at_uart_ops_t *uart_ops, at_table_t *cmd_table);
int at_cmd_handle(void);
#endif

View File

@@ -1,98 +1,35 @@
#include "LoRaApi.h"
#include <stdio.h>
#include <string.h>
#include "tos_k.h"
#include "atcmd-board.h"
/*LORA<52><41><EFBFBD><EFBFBD>״̬*/
uint8_t g_join_state = 0;
uint8_t g_st_state = 0;
/*<2A><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>*/
uint32_t g_rx_num = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
#define TASK1_PRIO 3
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB>С
#define TASK1_STK_SIZE (1024 * 4)
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>
k_task_t Task1TCB;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ
k_stack_t TASK1_STK[TASK1_STK_SIZE];
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void task1(void *arg);
void lora_send_timer(void* context)
k_task_t task1;
k_stack_t task1_stack[4096];
extern int lora_main(void);
void task1_fun(void *arg)
{
g_st_state =2;
}
void task1(void *arg)
{
at_cmd_init();
LoRa_Init();
printf_device_info();
TimerInit( &TxNextPacketTimer, lora_send_timer );
while(1)
{
LoRaMacProcess();
if(g_join_state == 0)
{
printf("start join...\r\n");
/*<2A><><EFBFBD><EFBFBD>*/
LoRa_JoinNetwork(1);
g_join_state = 1;
}
if(g_join_state == 2)
{
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if(g_st_state == 0)
{
g_st_state = 1;
TimerSetValue( &TxNextPacketTimer, 60000 );
TimerStart( &TxNextPacketTimer);
printf("\r\ntime to ");
}
else if(g_st_state == 2)
{
g_st_state = 3;
printf("send!\r\n");
/*<2A><><EFBFBD><EFBFBD>lora<72><61><EFBFBD><EFBFBD>*/
uint8_t tmpbuf[] = "tos tiny!";
Lora_Send(0, 2, tmpbuf, sizeof(tmpbuf));
g_rx_num++;
}
}
at_cmd_handle();
}
lora_main();
}
extern uint8_t sx1276_band;
int main(void)
{
k_err_t err;
TOS_CPU_CPSR_ALLOC();
BoardInitMcu( );
BoardInitPeriph( );
sx1276_band = 2;
printf("welcome to tencent IoTOS\r\n");
err = tos_knl_init(); //<2F><>ʼ<EFBFBD><CABC>TOS
if (err != K_ERR_NONE)
{
printf("tos init failed\r\n");
return err;
}
TOS_CPU_INT_DISABLE();//<2F><><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>
err = tos_task_create((k_task_t * )&Task1TCB, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>
(char * )"task1", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
(k_task_entry_t )task1, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
(void * )0, //<2F><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
(k_prio_t )TASK1_PRIO, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
TASK1_STK, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ַ
(size_t)TASK1_STK_SIZE, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB>С
(size_t )0); //<2F><>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1>Ƭ<EFBFBD><C6AC>תʱ<D7AA><CAB1>ʱ<EFBFBD><CAB1>Ƭ<EFBFBD><C6AC><EFBFBD>ȣ<EFBFBD>Ϊ0ʱΪĬ<CEAA>ϳ<EFBFBD><CFB3>ȣ<EFBFBD>
printf("Welcome to TencentOS Tiny! \r\n");
tos_knl_init();
TOS_CPU_INT_DISABLE();
err = tos_task_create(&task1,
"task1",
task1_fun,
NULL,
3,
task1_stack,
4096,
20);
if(err != K_ERR_NONE)
printf("TencentOS Tiny Create task1 fail! code : %d \r\n",err);
TOS_CPU_INT_ENABLE(); //<2F>˳<EFBFBD><CBB3>ٽ<EFBFBD><D9BD><EFBFBD>
tos_knl_start(); //<2F><><EFBFBD><EFBFBD>TOS
while (1)
{
}
TOS_CPU_INT_ENABLE();
tos_knl_start();
}

View File

@@ -0,0 +1,257 @@
/*!
* \file CayenneLpp.c
*
* \brief Implements the Cayenne Low Power Protocol
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include <stdint.h>
#include "utilities.h"
#include "CayenneLpp.h"
#define CAYENNE_LPP_MAXBUFFER_SIZE 242
static uint8_t CayenneLppBuffer[CAYENNE_LPP_MAXBUFFER_SIZE];
static uint8_t CayenneLppCursor = 0;
void CayenneLppInit( void )
{
CayenneLppCursor = 0;
}
void CayenneLppReset( void )
{
CayenneLppCursor = 0;
}
uint8_t CayenneLppGetSize( void )
{
return CayenneLppCursor;
}
uint8_t* CayenneLppGetBuffer( void )
{
return CayenneLppBuffer;
}
uint8_t CayenneLppCopy( uint8_t* dst )
{
memcpy1( dst, CayenneLppBuffer, CayenneLppCursor );
return CayenneLppCursor;
}
uint8_t CayenneLppAddDigitalInput( uint8_t channel, uint8_t value )
{
if( ( CayenneLppCursor + LPP_DIGITAL_INPUT_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_DIGITAL_INPUT;
CayenneLppBuffer[CayenneLppCursor++] = value;
return CayenneLppCursor;
}
uint8_t CayenneLppAddDigitalOutput( uint8_t channel, uint8_t value )
{
if( ( CayenneLppCursor + LPP_DIGITAL_OUTPUT_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_DIGITAL_OUTPUT;
CayenneLppBuffer[CayenneLppCursor++] = value;
return CayenneLppCursor;
}
uint8_t CayenneLppAddAnalogInput( uint8_t channel, float value )
{
if( ( CayenneLppCursor + LPP_ANALOG_INPUT_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t val = value * 100;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_ANALOG_INPUT;
CayenneLppBuffer[CayenneLppCursor++] = val >> 8;
CayenneLppBuffer[CayenneLppCursor++] = val;
return CayenneLppCursor;
}
uint8_t CayenneLppAddAnalogOutput( uint8_t channel, float value )
{
if( ( CayenneLppCursor + LPP_ANALOG_OUTPUT_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t val = value * 100;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_ANALOG_OUTPUT;
CayenneLppBuffer[CayenneLppCursor++] = val >> 8;
CayenneLppBuffer[CayenneLppCursor++] = val;
return CayenneLppCursor;
}
uint8_t CayenneLppAddLuminosity( uint8_t channel, uint16_t lux )
{
if( ( CayenneLppCursor + LPP_LUMINOSITY_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_LUMINOSITY;
CayenneLppBuffer[CayenneLppCursor++] = lux >> 8;
CayenneLppBuffer[CayenneLppCursor++] = lux;
return CayenneLppCursor;
}
uint8_t CayenneLppAddPresence( uint8_t channel, uint8_t value )
{
if( ( CayenneLppCursor + LPP_PRESENCE_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_PRESENCE;
CayenneLppBuffer[CayenneLppCursor++] = value;
return CayenneLppCursor;
}
uint8_t CayenneLppAddTemperature( uint8_t channel, float celsius )
{
if( ( CayenneLppCursor + LPP_TEMPERATURE_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t val = celsius * 10;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_TEMPERATURE;
CayenneLppBuffer[CayenneLppCursor++] = val >> 8;
CayenneLppBuffer[CayenneLppCursor++] = val;
return CayenneLppCursor;
}
uint8_t CayenneLppAddRelativeHumidity( uint8_t channel, float rh )
{
if( ( CayenneLppCursor + LPP_RELATIVE_HUMIDITY_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_RELATIVE_HUMIDITY;
CayenneLppBuffer[CayenneLppCursor++] = rh * 2;
return CayenneLppCursor;
}
uint8_t CayenneLppAddAccelerometer( uint8_t channel, float x, float y, float z )
{
if( ( CayenneLppCursor + LPP_ACCELEROMETER_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t vx = x * 1000;
int16_t vy = y * 1000;
int16_t vz = z * 1000;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_ACCELEROMETER;
CayenneLppBuffer[CayenneLppCursor++] = vx >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vx;
CayenneLppBuffer[CayenneLppCursor++] = vy >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vy;
CayenneLppBuffer[CayenneLppCursor++] = vz >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vz;
return CayenneLppCursor;
}
uint8_t CayenneLppAddBarometricPressure( uint8_t channel, float hpa )
{
if( ( CayenneLppCursor + LPP_BAROMETRIC_PRESSURE_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t val = hpa * 10;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_BAROMETRIC_PRESSURE;
CayenneLppBuffer[CayenneLppCursor++] = val >> 8;
CayenneLppBuffer[CayenneLppCursor++] = val;
return CayenneLppCursor;
}
uint8_t CayenneLppAddGyrometer( uint8_t channel, float x, float y, float z )
{
if( ( CayenneLppCursor + LPP_GYROMETER_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int16_t vx = x * 100;
int16_t vy = y * 100;
int16_t vz = z * 100;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_GYROMETER;
CayenneLppBuffer[CayenneLppCursor++] = vx >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vx;
CayenneLppBuffer[CayenneLppCursor++] = vy >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vy;
CayenneLppBuffer[CayenneLppCursor++] = vz >> 8;
CayenneLppBuffer[CayenneLppCursor++] = vz;
return CayenneLppCursor;
}
uint8_t CayenneLppAddGps( uint8_t channel, float latitude, float longitude, float meters )
{
if( ( CayenneLppCursor + LPP_GPS_SIZE ) > CAYENNE_LPP_MAXBUFFER_SIZE )
{
return 0;
}
int32_t lat = latitude * 10000;
int32_t lon = longitude * 10000;
int32_t alt = meters * 100;
CayenneLppBuffer[CayenneLppCursor++] = channel;
CayenneLppBuffer[CayenneLppCursor++] = LPP_GPS;
CayenneLppBuffer[CayenneLppCursor++] = lat >> 16;
CayenneLppBuffer[CayenneLppCursor++] = lat >> 8;
CayenneLppBuffer[CayenneLppCursor++] = lat;
CayenneLppBuffer[CayenneLppCursor++] = lon >> 16;
CayenneLppBuffer[CayenneLppCursor++] = lon >> 8;
CayenneLppBuffer[CayenneLppCursor++] = lon;
CayenneLppBuffer[CayenneLppCursor++] = alt >> 16;
CayenneLppBuffer[CayenneLppCursor++] = alt >> 8;
CayenneLppBuffer[CayenneLppCursor++] = alt;
return CayenneLppCursor;
}

View File

@@ -0,0 +1,76 @@
/*!
* \file CayenneLpp.h
*
* \brief Implements the Cayenne Low Power Protocol
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __CAYENNE_LPP_H__
#define __CAYENNE_LPP_H__
#include <stdint.h>
#define LPP_DIGITAL_INPUT 0 // 1 byte
#define LPP_DIGITAL_OUTPUT 1 // 1 byte
#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed
#define LPP_ANALOG_OUTPUT 3 // 2 bytes, 0.01 signed
#define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned
#define LPP_PRESENCE 102 // 1 byte, 1
#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed
#define LPP_RELATIVE_HUMIDITY 104 // 1 byte, 0.5% unsigned
#define LPP_ACCELEROMETER 113 // 2 bytes per axis, 0.001G
#define LPP_BAROMETRIC_PRESSURE 115 // 2 bytes 0.1 hPa Unsigned
#define LPP_GYROMETER 134 // 2 bytes per axis, 0.01 °/s
#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
// Data ID + Data Type + Data Size
#define LPP_DIGITAL_INPUT_SIZE 3
#define LPP_DIGITAL_OUTPUT_SIZE 3
#define LPP_ANALOG_INPUT_SIZE 4
#define LPP_ANALOG_OUTPUT_SIZE 4
#define LPP_LUMINOSITY_SIZE 4
#define LPP_PRESENCE_SIZE 3
#define LPP_TEMPERATURE_SIZE 4
#define LPP_RELATIVE_HUMIDITY_SIZE 3
#define LPP_ACCELEROMETER_SIZE 8
#define LPP_BAROMETRIC_PRESSURE_SIZE 4
#define LPP_GYROMETER_SIZE 8
#define LPP_GPS_SIZE 11
void CayenneLppInit( void );
void CayenneLppReset( void );
uint8_t CayenneLppGetSize( void );
uint8_t* CayenneLppGetBuffer( void );
uint8_t CayenneLppCopy( uint8_t* buffer );
uint8_t CayenneLppAddDigitalInput( uint8_t channel, uint8_t value );
uint8_t CayenneLppAddDigitalOutput( uint8_t channel, uint8_t value );
uint8_t CayenneLppAddAnalogInput( uint8_t channel, float value );
uint8_t CayenneLppAddAnalogOutput( uint8_t channel, float value );
uint8_t CayenneLppAddLuminosity( uint8_t channel, uint16_t lux );
uint8_t CayenneLppAddPresence( uint8_t channel, uint8_t value );
uint8_t CayenneLppAddTemperature( uint8_t channel, float celsius );
uint8_t CayenneLppAddRelativeHumidity( uint8_t channel, float rh );
uint8_t CayenneLppAddAccelerometer( uint8_t channel, float x, float y, float z );
uint8_t CayenneLppAddBarometricPressure( uint8_t channel, float hpa );
uint8_t CayenneLppAddGyrometer( uint8_t channel, float x, float y, float z );
uint8_t CayenneLppAddGps( uint8_t channel, float latitude, float longitude, float meters );
#endif // __CAYENNE_LPP_H__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,335 @@
/*!
* \file LmHandler.h
*
* \brief Implements the LoRaMac layer handling.
* Provides the possibility to register applicative packages.
*
* \remark Inspired by the examples provided on the en.i-cube_lrwan fork.
* MCD Application Team ( STMicroelectronics International )
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LORAMAC_HANDLER_H__
#define __LORAMAC_HANDLER_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "LmHandlerTypes.h"
#include "LmhpCompliance.h"
typedef struct LmHandlerJoinParams_s
{
CommissioningParams_t *CommissioningParams;
int8_t Datarate;
LmHandlerErrorStatus_t Status;
}LmHandlerJoinParams_t;
typedef struct LmHandlerTxParams_s
{
uint8_t IsMcpsConfirm;
LoRaMacEventInfoStatus_t Status;
CommissioningParams_t *CommissioningParams;
LmHandlerMsgTypes_t MsgType;
uint8_t AckReceived;
int8_t Datarate;
uint32_t UplinkCounter;
LmHandlerAppData_t AppData;
int8_t TxPower;
uint8_t Channel;
}LmHandlerTxParams_t;
typedef struct LmHandlerRxParams_s
{
uint8_t IsMcpsIndication;
LoRaMacEventInfoStatus_t Status;
CommissioningParams_t *CommissioningParams;
int8_t Datarate;
int8_t Rssi;
int8_t Snr;
uint32_t DownlinkCounter;
int8_t RxSlot;
}LmHandlerRxParams_t;
typedef struct LoRaMAcHandlerBeaconParams_s
{
LoRaMacEventInfoStatus_t Status;
LmHandlerBeaconState_t State;
BeaconInfo_t Info;
}LoRaMAcHandlerBeaconParams_t;
typedef struct LmHandlerParams_s
{
/*!
* Region
*/
LoRaMacRegion_t Region;
/*!
* Holds the ADR state
*/
bool AdrEnable;
/*!
* Uplink datarate, when \ref AdrEnable is OFF
*/
int8_t TxDatarate;
/*!
* Enables/Disables a public network usage
*/
bool PublicNetworkEnable;
/*!
* LoRaWAN ETSI duty cycle control enable/disable
*
* \remark Please note that ETSI mandates duty cycled transmissions. Use only for test purposes
*/
bool DutyCycleEnabled;
/*!
* Application data buffer maximum size
*/
uint8_t DataBufferMaxSize;
/*!
* Application data buffer pointer
*/
uint8_t *DataBuffer;
}LmHandlerParams_t;
typedef struct LmHandlerCallbacks_s
{
/*!
* Get the current battery level
*
* \retval value Battery level ( 0: very low, 254: fully charged )
*/
uint8_t ( *GetBatteryLevel )( void );
/*!
* Get the current temperature
*
* \retval value Temperature in degree Celsius
*/
float ( *GetTemperature )( void );
/*!
* Returns a pseudo random seed generated using the MCU Unique ID
*
* \retval seed Generated pseudo random seed
*/
uint32_t ( *GetRandomSeed )( void );
/*!
*\brief Will be called each time a Radio IRQ is handled by the MAC
* layer.
*
*\warning Runs in a IRQ context. Should only change variables state.
*/
void ( *OnMacProcess )( void );
/*!
* Notifies the upper layer that the NVM context has changed
*
* \param [IN] stored Indicates if we are storing (true) or
* restoring (false) the NVM context
*/
void ( *OnNvmContextChange )( LmHandlerNvmContextStates_t state );
/*!
* Notifies the upper layer that a network parameters have been set
*
* \param [IN] params notification parameters
*/
void ( *OnNetworkParametersChange )( CommissioningParams_t *params );
/*!
* Notifies the upper layer that a MCPS request has been made to the MAC layer
*
* \param [IN] status - Request returned status
* \param [IN] mcpsRequest - Performed MCPS-Request. Refer to \ref McpsReq_t.
* \param [IN] nextTxDelay - Time to wait until another TX is possible.
*/
void ( *OnMacMcpsRequest )( LoRaMacStatus_t status, McpsReq_t *mcpsReq, TimerTime_t nextTxDelay );
/*!
* Notifies the upper layer that a MLME request has been made to the MAC layer
*
* \param [IN] status - Request returned status
* \param [IN] mlmeRequest - Performed MLME-Request. Refer to \ref MlmeReq_t.
* \param [IN] nextTxDelay - Time to wait until another TX is possible.
*/
void ( *OnMacMlmeRequest )( LoRaMacStatus_t status, MlmeReq_t *mlmeReq, TimerTime_t nextTxDelay );
/*!
* Notifies the upper layer that a network has been joined
*
* \param [IN] params notification parameters
*/
void ( *OnJoinRequest )( LmHandlerJoinParams_t *params );
/*!
* Notifies upper layer that a frame has been transmitted
*
* \param [IN] params notification parameters
*/
void ( *OnTxData )( LmHandlerTxParams_t *params );
/*!
* Notifies the upper layer that an applicative frame has been received
*
* \param [IN] appData Received applicative data
* \param [IN] params notification parameters
*/
void ( *OnRxData )( LmHandlerAppData_t *appData, LmHandlerRxParams_t *params );
/*!
* Confirms the LoRaWAN device class change
*
* \param [IN] deviceClass New end-device class
*/
void ( *OnClassChange )( DeviceClass_t deviceClass );
/*!
* Notifies the upper layer that the beacon status has changed
*
* \param [IN] params notification parameters
*/
void ( *OnBeaconStatusChange )( LoRaMAcHandlerBeaconParams_t *params );
#if( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
/*!
* Notifies the upper layer that the system time has been updated.
*
* \param [in] isSynchronized Indicates if the system time is synchronized in the range +/-1 second
* \param [in] timeCorrection Received time correction value
*/
void ( *OnSysTimeUpdate )( bool isSynchronized, int32_t timeCorrection );
#else
/*!
* Notifies the upper layer that the system time has been updated.
*/
void ( *OnSysTimeUpdate )( void );
#endif
}LmHandlerCallbacks_t;
/*!
* LoRaMac handler initialisation
*
* \param [IN] callbacks LoRaMac handler callbacks
* \param [IN] handlerParams LoRaMac handler parameters
*
* \retval none
*/
LmHandlerErrorStatus_t LmHandlerInit( LmHandlerCallbacks_t *callbacks,
LmHandlerParams_t *handlerParams );
/*!
* Indicates if the LoRaMacHandler is busy
*
* \retval status [true] Busy, [false] free
*/
bool LmHandlerIsBusy( void );
/*!
* Processes the LoRaMac and Radio events.
* When no pendig operation asks to go in low power mode.
*
* \remark This function must be called in the main loop.
*/
void LmHandlerProcess( void );
/*!
* Instructs the MAC layer to send a ClassA uplink
*
* \param [IN] appData Data to be sent
* \param [IN] isTxConfirmed Indicates if the uplink requires an acknowledgement
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t LmHandlerSend( LmHandlerAppData_t *appData, LmHandlerMsgTypes_t isTxConfirmed );
/*!
* Join a LoRa Network in classA
*
* \Note if the device is ABP, this is a pass through function
*/
void LmHandlerJoin( void );
/*!
* Check whether the Device is joined to the network
*
* \param [IN] none
*
* \retval status Returns \ref LORAMAC_HANDLER_SET if joined else \ref LORAMAC_HANDLER_RESET
*/
LmHandlerFlagStatus_t LmHandlerJoinStatus( void );
/*!
* Informs the server on the ping-slot periodicity to use
*
* \param [IN] periodicity Is equal to 2^periodicity seconds.
* Example: 2^3 = 8 seconds. The end-device will open an Rx slot every 8 seconds.
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t LmHandlerPingSlotReq( uint8_t periodicity );
/*!
* Request the MAC layer to change LoRaWAN class
*
* \Note Callback \ref LmHandlerConfirmClass informs upper layer that the change has occurred
* \Note Only switch from class A to class B/C OR from class B/C to class A is allowed
*
* \param [IN] newClass New class to be requested
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t LmHandlerRequestClass( DeviceClass_t newClass );
/*!
* Gets the current LoRaWAN class
*
* \retval currentClass Current LoRaWAN class
*/
DeviceClass_t LmHandlerGetCurrentClass( void );
/*!
* Gets the current datarate
*
* \retval currentDatarate Current datarate
*/
int8_t LmHandlerGetCurrentDatarate( void );
/*!
* Gets the current active region
*
* \retval currentRegion Current active region
*/
LoRaMacRegion_t LmHandlerGetActiveRegion( void );
/*!
* Set system maximum tolerated rx error in milliseconds
*
* \param [IN] maxErrorInMs Maximum tolerated error in milliseconds
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t LmHandlerSetSystemMaxRxError( uint32_t maxErrorInMs );
/*
*=============================================================================
* PACKAGES HANDLING
*=============================================================================
*/
LmHandlerErrorStatus_t LmHandlerPackageRegister( uint8_t id, void *params );
bool LmHandlerPackageIsInitialized( uint8_t id );
bool LmHandlerPackageIsRunning( uint8_t id );
#ifdef __cplusplus
}
#endif
#endif // __LORAMAC_HANDLER_H__

View File

@@ -0,0 +1,124 @@
/*!
* \file LmHandlerTypes.h
*
* \brief Defines the types used by LmHandler
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LORAMAC_HANDLER_TYPES_H__
#define __LORAMAC_HANDLER_TYPES_H__
#include "LoRaMac.h"
/*!
* If set to 1 the new API defining \ref OnSysTimeUpdate callback is used.
*/
#define LMH_SYS_TIME_UPDATE_NEW_API 1
/*!
*
*/
typedef enum
{
LORAMAC_HANDLER_ADR_OFF = 0,
LORAMAC_HANDLER_ADR_ON = !LORAMAC_HANDLER_ADR_OFF
}LmHandlerAdrStates_t;
/*!
*
*/
typedef enum
{
LORAMAC_HANDLER_RESET = 0,
LORAMAC_HANDLER_SET = !LORAMAC_HANDLER_RESET
}LmHandlerFlagStatus_t;
/*!
*
*/
typedef enum
{
LORAMAC_HANDLER_ERROR = -1,
LORAMAC_HANDLER_SUCCESS = 0
}LmHandlerErrorStatus_t;
/*!
*
*/
typedef enum
{
LORAMAC_HANDLER_UNCONFIRMED_MSG = 0,
LORAMAC_HANDLER_CONFIRMED_MSG = !LORAMAC_HANDLER_UNCONFIRMED_MSG
}LmHandlerMsgTypes_t;
/*!
*
*/
typedef enum
{
LORAMAC_HANDLER_FALSE = 0,
LORAMAC_HANDLER_TRUE = !LORAMAC_HANDLER_FALSE
}LmHandlerBoolean_t;
typedef enum
{
LORAMAC_HANDLER_BEACON_ACQUIRING,
LORAMAC_HANDLER_BEACON_LOST,
LORAMAC_HANDLER_BEACON_RX,
LORAMAC_HANDLER_BEACON_NRX
}LmHandlerBeaconState_t;
typedef enum
{
LORAMAC_HANDLER_NVM_RESTORE,
LORAMAC_HANDLER_NVM_STORE,
}LmHandlerNvmContextStates_t;
/*!
* Commissioning parameters
*/
typedef struct CommissioningParams_s
{
bool IsOtaaActivation;
uint8_t DevEui[8];
uint8_t JoinEui[8];
uint8_t SePin[4];
uint32_t NetworkId;
uint32_t DevAddr;
}CommissioningParams_t;
/*!
* Application data structure
*/
typedef struct LmHandlerAppData_s
{
uint8_t Port;
uint8_t BufferSize;
uint8_t *Buffer;
}LmHandlerAppData_t;
typedef struct LmHandlerRequestParams_s
{
uint8_t IsMcpsRequest;
LoRaMacStatus_t Status;
union
{
Mcps_t Mcps;
Mlme_t Mlme;
}RequestType;
}LmHandlerRequestParams_t;
#endif // __LORAMAC_HANDLER_TYPES_H__

View File

@@ -0,0 +1,750 @@
/*!
* \file FragDecoder.c
*
* \brief Implements the LoRa-Alliance fragmentation decoder
* Specification: https://lora-alliance.org/sites/default/files/2018-09/fragmented_data_block_transport_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Fabien Holin ( Semtech )
* \author Miguel Luis ( Semtech )
*/
#include <stddef.h>
#include <stdbool.h>
#include "utilities.h"
#include "FragDecoder.h"
#define DBG_TRACE 0
#if DBG_TRACE == 1
#include <stdio.h>
/*!
* Works in the same way as the printf function does.
*/
#define DBG( ... ) \
do \
{ \
printf( __VA_ARGS__ ); \
}while( 0 )
#else
#define DBG( fmt, ... )
#endif
/*
*=============================================================================
* Fragmentation decoder algorithm utilities
*=============================================================================
*/
typedef struct
{
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
FragDecoderCallbacks_t *Callbacks;
#else
uint8_t *File;
uint32_t FileSize;
#endif
uint16_t FragNb;
uint8_t FragSize;
uint32_t M2BLine;
uint8_t MatrixM2B[( ( FRAG_MAX_REDUNDANCY >> 3 ) + 1 ) * FRAG_MAX_REDUNDANCY];
uint16_t FragNbMissingIndex[FRAG_MAX_NB];
uint8_t S[( FRAG_MAX_REDUNDANCY >> 3 ) + 1];
FragDecoderStatus_t Status;
}FragDecoder_t;
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* \brief Sets a row from source into file destination
*
* \param [IN] src Source buffer pointer
* \param [IN] row Destination index of the row to be copied
* \param [IN] size Source number of bytes to be copied
*/
static void SetRow( uint8_t *src, uint16_t row, uint16_t size );
#else
/*!
* \brief Sets a row from source into destination
*
* \param [IN] dst Destination buffer pointer
* \param [IN] src Source buffer pointer
* \param [IN] row Destination index of the row to be copied
* \param [IN] size Source number of bytes to be copied
*/
static void SetRow( uint8_t *dst, uint8_t *src, uint16_t row, uint16_t size );
#endif
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* \brief Gets a row from source and stores it into file destination
*
* \param [IN] src Source buffer pointer
* \param [IN] row Source index of the row to be copied
* \param [IN] size Source number of bytes to be copied
*/
static void GetRow( uint8_t *src, uint16_t row, uint16_t size );
#else
/*!
* \brief Gets a row from source and stores it into destination
*
* \param [IN] dst Destination buffer pointer
* \param [IN] src Source buffer pointer
* \param [IN] row Source index of the row to be copied
* \param [IN] size Source number of bytes to be copied
*/
static void GetRow( uint8_t *dst, uint8_t *src, uint16_t row, uint16_t size );
#endif
/*!
* \brief Gets the parity value from a given row of the parity matrix
*
* \param [IN] index The index of the row to be computed
* \param [IN] matrixRow Pointer to the parity matrix (parity bit array)
*
* \retval parity Parity value at the given index
*/
static uint8_t GetParity( uint16_t index, uint8_t *matrixRow );
/*!
* \brief Sets the parity value on the given row of the parity matrix
*
* \param [IN] index The index of the row to be computed
* \param [IN/OUT] matrixRow Pointer to the parity matrix.
* \param [IN] parity The parity value to be set in the parity matrix
*/
static void SetParity( uint16_t index, uint8_t *matrixRow, uint8_t parity );
/*!
* \brief Check if the provided value is a power of 2
*
* \param [IN] x Value to be tested
*
* \retval status Return true if frame is a power of two
*/
static bool IsPowerOfTwo( uint32_t x );
/*!
* \brief XOrs two data lines
*
* \param [IN] line1 1st Data line to be XORed
* \param [IN] line2 2nd Data line to be XORed
* \param [IN] size Number of elements in line1
*
* \param [OUT] result XOR( line1, line2 ) result stored in line1
*/
static void XorDataLine( uint8_t *line1, uint8_t *line2, int32_t size );
/*!
* \brief XORs two parity lines
*
* \param [IN] line1 1st Parity line to be XORed
* \param [IN] line2 2nd Parity line to be XORed
* \param [IN] size Number of elements in line1
*
* \param [OUT] result XOR( line1, line2 ) result stored in line1
*/
static void XorParityLine( uint8_t* line1, uint8_t* line2, int32_t size );
/*!
* \brief Generates a pseudo random number : PRBS23
*
* \param [IN] value The input of the PRBS23 generator
*
* \retval nextValue Returns the next pseudo random number
*/
static int32_t FragPrbs23( int32_t value );
/*!
* \brief Gets and fills the parity matrix
*
* \param [IN] n Fragment N
* \param [IN] m Fragment number
* \param [OUT] matrixRow Parity matrix
*/
static void FragGetParityMatrixRow( int32_t n, int32_t m, uint8_t *matrixRow );
/*!
* \brief Finds the index of the first one in a bit array
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] size Bit array size
* \retval index The index of the first 1 in the bit array
*/
static uint16_t BitArrayFindFirstOne( uint8_t *bitArray, uint16_t size );
/*!
* \brief Checks if the provided bit array only contains zeros
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] size Bit array size
* \retval isAllZeros [0: Contains ones, 1: Contains all zeros]
*/
static uint8_t BitArrayIsAllZeros( uint8_t *bitArray, uint16_t size );
/*!
* \brief Finds & marks missing fragments
*
* \param [IN] counter Current fragment counter
* \param [OUT] FragDecoder.FragNbMissingIndex[] array is updated in place
*/
static void FragFindMissingFrags( uint16_t counter );
/*!
* \brief Finds the index (frag counter) of the x th missing frag
*
* \param [IN] x x th missing frag
*
* \retval counter The counter value associated to the x th missing frag
*/
static uint16_t FragFindMissingIndex( uint16_t x );
/*!
* \brief Extacts a row from the binary matrix and expands it to a bitArray
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] rowIndex Matrix row index
* \param [IN] bitsInRow Number of bits in one row
*/
static void FragExtractLineFromBinaryMatrix( uint8_t* bitArray, uint16_t rowIndex, uint16_t bitsInRow );
/*!
* \brief Collapses and Pushs a row of a bit array to the matrix
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] rowIndex Matrix row index
* \param [IN] bitsInRow Number of bits in one row
*/
static void FragPushLineToBinaryMatrix( uint8_t *bitArray, uint16_t rowIndex, uint16_t bitsInRow );
/*
*=============================================================================
* Fragmentation decoder algorithm
*=============================================================================
*/
static FragDecoder_t FragDecoder;
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
void FragDecoderInit( uint16_t fragNb, uint8_t fragSize, FragDecoderCallbacks_t *callbacks )
#else
void FragDecoderInit( uint16_t fragNb, uint8_t fragSize, uint8_t *file, uint32_t fileSize )
#endif
{
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
FragDecoder.Callbacks = callbacks;
#else
FragDecoder.File = file;
FragDecoder.FileSize = fileSize;
#endif
FragDecoder.FragNb = fragNb; // FragNb = FRAG_MAX_SIZE
FragDecoder.FragSize = fragSize; // number of byte on a row
FragDecoder.Status.FragNbLastRx = 0;
FragDecoder.Status.FragNbLost = 0;
FragDecoder.M2BLine = 0;
// Initialize missing fragments index array
for( uint16_t i = 0; i < FRAG_MAX_NB; i++ )
{
FragDecoder.FragNbMissingIndex[i] = 1;
}
// Initialize parity matrix
for( uint32_t i = 0; i < ( ( FRAG_MAX_REDUNDANCY >> 3 ) + 1 ); i++ )
{
FragDecoder.S[i] = 0;
}
for( uint32_t i = 0; i < ( ( ( FRAG_MAX_REDUNDANCY >> 3 ) + 1 ) * FRAG_MAX_REDUNDANCY ); i++ )
{
FragDecoder.MatrixM2B[i] = 0xFF;
}
// Initialize final uncoded data buffer ( FRAG_MAX_NB * FRAG_MAX_SIZE )
for( uint32_t i = 0; i < ( fragNb * fragSize ); i++ )
{
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
if( ( FragDecoder.Callbacks != NULL ) && ( FragDecoder.Callbacks->FragDecoderWrite != NULL ) )
{
FragDecoder.Callbacks->FragDecoderWrite( i, ( uint8_t[] ){ 0xFF }, 1 );
}
#else
FragDecoder.File[i] = 0xFF;
#endif
}
FragDecoder.Status.FragNbLost = 0;
FragDecoder.Status.FragNbLastRx = 0;
}
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
uint32_t FragDecoderGetMaxFileSize( void )
{
return FRAG_MAX_NB * FRAG_MAX_SIZE;
}
#endif
int32_t FragDecoderProcess( uint16_t fragCounter, uint8_t *rawData )
{
uint16_t firstOneInRow = 0;
int32_t first = 0;
int32_t noInfo = 0;
uint8_t matrixRow[(FRAG_MAX_NB >> 3 ) + 1];
uint8_t matrixDataTemp[FRAG_MAX_SIZE];
uint8_t dataTempVector[( FRAG_MAX_REDUNDANCY >> 3 ) + 1];
uint8_t dataTempVector2[( FRAG_MAX_REDUNDANCY >> 3 ) + 1];
memset1( matrixRow, 0, ( FRAG_MAX_NB >> 3 ) + 1 );
memset1( matrixDataTemp, 0, FRAG_MAX_SIZE );
memset1( dataTempVector, 0, ( FRAG_MAX_REDUNDANCY >> 3 ) + 1 );
memset1( dataTempVector2, 0, ( FRAG_MAX_REDUNDANCY >> 3 ) + 1 );
FragDecoder.Status.FragNbRx = fragCounter;
if( fragCounter < FragDecoder.Status.FragNbLastRx )
{
return FRAG_SESSION_ONGOING; // Drop frame out of order
}
// The M (FragNb) first packets aren't encoded or in other words they are
// encoded with the unitary matrix
if( fragCounter < ( FragDecoder.FragNb + 1 ) )
{
// The M first frame are not encoded store them
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
SetRow( rawData, fragCounter - 1, FragDecoder.FragSize );
#else
SetRow( FragDecoder.File, rawData, fragCounter - 1, FragDecoder.FragSize );
#endif
FragDecoder.FragNbMissingIndex[fragCounter - 1] = 0;
// Update the FragDecoder.FragNbMissingIndex with the loosing frame
FragFindMissingFrags( fragCounter );
}
else
{
if( FragDecoder.Status.FragNbLost > FRAG_MAX_REDUNDANCY )
{
FragDecoder.Status.MatrixError = 1;
return FRAG_SESSION_FINISHED;
}
// At this point we receive encoded frames and the number of loosing frames
// is well known: FragDecoder.FragNbLost - 1;
// In case of the end of true data is missing
FragFindMissingFrags( fragCounter );
if( FragDecoder.Status.FragNbLost == 0 )
{
// the case : all the M(FragNb) first rows have been transmitted with no error
return FragDecoder.Status.FragNbLost;
}
// fragCounter - FragDecoder.FragNb
FragGetParityMatrixRow( fragCounter - FragDecoder.FragNb, FragDecoder.FragNb, matrixRow );
for( int32_t i = 0; i < FragDecoder.FragNb; i++ )
{
if( GetParity( i , matrixRow ) == 1 )
{
if( FragDecoder.FragNbMissingIndex[i] == 0 )
{
// XOR with already receive frag
SetParity( i, matrixRow, 0 );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
GetRow( matrixDataTemp, i, FragDecoder.FragSize );
#else
GetRow( matrixDataTemp, FragDecoder.File, i, FragDecoder.FragSize );
#endif
XorDataLine( rawData, matrixDataTemp, FragDecoder.FragSize );
}
else
{
// Fill the "little" boolean matrix m2b
SetParity( FragDecoder.FragNbMissingIndex[i] - 1, dataTempVector, 1 );
if( first == 0 )
{
first = 1;
}
}
}
}
firstOneInRow = BitArrayFindFirstOne( dataTempVector, FragDecoder.Status.FragNbLost );
if( first > 0 )
{
int32_t li;
int32_t lj;
// Manage a new line in MatrixM2B
while( GetParity( firstOneInRow, FragDecoder.S ) == 1 )
{
// Row already diagonalized exist & ( FragDecoder.MatrixM2B[firstOneInRow][0] )
FragExtractLineFromBinaryMatrix( dataTempVector2, firstOneInRow, FragDecoder.Status.FragNbLost );
XorParityLine( dataTempVector, dataTempVector2, FragDecoder.Status.FragNbLost );
// Have to store it in the mi th position of the missing frag
li = FragFindMissingIndex( firstOneInRow );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
GetRow( matrixDataTemp, li, FragDecoder.FragSize );
#else
GetRow( matrixDataTemp, FragDecoder.File, li, FragDecoder.FragSize );
#endif
XorDataLine( rawData, matrixDataTemp, FragDecoder.FragSize );
if( BitArrayIsAllZeros( dataTempVector, FragDecoder.Status.FragNbLost ) )
{
noInfo = 1;
break;
}
firstOneInRow = BitArrayFindFirstOne( dataTempVector, FragDecoder.Status.FragNbLost );
}
if( noInfo == 0 )
{
FragPushLineToBinaryMatrix( dataTempVector, firstOneInRow, FragDecoder.Status.FragNbLost );
li = FragFindMissingIndex( firstOneInRow );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
SetRow( rawData, li, FragDecoder.FragSize );
#else
SetRow( FragDecoder.File, rawData, li, FragDecoder.FragSize );
#endif
SetParity( firstOneInRow, FragDecoder.S, 1 );
FragDecoder.M2BLine++;
}
if( FragDecoder.M2BLine == FragDecoder.Status.FragNbLost )
{
// Then last step diagonalized
if( FragDecoder.Status.FragNbLost > 1 )
{
int32_t i, j;
for( i = ( FragDecoder.Status.FragNbLost - 2 ); i >= 0 ; i-- )
{
li = FragFindMissingIndex( i );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
GetRow( matrixDataTemp, li, FragDecoder.FragSize );
#else
GetRow( matrixDataTemp, FragDecoder.File, li, FragDecoder.FragSize );
#endif
for( j = ( FragDecoder.Status.FragNbLost - 1 ); j > i; j--)
{
FragExtractLineFromBinaryMatrix( dataTempVector2, i, FragDecoder.Status.FragNbLost );
FragExtractLineFromBinaryMatrix( dataTempVector, j, FragDecoder.Status.FragNbLost );
if( GetParity( j, dataTempVector2 ) == 1 )
{
XorParityLine( dataTempVector2, dataTempVector, FragDecoder.Status.FragNbLost );
lj = FragFindMissingIndex( j );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
GetRow( rawData, lj, FragDecoder.FragSize );
#else
GetRow( rawData, FragDecoder.File, lj, FragDecoder.FragSize );
#endif
XorDataLine( matrixDataTemp , rawData , FragDecoder.FragSize );
}
}
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
SetRow( matrixDataTemp, li, FragDecoder.FragSize );
#else
SetRow( FragDecoder.File, matrixDataTemp, li, FragDecoder.FragSize );
#endif
}
return FragDecoder.Status.FragNbLost;
}
else
{
//If not ( FragDecoder.FragNbLost > 1 )
return FragDecoder.Status.FragNbLost;
}
}
}
}
return FRAG_SESSION_ONGOING;
}
FragDecoderStatus_t FragDecoderGetStatus( void )
{
return FragDecoder.Status;
}
/*
*=============================================================================
* Fragmentation decoder algorithm utilities
*=============================================================================
*/
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
static void SetRow( uint8_t *src, uint16_t row, uint16_t size )
{
if( ( FragDecoder.Callbacks != NULL ) && ( FragDecoder.Callbacks->FragDecoderWrite != NULL ) )
{
FragDecoder.Callbacks->FragDecoderWrite( row * size, src, size );
}
}
static void GetRow( uint8_t *dst, uint16_t row, uint16_t size )
{
if( ( FragDecoder.Callbacks != NULL ) && ( FragDecoder.Callbacks->FragDecoderRead != NULL ) )
{
FragDecoder.Callbacks->FragDecoderRead( row * size, dst, size );
}
}
#else
static void SetRow( uint8_t *dst, uint8_t *src, uint16_t row, uint16_t size )
{
memcpy1( &dst[row * size], src, size );
}
static void GetRow( uint8_t *dst, uint8_t *src, uint16_t row, uint16_t size )
{
memcpy1( dst, &src[row * size], size );
}
#endif
static uint8_t GetParity( uint16_t index, uint8_t *matrixRow )
{
uint8_t parity;
parity = matrixRow[index >> 3];
parity = ( parity >> ( 7 - ( index % 8 ) ) ) & 0x01;
return parity;
}
static void SetParity( uint16_t index, uint8_t *matrixRow, uint8_t parity )
{
uint8_t mask = 0xFF - ( 1 << ( 7 - ( index % 8 ) ) );
parity = parity << ( 7 - ( index % 8 ) );
matrixRow[index >> 3] = ( matrixRow[index >> 3] & mask ) + parity;
}
static bool IsPowerOfTwo( uint32_t x )
{
uint8_t sumBit = 0;
for( uint8_t i = 0; i < 32; i++ )
{
sumBit += ( x & ( 1 << i ) ) >> i;
}
if( sumBit == 1 )
{
return true;
}
return false;
}
static void XorDataLine( uint8_t *line1, uint8_t *line2, int32_t size )
{
for( int32_t i = 0; i < size; i++ )
{
line1[i] = line1[i] ^ line2[i];
}
}
static void XorParityLine( uint8_t* line1, uint8_t* line2, int32_t size )
{
for( int32_t i = 0; i < size; i++ )
{
SetParity( i, line1, ( GetParity( i, line1 ) ^ GetParity( i, line2 ) ) );
}
}
static int32_t FragPrbs23( int32_t value )
{
int32_t b0 = value & 0x01;
int32_t b1 = ( value & 0x20 ) >> 5;
return ( value >> 1 ) + ( ( b0 ^ b1 ) << 22 );;
}
static void FragGetParityMatrixRow( int32_t n, int32_t m, uint8_t *matrixRow )
{
int32_t mTemp;
int32_t x;
int32_t nbCoeff = 0;
int32_t r;
if( IsPowerOfTwo( m ) != false )
{
mTemp = 1;
}
else
{
mTemp = 0;
}
x = 1 + ( 1001 * n );
for( uint8_t i = 0; i < ( ( m >> 3 ) + 1 ); i++ )
{
matrixRow[i] = 0;
}
while( nbCoeff < ( m >> 1 ) )
{
r = 1 << 16;
while( r >= m )
{
x = FragPrbs23( x );
r = x % ( m + mTemp );
}
SetParity( r, matrixRow, 1 );
nbCoeff += 1;
}
}
static uint16_t BitArrayFindFirstOne( uint8_t *bitArray, uint16_t size )
{
for( uint16_t i = 0; i < size; i++)
{
if ( GetParity( i, bitArray ) == 1 )
{
return i;
}
}
return 0;
}
static uint8_t BitArrayIsAllZeros( uint8_t *bitArray, uint16_t size )
{
for( uint16_t i = 0; i < size; i++ )
{
if( GetParity( i, bitArray ) == 1 )
{
return 0;
}
}
return 1;
}
/*!
* \brief Finds & marks missing fragments
*
* \param [IN] counter Current fragment counter
* \param [OUT] FragDecoder.FragNbMissingIndex[] array is updated in place
*/
static void FragFindMissingFrags( uint16_t counter )
{
int32_t i;
for( i = FragDecoder.Status.FragNbLastRx; i < ( counter - 1 ); i++ )
{
if( i < FragDecoder.FragNb )
{
FragDecoder.Status.FragNbLost++;
FragDecoder.FragNbMissingIndex[i] = FragDecoder.Status.FragNbLost;
}
}
if( i < FragDecoder.FragNb )
{
FragDecoder.Status.FragNbLastRx = counter;
}
else
{
FragDecoder.Status.FragNbLastRx = FragDecoder.FragNb + 1;
}
DBG( "RECEIVED : %5d / %5d Fragments\n", FragDecoder.Status.FragNbRx, FragDecoder.FragNb );
DBG( " %5d / %5d Bytes\n", FragDecoder.Status.FragNbRx * FragDecoder.FragSize, FragDecoder.FragNb * FragDecoder.FragSize );
DBG( "LOST : %7d Fragments\n\n", FragDecoder.Status.FragNbLost );
}
/*!
* \brief Finds the index (frag counter) of the x th missing frag
*
* \param [IN] x x th missing frag
*
* \retval counter The counter value associated to the x th missing frag
*/
static uint16_t FragFindMissingIndex( uint16_t x )
{
for( uint16_t i = 0; i < FragDecoder.FragNb; i++ )
{
if( FragDecoder.FragNbMissingIndex[i] == ( x + 1 ) )
{
return i;
}
}
return 0;
}
/*!
* \brief Extacts a row from the binary matrix and expands it to a bitArray
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] rowIndex Matrix row index
* \param [IN] bitsInRow Number of bits in one row
*/
static void FragExtractLineFromBinaryMatrix( uint8_t* bitArray, uint16_t rowIndex, uint16_t bitsInRow )
{
uint32_t findByte = 0;
uint32_t findBitInByte = 0;
if( rowIndex > 0 )
{
findByte = ( rowIndex * bitsInRow - ( ( rowIndex * ( rowIndex - 1 ) ) >> 1 ) ) >> 3;
findBitInByte = ( rowIndex * bitsInRow - ( ( rowIndex * ( rowIndex - 1 ) ) >> 1 ) ) % 8;
}
if( rowIndex > 0 )
{
for( uint16_t i = 0; i < rowIndex; i++ )
{
SetParity( i, bitArray, 0 );
}
}
for( uint16_t i = rowIndex; i < bitsInRow; i++ )
{
SetParity( i,
bitArray,
( FragDecoder.MatrixM2B[findByte] >> ( 7 - findBitInByte ) ) & 0x01 );
findBitInByte++;
if( findBitInByte == 8 )
{
findBitInByte = 0;
findByte++;
}
}
}
/*!
* \brief Collapses and Pushs a row of a bit array to the matrix
*
* \param [IN] bitArray Pointer to the bit array
* \param [IN] rowIndex Matrix row index
* \param [IN] bitsInRow Number of bits in one row
*/
static void FragPushLineToBinaryMatrix( uint8_t *bitArray, uint16_t rowIndex, uint16_t bitsInRow )
{
uint32_t findByte = 0;
uint32_t findBitInByte = 0;
if ( rowIndex > 0) {
findByte = ( rowIndex * bitsInRow - ( ( rowIndex * ( rowIndex - 1 ) ) >> 1 ) ) >> 3;
findBitInByte = ( rowIndex * bitsInRow - ( ( rowIndex * ( rowIndex - 1 ) ) >> 1 ) ) % 8;
}
for( uint16_t i = rowIndex; i < bitsInRow; i++ )
{
if( GetParity( i, bitArray ) == 0 )
{
FragDecoder.MatrixM2B[findByte] = FragDecoder.MatrixM2B[findByte] & ( 0xFF - ( 1 << ( 7 - findBitInByte ) ) );
}
findBitInByte++;
if( findBitInByte == 8 )
{
findBitInByte = 0;
findByte++;
}
}
}

View File

@@ -0,0 +1,143 @@
/*!
* \file FragDecoder.h
*
* \brief Implements the LoRa-Alliance fragmentation decoder
* Specification: https://lora-alliance.org/sites/default/files/2018-09/fragmented_data_block_transport_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Fabien Holin ( Semtech )
* \author Miguel Luis ( Semtech )
*/
#ifndef __FRAG_DECODER_H__
#define __FRAG_DECODER_H__
#include <stdint.h>
/*!
* If set to 1 the new API defining \ref FragDecoderWrite and
* \ref FragDecoderReadfunction callbacks is used.
*/
#define FRAG_DECODER_FILE_HANDLING_NEW_API 1
/*!
* Maximum number of fragment that can be handled.
*
* \remark This parameter has an impact on the memory footprint.
*/
#define FRAG_MAX_NB 21
/*!
* Maximum fragment size that can be handled.
*
* \remark This parameter has an impact on the memory footprint.
*/
#define FRAG_MAX_SIZE 50
/*!
* Maximum number of extra frames that can be handled.
*
* \remark This parameter has an impact on the memory footprint.
*/
#define FRAG_MAX_REDUNDANCY 5
#define FRAG_SESSION_FINISHED ( int32_t )0
#define FRAG_SESSION_NOT_STARTED ( int32_t )-2
#define FRAG_SESSION_ONGOING ( int32_t )-1
typedef struct sFragDecoderStatus
{
uint16_t FragNbRx;
uint16_t FragNbLost;
uint16_t FragNbLastRx;
uint8_t MatrixError;
}FragDecoderStatus_t;
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
typedef struct sFragDecoderCallbacks
{
/*!
* Writes `data` buffer of `size` starting at address `addr`
*
* \param [IN] addr Address start index to write to.
* \param [IN] data Data buffer to be written.
* \param [IN] size Size of data buffer to be written.
*
* \retval status Write operation status [0: Success, -1 Fail]
*/
uint8_t ( *FragDecoderWrite )( uint32_t addr, uint8_t *data, uint32_t size );
/*!
* Reads `data` buffer of `size` starting at address `addr`
*
* \param [IN] addr Address start index to read from.
* \param [IN] data Data buffer to be read.
* \param [IN] size Size of data buffer to be read.
*
* \retval status Read operation status [0: Success, -1 Fail]
*/
uint8_t ( *FragDecoderRead )( uint32_t addr, uint8_t *data, uint32_t size );
}FragDecoderCallbacks_t;
#endif
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* \brief Initializes the fragmentation decoder
*
* \param [IN] fragNb Number of expected fragments (without redundancy packets)
* \param [IN] fragSize Size of a fragment
* \param [IN] callbacks Pointer to the Write/Read functions.
*/
void FragDecoderInit( uint16_t fragNb, uint8_t fragSize, FragDecoderCallbacks_t *callbacks );
#else
/*!
* \brief Initializes the fragmentation decoder
*
* \param [IN] fragNb Number of expected fragments (without redundancy packets)
* \param [IN] fragSize Size of a fragment
* \param [IN] file Pointer to file buffer size
* \param [IN] fileSize File buffer size
*/
void FragDecoderInit( uint16_t fragNb, uint8_t fragSize, uint8_t *file, uint32_t fileSize );
#endif
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* \brief Gets the maximum file size that can be received
*
* \retval size FileSize
*/
uint32_t FragDecoderGetMaxFileSize( void );
#endif
/*!
* \brief Function to decode and reconstruct the binary file
* Called for each receive frame
*
* \param [IN] fragCounter Fragment counter [1..(FragDecoder.FragNb + FragDecoder.Redundancy)]
* \param [IN] rawData Pointer to the fragment to be processed (length = FragDecoder.FragSize)
*
* \retval status Process status. [FRAG_SESSION_ONGOING,
* FRAG_SESSION_FINISHED or
* FragDecoder.Status.FragNbLost]
*/
int32_t FragDecoderProcess( uint16_t fragCounter, uint8_t *rawData );
/*!
* \brief Gets the current fragmentation status
*
* \retval status Fragmentation decoder status
*/
FragDecoderStatus_t FragDecoderGetStatus( void );
#endif // __FRAG_DECODER_H__

View File

@@ -0,0 +1,156 @@
/*!
* \file LmPackage.h
*
* \brief Defines the packages API
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMH_PACKAGE_H__
#define __LMH_PACKAGE_H__
#include <stdint.h>
#include <stdbool.h>
#include "LmHandlerTypes.h"
/*!
* Maximum number of packages
*/
#define PKG_MAX_NUMBER 4
typedef struct LmhPackage_s
{
uint8_t Port;
/*
*=========================================================================
* Below callbacks must be initialized in package variable declaration
*=========================================================================
*/
/*!
* Initializes the package with provided parameters
*
* \param [IN] params Pointer to the package parameters
* \param [IN] dataBuffer Pointer to main application buffer
* \param [IN] dataBufferMaxSize Main application buffer maximum size
*/
void ( *Init )( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize );
/*!
* Returns the current package initialization status.
*
* \retval status Package initialization status
* [true: Initialized, false: Not initialized]
*/
bool ( *IsInitialized )( void );
/*!
* Returns the package operation status.
*
* \retval status Package operation status
* [true: Running, false: Not running]
*/
bool ( *IsRunning )( void );
/*!
* Processes the internal package events.
*/
void ( *Process )( void );
/*!
* Processes the MCSP Confirm
*
* \param [IN] mcpsConfirm MCPS confirmation primitive data
*/
void ( *OnMcpsConfirmProcess )( McpsConfirm_t *mcpsConfirm );
/*!
* Processes the MCPS Indication
*
* \param [IN] mcpsIndication MCPS indication primitive data
*/
void ( *OnMcpsIndicationProcess )( McpsIndication_t *mcpsIndication );
/*!
* Processes the MLME Confirm
*
* \param [IN] mlmeConfirm MLME confirmation primitive data
*/
void ( *OnMlmeConfirmProcess )( MlmeConfirm_t *mlmeConfirm );
/*!
* Processes the MLME Indication
*
* \param [IN] mlmeIndication MLME indication primitive data
*/
void ( *OnMlmeIndicationProcess )( MlmeIndication_t *mlmeIndication );
/*
*=========================================================================
* Below callbacks must be initialized in LmHandler initialization with
* provideded LmHandlerSend and OnMacRequest functions
*=========================================================================
*/
/*!
* Notifies the upper layer that a MCPS request has been made to the MAC layer
*
* \param [IN] status - Request returned status
* \param [IN] mcpsRequest - Performed MCPS-Request. Refer to \ref McpsReq_t.
* \param [IN] nextTxDelay - Time to wait until another TX is possible.
*/
void ( *OnMacMcpsRequest )( LoRaMacStatus_t status, McpsReq_t *mcpsReq, TimerTime_t nextTxDelay );
/*!
* Notifies the upper layer that a MLME request has been made to the MAC layer
*
* \param [IN] status - Request returned status
* \param [IN] mlmeRequest - Performed MLME-Request. Refer to \ref MlmeReq_t.
* \param [IN] nextTxDelay - Time to wait until another TX is possible.
*/
void ( *OnMacMlmeRequest )( LoRaMacStatus_t status, MlmeReq_t *mlmeReq, TimerTime_t nextTxDelay );
/*!
* Join a LoRa Network in classA
*
* \Note if the device is ABP, this is a pass through function
*
* \param [IN] isOtaa Indicates which activation mode must be used
*/
void ( *OnJoinRequest )( bool isOtaa );
/*!
* Instructs the MAC layer to send a ClassA uplink
*
* \param [IN] appData Data to be sent
* \param [IN] isTxConfirmed Indicates if the uplink requires an acknowledgement
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t ( *OnSendRequest )( LmHandlerAppData_t *appData, LmHandlerMsgTypes_t isTxConfirmed );
/*!
* Requests network server time update
*
* \retval status Returns \ref LORAMAC_HANDLER_SET if joined else \ref LORAMAC_HANDLER_RESET
*/
LmHandlerErrorStatus_t ( *OnDeviceTimeRequest )( void );
#if( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
/*!
* Notifies the upper layer that the system time has been updated.
*
* \param [in] isSynchronized Indicates if the system time is synchronized in the range +/-1 second
* \param [in] timeCorrection Received time correction value
*/
void ( *OnSysTimeUpdate )( bool isSynchronized, int32_t timeCorrection );
#else
/*!
* Notifies the upper layer that the system time has been updated.
*/
void ( *OnSysTimeUpdate )( void );
#endif
}LmhPackage_t;
#endif // __LMH_PACKAGE_H__

View File

@@ -0,0 +1,375 @@
/*!
* \file LmhpClockSync.c
*
* \brief Implements the LoRa-Alliance clock synchronization package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/application_layer_clock_synchronization_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include "systime.h"
#include "LmHandler.h"
#include "LmhpClockSync.h"
/*!
* LoRaWAN Application Layer Clock Synchronization Specification
*/
#define CLOCK_SYNC_PORT 202
#define CLOCK_SYNC_ID 1
#define CLOCK_SYNC_VERSION 1
/*!
* Package current context
*/
typedef struct LmhpClockSyncState_s
{
bool Initialized;
bool IsRunning;
uint8_t DataBufferMaxSize;
uint8_t *DataBuffer;
union
{
uint8_t Value;
struct
{
uint8_t TokenReq: 4;
uint8_t AnsRequired: 1;
uint8_t RFU: 3;
}Fields;
}TimeReqParam;
bool AppTimeReqPending;
bool AdrEnabledPrev;
uint8_t NbTransPrev;
uint8_t DataratePrev;
uint8_t NbTransmissions;
}LmhpClockSyncState_t;
typedef enum LmhpClockSyncMoteCmd_e
{
CLOCK_SYNC_PKG_VERSION_ANS = 0x00,
CLOCK_SYNC_APP_TIME_REQ = 0x01,
CLOCK_SYNC_APP_TIME_PERIOD_ANS = 0x02,
CLOCK_SYNC_FORCE_RESYNC_ANS = 0x03,
}LmhpClockSyncMoteCmd_t;
typedef enum LmhpClockSyncSrvCmd_e
{
CLOCK_SYNC_PKG_VERSION_REQ = 0x00,
CLOCK_SYNC_APP_TIME_ANS = 0x01,
CLOCK_SYNC_APP_TIME_PERIOD_REQ = 0x02,
CLOCK_SYNC_FORCE_RESYNC_REQ = 0x03,
}LmhpClockSyncSrvCmd_t;
/*!
* Initializes the package with provided parameters
*
* \param [IN] params Pointer to the package parameters
* \param [IN] dataBuffer Pointer to main application buffer
* \param [IN] dataBufferMaxSize Main application buffer maximum size
*/
static void LmhpClockSyncInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize );
/*!
* Returns the current package initialization status.
*
* \retval status Package initialization status
* [true: Initialized, false: Not initialized]
*/
static bool LmhpClockSyncIsInitialized( void );
/*!
* Returns the package operation status.
*
* \retval status Package operation status
* [true: Running, false: Not running]
*/
static bool LmhpClockSyncIsRunning( void );
/*!
* Processes the internal package events.
*/
static void LmhpClockSyncProcess( void );
/*!
* Processes the MCSP Confirm
*
* \param [IN] mcpsConfirm MCPS confirmation primitive data
*/
static void LmhpClockSyncOnMcpsConfirm( McpsConfirm_t *mcpsConfirm );
/*!
* Processes the MCPS Indication
*
* \param [IN] mcpsIndication MCPS indication primitive data
*/
static void LmhpClockSyncOnMcpsIndication( McpsIndication_t *mcpsIndication );
static LmhpClockSyncState_t LmhpClockSyncState =
{
.Initialized = false,
.IsRunning = false,
.TimeReqParam.Value = 0,
.AppTimeReqPending = false,
.AdrEnabledPrev = false,
.NbTransPrev = 0,
.NbTransmissions = 0,
};
static LmhPackage_t LmhpClockSyncPackage =
{
.Port = CLOCK_SYNC_PORT,
.Init = LmhpClockSyncInit,
.IsInitialized = LmhpClockSyncIsInitialized,
.IsRunning = LmhpClockSyncIsRunning,
.Process = LmhpClockSyncProcess,
.OnMcpsConfirmProcess = LmhpClockSyncOnMcpsConfirm,
.OnMcpsIndicationProcess = LmhpClockSyncOnMcpsIndication,
.OnMlmeConfirmProcess = NULL, // Not used in this package
.OnMlmeIndicationProcess = NULL, // Not used in this package
.OnMacMcpsRequest = NULL, // To be initialized by LmHandler
.OnMacMlmeRequest = NULL, // To be initialized by LmHandler
.OnJoinRequest = NULL, // To be initialized by LmHandler
.OnSendRequest = NULL, // To be initialized by LmHandler
.OnDeviceTimeRequest = NULL, // To be initialized by LmHandler
.OnSysTimeUpdate = NULL, // To be initialized by LmHandler
};
LmhPackage_t *LmphClockSyncPackageFactory( void )
{
return &LmhpClockSyncPackage;
}
static void LmhpClockSyncInit( void * params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize )
{
if( dataBuffer != NULL )
{
LmhpClockSyncState.DataBuffer = dataBuffer;
LmhpClockSyncState.DataBufferMaxSize = dataBufferMaxSize;
LmhpClockSyncState.Initialized = true;
LmhpClockSyncState.IsRunning = true;
}
else
{
LmhpClockSyncState.IsRunning = false;
LmhpClockSyncState.Initialized = false;
}
}
static bool LmhpClockSyncIsInitialized( void )
{
return LmhpClockSyncState.Initialized;
}
static bool LmhpClockSyncIsRunning( void )
{
if( LmhpClockSyncState.Initialized == false )
{
return false;
}
return LmhpClockSyncState.IsRunning;
}
static void LmhpClockSyncProcess( void )
{
if( LmhpClockSyncState.NbTransmissions > 0 )
{
if( LmhpClockSyncAppTimeReq( ) == LORAMAC_HANDLER_SUCCESS )
{
LmhpClockSyncState.NbTransmissions--;
}
}
}
static void LmhpClockSyncOnMcpsConfirm( McpsConfirm_t *mcpsConfirm )
{
MibRequestConfirm_t mibReq;
if( LmhpClockSyncState.AppTimeReqPending == true )
{
// Revert ADR setting
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = LmhpClockSyncState.AdrEnabledPrev;
LoRaMacMibSetRequestConfirm( &mibReq );
// Revert NbTrans setting
mibReq.Type = MIB_CHANNELS_NB_TRANS;
mibReq.Param.ChannelsNbTrans = LmhpClockSyncState.NbTransPrev;
LoRaMacMibSetRequestConfirm( &mibReq );
// Revert data rate setting
mibReq.Type = MIB_CHANNELS_DATARATE;
mibReq.Param.ChannelsDatarate = LmhpClockSyncState.DataratePrev;
LoRaMacMibSetRequestConfirm( &mibReq );
LmhpClockSyncState.AppTimeReqPending = false;
}
}
static void LmhpClockSyncOnMcpsIndication( McpsIndication_t *mcpsIndication )
{
uint8_t cmdIndex = 0;
uint8_t dataBufferIndex = 0;
while( cmdIndex < mcpsIndication->BufferSize )
{
switch( mcpsIndication->Buffer[cmdIndex++] )
{
case CLOCK_SYNC_PKG_VERSION_REQ:
{
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = CLOCK_SYNC_PKG_VERSION_ANS;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = CLOCK_SYNC_ID;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = CLOCK_SYNC_VERSION;
break;
}
case CLOCK_SYNC_APP_TIME_ANS:
{
LmhpClockSyncState.NbTransmissions = 0;
// Check if a more precise time correction has been received.
// If yes then don't process and ignore this answer.
if( mcpsIndication->DeviceTimeAnsReceived == true )
{
cmdIndex += 5;
break;
}
int32_t timeCorrection = 0;
timeCorrection = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
timeCorrection += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
timeCorrection += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
timeCorrection += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
if( ( mcpsIndication->Buffer[cmdIndex++] & 0x0F ) == LmhpClockSyncState.TimeReqParam.Fields.TokenReq )
{
SysTime_t curTime = { .Seconds = 0, .SubSeconds = 0 };
curTime = SysTimeGet( );
curTime.Seconds += timeCorrection;
SysTimeSet( curTime );
LmhpClockSyncState.TimeReqParam.Fields.TokenReq = ( LmhpClockSyncState.TimeReqParam.Fields.TokenReq + 1 ) & 0x0F;
if( LmhpClockSyncPackage.OnSysTimeUpdate != NULL )
{
#if( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
LmhpClockSyncPackage.OnSysTimeUpdate(
( timeCorrection >= -1 ) && ( timeCorrection <= 1 ),
timeCorrection );
#else
if( ( timeCorrection >= -1 ) && ( timeCorrection <= 1 ) )
{
LmhpClockSyncPackage.OnSysTimeUpdate( );
}
#endif
}
}
break;
}
case CLOCK_SYNC_APP_TIME_PERIOD_REQ:
{
// Increment index
cmdIndex++;
// TODO implement command prosessing and handling
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = CLOCK_SYNC_APP_TIME_PERIOD_ANS;
// Answer status not supported.
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = 0x01;
SysTime_t curTime = SysTimeGet( );
// Substract Unix to Gps epcoh offset. The system time is based on Unix time.
curTime.Seconds -= UNIX_GPS_EPOCH_OFFSET;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 0 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 8 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 16 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 24 ) & 0xFF;
break;
}
case CLOCK_SYNC_FORCE_RESYNC_REQ:
{
LmhpClockSyncState.NbTransmissions = mcpsIndication->Buffer[cmdIndex++] & 0X07;
break;
}
}
}
if( dataBufferIndex != 0 )
{
// Answer commands
LmHandlerAppData_t appData =
{
.Buffer = LmhpClockSyncState.DataBuffer,
.BufferSize = dataBufferIndex,
.Port = CLOCK_SYNC_PORT
};
LmhpClockSyncPackage.OnSendRequest( &appData, LORAMAC_HANDLER_UNCONFIRMED_MSG );
}
}
LmHandlerErrorStatus_t LmhpClockSyncAppTimeReq( void )
{
if( LmHandlerIsBusy( ) == true )
{
return LORAMAC_HANDLER_ERROR;
}
if( LmhpClockSyncState.AppTimeReqPending == false )
{
MibRequestConfirm_t mibReq;
// Disable ADR
mibReq.Type = MIB_ADR;
LoRaMacMibGetRequestConfirm( &mibReq );
LmhpClockSyncState.AdrEnabledPrev = mibReq.Param.AdrEnable;
mibReq.Param.AdrEnable = false;
LoRaMacMibSetRequestConfirm( &mibReq );
// Set NbTrans = 1
mibReq.Type = MIB_CHANNELS_NB_TRANS;
LoRaMacMibGetRequestConfirm( &mibReq );
LmhpClockSyncState.NbTransPrev = mibReq.Param.ChannelsNbTrans;
mibReq.Param.ChannelsNbTrans = 1;
LoRaMacMibSetRequestConfirm( &mibReq );
// Store data rate
mibReq.Type = MIB_CHANNELS_DATARATE;
LoRaMacMibGetRequestConfirm( &mibReq );
LmhpClockSyncState.DataratePrev = mibReq.Param.ChannelsDatarate;
// Add DeviceTimeReq MAC command.
// In case the network server supports this more precise command
// this package will use DeviceTimeAns answer as clock synchronization
// mechanism.
LmhpClockSyncPackage.OnDeviceTimeRequest( );
}
SysTime_t curTime = SysTimeGet( );
uint8_t dataBufferIndex = 0;
// Substract Unix to Gps epcoh offset. The system time is based on Unix time.
curTime.Seconds -= UNIX_GPS_EPOCH_OFFSET;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = CLOCK_SYNC_APP_TIME_REQ;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 0 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 8 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 16 ) & 0xFF;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = ( curTime.Seconds >> 24 ) & 0xFF;
LmhpClockSyncState.TimeReqParam.Fields.AnsRequired = 0;
LmhpClockSyncState.DataBuffer[dataBufferIndex++] = LmhpClockSyncState.TimeReqParam.Value;
LmHandlerAppData_t appData =
{
.Buffer = LmhpClockSyncState.DataBuffer,
.BufferSize = dataBufferIndex,
.Port = CLOCK_SYNC_PORT
};
LmhpClockSyncState.AppTimeReqPending = true;
return LmhpClockSyncPackage.OnSendRequest( &appData, LORAMAC_HANDLER_UNCONFIRMED_MSG );
}

View File

@@ -0,0 +1,49 @@
/*!
* \file LmhpClockSync.h
*
* \brief Implements the LoRa-Alliance clock synchronization package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/application_layer_clock_synchronization_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMHP_CLOCK_SYNC_H__
#define __LMHP_CLOCK_SYNC_H__
#include "LoRaMac.h"
#include "LmHandlerTypes.h"
#include "LmhPackage.h"
/*!
* Clock sync package identifier.
*
* \remark This value must be unique amongst the packages
*/
#define PACKAGE_ID_CLOCK_SYNC 1
/*!
* Clock sync package parameters
*
* This package doesn't require parameters
*/
//typedef struct LmphClockSyncParams_s
//{
//}LmphClockSyncParams_t;
LmhPackage_t *LmphClockSyncPackageFactory( void );
LmHandlerErrorStatus_t LmhpClockSyncAppTimeReq( void );
#endif // __LMHP_CLOCK_SYNC_H__

View File

@@ -0,0 +1,491 @@
/*!
* \file LmhpCompliance.c
*
* \brief Implements the LoRa-Alliance certification protocol handling
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "utilities.h"
#include "timer.h"
#include "LoRaMac.h"
#include "LoRaMacTest.h"
#include "Region.h"
#include "LmhPackage.h"
#include "LmhpCompliance.h"
/*!
* LoRaWAN compliance certification protocol port number.
*
* LoRaWAN Specification V1.0.2, chapter 4.3.2
*/
#define COMPLIANCE_PORT 224
/*!
* Defines the compliance mode data transmission duty cycle.
* An uplink will be transmitted ever \ref COMPLIANCE_TX_DUTYCYCLE [ms].
*/
#define COMPLIANCE_TX_DUTYCYCLE 5000
/*!
* LoRaWAN compliance tests support data
*/
typedef struct ComplianceTestState_s
{
bool Initialized;
bool IsRunning;
uint8_t State;
bool TxPending;
bool IsTxConfirmed;
uint8_t Port;
uint8_t DataBufferMaxSize;
uint8_t DataBufferSize;
uint8_t *DataBuffer;
uint16_t DownLinkCounter;
bool LinkCheck;
uint8_t DemodMargin;
uint8_t NbGateways;
}ComplianceTestState_t;
/*!
* Timer to handle the application data transmission duty cycle
*/
static TimerEvent_t ComplianceTxNextPacketTimer;
/*!
* Holds the compliance test current context
*/
static ComplianceTestState_t ComplianceTestState =
{
.Initialized = false,
.IsRunning = false,
.State = 0,
.TxPending = false,
.IsTxConfirmed = false,
.Port = 0,
.DataBufferMaxSize = 0,
.DataBufferSize = 0,
.DataBuffer = NULL,
.DownLinkCounter = 0,
.LinkCheck = false,
.DemodMargin = 0,
.NbGateways = 0
};
/*!
* LoRaWAN compliance tests protocol handler parameters
*/
static LmhpComplianceParams_t* LmhpComplianceParams;
/*!
* Initializes the compliance tests with provided parameters
*
* \param [IN] params Structure containing the initial compliance
* tests parameters.
* \param [IN] dataBuffer Pointer to main application buffer
* \param [IN] dataBufferMaxSize Application buffer maximum size
*/
static void LmhpComplianceInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize );
/*!
* Returns the current compliance certification protocol initialization status.
*
* \retval status Compliance certification protocol initialization status
* [true: Initialized, false: Not initialized]
*/
static bool LmhpComplianceIsInitialized( void );
/*!
* Returns the current compliance certification protocol handling status.
*
* \retval status Compliance certification protocol handling status
* [true: Running, false: Not running]
*/
static bool LmhpComplianceIsRunning( void );
/*!
* Processes the LoRaMac Compliance events.
*/
static void LmhpComplianceProcess( void );
/*!
* Processes the MCPS Indication
*
* \param [IN] mcpsIndication MCPS indication primitive data
*/
static void LmhpComplianceOnMcpsIndication( McpsIndication_t *mcpsIndication );
/*!
* Processes the MLME Confirm
*
* \param [IN] mlmeConfirm MLME confirmation primitive data
*/
static void LmhpComplianceOnMlmeConfirm( MlmeConfirm_t *mlmeConfirm );
/*!
* Function executed on TxNextPacket Timeout event
*/
static void OnComplianceTxNextPacketTimerEvent( void *context );
/*!
* Processes the data to transmit on port \ref COMPLIANCE_PORT
* Handles the compliance certification protocol data transmission
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else \ref LORAMAC_HANDLER_ERROR
*/
static LmHandlerErrorStatus_t LmhpComplianceTxProcess( void );
LmhPackage_t LmhpCompliancePackage =
{
.Port = COMPLIANCE_PORT,
.Init = LmhpComplianceInit,
.IsInitialized = LmhpComplianceIsInitialized,
.IsRunning = LmhpComplianceIsRunning,
.Process = LmhpComplianceProcess,
.OnMcpsConfirmProcess = NULL, // Not used in this package
.OnMcpsIndicationProcess = LmhpComplianceOnMcpsIndication,
.OnMlmeConfirmProcess = LmhpComplianceOnMlmeConfirm,
.OnMlmeIndicationProcess = NULL, // Not used in this package
.OnMacMcpsRequest = NULL, // To be initialized by LmHandler
.OnMacMlmeRequest = NULL, // To be initialized by LmHandler
.OnJoinRequest = NULL, // To be initialized by LmHandler
.OnSendRequest = NULL, // To be initialized by LmHandler
.OnDeviceTimeRequest = NULL, // To be initialized by LmHandler
.OnSysTimeUpdate = NULL, // To be initialized by LmHandler
};
LmhPackage_t *LmphCompliancePackageFactory( void )
{
return &LmhpCompliancePackage;
}
static void LmhpComplianceInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize )
{
if( ( params != NULL ) && ( dataBuffer != NULL ) )
{
LmhpComplianceParams = ( LmhpComplianceParams_t* )params;
ComplianceTestState.DataBuffer = dataBuffer;
ComplianceTestState.DataBufferMaxSize = dataBufferMaxSize;
ComplianceTestState.Initialized = true;
}
else
{
LmhpComplianceParams = NULL;
ComplianceTestState.Initialized = false;
}
}
static bool LmhpComplianceIsInitialized( void )
{
return ComplianceTestState.Initialized;
}
static bool LmhpComplianceIsRunning( void )
{
if( ComplianceTestState.Initialized == false )
{
return false;
}
return ComplianceTestState.IsRunning;
}
static void LmhpComplianceOnMlmeConfirm( MlmeConfirm_t *mlmeConfirm )
{
if( ComplianceTestState.Initialized == false )
{
return;
}
if( mlmeConfirm->MlmeRequest == MLME_LINK_CHECK )
{
ComplianceTestState.LinkCheck = true;
ComplianceTestState.DemodMargin = mlmeConfirm->DemodMargin;
ComplianceTestState.NbGateways = mlmeConfirm->NbGateways;
}
}
static LmHandlerErrorStatus_t LmhpComplianceTxProcess( void )
{
if( ComplianceTestState.Initialized == false )
{
return LORAMAC_HANDLER_ERROR;
}
if( ComplianceTestState.LinkCheck == true )
{
ComplianceTestState.LinkCheck = false;
ComplianceTestState.DataBufferSize = 3;
ComplianceTestState.DataBuffer[0] = 5;
ComplianceTestState.DataBuffer[1] = ComplianceTestState.DemodMargin;
ComplianceTestState.DataBuffer[2] = ComplianceTestState.NbGateways;
ComplianceTestState.State = 1;
}
else
{
switch( ComplianceTestState.State )
{
case 4:
ComplianceTestState.State = 1;
break;
case 1:
ComplianceTestState.DataBufferSize = 2;
ComplianceTestState.DataBuffer[0] = ComplianceTestState.DownLinkCounter >> 8;
ComplianceTestState.DataBuffer[1] = ComplianceTestState.DownLinkCounter;
break;
}
}
LmHandlerAppData_t appData =
{
.Buffer = ComplianceTestState.DataBuffer,
.BufferSize = ComplianceTestState.DataBufferSize,
.Port = COMPLIANCE_PORT
};
// Schedule next transmission
TimerStart( &ComplianceTxNextPacketTimer );
return LmhpCompliancePackage.OnSendRequest( &appData, ( LmHandlerMsgTypes_t )ComplianceTestState.IsTxConfirmed );
}
static void LmhpComplianceOnMcpsIndication( McpsIndication_t* mcpsIndication )
{
if( ComplianceTestState.Initialized == false )
{
return;
}
if( mcpsIndication->RxData == false )
{
return;
}
if( mcpsIndication->Port != COMPLIANCE_PORT )
{
return;
}
if( ComplianceTestState.IsRunning == false )
{
// Check compliance test enable command (i)
if( ( mcpsIndication->BufferSize == 4 ) &&
( mcpsIndication->Buffer[0] == 0x01 ) &&
( mcpsIndication->Buffer[1] == 0x01 ) &&
( mcpsIndication->Buffer[2] == 0x01 ) &&
( mcpsIndication->Buffer[3] == 0x01 ) )
{
MibRequestConfirm_t mibReq;
// Initialize compliance test mode context
ComplianceTestState.IsTxConfirmed = false;
ComplianceTestState.TxPending = false;
ComplianceTestState.Port = 224;
ComplianceTestState.DataBufferSize = 2;
ComplianceTestState.DownLinkCounter = 0;
ComplianceTestState.LinkCheck = false;
ComplianceTestState.DemodMargin = 0;
ComplianceTestState.NbGateways = 0;
ComplianceTestState.IsRunning = true;
ComplianceTestState.State = 1;
// Enable ADR while in compliance test mode
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = true;
LoRaMacMibSetRequestConfirm( &mibReq );
// Disable duty cycle enforcement while in compliance test mode
LoRaMacTestSetDutyCycleOn( false );
// Stop peripherals
if( LmhpComplianceParams->StopPeripherals != NULL )
{
LmhpComplianceParams->StopPeripherals( );
}
// Initialize compliance protocol transmission timer
TimerInit( &ComplianceTxNextPacketTimer, OnComplianceTxNextPacketTimerEvent );
TimerSetValue( &ComplianceTxNextPacketTimer, COMPLIANCE_TX_DUTYCYCLE );
// Confirm compliance test protocol activation
CRITICAL_SECTION_BEGIN( );
ComplianceTestState.TxPending = true; //LmhpComplianceTxProcess( );
CRITICAL_SECTION_END( );
}
}
else
{
// Increment the compliance certification protocol downlink counter
ComplianceTestState.DownLinkCounter++;
// Parse compliance test protocol
ComplianceTestState.State = mcpsIndication->Buffer[0];
switch( ComplianceTestState.State )
{
case 0: // Check compliance test disable command (ii)
{
MibRequestConfirm_t mibReq;
TimerStop( &ComplianceTxNextPacketTimer );
// Disable compliance test mode and reset the downlink counter.
ComplianceTestState.DownLinkCounter = 0;
ComplianceTestState.IsRunning = false;
// Restore previous ADR seeting
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = LmhpComplianceParams->AdrEnabled;
LoRaMacMibSetRequestConfirm( &mibReq );
// Enable duty cycle enforcement
LoRaMacTestSetDutyCycleOn( LmhpComplianceParams->DutyCycleEnabled );
// Restart peripherals
if( LmhpComplianceParams->StartPeripherals != NULL )
{
LmhpComplianceParams->StartPeripherals( );
}
}
break;
case 1: // (iii, iv)
ComplianceTestState.DataBufferSize = 2;
break;
case 2: // Enable confirmed messages (v)
ComplianceTestState.IsTxConfirmed = true;
ComplianceTestState.State = 1;
break;
case 3: // Disable confirmed messages (vi)
ComplianceTestState.IsTxConfirmed = false;
ComplianceTestState.State = 1;
break;
case 4: // (vii)
ComplianceTestState.DataBufferSize = mcpsIndication->BufferSize;
ComplianceTestState.DataBuffer[0] = 4;
for( uint8_t i = 1; i < MIN( ComplianceTestState.DataBufferSize, ComplianceTestState.DataBufferMaxSize ); i++ )
{
ComplianceTestState.DataBuffer[i] = mcpsIndication->Buffer[i] + 1;
}
break;
case 5: // (viii)
{
MlmeReq_t mlmeReq;
mlmeReq.Type = MLME_LINK_CHECK;
LmhpCompliancePackage.OnMacMlmeRequest( LoRaMacMlmeRequest( &mlmeReq ), &mlmeReq, 0 );
}
break;
case 6: // (ix)
{
MibRequestConfirm_t mibReq;
// Disable TestMode and revert back to normal operation
// Disable compliance test mode and reset the downlink counter.
ComplianceTestState.DownLinkCounter = 0;
ComplianceTestState.IsRunning = false;
// Restore previous ADR seeting
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = LmhpComplianceParams->AdrEnabled;
LoRaMacMibSetRequestConfirm( &mibReq );
// Enable duty cycle enforcement
LoRaMacTestSetDutyCycleOn( LmhpComplianceParams->DutyCycleEnabled );
// Restart peripherals
if( LmhpComplianceParams->StartPeripherals != NULL )
{
LmhpComplianceParams->StartPeripherals( );
}
LmhpCompliancePackage.OnJoinRequest( true );
}
break;
case 7: // (x)
{
MlmeReq_t mlmeReq;
if( mcpsIndication->BufferSize == 3 )
{
mlmeReq.Type = MLME_TXCW;
mlmeReq.Req.TxCw.Timeout = ( uint16_t )( ( mcpsIndication->Buffer[1] << 8 ) | mcpsIndication->Buffer[2] );
}
else if( mcpsIndication->BufferSize == 7 )
{
mlmeReq.Type = MLME_TXCW_1;
mlmeReq.Req.TxCw.Timeout = ( uint16_t )( ( mcpsIndication->Buffer[1] << 8 ) | mcpsIndication->Buffer[2] );
mlmeReq.Req.TxCw.Frequency = ( uint32_t )( ( mcpsIndication->Buffer[3] << 16 ) | ( mcpsIndication->Buffer[4] << 8 ) | mcpsIndication->Buffer[5] ) * 100;
mlmeReq.Req.TxCw.Power = mcpsIndication->Buffer[6];
}
LmhpCompliancePackage.OnMacMlmeRequest( LoRaMacMlmeRequest( &mlmeReq ), &mlmeReq, 0 );
ComplianceTestState.State = 1;
}
break;
case 8: // Send DeviceTimeReq
{
MlmeReq_t mlmeReq;
mlmeReq.Type = MLME_DEVICE_TIME;
LmhpCompliancePackage.OnMacMlmeRequest( LoRaMacMlmeRequest( &mlmeReq ), &mlmeReq, 0 );
}
break;
case 9: // Switch end device Class
{
MibRequestConfirm_t mibReq;
mibReq.Type = MIB_DEVICE_CLASS;
// CLASS_A = 0, CLASS_B = 1, CLASS_C = 2
mibReq.Param.Class = ( DeviceClass_t )mcpsIndication->Buffer[1];;
LoRaMacMibSetRequestConfirm( &mibReq );
}
break;
case 10: // Send PingSlotInfoReq
{
MlmeReq_t mlmeReq;
mlmeReq.Type = MLME_PING_SLOT_INFO;
mlmeReq.Req.PingSlotInfo.PingSlot.Value = mcpsIndication->Buffer[1];
LmhpCompliancePackage.OnMacMlmeRequest( LoRaMacMlmeRequest( &mlmeReq ), &mlmeReq, 0 );
}
break;
default:
break;
}
}
}
static void LmhpComplianceProcess( void )
{
bool isPending;
CRITICAL_SECTION_BEGIN( );
isPending = ComplianceTestState.TxPending;
ComplianceTestState.TxPending = false;
CRITICAL_SECTION_END( );
if( isPending == true )
{
LmhpComplianceTxProcess( );
}
}
static void OnComplianceTxNextPacketTimerEvent( void* context )
{
ComplianceTestState.TxPending = true;
}

View File

@@ -0,0 +1,68 @@
/*!
* \file LmhpCompliance.h
*
* \brief Implements the LoRa-Alliance certification protocol handling
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMHP_COMPLIANCE__
#define __LMHP_COMPLIANCE__
#include "LoRaMac.h"
#include "LmHandlerTypes.h"
#include "LmhPackage.h"
/*!
* Compliance package identifier.
*
* \remark This value must be unique amongst the packages
*/
#define PACKAGE_ID_COMPLIANCE 0
/*!
* Compliance test protocol handler parameters
*/
typedef struct LmhpComplianceParams_s
{
/*!
* Holds the ADR state
*/
bool AdrEnabled;
/*!
* LoRaWAN ETSI duty cycle control enable/disable
*
* \remark Please note that ETSI mandates duty cycled transmissions. Use only for test purposes
*/
bool DutyCycleEnabled;
/*!
* Stops unnecessary peripherals.
*
* \remark Use for the compliance tests protocol handling in order to
* reduce the power consumption.
*/
void ( *StopPeripherals )( void );
/*!
* Starts previously stopped peripherals.
*
* \remark Use for the compliance tests protocol handling in order to
* reduce the power consumption.
*/
void ( *StartPeripherals )( void );
}LmhpComplianceParams_t;
LmhPackage_t *LmphCompliancePackageFactory( void );
#endif // __LMHP_COMPLIANCE__

View File

@@ -0,0 +1,527 @@
/*!
* \file LmhpFragmentation.c
*
* \brief Implements the LoRa-Alliance fragmented data block transport package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/fragmented_data_block_transport_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include "LmHandler.h"
#include "LmhpFragmentation.h"
#include "FragDecoder.h"
/*!
* LoRaWAN Application Layer Fragmented Data Block Transport Specification
*/
#define FRAGMENTATION_PORT 201
#define FRAGMENTATION_ID 3
#define FRAGMENTATION_VERSION 1
#define FRAGMENTATION_MAX_SESSIONS 4
// Fragmentation Tx delay state
typedef enum LmhpFragmentationTxDelayStates_e
{
// Tx delay in idle state.
FRAGMENTATION_TX_DELAY_STATE_IDLE,
// Tx delay to be started.
FRAGMENTATION_TX_DELAY_STATE_START,
// Tx delay to be stopped.
FRAGMENTATION_TX_DELAY_STATE_STOP,
}LmhpFragmentationTxDelayStates_t;
/*!
* Package current context
*/
typedef struct LmhpFragmentationState_s
{
bool Initialized;
bool IsRunning;
LmhpFragmentationTxDelayStates_t TxDelayState;
uint8_t DataBufferMaxSize;
uint8_t *DataBuffer;
uint8_t *file;
}LmhpFragmentationState_t;
typedef enum LmhpFragmentationMoteCmd_e
{
FRAGMENTATION_PKG_VERSION_ANS = 0x00,
FRAGMENTATION_FRAG_STATUS_ANS = 0x01,
FRAGMENTATION_FRAG_SESSION_SETUP_ANS = 0x02,
FRAGMENTATION_FRAG_SESSION_DELETE_ANS = 0x03,
}LmhpFragmentationMoteCmd_t;
typedef enum LmhpFragmentationSrvCmd_e
{
FRAGMENTATION_PKG_VERSION_REQ = 0x00,
FRAGMENTATION_FRAG_STATUS_REQ = 0x01,
FRAGMENTATION_FRAG_SESSION_SETUP_REQ = 0x02,
FRAGMENTATION_FRAG_SESSION_DELETE_REQ = 0x03,
FRAGMENTATION_DATA_FRAGMENT = 0x08,
}LmhpFragmentationSrvCmd_t;
/*!
* LoRaWAN fragmented data block transport handler parameters
*/
static LmhpFragmentationParams_t* LmhpFragmentationParams;
/*!
* Initializes the package with provided parameters
*
* \param [IN] params Pointer to the package parameters
* \param [IN] dataBuffer Pointer to main application buffer
* \param [IN] dataBufferMaxSize Main application buffer maximum size
*/
static void LmhpFragmentationInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize );
/*!
* Returns the current package initialization status.
*
* \retval status Package initialization status
* [true: Initialized, false: Not initialized]
*/
static bool LmhpFragmentationIsInitialized( void );
/*!
* Returns the package operation status.
*
* \retval status Package operation status
* [true: Running, false: Not running]
*/
static bool LmhpFragmentationIsRunning( void );
/*!
* Processes the internal package events.
*/
static void LmhpFragmentationProcess( void );
/*!
* Processes the MCPS Indication
*
* \param [IN] mcpsIndication MCPS indication primitive data
*/
static void LmhpFragmentationOnMcpsIndication( McpsIndication_t *mcpsIndication );
static LmhpFragmentationState_t LmhpFragmentationState =
{
.Initialized = false,
.IsRunning = false,
.TxDelayState = FRAGMENTATION_TX_DELAY_STATE_IDLE,
};
typedef struct FragGroupData_s
{
bool IsActive;
union
{
uint8_t Value;
struct
{
uint8_t McGroupBitMask: 4;
uint8_t FragIndex: 2;
uint8_t RFU: 2;
}Fields;
}FragSession;
uint16_t FragNb;
uint8_t FragSize;
union
{
uint8_t Value;
struct
{
uint8_t BlockAckDelay: 3;
uint8_t FragAlgo: 3;
uint8_t RFU: 2;
}Fields;
}Control;
uint8_t Padding;
uint32_t Descriptor;
}FragGroupData_t;
typedef struct FragSessionData_s
{
FragGroupData_t FragGroupData;
FragDecoderStatus_t FragDecoderStatus;
int32_t FragDecoderPorcessStatus;
}FragSessionData_t;
FragSessionData_t FragSessionData[FRAGMENTATION_MAX_SESSIONS];
// Answer struct for the commands.
LmHandlerAppData_t DelayedReplyAppData;
static LmhPackage_t LmhpFragmentationPackage =
{
.Port = FRAGMENTATION_PORT,
.Init = LmhpFragmentationInit,
.IsInitialized = LmhpFragmentationIsInitialized,
.IsRunning = LmhpFragmentationIsRunning,
.Process = LmhpFragmentationProcess,
.OnMcpsConfirmProcess = NULL, // Not used in this package
.OnMcpsIndicationProcess = LmhpFragmentationOnMcpsIndication,
.OnMlmeConfirmProcess = NULL, // Not used in this package
.OnMlmeIndicationProcess = NULL, // Not used in this package
.OnMacMcpsRequest = NULL, // To be initialized by LmHandler
.OnMacMlmeRequest = NULL, // To be initialized by LmHandler
.OnJoinRequest = NULL, // To be initialized by LmHandler
.OnSendRequest = NULL, // To be initialized by LmHandler
.OnDeviceTimeRequest = NULL, // To be initialized by LmHandler
.OnSysTimeUpdate = NULL, // To be initialized by LmHandler
};
// Delay value.
static uint32_t TxDelayTime;
// Fragment Delay Timer struct
static TimerEvent_t FragmentTxDelayTimer;
/*!
* \brief Callback function for Fragment delay timer.
*/
static void OnFragmentTxDelay( void* context )
{
// Stop the timer.
TimerStop( &FragmentTxDelayTimer );
// Set the state.
LmhpFragmentationState.TxDelayState = FRAGMENTATION_TX_DELAY_STATE_STOP;
}
LmhPackage_t *LmhpFragmentationPackageFactory( void )
{
return &LmhpFragmentationPackage;
}
static void LmhpFragmentationInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize )
{
if( ( params != NULL ) && ( dataBuffer != NULL ) )
{
LmhpFragmentationParams = ( LmhpFragmentationParams_t* )params;
LmhpFragmentationState.DataBuffer = dataBuffer;
LmhpFragmentationState.DataBufferMaxSize = dataBufferMaxSize;
LmhpFragmentationState.Initialized = true;
LmhpFragmentationState.IsRunning = true;
// Initialize Fragmentation delay time.
TxDelayTime = 0;
// Initialize Fragmentation delay timer.
TimerInit( &FragmentTxDelayTimer, OnFragmentTxDelay );
}
else
{
LmhpFragmentationParams = NULL;
LmhpFragmentationState.IsRunning = false;
LmhpFragmentationState.Initialized = false;
}
}
static bool LmhpFragmentationIsInitialized( void )
{
return LmhpFragmentationState.Initialized;
}
static bool LmhpFragmentationIsRunning( void )
{
if( LmhpFragmentationState.Initialized == false )
{
return false;
}
return LmhpFragmentationState.IsRunning;
}
static void LmhpFragmentationProcess( void )
{
LmhpFragmentationTxDelayStates_t delayTimerState;
CRITICAL_SECTION_BEGIN( );
delayTimerState = LmhpFragmentationState.TxDelayState;
// Set the state to idle so that the other states are executed only when they are set
// in the appropriate functions.
LmhpFragmentationState.TxDelayState = FRAGMENTATION_TX_DELAY_STATE_IDLE;
CRITICAL_SECTION_END( );
switch( delayTimerState )
{
case FRAGMENTATION_TX_DELAY_STATE_START:
// Set the timer with the initially calculated Delay value.
TimerSetValue( &FragmentTxDelayTimer, TxDelayTime );
// Start the timer.
TimerStart( &FragmentTxDelayTimer );
break;
case FRAGMENTATION_TX_DELAY_STATE_STOP:
// Send the reply.
LmHandlerSend( &DelayedReplyAppData, LORAMAC_HANDLER_UNCONFIRMED_MSG );
break;
case FRAGMENTATION_TX_DELAY_STATE_IDLE:
// Intentional fall through
default:
// Nothing to do.
break;
}
}
static void LmhpFragmentationOnMcpsIndication( McpsIndication_t *mcpsIndication )
{
uint8_t cmdIndex = 0;
uint8_t dataBufferIndex = 0;
bool isAnswerDelayed = false;
// Answer struct for the commands.
LmHandlerAppData_t cmdReplyAppData;
// Co-efficient used to calculate delay.
uint8_t blockAckDelay = 0;
while( cmdIndex < mcpsIndication->BufferSize )
{
switch( mcpsIndication->Buffer[cmdIndex++] )
{
case FRAGMENTATION_PKG_VERSION_REQ:
{
if( mcpsIndication->Multicast == 1 )
{
// Multicast channel. Don't process command.
break;
}
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_PKG_VERSION_ANS;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_ID;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_VERSION;
break;
}
case FRAGMENTATION_FRAG_STATUS_REQ:
{
uint8_t fragIndex = mcpsIndication->Buffer[cmdIndex++];
uint8_t participants = fragIndex & 0x01;
fragIndex >>= 1;
FragSessionData[fragIndex].FragDecoderStatus = FragDecoderGetStatus( );
if( ( participants == 1 ) ||
( ( participants == 0 ) && ( FragSessionData[fragIndex].FragDecoderStatus.FragNbLost > 0 ) ) )
{
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_FRAG_STATUS_ANS;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = ( fragIndex << 14 ) |
( ( FragSessionData[fragIndex].FragDecoderStatus.FragNbRx >> 8 ) & 0x3F );
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FragSessionData[fragIndex].FragDecoderStatus.FragNbRx & 0xFF;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FragSessionData[fragIndex].FragDecoderStatus.FragNbLost;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FragSessionData[fragIndex].FragDecoderStatus.MatrixError & 0x01;
// Fetch the co-efficient value required to calculate delay of that respective session.
blockAckDelay = FragSessionData[fragIndex].FragGroupData.Control.Fields.BlockAckDelay;
isAnswerDelayed = true;
}
break;
}
case FRAGMENTATION_FRAG_SESSION_SETUP_REQ:
{
if( mcpsIndication->Multicast == 1 )
{
// Multicast channel. Don't process command.
break;
}
FragSessionData_t fragSessionData;
uint8_t status = 0x00;
fragSessionData.FragGroupData.FragSession.Value = mcpsIndication->Buffer[cmdIndex++];
fragSessionData.FragGroupData.FragNb = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x00FF;
fragSessionData.FragGroupData.FragNb |= ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0xFF00;
fragSessionData.FragGroupData.FragSize = mcpsIndication->Buffer[cmdIndex++];
fragSessionData.FragGroupData.Control.Value = mcpsIndication->Buffer[cmdIndex++];
fragSessionData.FragGroupData.Padding = mcpsIndication->Buffer[cmdIndex++];
fragSessionData.FragGroupData.Descriptor = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
fragSessionData.FragGroupData.Descriptor += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
fragSessionData.FragGroupData.Descriptor += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
fragSessionData.FragGroupData.Descriptor += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
if( fragSessionData.FragGroupData.Control.Fields.FragAlgo > 0 )
{
status |= 0x01; // Encoding unsupported
}
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
if( ( fragSessionData.FragGroupData.FragNb * fragSessionData.FragGroupData.FragSize ) > FragDecoderGetMaxFileSize( ) )
{
status |= 0x02; // Not enough Memory
}
#else
if( ( fragSessionData.FragGroupData.FragNb * fragSessionData.FragGroupData.FragSize ) > LmhpFragmentationParams->BufferSize )
{
status |= 0x02; // Not enough Memory
}
#endif
status |= ( fragSessionData.FragGroupData.FragSession.Fields.FragIndex << 6 ) & 0xC0;
if( fragSessionData.FragGroupData.FragSession.Fields.FragIndex >= FRAGMENTATION_MAX_SESSIONS )
{
status |= 0x04; // FragSession index not supported
}
// Descriptor is not really defined in the specification
// Not clear how to handle this.
// Currently the descriptor is always correct
if( fragSessionData.FragGroupData.Descriptor != 0x01020304 )
{
//status |= 0x08; // Wrong Descriptor
}
if( ( status & 0x0F ) == 0 )
{
// The FragSessionSetup is accepted
fragSessionData.FragGroupData.IsActive = true;
fragSessionData.FragDecoderPorcessStatus = FRAG_SESSION_ONGOING;
FragSessionData[fragSessionData.FragGroupData.FragSession.Fields.FragIndex] = fragSessionData;
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
FragDecoderInit( fragSessionData.FragGroupData.FragNb,
fragSessionData.FragGroupData.FragSize,
&LmhpFragmentationParams->DecoderCallbacks );
#else
FragDecoderInit( fragSessionData.FragGroupData.FragNb,
fragSessionData.FragGroupData.FragSize,
LmhpFragmentationParams->Buffer,
LmhpFragmentationParams->BufferSize );
#endif
}
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_FRAG_SESSION_SETUP_ANS;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = status;
isAnswerDelayed = false;
break;
}
case FRAGMENTATION_FRAG_SESSION_DELETE_REQ:
{
if( mcpsIndication->Multicast == 1 )
{
// Multicast channel. Don't process command.
break;
}
uint8_t status = 0x00;
uint8_t id = mcpsIndication->Buffer[cmdIndex++] & 0x03;
status |= id;
if( ( id >= FRAGMENTATION_MAX_SESSIONS ) || ( FragSessionData[id].FragGroupData.IsActive == false ) )
{
status |= 0x04; // Session does not exist
}
else
{
// Delete session
FragSessionData[id].FragGroupData.IsActive = false;
}
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = FRAGMENTATION_FRAG_SESSION_DELETE_ANS;
LmhpFragmentationState.DataBuffer[dataBufferIndex++] = status;
isAnswerDelayed = false;
break;
}
case FRAGMENTATION_DATA_FRAGMENT:
{
uint8_t fragIndex = 0;
uint16_t fragCounter = 0;
fragCounter = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x00FF;
fragCounter |= ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0xFF00;
fragIndex = ( fragCounter >> 14 ) & 0x03;
fragCounter &= 0x3FFF;
if( mcpsIndication->Multicast == 1 )
{
// Message received on a multicast address
//
// TODO: Not working yet
//
// Check McGroupBitMask
//uint8_t groupId = LoRaMacMcChannelGetGroupId( mcpsIndication->DevAddress );
//if( ( groupId == 0xFF ) ||
// ( ( FragSessionData[fragIndex].FragGroupData.FragSession.Fields.McGroupBitMask & ( 1 << groupId ) ) == 0 ) )
//{
// // Ignore message
// break;
//}
}
if( FragSessionData[fragIndex].FragDecoderPorcessStatus == FRAG_SESSION_ONGOING )
{
FragSessionData[fragIndex].FragDecoderPorcessStatus = FragDecoderProcess( fragCounter, &mcpsIndication->Buffer[cmdIndex] );
FragSessionData[fragIndex].FragDecoderStatus = FragDecoderGetStatus( );
if( LmhpFragmentationParams->OnProgress != NULL )
{
LmhpFragmentationParams->OnProgress( FragSessionData[fragIndex].FragDecoderStatus.FragNbRx,
FragSessionData[fragIndex].FragGroupData.FragNb,
FragSessionData[fragIndex].FragGroupData.FragSize,
FragSessionData[fragIndex].FragDecoderStatus.FragNbLost );
}
}
else
{
if( FragSessionData[fragIndex].FragDecoderPorcessStatus >= 0 )
{
// Fragmentation successfully done
FragSessionData[fragIndex].FragDecoderPorcessStatus = FRAG_SESSION_NOT_STARTED;
if( LmhpFragmentationParams->OnDone != NULL )
{
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
LmhpFragmentationParams->OnDone( FragSessionData[fragIndex].FragDecoderPorcessStatus,
( FragSessionData[fragIndex].FragGroupData.FragNb * FragSessionData[fragIndex].FragGroupData.FragSize ) - FragSessionData[fragIndex].FragGroupData.Padding );
#else
LmhpFragmentationParams->OnDone( FragSessionData[fragIndex].FragDecoderPorcessStatus,
LmhpFragmentationParams->Buffer,
( FragSessionData[fragIndex].FragGroupData.FragNb * FragSessionData[fragIndex].FragGroupData.FragSize ) - FragSessionData[fragIndex].FragGroupData.Padding );
#endif
}
}
}
cmdIndex += FragSessionData[fragIndex].FragGroupData.FragSize;
break;
}
default:
{
break;
}
}
}
// After processing the commands, if the end-node has to reply back then a flag is checked if the
// reply is to be sent immediately or with a delay.
// In some scenarios it is not desired that multiple end-notes send uplinks at the same time to
// the same server. (Example: Fragment status during a multicast FUOTA)
if( dataBufferIndex != 0 )
{
// Prepare Answer that is to be transmitted
cmdReplyAppData.Buffer = LmhpFragmentationState.DataBuffer;
cmdReplyAppData.BufferSize = dataBufferIndex;
cmdReplyAppData.Port = FRAGMENTATION_PORT;
if( isAnswerDelayed == true )
{
// Delay value is calculated using BlockAckDelay which is communicated by server during the FragSessionSetupReq
// Pseudo Random Delay = rand(0:1) * 2^(blockAckDelay + 4) Seconds.
// Delay = Pseudo Random Delay * 1000 milli seconds.
// Eg: blockAckDelay = 7
// Pseudo Random Delay = rand(0:1) * 2^11
// rand(0:1) seconds = rand(0:1000) milliseconds
// Delay = rand(0:1000) * 2048 => 2048000ms = 34 minutes
TxDelayTime = randr( 0, 1000 ) * ( 1 << ( blockAckDelay + 4 ) );
DelayedReplyAppData = cmdReplyAppData;
LmhpFragmentationState.TxDelayState = FRAGMENTATION_TX_DELAY_STATE_START;
}
else
{
// Send the prepared answer
LmhpFragmentationPackage.OnSendRequest( &cmdReplyAppData, LORAMAC_HANDLER_UNCONFIRMED_MSG );
}
}
}

View File

@@ -0,0 +1,92 @@
/*!
* \file LmhpFragmentation.h
*
* \brief Implements the LoRa-Alliance fragmented data block transport package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/fragmented_data_block_transport_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMHP_FRAGMENTATION_H__
#define __LMHP_FRAGMENTATION_H__
#include "LoRaMac.h"
#include "LmHandlerTypes.h"
#include "LmhPackage.h"
#include "FragDecoder.h"
/*!
* Fragmentation data block transport package identifier.
*
* \remark This value must be unique amongst the packages
*/
#define PACKAGE_ID_FRAGMENTATION 3
/*!
* Fragmentation package parameters
*/
typedef struct LmhpFragmentationParams_s
{
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* FragDecoder Write/Read function callbacks
*/
FragDecoderCallbacks_t DecoderCallbacks;
#else
/*!
* Pointer to the un-fragmented received buffer.
*/
uint8_t *Buffer;
/*!
* Size of the un-fragmented received buffer.
*/
uint32_t BufferSize;
#endif
/*!
* Notifies the progress of the current fragmentation session
*
* \param [IN] fragCounter Fragment counter
* \param [IN] fragNb Number of fragments
* \param [IN] fragSize Size of fragments
* \param [IN] fragNbLost Number of lost fragments
*/
void ( *OnProgress )( uint16_t fragCounter, uint16_t fragNb, uint8_t fragSize, uint16_t fragNbLost );
#if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
/*!
* Notifies that the fragmentation session is finished
*
* \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING,
* FRAG_SESSION_FINISHED or
* FragDecoder.Status.FragNbLost]
* \param [IN] size Received file size
*/
void ( *OnDone )( int32_t status, uint32_t size );
#else
/*!
* Notifies that the fragmentation session is finished
*
* \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING,
* FRAG_SESSION_FINISHED or
* FragDecoder.Status.FragNbLost]
* \param [IN] file Pointer to the reception file buffer
* \param [IN] size Received file size
*/
void ( *OnDone )( int32_t status, uint8_t *file, uint32_t size );
#endif
}LmhpFragmentationParams_t;
LmhPackage_t *LmhpFragmentationPackageFactory( void );
#endif // __LMHP_FRAGMENTATION_H__

View File

@@ -0,0 +1,459 @@
/*!
* \file LmhpRemoteMcastSetup.c
*
* \brief Implements the LoRa-Alliance remote multicast setup package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/remote_multicast_setup_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include "LmHandler.h"
#include "LmhpRemoteMcastSetup.h"
#define DBG_TRACE 1
#if DBG_TRACE == 1
#include <stdio.h>
/*!
* Works in the same way as the printf function does.
*/
#define DBG( ... ) \
do \
{ \
printf( __VA_ARGS__ ); \
}while( 0 )
#else
#define DBG( ... )
#endif
/*!
* LoRaWAN Application Layer Remote multicast setup Specification
*/
#define REMOTE_MCAST_SETUP_PORT 200
#define REMOTE_MCAST_SETUP_ID 2
#define REMOTE_MCAST_SETUP_VERSION 1
typedef enum LmhpRemoteMcastSetupSessionStates_e
{
REMOTE_MCAST_SETUP_SESSION_STATE_IDLE,
REMOTE_MCAST_SETUP_SESSION_STATE_START,
REMOTE_MCAST_SETUP_SESSION_STATE_STOP,
}LmhpRemoteMcastSetupSessionStates_t;
/*!
* Package current context
*/
typedef struct LmhpRemoteMcastSetupState_s
{
bool Initialized;
bool IsRunning;
LmhpRemoteMcastSetupSessionStates_t SessionState;
uint8_t DataBufferMaxSize;
uint8_t *DataBuffer;
}LmhpRemoteMcastSetupState_t;
typedef enum LmhpRemoteMcastSetupMoteCmd_e
{
REMOTE_MCAST_SETUP_PKG_VERSION_ANS = 0x00,
REMOTE_MCAST_SETUP_MC_GROUP_STATUS_ANS = 0x01,
REMOTE_MCAST_SETUP_MC_GROUP_SETUP_ANS = 0x02,
REMOTE_MCAST_SETUP_MC_GROUP_DELETE_ANS = 0x03,
REMOTE_MCAST_SETUP_MC_GROUP_CLASS_C_SESSION_ANS = 0x04,
REMOTE_MCAST_SETUP_MC_GROUP_CLASS_B_SESSION_ANS = 0x05,
}LmhpRemoteMcastSetupMoteCmd_t;
typedef enum LmhpRemoteMcastSetupSrvCmd_e
{
REMOTE_MCAST_SETUP_PKG_VERSION_REQ = 0x00,
REMOTE_MCAST_SETUP_MC_GROUP_STATUS_REQ = 0x01,
REMOTE_MCAST_SETUP_MC_GROUP_SETUP_REQ = 0x02,
REMOTE_MCAST_SETUP_MC_GROUP_DELETE_REQ = 0x03,
REMOTE_MCAST_SETUP_MC_GROUP_CLASS_C_SESSION_REQ = 0x04,
REMOTE_MCAST_SETUP_MC_GROUP_CLASS_B_SESSION_REQ = 0x05,
}LmhpRemoteMcastSetupSrvCmd_t;
/*!
* Initializes the package with provided parameters
*
* \param [IN] params Pointer to the package parameters
* \param [IN] dataBuffer Pointer to main application buffer
* \param [IN] dataBufferMaxSize Main application buffer maximum size
*/
static void LmhpRemoteMcastSetupInit( void *params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize );
/*!
* Returns the current package initialization status.
*
* \retval status Package initialization status
* [true: Initialized, false: Not initialized]
*/
static bool LmhpRemoteMcastSetupIsInitialized( void );
/*!
* Returns the package operation status.
*
* \retval status Package operation status
* [true: Running, false: Not running]
*/
static bool LmhpRemoteMcastSetupIsRunning( void );
/*!
* Processes the internal package events.
*/
static void LmhpRemoteMcastSetupProcess( void );
/*!
* Processes the MCPS Indication
*
* \param [IN] mcpsIndication MCPS indication primitive data
*/
static void LmhpRemoteMcastSetupOnMcpsIndication( McpsIndication_t *mcpsIndication );
static void OnSessionStartTimer( void *context );
static void OnSessionStopTimer( void *context );
static LmhpRemoteMcastSetupState_t LmhpRemoteMcastSetupState =
{
.Initialized = false,
.IsRunning = false,
.SessionState = REMOTE_MCAST_SETUP_SESSION_STATE_IDLE,
};
typedef struct McGroupData_s
{
union
{
uint8_t Value;
struct
{
uint8_t McGroupId: 2;
uint8_t RFU: 6;
}Fields;
}IdHeader;
uint32_t McAddr;
uint8_t McKeyEncrypted[16];
uint32_t McFCountMin;
uint32_t McFCountMax;
}McGroupData_t;
typedef enum eSessionState
{
SESSION_STOPED,
SESSION_STARTED
}SessionState_t;
typedef struct McSessionData_s
{
McGroupData_t McGroupData;
SessionState_t SessionState;
uint32_t SessionTime;
uint8_t SessionTimeout;
McRxParams_t RxParams;
}McSessionData_t;
McSessionData_t McSessionData[LORAMAC_MAX_MC_CTX];
/*!
* Session start timer
*/
static TimerEvent_t SessionStartTimer;
/*!
* Session start timer
*/
static TimerEvent_t SessionStopTimer;
static LmhPackage_t LmhpRemoteMcastSetupPackage =
{
.Port = REMOTE_MCAST_SETUP_PORT,
.Init = LmhpRemoteMcastSetupInit,
.IsInitialized = LmhpRemoteMcastSetupIsInitialized,
.IsRunning = LmhpRemoteMcastSetupIsRunning,
.Process = LmhpRemoteMcastSetupProcess,
.OnMcpsConfirmProcess = NULL, // Not used in this package
.OnMcpsIndicationProcess = LmhpRemoteMcastSetupOnMcpsIndication,
.OnMlmeConfirmProcess = NULL, // Not used in this package
.OnMlmeIndicationProcess = NULL, // Not used in this package
.OnMacMcpsRequest = NULL, // To be initialized by LmHandler
.OnMacMlmeRequest = NULL, // To be initialized by LmHandler
.OnJoinRequest = NULL, // To be initialized by LmHandler
.OnSendRequest = NULL, // To be initialized by LmHandler
.OnDeviceTimeRequest = NULL, // To be initialized by LmHandler
.OnSysTimeUpdate = NULL, // To be initialized by LmHandler
};
LmhPackage_t *LmhpRemoteMcastSetupPackageFactory( void )
{
return &LmhpRemoteMcastSetupPackage;
}
static void LmhpRemoteMcastSetupInit( void * params, uint8_t *dataBuffer, uint8_t dataBufferMaxSize )
{
if( dataBuffer != NULL )
{
LmhpRemoteMcastSetupState.DataBuffer = dataBuffer;
LmhpRemoteMcastSetupState.DataBufferMaxSize = dataBufferMaxSize;
LmhpRemoteMcastSetupState.Initialized = true;
LmhpRemoteMcastSetupState.IsRunning = true;
TimerInit( &SessionStartTimer, OnSessionStartTimer );
TimerInit( &SessionStopTimer, OnSessionStopTimer );
}
else
{
LmhpRemoteMcastSetupState.IsRunning = false;
LmhpRemoteMcastSetupState.Initialized = false;
}
}
static bool LmhpRemoteMcastSetupIsInitialized( void )
{
return LmhpRemoteMcastSetupState.Initialized;
}
static bool LmhpRemoteMcastSetupIsRunning( void )
{
if( LmhpRemoteMcastSetupState.Initialized == false )
{
return false;
}
return LmhpRemoteMcastSetupState.IsRunning;
}
static void LmhpRemoteMcastSetupProcess( void )
{
LmhpRemoteMcastSetupSessionStates_t state;
CRITICAL_SECTION_BEGIN( );
state = LmhpRemoteMcastSetupState.SessionState;
LmhpRemoteMcastSetupState.SessionState = REMOTE_MCAST_SETUP_SESSION_STATE_IDLE;
CRITICAL_SECTION_END( );
switch( state )
{
case REMOTE_MCAST_SETUP_SESSION_STATE_START:
// Switch to Class C
LmHandlerRequestClass( CLASS_C );
TimerSetValue( &SessionStopTimer, ( 1 << McSessionData[0].SessionTimeout ) * 1000 );
TimerStart( &SessionStopTimer );
break;
case REMOTE_MCAST_SETUP_SESSION_STATE_STOP:
// Switch back to Class A
LmHandlerRequestClass( CLASS_A );
break;
case REMOTE_MCAST_SETUP_SESSION_STATE_IDLE:
// Intentional fall through
default:
// Nothing to do.
break;
}
}
static void LmhpRemoteMcastSetupOnMcpsIndication( McpsIndication_t *mcpsIndication )
{
uint8_t cmdIndex = 0;
uint8_t dataBufferIndex = 0;
while( cmdIndex < mcpsIndication->BufferSize )
{
switch( mcpsIndication->Buffer[cmdIndex++] )
{
case REMOTE_MCAST_SETUP_PKG_VERSION_REQ:
{
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_PKG_VERSION_ANS;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_ID;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_VERSION;
break;
}
case REMOTE_MCAST_SETUP_MC_GROUP_STATUS_REQ:
{
// TODO implement command prosessing and handling
break;
}
case REMOTE_MCAST_SETUP_MC_GROUP_SETUP_REQ:
{
uint8_t id = mcpsIndication->Buffer[cmdIndex++];
McSessionData[id].McGroupData.IdHeader.Value = id;
McSessionData[id].McGroupData.McAddr = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
McSessionData[id].McGroupData.McAddr += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
McSessionData[id].McGroupData.McAddr += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
McSessionData[id].McGroupData.McAddr += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
for( int8_t i = 0; i < 16; i++ )
{
McSessionData[id].McGroupData.McKeyEncrypted[i] = mcpsIndication->Buffer[cmdIndex++];
}
McSessionData[id].McGroupData.McFCountMin = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
McSessionData[id].McGroupData.McFCountMin += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
McSessionData[id].McGroupData.McFCountMin += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
McSessionData[id].McGroupData.McFCountMin += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
McSessionData[id].McGroupData.McFCountMax = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
McSessionData[id].McGroupData.McFCountMax += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
McSessionData[id].McGroupData.McFCountMax += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
McSessionData[id].McGroupData.McFCountMax += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
McChannelParams_t channel =
{
.IsRemotelySetup = true,
.Class = CLASS_C, // Field not used for multicast channel setup. Must be initialized to something
.IsEnabled = true,
.GroupID = ( AddressIdentifier_t )McSessionData[id].McGroupData.IdHeader.Fields.McGroupId,
.Address = McSessionData[id].McGroupData.McAddr,
.McKeys.McKeyE = McSessionData[id].McGroupData.McKeyEncrypted,
.FCountMin = McSessionData[id].McGroupData.McFCountMin,
.FCountMax = McSessionData[id].McGroupData.McFCountMax,
.RxParams.ClassC = // Field not used for multicast channel setup. Must be initialized to something
{
.Frequency = 0,
.Datarate = 0
}
};
uint8_t idError = 0x01; // One bit value
if( LoRaMacMcChannelSetup( &channel ) == LORAMAC_STATUS_OK )
{
idError = 0x00;
}
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_MC_GROUP_SETUP_ANS;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = ( idError << 2 ) | McSessionData[id].McGroupData.IdHeader.Fields.McGroupId;
break;
}
case REMOTE_MCAST_SETUP_MC_GROUP_DELETE_REQ:
{
uint8_t status = 0x00;
uint8_t id = mcpsIndication->Buffer[cmdIndex++] & 0x03;
status = id;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_MC_GROUP_DELETE_ANS;
if( LoRaMacMcChannelDelete( ( AddressIdentifier_t )id ) != LORAMAC_STATUS_OK )
{
status |= 0x04; // McGroupUndefined bit set
}
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = status;
break;
}
case REMOTE_MCAST_SETUP_MC_GROUP_CLASS_C_SESSION_REQ:
{
uint8_t status = 0x00;
uint8_t id = mcpsIndication->Buffer[cmdIndex++] & 0x03;
McSessionData[id].SessionTime = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
McSessionData[id].SessionTime += ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
McSessionData[id].SessionTime += ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
McSessionData[id].SessionTime += ( mcpsIndication->Buffer[cmdIndex++] << 24 ) & 0xFF000000;
// Add Unix to Gps epcoh offset. The system time is based on Unix time.
McSessionData[id].SessionTime += UNIX_GPS_EPOCH_OFFSET;
McSessionData[id].SessionTimeout = mcpsIndication->Buffer[cmdIndex++] & 0x0F;
McSessionData[id].RxParams.ClassC.Frequency = ( mcpsIndication->Buffer[cmdIndex++] << 0 ) & 0x000000FF;
McSessionData[id].RxParams.ClassC.Frequency |= ( mcpsIndication->Buffer[cmdIndex++] << 8 ) & 0x0000FF00;
McSessionData[id].RxParams.ClassC.Frequency |= ( mcpsIndication->Buffer[cmdIndex++] << 16 ) & 0x00FF0000;
McSessionData[id].RxParams.ClassC.Frequency *= 100;
McSessionData[id].RxParams.ClassC.Datarate = mcpsIndication->Buffer[cmdIndex++];
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = REMOTE_MCAST_SETUP_MC_GROUP_CLASS_C_SESSION_ANS;
if( LoRaMacMcChannelSetupRxParams( ( AddressIdentifier_t )id, &McSessionData[id].RxParams, &status ) == LORAMAC_STATUS_OK )
{
SysTime_t curTime = { .Seconds = 0, .SubSeconds = 0 };
curTime = SysTimeGet( );
int32_t timeToSessionStart = McSessionData[id].SessionTime - curTime.Seconds;
if( timeToSessionStart > 0 )
{
// Start session start timer
TimerSetValue( &SessionStartTimer, timeToSessionStart * 1000 );
TimerStart( &SessionStartTimer );
DBG( "Time2SessionStart: %ld ms\n", timeToSessionStart * 1000 );
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = status;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = ( timeToSessionStart >> 0 ) & 0xFF;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = ( timeToSessionStart >> 8 ) & 0xFF;
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = ( timeToSessionStart >> 16 ) & 0xFF;
break;
}
else
{
// Session start time before current device time
status |= 0x10;
}
}
LmhpRemoteMcastSetupState.DataBuffer[dataBufferIndex++] = status;
break;
}
case REMOTE_MCAST_SETUP_MC_GROUP_CLASS_B_SESSION_REQ:
{
// TODO implement command prosessing and handling
break;
}
default:
{
break;
}
}
}
if( dataBufferIndex != 0 )
{
// Answer commands
LmHandlerAppData_t appData =
{
.Buffer = LmhpRemoteMcastSetupState.DataBuffer,
.BufferSize = dataBufferIndex,
.Port = REMOTE_MCAST_SETUP_PORT
};
LmhpRemoteMcastSetupPackage.OnSendRequest( &appData, LORAMAC_HANDLER_UNCONFIRMED_MSG );
DBG( "ID : %d\n", McSessionData[0].McGroupData.IdHeader.Fields.McGroupId );
DBG( "McAddr : %08lX\n", McSessionData[0].McGroupData.McAddr );
DBG( "McKey : %02X", McSessionData[0].McGroupData.McKeyEncrypted[0] );
for( int i = 1; i < 16; i++ )
{
DBG( "-%02X", McSessionData[0].McGroupData.McKeyEncrypted[i] );
}
DBG( "\n" );
DBG( "McFCountMin : %lu\n", McSessionData[0].McGroupData.McFCountMin );
DBG( "McFCountMax : %lu\n", McSessionData[0].McGroupData.McFCountMax );
DBG( "SessionTime : %lu\n", McSessionData[0].SessionTime );
DBG( "SessionTimeT: %d\n", McSessionData[0].SessionTimeout );
DBG( "Rx Freq : %lu\n", McSessionData[0].RxParams.ClassC.Frequency );
DBG( "Rx DR : DR_%d\n", McSessionData[0].RxParams.ClassC.Datarate );
}
}
static void OnSessionStartTimer( void *context )
{
TimerStop( &SessionStartTimer );
LmhpRemoteMcastSetupState.SessionState = REMOTE_MCAST_SETUP_SESSION_STATE_START;
}
static void OnSessionStopTimer( void *context )
{
TimerStop( &SessionStopTimer );
LmhpRemoteMcastSetupState.SessionState = REMOTE_MCAST_SETUP_SESSION_STATE_STOP;
}

View File

@@ -0,0 +1,47 @@
/*!
* \file LmhpRemoteMcastSetup.h
*
* \brief Implements the LoRa-Alliance remote multicast setup package
* Specification: https://lora-alliance.org/sites/default/files/2018-09/remote_multicast_setup_v1.0.0.pdf
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2018 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMHP_REMOTE_MCAST_SETUP_H__
#define __LMHP_REMOTE_MCAST_SETUP_H__
#include "LoRaMac.h"
#include "LmHandlerTypes.h"
#include "LmhPackage.h"
/*!
* Remote multicast setup package identifier.
*
* \remark This value must be unique amongst the packages
*/
#define PACKAGE_ID_REMOTE_MCAST_SETUP 2
/*!
* Remote multicast setup package parameters
*
* This package doesn't require parameters
*/
//typedef struct LmhpRemoteMcastSetupParams_s
//{
//}LmhpRemoteMcastSetupParams_t;
LmhPackage_t *LmhpRemoteMcastSetupPackageFactory( void );
#endif // __LMHP_REMOTE_MCAST_SETUP_H__

View File

@@ -0,0 +1,434 @@
/*!
* \file LmHandlerMsgDisplay.h
*
* \brief Common set of functions to display default messages from
* LoRaMacHandler.
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2019 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "utilities.h"
#include "timer.h"
#include "LmHandlerMsgDisplay.h"
/*!
* MAC status strings
*/
const char* MacStatusStrings[] =
{
"OK", // LORAMAC_STATUS_OK
"Busy", // LORAMAC_STATUS_BUSY
"Service unknown", // LORAMAC_STATUS_SERVICE_UNKNOWN
"Parameter invalid", // LORAMAC_STATUS_PARAMETER_INVALID
"Frequency invalid", // LORAMAC_STATUS_FREQUENCY_INVALID
"Datarate invalid", // LORAMAC_STATUS_DATARATE_INVALID
"Frequency or datarate invalid", // LORAMAC_STATUS_FREQ_AND_DR_INVALID
"No network joined", // LORAMAC_STATUS_NO_NETWORK_JOINED
"Length error", // LORAMAC_STATUS_LENGTH_ERROR
"Region not supported", // LORAMAC_STATUS_REGION_NOT_SUPPORTED
"Skipped APP data", // LORAMAC_STATUS_SKIPPED_APP_DATA
"Duty-cycle restricted", // LORAMAC_STATUS_DUTYCYCLE_RESTRICTED
"No channel found", // LORAMAC_STATUS_NO_CHANNEL_FOUND
"No free channel found", // LORAMAC_STATUS_NO_FREE_CHANNEL_FOUND
"Busy beacon reserved time", // LORAMAC_STATUS_BUSY_BEACON_RESERVED_TIME
"Busy ping-slot window time", // LORAMAC_STATUS_BUSY_PING_SLOT_WINDOW_TIME
"Busy uplink collision", // LORAMAC_STATUS_BUSY_UPLINK_COLLISION
"Crypto error", // LORAMAC_STATUS_CRYPTO_ERROR
"FCnt handler error", // LORAMAC_STATUS_FCNT_HANDLER_ERROR
"MAC command error", // LORAMAC_STATUS_MAC_COMMAD_ERROR
"ClassB error", // LORAMAC_STATUS_CLASS_B_ERROR
"Confirm queue error", // LORAMAC_STATUS_CONFIRM_QUEUE_ERROR
"Multicast group undefined", // LORAMAC_STATUS_MC_GROUP_UNDEFINED
"Unknown error", // LORAMAC_STATUS_ERROR
};
/*!
* MAC event info status strings.
*/
const char* EventInfoStatusStrings[] =
{
"OK", // LORAMAC_EVENT_INFO_STATUS_OK
"Error", // LORAMAC_EVENT_INFO_STATUS_ERROR
"Tx timeout", // LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT
"Rx 1 timeout", // LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT
"Rx 2 timeout", // LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT
"Rx1 error", // LORAMAC_EVENT_INFO_STATUS_RX1_ERROR
"Rx2 error", // LORAMAC_EVENT_INFO_STATUS_RX2_ERROR
"Join failed", // LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL
"Downlink repeated", // LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED
"Tx DR payload size error", // LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR
"Downlink too many frames loss", // LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS
"Address fail", // LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL
"MIC fail", // LORAMAC_EVENT_INFO_STATUS_MIC_FAIL
"Multicast fail", // LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL
"Beacon locked", // LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED
"Beacon lost", // LORAMAC_EVENT_INFO_STATUS_BEACON_LOST
"Beacon not found" // LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND
};
/*!
* Prints the provided buffer in HEX
*
* \param buffer Buffer to be printed
* \param size Buffer size to be printed
*/
void PrintHexBuffer( uint8_t *buffer, uint8_t size )
{
uint8_t newline = 0;
for( uint8_t i = 0; i < size; i++ )
{
if( newline != 0 )
{
printf( "\n" );
newline = 0;
}
printf( "%02X ", buffer[i] );
if( ( ( i + 1 ) % 16 ) == 0 )
{
newline = 1;
}
}
printf( "\n" );
}
void DisplayNvmContextChange( LmHandlerNvmContextStates_t state )
{
if( state == LORAMAC_HANDLER_NVM_STORE )
{
printf( "\n###### ============ CTXS STORED ============ ######\n\n" );
}
else
{
printf( "\n###### =========== CTXS RESTORED =========== ######\n\n" );
}
}
void DisplayNetworkParametersUpdate( CommissioningParams_t *commissioningParams )
{
printf( "DevEui : %02X", commissioningParams->DevEui[0] );
for( int i = 1; i < 8; i++ )
{
printf( "-%02X", commissioningParams->DevEui[i] );
}
printf( "\n" );
printf( "JoinEui : %02X", commissioningParams->JoinEui[0] );
for( int i = 1; i < 8; i++ )
{
printf( "-%02X", commissioningParams->JoinEui[i] );
}
printf( "\n" );
printf( "Pin : %02X", commissioningParams->SePin[0] );
for( int i = 1; i < 4; i++ )
{
printf( "-%02X", commissioningParams->SePin[i] );
}
printf( "\n\n" );
}
void DisplayMacMcpsRequestUpdate( LoRaMacStatus_t status, McpsReq_t *mcpsReq, TimerTime_t nextTxIn )
{
switch( mcpsReq->Type )
{
case MCPS_CONFIRMED:
{
printf( "\n###### =========== MCPS-Request ============ ######\n" );
printf( "###### MCPS_CONFIRMED ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MCPS_UNCONFIRMED:
{
printf( "\n###### =========== MCPS-Request ============ ######\n" );
printf( "###### MCPS_UNCONFIRMED ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MCPS_PROPRIETARY:
{
printf( "\n###### =========== MCPS-Request ============ ######\n" );
printf( "###### MCPS_PROPRIETARY ######\n");
printf( "###### ===================================== ######\n");
break;
}
default:
{
printf( "\n###### =========== MCPS-Request ============ ######\n" );
printf( "###### MCPS_ERROR ######\n");
printf( "###### ===================================== ######\n");
break;
}
}
printf( "STATUS : %s\n", MacStatusStrings[status] );
if( status == LORAMAC_STATUS_DUTYCYCLE_RESTRICTED )
{
printf( "Next Tx in : %lu [ms]\n", nextTxIn );
}
}
void DisplayMacMlmeRequestUpdate( LoRaMacStatus_t status, MlmeReq_t *mlmeReq, TimerTime_t nextTxIn )
{
switch( mlmeReq->Type )
{
case MLME_JOIN:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_JOIN ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MLME_LINK_CHECK:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_LINK_CHECK ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MLME_DEVICE_TIME:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_DEVICE_TIME ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MLME_TXCW:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_TXCW ######\n");
printf( "###### ===================================== ######\n");
break;
}
case MLME_TXCW_1:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_TXCW_1 ######\n");
printf( "###### ===================================== ######\n");
break;
}
default:
{
printf( "\n###### =========== MLME-Request ============ ######\n" );
printf( "###### MLME_UNKNOWN ######\n");
printf( "###### ===================================== ######\n");
break;
}
}
printf( "STATUS : %s\n", MacStatusStrings[status] );
if( status == LORAMAC_STATUS_DUTYCYCLE_RESTRICTED )
{
printf( "Next Tx in : %lu [ms]\n", nextTxIn );
}
}
void DisplayJoinRequestUpdate( LmHandlerJoinParams_t *params )
{
if( params->CommissioningParams->IsOtaaActivation == true )
{
if( params->Status == LORAMAC_HANDLER_SUCCESS )
{
printf( "###### =========== JOINED ============ ######\n" );
printf( "\nOTAA\n\n" );
printf( "DevAddr : %08lX\n", params->CommissioningParams->DevAddr );
printf( "\n\n" );
printf( "DATA RATE : DR_%d\n\n", params->Datarate );
}
}
#if ( OVER_THE_AIR_ACTIVATION == 0 )
else
{
printf( "###### =========== JOINED ============ ######\n" );
printf( "\nABP\n\n" );
printf( "DevAddr : %08lX\n", params->CommissioningParams->DevAddr );
printf( "\n\n" );
}
#endif
}
void DisplayTxUpdate( LmHandlerTxParams_t *params )
{
MibRequestConfirm_t mibGet;
if( params->IsMcpsConfirm == 0 )
{
printf( "\n###### =========== MLME-Confirm ============ ######\n" );
printf( "STATUS : %s\n", EventInfoStatusStrings[params->Status] );
return;
}
printf( "\n###### =========== MCPS-Confirm ============ ######\n" );
printf( "STATUS : %s\n", EventInfoStatusStrings[params->Status] );
printf( "\n###### ===== UPLINK FRAME %8lu ===== ######\n", params->UplinkCounter );
printf( "\n" );
printf( "CLASS : %c\n", "ABC"[LmHandlerGetCurrentClass( )] );
printf( "\n" );
printf( "TX PORT : %d\n", params->AppData.Port );
if( params->AppData.BufferSize != 0 )
{
printf( "TX DATA : " );
if( params->MsgType == LORAMAC_HANDLER_CONFIRMED_MSG )
{
printf( "CONFIRMED - %s\n", ( params->AckReceived != 0 ) ? "ACK" : "NACK" );
}
else
{
printf( "UNCONFIRMED\n" );
}
PrintHexBuffer( params->AppData.Buffer, params->AppData.BufferSize );
}
printf( "\n" );
printf( "DATA RATE : DR_%d\n", params->Datarate );
mibGet.Type = MIB_CHANNELS;
if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK )
{
printf( "U/L FREQ : %lu\n", mibGet.Param.ChannelList[params->Channel].Frequency );
}
printf( "TX POWER : %d\n", params->TxPower );
mibGet.Type = MIB_CHANNELS_MASK;
if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK )
{
printf("CHANNEL MASK: ");
switch( LmHandlerGetActiveRegion( ) )
{
case LORAMAC_REGION_AS923:
case LORAMAC_REGION_CN779:
case LORAMAC_REGION_EU868:
case LORAMAC_REGION_IN865:
case LORAMAC_REGION_KR920:
case LORAMAC_REGION_EU433:
case LORAMAC_REGION_RU864:
{
printf( "%04X ", mibGet.Param.ChannelsMask[0] );
break;
}
case LORAMAC_REGION_AU915:
case LORAMAC_REGION_CN470:
case LORAMAC_REGION_US915:
{
for( uint8_t i = 0; i < 5; i++)
{
printf( "%04X ", mibGet.Param.ChannelsMask[i] );
}
break;
}
default:
{
printf( "\n###### ========= Unknown Region ============ ######" );
break;
}
}
printf("\n");
}
printf( "\n" );
}
void DisplayRxUpdate( LmHandlerAppData_t *appData, LmHandlerRxParams_t *params )
{
const char *slotStrings[] = { "1", "2", "C", "C Multicast", "B Ping-Slot", "B Multicast Ping-Slot" };
if( params->IsMcpsIndication == 0 )
{
printf( "\n###### ========== MLME-Indication ========== ######\n" );
printf( "STATUS : %s\n", EventInfoStatusStrings[params->Status] );
return;
}
printf( "\n###### ========== MCPS-Indication ========== ######\n" );
printf( "STATUS : %s\n", EventInfoStatusStrings[params->Status] );
printf( "\n###### ===== DOWNLINK FRAME %8lu ===== ######\n", params->DownlinkCounter );
printf( "RX WINDOW : %s\n", slotStrings[params->RxSlot] );
printf( "RX PORT : %d\n", appData->Port );
if( appData->BufferSize != 0 )
{
printf( "RX DATA : \n" );
PrintHexBuffer( appData->Buffer, appData->BufferSize );
}
printf( "\n" );
printf( "DATA RATE : DR_%d\n", params->Datarate );
printf( "RX RSSI : %d\n", params->Rssi );
printf( "RX SNR : %d\n", params->Snr );
printf( "\n" );
}
void DisplayBeaconUpdate( LoRaMAcHandlerBeaconParams_t *params )
{
switch( params->State )
{
default:
case LORAMAC_HANDLER_BEACON_ACQUIRING:
{
printf( "\n###### ========= BEACON ACQUIRING ========== ######\n" );
break;
}
case LORAMAC_HANDLER_BEACON_LOST:
{
printf( "\n###### ============ BEACON LOST ============ ######\n" );
break;
}
case LORAMAC_HANDLER_BEACON_RX:
{
printf( "\n###### ===== BEACON %8lu ==== ######\n", params->Info.Time.Seconds );
printf( "GW DESC : %d\n", params->Info.GwSpecific.InfoDesc );
printf( "GW INFO : " );
PrintHexBuffer( params->Info.GwSpecific.Info, 6 );
printf( "\n" );
printf( "FREQ : %lu\n", params->Info.Frequency );
printf( "DATA RATE : DR_%d\n", params->Info.Datarate );
printf( "RX RSSI : %d\n", params->Info.Rssi );
printf( "RX SNR : %d\n", params->Info.Snr );
printf( "\n" );
break;
}
case LORAMAC_HANDLER_BEACON_NRX:
{
printf( "\n###### ======== BEACON NOT RECEIVED ======== ######\n" );
break;
}
}
}
void DisplayClassUpdate( DeviceClass_t deviceClass )
{
printf( "\n\n###### ===== Switch to Class %c done. ===== ######\n\n", "ABC"[deviceClass] );
}
void DisplayAppInfo( const char* appName, const Version_t* appVersion, const Version_t* gitHubVersion )
{
printf( "\n###### ===================================== ######\n\n" );
printf( "Application name : %s\n", appName );
printf( "Application version: %d.%d.%d\n", appVersion->Fields.Major, appVersion->Fields.Minor, appVersion->Fields.Patch );
printf( "GitHub base version: %d.%d.%d\n", gitHubVersion->Fields.Major, gitHubVersion->Fields.Minor, gitHubVersion->Fields.Patch );
printf( "\n###### ===================================== ######\n\n" );
}

View File

@@ -0,0 +1,102 @@
/*!
* \file LmHandlerMsgDisplay.h
*
* \brief Common set of functions to display default messages from
* LoRaMacHandler.
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2019 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*/
#ifndef __LMHANDLER_MSG_DISPLAY_H__
#define __LMHANDLER_MSG_DISPLAY_H__
#include "utilities.h"
#include "LmHandler.h"
/*!
* \brief Displays NVM context operation state
*
* \param [IN] state Indicates if we are storing (true) or
* restoring (false) the NVM context
*/
void DisplayNvmContextChange( LmHandlerNvmContextStates_t state );
/*!
* \brief Displays updated network parameters
*
* \param [IN] commissioningParams Commissioning provided parameters
*/
void DisplayNetworkParametersUpdate( CommissioningParams_t* commissioningParams );
/*!
* \brief Displays updated McpsRequest
*
* \param [IN] status McpsRequest execution status
* \param [IN] mcpsReq McpsRequest command executed
* \param [IN] nextTxIn Time to wait for the next uplink transmission
*/
void DisplayMacMcpsRequestUpdate( LoRaMacStatus_t status, McpsReq_t *mcpsReq, TimerTime_t nextTxIn );
/*!
* \brief Displays updated MlmeRequest
*
* \param [IN] status MlmeRequest execution status
* \param [IN] mlmeReq MlmeRequest command executed
* \param [IN] nextTxIn Time to wait for the next uplink transmission
*/
void DisplayMacMlmeRequestUpdate( LoRaMacStatus_t status, MlmeReq_t *mlmeReq, TimerTime_t nextTxIn );
/*!
* \brief Displays updated JoinRequest
*
* \param [IN] params Executed JoinRequest parameters
*/
void DisplayJoinRequestUpdate( LmHandlerJoinParams_t* params );
/*!
* \brief Displays Tx params
*
* \param [IN] params Tx parameters
*/
void DisplayTxUpdate( LmHandlerTxParams_t* params );
/*!
* \brief Displays Rx params
*
* \param [IN] appData Receive data payload and port number
* \param [IN] params Rx parameters
*/
void DisplayRxUpdate( LmHandlerAppData_t* appData, LmHandlerRxParams_t* params );
/*!
* \brief Displays beacon status update
*
* \param [IN] params Beacon parameters
*/
void DisplayBeaconUpdate( LoRaMAcHandlerBeaconParams_t* params );
/*!
* \brief Displays end-device class update
*
* \param [IN] deviceClass Current end-device class
*/
void DisplayClassUpdate( DeviceClass_t deviceClass );
/*!
* \brief Displays application information
*/
void DisplayAppInfo( const char* appName, const Version_t* appVersion, const Version_t* gitHubVersion );
#endif // __LMHANDLER_MSG_DISPLAY_H__

View File

@@ -112,7 +112,6 @@ LoRaMacCtxUpdateStatus_t CtxUpdateStatus = { .Value = 0 };
/*
* Nvmm handles
*/
static NvmmDataBlock_t FCntHandlerNvmCtxDataBlock;
static NvmmDataBlock_t SecureElementNvmCtxDataBlock;
static NvmmDataBlock_t CryptoNvmCtxDataBlock;
#if ( MAX_PERSISTENT_CTX_MGMT_ENABLED == 1 )
@@ -164,11 +163,6 @@ void NvmCtxMgmtEvent( LoRaMacNvmCtxModule_t module )
CtxUpdateStatus.Elements.ConfirmQueue = 1;
break;
}
case LORAMAC_NVMCTXMODULE_FCNT_HANDLER:
{
CtxUpdateStatus.Elements.FCntHandlerNvmCtx = 1;
break;
}
default:
{
break;
@@ -213,14 +207,6 @@ NvmCtxMgmtStatus_t NvmCtxMgmtStore( void )
}
}
if( CtxUpdateStatus.Elements.FCntHandlerNvmCtx == 1 )
{
if( NvmmWrite( &FCntHandlerNvmCtxDataBlock, MacContexts->FCntHandlerNvmCtx, MacContexts->FCntHandlerNvmCtxSize ) != NVMM_SUCCESS )
{
return NVMCTXMGMT_STATUS_FAIL;
}
}
#if ( MAX_PERSISTENT_CTX_MGMT_ENABLED == 1 )
if( CtxUpdateStatus.Elements.Mac == 1 )
{
@@ -288,7 +274,6 @@ NvmCtxMgmtStatus_t NvmCtxMgmtRestore( void )
uint8_t NvmCryptoCtxRestore[mibReq.Param.Contexts->CryptoNvmCtxSize];
uint8_t NvmSecureElementCtxRestore[mibReq.Param.Contexts->SecureElementNvmCtxSize];
uint8_t NvmFCntHandlerCtxRestore[mibReq.Param.Contexts->FCntHandlerNvmCtxSize];
#if ( MAX_PERSISTENT_CTX_MGMT_ENABLED == 1 )
uint8_t NvmMacCtxRestore[mibReq.Param.Contexts->MacNvmCtxSize];
uint8_t NvmRegionCtxRestore[mibReq.Param.Contexts->RegionNvmCtxSize];
@@ -319,17 +304,6 @@ NvmCtxMgmtStatus_t NvmCtxMgmtRestore( void )
status = NVMCTXMGMT_STATUS_FAIL;
}
if ( NvmmDeclare( &FCntHandlerNvmCtxDataBlock, mibReq.Param.Contexts->FCntHandlerNvmCtxSize ) == NVMM_SUCCESS )
{
NvmmRead( &FCntHandlerNvmCtxDataBlock, NvmFCntHandlerCtxRestore, mibReq.Param.Contexts->FCntHandlerNvmCtxSize );
contexts.FCntHandlerNvmCtx = &NvmFCntHandlerCtxRestore;
contexts.FCntHandlerNvmCtxSize = mibReq.Param.Contexts->FCntHandlerNvmCtxSize;
}
else
{
status = NVMCTXMGMT_STATUS_FAIL;
}
#if ( MAX_PERSISTENT_CTX_MGMT_ENABLED == 1 )
if( NvmmDeclare( &MacNvmCtxDataBlock, mibReq.Param.Contexts->MacNvmCtxSize ) == NVMM_SUCCESS )
{

View File

@@ -25,8 +25,6 @@
#define TOS_CFG_SEM_EN 1u
#define TOS_CFG_VFS_EN 1u
#define TOS_CFG_IDLE_TASK_STK_SIZE 80u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u

Some files were not shown because too many files have changed in this diff Show More