From 0fe13987087976bd66c8ea0528bd511fbb52ed78 Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Wed, 23 Oct 2024 20:06:50 +0800
Subject: [PATCH 1/7] wip not good

---
 Core/Inc/main.h                               | 27 +++++++++---------
 Core/Inc/sys_conf.h                           |  8 +++---
 Core/Src/gpio.c                               |  2 +-
 Core/Src/i2c.c                                |  4 +++
 Core/Src/main.c                               |  6 +++-
 LoRaWAN/App/lora_app.c                        |  8 ++++--
 LoRaWAN/Target/lorawan_conf.h                 |  2 +-
 .../User/STS/TOF/vl53l0x/subdir.mk            |  9 ------
 .../Drivers/BSP/STM32WLxx_Nucleo/subdir.mk    | 23 ---------------
 STM32CubeIDE/Release/makefile                 |  1 +
 STM32CubeIDE/Release/sources.mk               |  1 +
 STS/Core/Src/yunhorn_sts_process.c            | 28 +++++++++++--------
 12 files changed, 53 insertions(+), 66 deletions(-)
 delete mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk

diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index d870785..38ae308 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -101,15 +101,15 @@ void Error_Handler(void);
 #define LED1_OFF		HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
 #define LED1_STATE		HAL_GPIO_ReadPin(LED1_GPIO_Port, LED1_Pin)
 #define LED1_TOGGLE		HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
-//#define MEMS_POWER_Pin							GPIO_PIN_4				// PMU_ENABLE
-//#define MEMS_POWER_GPIO_Port 					GPIOB					// PMU_ENABLE
+#define MEMS_POWER_Pin							GPIO_PIN_4				// PMU_ENABLE
+#define MEMS_POWER_GPIO_Port 					GPIOB					// PMU_ENABLE
 
-//#define MEMS_RESET_Pin							GPIO_PIN_4
-//#define MEMS_RESET_GPIO_Port 					GPIOB
+#define MEMS_RESET_Pin							GPIO_PIN_4
+#define MEMS_RESET_GPIO_Port 					GPIOB
 
-#define PME_ON			//HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET )
-#define PME_OFF			//HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET )
-#define PME_TOGGLE		//HAL_GPIO_TogglePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin)
+#define PME_ON			HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET )
+#define PME_OFF			HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET )
+#define PME_TOGGLE		HAL_GPIO_TogglePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin)
 
 #if (defined(TOF_1)||defined(TOF_2)||defined(STS_R1)||defined(STS_R5)||defined(STS_R1D))
 #define VL53L0
@@ -224,24 +224,25 @@ void Error_Handler(void);
 #define I2C2_STANDARD_100K			0x00000E14
 #define I2C2_FAST_400K				0x00000004
 #define I2C2_FAST_PLUS_1M			0x00000000
-#endif
-
+#else
 /*
  * FOR STM32WLE5CCU6 UFQFPN48  PA12 PA11
- *
+ */
 #define I2C2_STANDARD_100K			0x00000E14
 #define I2C2_FAST_400K				0x00000004
 #define I2C2_FAST_PLUS_1M			0x00000000
-*/
+
+#endif
+
 
 /*
  * FOR STM32WL55JCIX UFBGA73  PA12 PA11
  */
-
+#ifdef	STM32WL55xx
 #define I2C2_STANDARD_100K			0x10805D88
 #define I2C2_FAST_400K				0x0090194B
 #define I2C2_FAST_PLUS_1M			0x00700814
-
+#endif
 #if defined(STS_R4)
 /* IF_SOAP_IN, MEMS_IF_3, PA10  */
 #define SOAP_STATUS_Pin			GPIO_PIN_10
diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h
index 4941614..f10502a 100644
--- a/Core/Inc/sys_conf.h
+++ b/Core/Inc/sys_conf.h
@@ -47,12 +47,12 @@ extern "C" {
 /**
   * @brief  Verbose level for all trace logs
   */
-#define VERBOSE_LEVEL                        VLEVEL_OFF
+#define VERBOSE_LEVEL                        VLEVEL_M
 
 /**
   * @brief Enable trace logs
   */
-#define APP_LOG_ENABLED                      0
+#define APP_LOG_ENABLED                      1
 
 /**
   * @brief Activate monitoring (probes) of some internal RF signals for debug purpose
@@ -75,13 +75,13 @@ extern "C" {
   * @brief Enable/Disable MCU Debugger pins (dbg serial wires)
   * @note  by HW serial wires are ON by default, need to put them OFF to save power
   */
-#define DEBUGGER_ENABLED                     0
+#define DEBUGGER_ENABLED                     1
 
 /**
   * @brief Disable Low Power mode
   * @note  0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only
   */
-#define LOW_POWER_DISABLE                    0
+#define LOW_POWER_DISABLE                    1
 
 /* USER CODE BEGIN EC */
 
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
index 172fbd9..85140f6 100644
--- a/Core/Src/gpio.c
+++ b/Core/Src/gpio.c
@@ -81,7 +81,7 @@ void MX_GPIO_Init(void)
   GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
   GPIO_InitStruct.Pull = GPIO_PULLUP;
   HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct);
-#if 0
+#ifndef	L8
   /*     STS-PME      PB-4                  */
   /*Configure GPIO pins : PBPin PBPin PBPin */
     GPIO_InitStruct.Pin = MEMS_POWER_Pin;
diff --git a/Core/Src/i2c.c b/Core/Src/i2c.c
index 6d4c951..2713947 100644
--- a/Core/Src/i2c.c
+++ b/Core/Src/i2c.c
@@ -43,7 +43,11 @@ void MX_I2C2_Init(void)
 
   /* USER CODE END I2C2_Init 1 */
   hi2c2.Instance = I2C2;
+#ifdef L8
   hi2c2.Init.Timing = I2C2_FAST_PLUS_1M;
+#else
+  hi2c2.Init.Timing = I2C2_STANDARD_100K;
+#endif
   hi2c2.Init.OwnAddress1 = 0;
   hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
   hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 66c56f9..8498dbf 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -105,16 +105,20 @@ int main(void)
   if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
   {
 	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
+	  printf("\n***** PWR_FLAG_SB \n\r");
   }
   else
   {
+#ifndef STS_R4
 	  MX_I2C2_Init();
 	  MX_DMA_Init();
+#endif
+
       MX_LoRaWAN_Init();
   }
 
   /* USER CODE BEGIN 2 */
-  MX_USART2_UART_Init();
+  //MX_USART2_UART_Init();
   /* USER CODE END 2 */
 
   /* Infinite loop */
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 141d956..0eda4b8 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -1476,7 +1476,7 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t newperiodicity)
 	  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
-  APP_LOG(TS_OFF, VLEVEL_H,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
 }
 
@@ -1502,13 +1502,15 @@ void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity)
   /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
 
   /* Update timer OnYunhornSTSTxPeriodicityChanged */
-
+	OnTxPeriodicityChanged(periodicity);
+	/*
 	  UTIL_TIMER_Stop(&TxTimer);
 	  TxPeriodicity = periodicity;
 	  UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
 	  UTIL_TIMER_Start(&TxTimer);
+	  */
 
   /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */
-  APP_LOG(TS_OFF, VLEVEL_H,"* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_M,"* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
   /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
 }
diff --git a/LoRaWAN/Target/lorawan_conf.h b/LoRaWAN/Target/lorawan_conf.h
index 9ddccb0..1706743 100644
--- a/LoRaWAN/Target/lorawan_conf.h
+++ b/LoRaWAN/Target/lorawan_conf.h
@@ -109,7 +109,7 @@ extern "C" {
  *        - CHANNEL_PLAN_GROUP_AS923_4    (Freq offset = -5.90 MHz / Freq range = 917-920MHz)
  *        - CHANNEL_PLAN_GROUP_AS923_1_JP (Freq offset = 0.0 MHz   / Freq range = 920.6-923.4MHz)
  */
-#define REGION_AS923_DEFAULT_CHANNEL_PLAN              CHANNEL_PLAN_GROUP_AS923_1_JP
+#define REGION_AS923_DEFAULT_CHANNEL_PLAN              CHANNEL_PLAN_GROUP_AS923_1
 
 /*!
  * @brief Limits the number usable channels by default for AU915, CN470 and US915 regions
diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk
deleted file mode 100644
index 7effbaf..0000000
--- a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-# Toolchain: GNU Tools for STM32 (12.3.rel1)
-################################################################################
-
-# Add inputs and outputs from these tool invocations to the build variables 
-
-# Each subdirectory must supply rules for building sources it contributes
-
diff --git a/STM32CubeIDE/Release/Drivers/BSP/STM32WLxx_Nucleo/subdir.mk b/STM32CubeIDE/Release/Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
index 016fab4..7effbaf 100644
--- a/STM32CubeIDE/Release/Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
+++ b/STM32CubeIDE/Release/Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
@@ -4,29 +4,6 @@
 ################################################################################
 
 # Add inputs and outputs from these tool invocations to the build variables 
-C_SRCS += \
-D:/ONEDRIVE/STM32WLV13/Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.c \
-D:/ONEDRIVE/STM32WLV13/Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.c 
-
-OBJS += \
-./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.o \
-./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.o 
-
-C_DEPS += \
-./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.d \
-./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.d 
-
 
 # Each subdirectory must supply rules for building sources it contributes
-Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.c Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
-	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
-Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.c Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
-	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
-
-clean: clean-Drivers-2f-BSP-2f-STM32WLxx_Nucleo
-
-clean-Drivers-2f-BSP-2f-STM32WLxx_Nucleo:
-	-$(RM) ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.cyclo ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.d ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.o ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.su ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.cyclo ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.d ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.o ./Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.su
-
-.PHONY: clean-Drivers-2f-BSP-2f-STM32WLxx_Nucleo
 
diff --git a/STM32CubeIDE/Release/makefile b/STM32CubeIDE/Release/makefile
index d69689a..895fe99 100644
--- a/STM32CubeIDE/Release/makefile
+++ b/STM32CubeIDE/Release/makefile
@@ -14,6 +14,7 @@ RM := rm -rf
 -include Middlewares/LoRaWAN/subdir.mk
 -include Drivers/STM32WLxx_HAL_Driver/subdir.mk
 -include Drivers/CMSIS/subdir.mk
+-include Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
 -include Application/User/Startup/subdir.mk
 -include Application/User/STS/TOF/Target/subdir.mk
 -include Application/User/STS/TOF/App/subdir.mk
diff --git a/STM32CubeIDE/Release/sources.mk b/STM32CubeIDE/Release/sources.mk
index 5a59fc8..6ec74ed 100644
--- a/STM32CubeIDE/Release/sources.mk
+++ b/STM32CubeIDE/Release/sources.mk
@@ -29,6 +29,7 @@ Application/User/STS/Core/Src \
 Application/User/STS/TOF/App \
 Application/User/STS/TOF/Target \
 Application/User/Startup \
+Drivers/BSP/STM32WLxx_Nucleo \
 Drivers/CMSIS \
 Drivers/STM32WLxx_HAL_Driver \
 Middlewares/LoRaWAN \
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index b66dea1..bd31807 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -57,10 +57,15 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
 		sts_mtmcode2,
 		sts_version,
 		sts_hardware_ver,
-		0x05,		//Regular TxPeriodicity interval
-		'M', 		//Uplink data interval unit,  for heart-beat uplink
+		0x20,		//Regular TxPeriodicity interval
+		'S', 		//Uplink data interval unit,  for heart-beat uplink
+#ifdef	STS_L8
 		0x01,		//Heart-beat interval or Sampling interval
 		'S', 		//Sampling sensor interval unit, for real-time sensing of MEMS
+#else
+		0x05,		//Heart-beat interval or Sampling interval
+		'M', 		//Sampling sensor interval unit, for real-time sensing of MEMS
+#endif
 		0x04,		// dual mode=4, uni_mode =5
 		0x00,		// sts service mask
 		0x00, 		//sts_ioc_mask
@@ -114,7 +119,7 @@ volatile uint16_t sts_sensor_install_height=3000;
 volatile uint8_t sensor_data_ready=0;
 
 #if	defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)
-volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=300, STS_HeartBeatTimerPeriod_sec=3600;
+volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=300;
 #endif
 
 #if	defined(STS_L8)||defined(STS_P2)||defined(STS_O6T)||defined(STS_T6)
@@ -477,7 +482,7 @@ void STS_YunhornSTSEventP6_Process(void)
 	//sts_soap_level_state = 0;
 	sts_soap_level_state = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin);
 	//APP_LOG(TS_OFF, VLEVEL_M, "\r\n Soap State = 0x%02X \r\n", sts_soap_level_state);
-	APP_LOG(TS_OFF, VLEVEL_L, "\r\n Soap State = %s \r\n", (sts_soap_level_state==0x0)?"  +++  Liquid Detected":"  ---  No Liquid");
+	APP_LOG(TS_OFF, VLEVEL_M, "\r\n Soap State read=%02x  State: %s \r\n", sts_soap_level_state, (sts_soap_level_state==0x0)?"  +++  Liquid Detected":"  ---  No Liquid");
 
 	HAL_GPIO_WritePin(SOAP_SWITCH_GPIO_Port, SOAP_SWITCH_Pin, GPIO_PIN_RESET);
 
@@ -1583,7 +1588,7 @@ void STS_REBOOT_CONFIG_Init(void)
 		}
 
 	}
-  	//STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
+  	STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
 	OnRestoreSTSCFGContextProcess();
 
   /* USER CODE END OnRestoreContextRequest_Last */
@@ -1601,7 +1606,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	}
 	periodicity = (periodicity > 10)? periodicity : 10;		// in seconds unit
 
-	APP_LOG(TS_OFF, VLEVEL_H, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
+	APP_LOG(TS_OFF, VLEVEL_M, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
 
 	TxPeriodicity= periodicity*1000;  // to ms
 	STS_TxPeriod_sec = periodicity;
@@ -1615,19 +1620,20 @@ void OnRestoreSTSCFGContextProcess(void)
 		sampling_heartbeat_periodicity *= 1;
 	}
 	STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity;
-	APP_LOG(TS_OFF, VLEVEL_H, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
+	APP_LOG(TS_OFF, VLEVEL_M, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
 
 	if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
 	{															// ensure it's not in production yet
 		//OnTxPeriodicityChanged(APP_TX_DUTYCYCLE);				// in msec unit
-		//OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); TODO XXXX
+		OnYunhornSTSTxPeriodicityChanged(APP_TX_DUTYCYCLE);				// in msec unit
+		OnYunhornSTSHeartBeatPeriodicityChanged(120*1000); //TODO XXXX
 		//OnTxPeriodicityChanged(10000);				// APP_TX_DUTYCYCLE in msec unit
-		//TxPeriodicity = APP_TX_DUTYCYCLE;
+		TxPeriodicity = APP_TX_DUTYCYCLE;
 
 	} else
 	{
 		OnYunhornSTSTxPeriodicityChanged(TxPeriodicity);				// in msec unit
-		//OnTxPeriodicityChanged(periodicity*1000);
+		//OnTxPeriodicityChanged(TxPeriodicity);
 		//Heart-beat or Sampling interval
 		//sampling_heartbeat_periodicity = (sampling_heartbeat_periodicity > 0)? sampling_heartbeat_periodicity : 1;		// in seconds unit
 		//sampling_heartbeat_periodicity = sampling_heartbeat_periodicity*1000;
@@ -1639,7 +1645,7 @@ void OnRestoreSTSCFGContextProcess(void)
 #endif
 
 #if	defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)||defined(YUNHORN_STS_R4_ENABLED)
-	OnYunhornSTSHeartBeatPeriodicityChanged(sampling_heartbeat_periodicity*1000);
+	OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000);
 #endif
 	}
 

From 0a7df45a5ceff59245caf6af97db5d4d2c39c4df Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Wed, 23 Oct 2024 20:10:16 +0800
Subject: [PATCH 2/7] ---Revert "refine R4 logic"

This reverts commit 7b1863a2dec3b0380a2daa2ca1685598f5eaa1f3.
---
 Core/Src/main.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/Core/Src/main.c b/Core/Src/main.c
index 8498dbf..e176d13 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -102,19 +102,20 @@ int main(void)
   /* Initialize all configured peripherals */
   MX_GPIO_Init();
 
-  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
+  MX_I2C2_Init();
+  MX_DMA_Init();
+  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET)
   {
-	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
-	  printf("\n***** PWR_FLAG_SB \n\r");
-  }
-  else
-  {
-#ifndef STS_R4
-	  MX_I2C2_Init();
-	  MX_DMA_Init();
-#endif
 
       MX_LoRaWAN_Init();
+  } else
+  {
+	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
+
+	      /* Enable access to RTC domain for following wake-up source configuration */
+	      //HAL_PWR_EnableBkUpAccess();
+	      //__HAL_RCC_RTCAPB_CLK_ENABLE();
+
   }
 
   /* USER CODE BEGIN 2 */
@@ -176,7 +177,7 @@ void SystemClock_Config(void)
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
-  //RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
+  RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
 
   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
   {

From 9b3f200fa5c23e4bfdb21ea14b0ec7af50dca2c3 Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Wed, 23 Oct 2024 20:43:12 +0800
Subject: [PATCH 3/7] Revert "--- refine STS-R4 txperiod and heart-beat period"

This reverts commit 78e652fd20fb1cecde9c849875355c7a68790754.
---
 Core/Src/main.c                    | 14 +-------------
 LoRaWAN/App/lora_app.c             | 13 +++++++------
 LoRaWAN/App/lora_app.h             |  2 +-
 STS/Core/Src/yunhorn_sts_process.c | 16 +++++++++-------
 4 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/Core/Src/main.c b/Core/Src/main.c
index e176d13..16ed38d 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -104,20 +104,8 @@ int main(void)
 
   MX_I2C2_Init();
   MX_DMA_Init();
-  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET)
-  {
-
-      MX_LoRaWAN_Init();
-  } else
-  {
-	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
-
-	      /* Enable access to RTC domain for following wake-up source configuration */
-	      //HAL_PWR_EnableBkUpAccess();
-	      //__HAL_RCC_RTCAPB_CLK_ENABLE();
-
-  }
 
+  MX_LoRaWAN_Init();
   /* USER CODE BEGIN 2 */
   //MX_USART2_UART_Init();
   /* USER CODE END 2 */
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 0eda4b8..1d29019 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -1107,7 +1107,6 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
       LmHandlerParams.IsTxConfirmed = true;
       LmHandlerErrorStatus_t status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
       if (status ==LORAMAC_HANDLER_SUCCESS )  LmHandlerParams.IsTxConfirmed = false;
-
     }
     else
     {
@@ -1457,26 +1456,28 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
   * @brief  Yunhorn STS Heart Beat Periodicity Chagne function
   * @param  duration of periodicty in ms (1/1000 sec)
   */
-void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t newperiodicity)
+void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
 {
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_1 */
 
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_1 */
 
-  if (newperiodicity == 0)
+  if (periodicity == 0)
   {
     /* Revert to application default Heat-beat periodicity */
-	  newperiodicity = 10*APP_TX_DUTYCYCLE;		//10*10 000 ms
+	  periodicity = 10*APP_TX_DUTYCYCLE;		//10*10 000 ms
   }
 
   /* Update timer YunhornSTSHeartBeatTimer */
 
 	  UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
-	  UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, newperiodicity);
+	  UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, periodicity);
 	  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
-  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
+
+  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
+
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
 }
 
diff --git a/LoRaWAN/App/lora_app.h b/LoRaWAN/App/lora_app.h
index ae4a403..52f4d16 100644
--- a/LoRaWAN/App/lora_app.h
+++ b/LoRaWAN/App/lora_app.h
@@ -68,7 +68,7 @@ extern "C" {
 /*!
  * LoRaWAN default class
  */
-#define LORAWAN_DEFAULT_CLASS                       CLASS_A
+#define LORAWAN_DEFAULT_CLASS                       CLASS_C
 
 /*!
  * LoRaWAN default confirm state
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index bd31807..760a1c9 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -1363,11 +1363,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
 
 					sts_cfg_nvm.sts_service_mask = sts_service_mask;
 					OnStoreSTSCFGContextRequest();
-					i=0;
-					UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
-					UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, parse_buffer_size);
-					i = parse_buffer_size;
-					STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
+
 
 				} else {
 					sts_service_mask = STS_SERVICE_MASK_L2;
@@ -1375,6 +1371,12 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
 					sts_ac_code[19]	=0x0;
 				}
 
+				i=0;
+				UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
+				UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, parse_buffer_size);
+				i = parse_buffer_size;
+				STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
+
 			}
 		break;
 	default:
@@ -1609,8 +1611,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	APP_LOG(TS_OFF, VLEVEL_M, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
 
 	TxPeriodicity= periodicity*1000;  // to ms
-	STS_TxPeriod_sec = periodicity;
-	//STS_TxPeriod_sec=10, STS_HeartBeatTimerPeriod_sec=60;
+
 	uint32_t sampling_heartbeat_periodicity = (sts_cfg_nvm.sampling);		//Heart-beat or Sampling interval
 	if ((char)sts_cfg_nvm.s_unit =='M') {
 		sampling_heartbeat_periodicity *= 60;
@@ -1619,6 +1620,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	} else if ((char) sts_cfg_nvm.s_unit =='S') {
 		sampling_heartbeat_periodicity *= 1;
 	}
+
 	STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity;
 	APP_LOG(TS_OFF, VLEVEL_M, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
 

From 66bed67e4a13c54d0e08ac79570bd80ab79a7aea Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Wed, 23 Oct 2024 20:47:34 +0800
Subject: [PATCH 4/7] Revert "--- refine STS-R4 txperiod and heart-beat period"

This reverts commit 78e652fd20fb1cecde9c849875355c7a68790754.
---
 LoRaWAN/App/lora_app.c             | 4 ++++
 STS/Core/Src/yunhorn_sts_process.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 1d29019..1e8f798 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -1475,9 +1475,13 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
 	  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
+<<<<<<< HEAD
 
   APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
 
+=======
+  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
+>>>>>>> parent of 78e652f (--- refine STS-R4 txperiod and heart-beat period)
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
 }
 
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index 760a1c9..cda4154 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -117,6 +117,7 @@ volatile uint8_t sts_work_mode=4;
 volatile uint32_t rfac_timer=0;
 volatile uint16_t sts_sensor_install_height=3000;
 volatile uint8_t sensor_data_ready=0;
+<<<<<<< HEAD
 
 #if	defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)
 volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=300;
@@ -126,6 +127,9 @@ volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatT
 volatile uint32_t STS_TOFScanPeriod_msec=5000, STS_TxPeriod_sec=10, STS_HeartBeatTimerPeriod_sec=60;
 #endif
 
+=======
+volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=10, STS_HeartBeatTimerPeriod_sec=60;
+>>>>>>> parent of 78e652f (--- refine STS-R4 txperiod and heart-beat period)
 static uint8_t outbuf[128]={0x0};
 extern volatile hmac_result_t hmac_result;
 extern uint16_t sensor_id;
@@ -1621,8 +1625,12 @@ void OnRestoreSTSCFGContextProcess(void)
 		sampling_heartbeat_periodicity *= 1;
 	}
 
+<<<<<<< HEAD
 	STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity;
 	APP_LOG(TS_OFF, VLEVEL_M, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
+=======
+	APP_LOG(TS_OFF, VLEVEL_H, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
+>>>>>>> parent of 78e652f (--- refine STS-R4 txperiod and heart-beat period)
 
 	if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
 	{															// ensure it's not in production yet

From c7a05575cc76aee4288a152732ff1d2d2fee92f6 Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Wed, 23 Oct 2024 23:12:13 +0800
Subject: [PATCH 5/7] ---- workable STS-R4

---
 Core/Inc/sys_conf.h                |  8 ++++----
 Core/Src/main.c                    |  2 +-
 LoRaWAN/App/lora_app.c             |  4 ++--
 STM32CubeIDE/Release/makefile      |  2 --
 STM32CubeIDE/Release/sources.mk    |  2 --
 STS/Core/Src/yunhorn_sts_process.c | 18 ++++++++++--------
 6 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h
index 4941614..f10502a 100644
--- a/Core/Inc/sys_conf.h
+++ b/Core/Inc/sys_conf.h
@@ -47,12 +47,12 @@ extern "C" {
 /**
   * @brief  Verbose level for all trace logs
   */
-#define VERBOSE_LEVEL                        VLEVEL_OFF
+#define VERBOSE_LEVEL                        VLEVEL_M
 
 /**
   * @brief Enable trace logs
   */
-#define APP_LOG_ENABLED                      0
+#define APP_LOG_ENABLED                      1
 
 /**
   * @brief Activate monitoring (probes) of some internal RF signals for debug purpose
@@ -75,13 +75,13 @@ extern "C" {
   * @brief Enable/Disable MCU Debugger pins (dbg serial wires)
   * @note  by HW serial wires are ON by default, need to put them OFF to save power
   */
-#define DEBUGGER_ENABLED                     0
+#define DEBUGGER_ENABLED                     1
 
 /**
   * @brief Disable Low Power mode
   * @note  0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only
   */
-#define LOW_POWER_DISABLE                    0
+#define LOW_POWER_DISABLE                    1
 
 /* USER CODE BEGIN EC */
 
diff --git a/Core/Src/main.c b/Core/Src/main.c
index a24ded7..203cc78 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -165,7 +165,7 @@ void SystemClock_Config(void)
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
-  //RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
+  RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
 
   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
   {
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 9f3c5fb..d5a36cd 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -1446,7 +1446,7 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t newperiodicity)
 	  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
-  APP_LOG(TS_OFF, VLEVEL_H,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
 }
 
@@ -1479,6 +1479,6 @@ void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity)
 	  UTIL_TIMER_Start(&TxTimer);
 
   /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */
-  APP_LOG(TS_OFF, VLEVEL_H,"* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_M,"\n* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
   /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
 }
diff --git a/STM32CubeIDE/Release/makefile b/STM32CubeIDE/Release/makefile
index 7427775..2173897 100644
--- a/STM32CubeIDE/Release/makefile
+++ b/STM32CubeIDE/Release/makefile
@@ -15,8 +15,6 @@ RM := rm -rf
 -include Drivers/STM32WLxx_HAL_Driver/subdir.mk
 -include Drivers/CMSIS/subdir.mk
 -include Drivers/BSP/STM32WLxx_Nucleo/subdir.mk
--include Drivers/BSP/Components/subdir.mk
--include Drivers/BSP/53L8A1/subdir.mk
 -include Application/User/Startup/subdir.mk
 -include Application/User/STS/TOF/vl53l0x/subdir.mk
 -include Application/User/STS/TOF/Target/subdir.mk
diff --git a/STM32CubeIDE/Release/sources.mk b/STM32CubeIDE/Release/sources.mk
index f021f94..a6f330f 100644
--- a/STM32CubeIDE/Release/sources.mk
+++ b/STM32CubeIDE/Release/sources.mk
@@ -30,8 +30,6 @@ Application/User/STS/TOF/App \
 Application/User/STS/TOF/Target \
 Application/User/STS/TOF/vl53l0x \
 Application/User/Startup \
-Drivers/BSP/53L8A1 \
-Drivers/BSP/Components \
 Drivers/BSP/STM32WLxx_Nucleo \
 Drivers/CMSIS \
 Drivers/STM32WLxx_HAL_Driver \
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index a05e377..4caa80a 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -1198,7 +1198,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
 					STS_TxPeriod_sec = periodicity_length;
 
 					TxPeriodicity = periodicity_length*1000;
-					APP_LOG(TS_OFF,VLEVEL_M, "\nTx Periodicty changed to %u", TxPeriodicity);
+					APP_LOG(TS_OFF,VLEVEL_M, "\nSTS Tx Periodicty changed to %u sec\n\r", STS_TxPeriod_sec);
 #ifdef	STS_R4
 					OnYunhornSTSTxPeriodicityChanged(STS_TxPeriod_sec*1000);
 #endif
@@ -1555,7 +1555,7 @@ void STS_REBOOT_CONFIG_Init(void)
 		}
 
 	}
-  	//STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
+  	STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
 	OnRestoreSTSCFGContextProcess();
 
   /* USER CODE END OnRestoreContextRequest_Last */
@@ -1573,7 +1573,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	}
 	periodicity = (periodicity > 10)? periodicity : 10;		// in seconds unit
 
-	APP_LOG(TS_OFF, VLEVEL_H, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
+	APP_LOG(TS_OFF, VLEVEL_M, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
 
 	TxPeriodicity= periodicity*1000;  // to ms
 	STS_TxPeriod_sec = periodicity;
@@ -1586,13 +1586,14 @@ void OnRestoreSTSCFGContextProcess(void)
 	} else if ((char) sts_cfg_nvm.s_unit =='S') {
 		sampling_heartbeat_periodicity *= 1;
 	}
-	STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity;
-	APP_LOG(TS_OFF, VLEVEL_H, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
+
+	STS_HeartBeatTimerPeriod_sec = MAX(sampling_heartbeat_periodicity,5*periodicity);
+	APP_LOG(TS_OFF, VLEVEL_M, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
 
 	if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
 	{															// ensure it's not in production yet
-		//OnTxPeriodicityChanged(APP_TX_DUTYCYCLE);				// in msec unit
-		//OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); TODO XXXX
+		OnYunhornSTSTxPeriodicityChanged(APP_TX_DUTYCYCLE);				// in msec unit
+		OnYunhornSTSHeartBeatPeriodicityChanged(APP_TX_DUTYCYCLE*5); //TODO XXXX
 		//OnTxPeriodicityChanged(10000);				// APP_TX_DUTYCYCLE in msec unit
 		//TxPeriodicity = APP_TX_DUTYCYCLE;
 
@@ -1611,7 +1612,8 @@ void OnRestoreSTSCFGContextProcess(void)
 #endif
 
 #if	defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)||defined(YUNHORN_STS_R4_ENABLED)
-	OnYunhornSTSHeartBeatPeriodicityChanged(sampling_heartbeat_periodicity*1000);
+	//OnYunhornSTSHeartBeatPeriodicityChanged(sampling_heartbeat_periodicity*1000);
+	OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000);
 #endif
 	}
 

From 49c056d6413e17eba424711f107455137767660c Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Thu, 24 Oct 2024 14:02:53 +0800
Subject: [PATCH 6/7] stable R4-AAA

---
 Core/Inc/sys_conf.h                |  8 +--
 Core/Src/dma.c                     | 19 +++++-
 Core/Src/i2c.c                     |  4 +-
 Core/Src/stm32wlxx_it.c            | 83 ++++++++++++++++++++++---
 Core/Src/usart.c                   | 28 ++++++++-
 Core/Src/usart_if.c                |  2 +-
 LoRaWAN/App/lora_app.c             | 11 ++--
 STS/Core/Src/yunhorn_sts_process.c | 98 +++++++++++++++++-------------
 8 files changed, 189 insertions(+), 64 deletions(-)

diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h
index f10502a..4941614 100644
--- a/Core/Inc/sys_conf.h
+++ b/Core/Inc/sys_conf.h
@@ -47,12 +47,12 @@ extern "C" {
 /**
   * @brief  Verbose level for all trace logs
   */
-#define VERBOSE_LEVEL                        VLEVEL_M
+#define VERBOSE_LEVEL                        VLEVEL_OFF
 
 /**
   * @brief Enable trace logs
   */
-#define APP_LOG_ENABLED                      1
+#define APP_LOG_ENABLED                      0
 
 /**
   * @brief Activate monitoring (probes) of some internal RF signals for debug purpose
@@ -75,13 +75,13 @@ extern "C" {
   * @brief Enable/Disable MCU Debugger pins (dbg serial wires)
   * @note  by HW serial wires are ON by default, need to put them OFF to save power
   */
-#define DEBUGGER_ENABLED                     1
+#define DEBUGGER_ENABLED                     0
 
 /**
   * @brief Disable Low Power mode
   * @note  0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only
   */
-#define LOW_POWER_DISABLE                    1
+#define LOW_POWER_DISABLE                    0
 
 /* USER CODE BEGIN EC */
 
diff --git a/Core/Src/dma.c b/Core/Src/dma.c
index d048a4e..7b1446b 100644
--- a/Core/Src/dma.c
+++ b/Core/Src/dma.c
@@ -58,9 +58,24 @@ void MX_DMA_Init(void)
 #endif
 
   /* DMA1_Channel5_IRQn interrupt configuration */
-  HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 2, 0);
-  HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
+  // HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 2, 0);
+  // HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
 
+  // I2C2
+   /* DMA1_Channel4_IRQn interrupt configuration */
+   HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
+   HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
+   /* DMA1_Channel5_IRQn interrupt configuration */
+   HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
+   HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
+
+   // USART2
+   /* DMA1_Channel6_IRQn interrupt configuration */
+   HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
+   HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
+   /* DMA1_Channel7_IRQn interrupt configuration */
+   //HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
+   //HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
 }
 
 /* USER CODE BEGIN 2 */
diff --git a/Core/Src/i2c.c b/Core/Src/i2c.c
index 311e22f..4f60034 100644
--- a/Core/Src/i2c.c
+++ b/Core/Src/i2c.c
@@ -112,7 +112,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
 
     /* I2C2 DMA Init */
     /* I2C2_RX Init */
-    hdma_i2c2_rx.Instance = DMA1_Channel3;
+    hdma_i2c2_rx.Instance = DMA1_Channel4;
     hdma_i2c2_rx.Init.Request = DMA_REQUEST_I2C2_RX;
     hdma_i2c2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
     hdma_i2c2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -134,7 +134,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
     __HAL_LINKDMA(i2cHandle,hdmarx,hdma_i2c2_rx);
 
     /* I2C2_TX Init */
-    hdma_i2c2_tx.Instance = DMA1_Channel4;
+    hdma_i2c2_tx.Instance = DMA1_Channel5;
     hdma_i2c2_tx.Init.Request = DMA_REQUEST_I2C2_TX;
     hdma_i2c2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
     hdma_i2c2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c
index 64715f8..1a5bcec 100644
--- a/Core/Src/stm32wlxx_it.c
+++ b/Core/Src/stm32wlxx_it.c
@@ -58,6 +58,7 @@
 extern RTC_HandleTypeDef hrtc;
 extern SUBGHZ_HandleTypeDef hsubghz;
 extern DMA_HandleTypeDef hdma_usart2_tx;
+extern DMA_HandleTypeDef hdma_usart2_rx;
 extern UART_HandleTypeDef huart2;
 /* USER CODE BEGIN EV */
 //#if	defined(VL53LX)||defined(VL53L0)
@@ -258,7 +259,34 @@ void EXTI3_IRQHandler(void)
   /* USER CODE END EXTI3_IRQn 1 */
 }
 
-/*       I2C2             */
+/**
+  * @brief This function handles EXTI Line 1 Interrupt.
+  */
+void EXTI4_IRQHandler(void)
+{
+  /* USER CODE BEGIN EXTI1_IRQn 0 */
+
+  /* USER CODE END EXTI1_IRQn 0 */
+  //HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN);
+  /* USER CODE BEGIN EXTI1_IRQn 1 */
+
+  /* USER CODE END EXTI1_IRQn 1 */
+}
+
+/*       SPI1             */
+/**
+  * @brief This function handles DMA1 Channel 2 Interrupt.
+  */
+void DMA1_Channel2_IRQHandler(void)
+{
+  /* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
+
+  /* USER CODE END DMA1_Channel2_IRQn 0 */
+  //HAL_DMA_IRQHandler(&hdma_spi1_rx);
+  /* USER CODE BEGIN DMA1_Channel2_IRQn 1 */
+
+  /* USER CODE END DMA1_Channel2_IRQn 1 */
+}
 /**
   * @brief This function handles DMA1 Channel 3 Interrupt.
   */
@@ -267,13 +295,13 @@ void DMA1_Channel3_IRQHandler(void)
   /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
 
   /* USER CODE END DMA1_Channel3_IRQn 0 */
-  HAL_DMA_IRQHandler(&hdma_i2c2_rx);
+  //HAL_DMA_IRQHandler(&hdma_spi1_tx);
   /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */
 
   /* USER CODE END DMA1_Channel3_IRQn 1 */
 }
 
-
+// I2C2
 /**
   * @brief This function handles DMA1 Channel 4 Interrupt.
   */
@@ -282,14 +310,12 @@ void DMA1_Channel4_IRQHandler(void)
   /* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
 
   /* USER CODE END DMA1_Channel4_IRQn 0 */
-  HAL_DMA_IRQHandler(&hdma_i2c2_tx);
+  HAL_DMA_IRQHandler(&hdma_i2c2_rx);
   /* USER CODE BEGIN DMA1_Channel4_IRQn 1 */
 
   /* USER CODE END DMA1_Channel4_IRQn 1 */
 }
 
-
-
 /**
   * @brief This function handles DMA1 Channel 5 Interrupt.
   */
@@ -298,12 +324,41 @@ void DMA1_Channel5_IRQHandler(void)
   /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
 
   /* USER CODE END DMA1_Channel5_IRQn 0 */
-  HAL_DMA_IRQHandler(&hdma_usart2_tx);
+  HAL_DMA_IRQHandler(&hdma_i2c2_tx);
   /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
 
   /* USER CODE END DMA1_Channel5_IRQn 1 */
 }
 
+// USART2
+/**
+  * @brief This function handles DMA1 Channel 6 Interrupt.
+  */
+void DMA1_Channel6_IRQHandler(void)
+{
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
+
+  /* USER CODE END DMA1_Channel6_IRQn 0 */
+  HAL_DMA_IRQHandler(&hdma_usart2_tx);
+  /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
+
+  /* USER CODE END DMA1_Channel6_IRQn 1 */
+}
+
+/**
+  * @brief This function handles DMA1 Channel 7 Interrupt.
+  */
+void DMA1_Channel7_IRQHandler(void)
+{
+  /* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
+
+  /* USER CODE END DMA1_Channel7_IRQn 0 */
+	//HAL_DMA_IRQHandler(&hdma_usart2_rx);
+  /* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
+
+  /* USER CODE END DMA1_Channel7_IRQn 1 */
+}
+
 /**
   * @brief This function handles EXTI Lines [9:5] Interrupt.
   */
@@ -323,6 +378,20 @@ void EXTI9_5_IRQHandler(void)
   /* USER CODE END EXTI9_5_IRQn 1 */
 }
 
+/**
+  * @brief This function handles EXTI Lines [15:10] Interrupt.
+  */
+void EXTI15_10_IRQHandler(void)
+{
+  /* USER CODE BEGIN EXTI15_10_IRQn 0 */
+
+  /* USER CODE END EXTI15_10_IRQn 0 */
+  //HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN);
+  /* USER CODE BEGIN EXTI15_10_IRQn 1 */
+
+  /* USER CODE END EXTI15_10_IRQn 1 */
+}
+
 /**
   * @brief This function handles USART2 Interrupt.
   */
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
index fa22f23..eaaf685 100644
--- a/Core/Src/usart.c
+++ b/Core/Src/usart.c
@@ -26,6 +26,7 @@
 
 UART_HandleTypeDef huart2;
 DMA_HandleTypeDef hdma_usart2_tx;
+DMA_HandleTypeDef hdma_usart2_rx;
 
 /* USART2 init function */
 
@@ -109,7 +110,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
 
     /* USART2 DMA Init */
     /* USART2_TX Init */
-    hdma_usart2_tx.Instance = DMA1_Channel5;
+    hdma_usart2_tx.Instance = DMA1_Channel6;
     hdma_usart2_tx.Init.Request = DMA_REQUEST_USART2_TX;
     hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
     hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -129,6 +130,29 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
     }
 #endif
     __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
+#if 0
+    /* USART2_RX Init */
+     hdma_usart2_rx.Instance = DMA1_Channel7;
+     hdma_usart2_rx.Init.Request = DMA_REQUEST_USART2_RX;
+     hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
+     hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
+     hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
+     hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+     hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
+     hdma_usart2_rx.Init.Mode = DMA_NORMAL;
+     hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
+     if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
+     {
+       Error_Handler();
+     }
+#ifdef STM32WL55xx
+     if (HAL_DMA_ConfigChannelAttributes(&hdma_usart2_rx, DMA_CHANNEL_NPRIV) != HAL_OK)
+     {
+       Error_Handler();
+     }
+#endif
+     __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
+#endif
 
     /* USART2 interrupt Init */
     HAL_NVIC_SetPriority(USART2_IRQn, 2, 0);
@@ -158,7 +182,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
 
     /* USART2 DMA DeInit */
     HAL_DMA_DeInit(uartHandle->hdmatx);
-
+    //HAL_DMA_DeInit(uartHandle->hdmarx);
     /* USART2 interrupt Deinit */
     HAL_NVIC_DisableIRQ(USART2_IRQn);
   /* USER CODE BEGIN USART2_MspDeInit 1 */
diff --git a/Core/Src/usart_if.c b/Core/Src/usart_if.c
index 9f0331e..8ac0e4a 100644
--- a/Core/Src/usart_if.c
+++ b/Core/Src/usart_if.c
@@ -127,7 +127,7 @@ UTIL_ADV_TRACE_Status_t vcom_DeInit(void)
 
   /* ##-3- Disable the NVIC for DMA ########################################### */
   /* USER CODE BEGIN 1 */
-  HAL_NVIC_DisableIRQ(DMA1_Channel5_IRQn);
+  HAL_NVIC_DisableIRQ(DMA1_Channel6_IRQn);
 
   return UTIL_ADV_TRACE_OK;
   /* USER CODE END 1 */
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index d5a36cd..910d173 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -490,6 +490,9 @@ void LoRaWAN_Init(void)
 
   LmHandlerJoin(ActivationType, ForceRejoin);
 
+    UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
+    UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
+
   if (EventType == TX_ON_TIMER)
   {
 
@@ -536,8 +539,8 @@ void LoRaWAN_Init(void)
 #endif
 
   //UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
-  UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
-  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
+//  UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
+//  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE END LoRaWAN_Init_Last */
 }
@@ -1446,7 +1449,7 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t newperiodicity)
 	  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
 
   /* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
-  APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_H,"* STS HeartBeatPeriodicity = %u (sec)\r\n", newperiodicity/1000 );
   /* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
 }
 
@@ -1479,6 +1482,6 @@ void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity)
 	  UTIL_TIMER_Start(&TxTimer);
 
   /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */
-  APP_LOG(TS_OFF, VLEVEL_M,"\n* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
+  APP_LOG(TS_OFF, VLEVEL_H,"\n* STS TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
   /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
 }
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index 4caa80a..544038a 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -54,9 +54,14 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
 		sts_version,
 		sts_hardware_ver,
 		0x05,		//Regular TxPeriodicity interval
-		'M', 		//Uplink data interval unit,  for heart-beat uplink
+		'M', 		//TxPeriodicity Uplink data interval unit
+#if	defined(STS_P2)||defined(L8)||defined(STS_O6T)||defined(STS_T6)
 		0x01,		//Heart-beat interval or Sampling interval
 		'S', 		//Sampling sensor interval unit, for real-time sensing of MEMS
+#else
+		0x3C,		//Heart-beat interval ,  for heart-beat uplink
+		'M', 		//Heart-beat interval unit
+#endif
 		0x04,		// dual mode=4, uni_mode =5
 		0x00,		// sts service mask
 		0x00, 		//sts_ioc_mask
@@ -101,7 +106,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
 					// below 20 bytes for RFAC code
 		{0x0,0x0,0x0,0x0,0x0,   0x0,0x0,0x0,0x0,0x0,    0x0,0x0,0x0,0x0,0x0,   0x0,0x0,0x0,0x0,0x0}
 };
-//volatile uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
+volatile uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
 volatile uint8_t sts_ac_code[20]={0x0};
 volatile uint8_t sts_service_mask=STS_SERVICE_MASK_L0;
 volatile uint8_t sts_work_mode=4;
@@ -1438,50 +1443,56 @@ void OnStoreSTSCFGContextRequest(void)
 {
   /* USER CODE BEGIN OnStoreContextRequest_1 */
 	uint8_t i=0,j=0;
-	uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};  /*  KEEP THIS LOCAL */
+	uint8_t to_store__value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};  /*  KEEP THIS LOCAL */
 	sts_cfg_nvm.length   = STS_NVM_CFG_SIZE;
-	nvm_store_value[i++] = sts_cfg_nvm.mtmcode1;
-	nvm_store_value[i++] = sts_cfg_nvm.mtmcode2;
-	nvm_store_value[i++] = sts_cfg_nvm.version;
-	nvm_store_value[i++] = sts_cfg_nvm.hardware_ver;
-	nvm_store_value[i++] = sts_cfg_nvm.periodicity;
-	nvm_store_value[i++] = sts_cfg_nvm.unit;
-	nvm_store_value[i++] = sts_cfg_nvm.sampling;
-	nvm_store_value[i++] = sts_cfg_nvm.s_unit;
-	nvm_store_value[i++] = sts_cfg_nvm.work_mode;
-	nvm_store_value[i++] = sts_cfg_nvm.sts_service_mask;
-	nvm_store_value[i++] = sts_cfg_nvm.sts_ioc_mask;
-	nvm_store_value[i++] = (uint8_t) STS_CFG_PCFG_SIZE; //sts_cfg_nvm.length;
+	to_store__value[i++] = sts_cfg_nvm.mtmcode1;
+	to_store__value[i++] = sts_cfg_nvm.mtmcode2;
+	to_store__value[i++] = sts_cfg_nvm.version;
+	to_store__value[i++] = sts_cfg_nvm.hardware_ver;
+	to_store__value[i++] = sts_cfg_nvm.periodicity;
+	to_store__value[i++] = sts_cfg_nvm.unit;
+	to_store__value[i++] = sts_cfg_nvm.sampling;
+	to_store__value[i++] = sts_cfg_nvm.s_unit;
+	to_store__value[i++] = sts_cfg_nvm.work_mode;
+	to_store__value[i++] = sts_cfg_nvm.sts_service_mask;
+	to_store__value[i++] = sts_cfg_nvm.sts_ioc_mask;
+	to_store__value[i++] = (uint8_t) STS_CFG_PCFG_SIZE; //sts_cfg_nvm.length;
 
 	for (j = 0; j < STS_CFG_PCFG_SIZE; j++) {
-		nvm_store_value[i++] = (sts_cfg_nvm.p[j]);
+		to_store__value[i++] = (sts_cfg_nvm.p[j]);
 	}
 
-	nvm_store_value[i++] = sts_cfg_nvm.reserve02;
-	nvm_store_value[i++] = sts_cfg_nvm.reserve03;
-	nvm_store_value[i++] = sts_cfg_nvm.sensor_install_height_in_10cm;
-	nvm_store_value[i++] = sts_cfg_nvm.alarm_parameter05;
-	nvm_store_value[i++] = sts_cfg_nvm.alarm_mute_reset_timer_in_10sec;
-	nvm_store_value[i++] = sts_cfg_nvm.alarm_lamp_bar_flashing_color;
-	nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold_in_10min;
+	to_store__value[i++] = sts_cfg_nvm.reserve02;
+	to_store__value[i++] = sts_cfg_nvm.reserve03;
+	to_store__value[i++] = sts_cfg_nvm.sensor_install_height_in_10cm;
+	to_store__value[i++] = sts_cfg_nvm.alarm_parameter05;
+	to_store__value[i++] = sts_cfg_nvm.alarm_mute_reset_timer_in_10sec;
+	to_store__value[i++] = sts_cfg_nvm.alarm_lamp_bar_flashing_color;
+	to_store__value[i++] = sts_cfg_nvm.occupancy_overtime_threshold_in_10min;
 
-	nvm_store_value[i++] = sts_cfg_nvm.motionless_duration_threshold_in_min;
-	nvm_store_value[i++] = sts_cfg_nvm.unconscious_or_motionless_level_threshold;
-	nvm_store_value[i++] = sts_cfg_nvm.fall_detection_acc_threshold;
-	nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
-	nvm_store_value[i++] = sts_cfg_nvm.fall_confirm_threshold_in_10sec;
+	to_store__value[i++] = sts_cfg_nvm.motionless_duration_threshold_in_min;
+	to_store__value[i++] = sts_cfg_nvm.unconscious_or_motionless_level_threshold;
+	to_store__value[i++] = sts_cfg_nvm.fall_detection_acc_threshold;
+	to_store__value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
+	to_store__value[i++] = sts_cfg_nvm.fall_confirm_threshold_in_10sec;
 
-	if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) {
-		for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) {
-			nvm_store_value[i++] = (sts_cfg_nvm.ac[j]);
-		}
+	if ((nvm_store_value[NVM_AC_CODE_START]!= 0x0) && (nvm_store_value[NVM_AC_CODE_START+19]!=0x0))
+	{
+		//APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer good NVM Stored ac_code to NVM_STORE_VALUE\r\n");
+		UTIL_MEM_cpy_8((void*)&to_store__value[NVM_AC_CODE_START], (void*)&nvm_store_value[NVM_AC_CODE_START],YUNHORN_STS_AC_CODE_SIZE);
+	} else if ((sts_ac_code[0]!=0x0) && (sts_ac_code[YUNHORN_STS_AC_CODE_SIZE-1]!=0x0))
+	{
+		//APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer new generated ac_code to NVM_STORE_VALUE\r\n");
+		UTIL_MEM_cpy_8((void*)&to_store__value[NVM_AC_CODE_START], (void*)sts_ac_code,YUNHORN_STS_AC_CODE_SIZE);
+		UTIL_MEM_cpy_8((void*)&nvm_store_value[NVM_AC_CODE_START], (void*)sts_ac_code,YUNHORN_STS_AC_CODE_SIZE);
 	}
+
   /* USER CODE END OnStoreContextRequest_1 */
   /* store nvm in flash */
 
   if (FLASH_IF_Erase(STS_CONFIG_NVM_BASE_ADDRESS, FLASH_PAGE_SIZE) == FLASH_IF_OK)
   {
-	  FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
+	  FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)to_store__value, YUNHORN_STS_MAX_NVM_CFG_SIZE);
   }
 
   /* USER CODE BEGIN OnStoreContextRequest_Last */
@@ -1505,14 +1516,15 @@ void OnRestoreSTSCFGContextRequest(uint8_t *cfg_in_nvm)
 void STS_REBOOT_CONFIG_Init(void)
 {
   /* USER CODE BEGIN OnRestoreContextRequest_1 */
-	uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
+	//uint8_t nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
   /* USER CODE END OnRestoreContextRequest_1 */
-	FLASH_IF_Read(nvm_store_value, STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE);
+	FLASH_IF_Read((void*)nvm_store_value, (void*)STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE);
+	//STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
   /* USER CODE BEGIN OnRestoreContextRequest_Last */
 
   if ((nvm_store_value[NVM_MTM1] != sts_mtmcode1) || (nvm_store_value[NVM_MTM2] != sts_mtmcode2) || (nvm_store_value[NVM_VER] != sts_version))
 	{
-		APP_LOG(TS_OFF, VLEVEL_M, "\r\nInitial Boot with Empty Config, Flash with default config....\r\n");
+		APP_LOG(TS_OFF, VLEVEL_L, "\r\nInitial Boot with Empty Config, Flash with default config....\r\n");
 		OnStoreSTSCFGContextRequest();
 		//UTIL_MEM_set_8((void *)sts_ac_code, 0x00, YUNHORN_STS_AC_CODE_SIZE);
 		HAL_Delay(1000);
@@ -1555,7 +1567,7 @@ void STS_REBOOT_CONFIG_Init(void)
 		}
 
 	}
-  	STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
+  	//STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value);
 	OnRestoreSTSCFGContextProcess();
 
   /* USER CODE END OnRestoreContextRequest_Last */
@@ -1573,7 +1585,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	}
 	periodicity = (periodicity > 10)? periodicity : 10;		// in seconds unit
 
-	APP_LOG(TS_OFF, VLEVEL_M, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
+	APP_LOG(TS_OFF, VLEVEL_H, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
 
 	TxPeriodicity= periodicity*1000;  // to ms
 	STS_TxPeriod_sec = periodicity;
@@ -1588,7 +1600,7 @@ void OnRestoreSTSCFGContextProcess(void)
 	}
 
 	STS_HeartBeatTimerPeriod_sec = MAX(sampling_heartbeat_periodicity,5*periodicity);
-	APP_LOG(TS_OFF, VLEVEL_M, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
+	APP_LOG(TS_OFF, VLEVEL_H, "\n\n sampling or heartbeat periodicity in NVM =%u sec\n",sampling_heartbeat_periodicity);
 
 	if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
 	{															// ensure it's not in production yet
@@ -1645,16 +1657,18 @@ void OnRestoreSTSCFGContextProcess(void)
 
 }
 
-static void STS_Show_STS_CFG_NVM(uint8_t * nvm_store_value)
+static void STS_Show_STS_CFG_NVM(uint8_t * store_value)
 {
-	APP_LOG(TS_OFF, VLEVEL_M, "\n ***   STS_CFG_NVM    ***\n");
+	APP_LOG(TS_OFF, VLEVEL_M, "\n-----------------------------------------------\n");
 	APP_LOG(TS_OFF, VLEVEL_M, "\n00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15\n");
 	for (uint8_t i=0; i<YUNHORN_STS_MAX_NVM_CFG_SIZE; i++)
 	{
 		if (i%16==0) APP_LOG(TS_OFF, VLEVEL_M, "\n");
-		APP_LOG(TS_OFF, VLEVEL_M, "%02X ", nvm_store_value[i]);
+		APP_LOG(TS_OFF, VLEVEL_M, "%02X ", store_value[i]);
 
 	}
+	APP_LOG(TS_OFF, VLEVEL_M, "\n\r");
+	APP_LOG(TS_OFF, VLEVEL_M, "\n###############################################\n\r");
 }
 void STS_SENSOR_Distance_Test_Process(void)
 {

From 30e23a38942e5b0424bd736377a519f366b2b933 Mon Sep 17 00:00:00 2001
From: YunHorn Technology <dp.s@yunhorn.com>
Date: Thu, 24 Oct 2024 14:52:17 +0800
Subject: [PATCH 7/7] add missing subdir.mk

---
 .../User/STS/TOF/App_l1cb/Src/subdir.mk       |  9 ++++
 .../User/STS/TOF/vl53l0x/subdir.mk            |  9 ++++
 .../User/STS/TOF/vl53l1cb/modules/subdir.mk   |  9 ++++
 .../User/STS/TOF/vl53l1cb/porting/subdir.mk   |  9 ++++
 .../User/STS/TOF/vl53l1cb/subdir.mk           |  9 ++++
 .../Release/Drivers/BSP/53L8A1/subdir.mk      | 27 ++++++++++
 .../Release/Drivers/BSP/Components/subdir.mk  | 52 +++++++++++++++++++
 7 files changed, 124 insertions(+)
 create mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/App_l1cb/Src/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/modules/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/porting/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Drivers/BSP/53L8A1/subdir.mk
 create mode 100644 STM32CubeIDE/Release/Drivers/BSP/Components/subdir.mk

diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/App_l1cb/Src/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/App_l1cb/Src/subdir.mk
new file mode 100644
index 0000000..acbe69a
--- /dev/null
+++ b/STM32CubeIDE/Release/Application/User/STS/TOF/App_l1cb/Src/subdir.mk
@@ -0,0 +1,9 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+
+# Each subdirectory must supply rules for building sources it contributes
+
diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk
new file mode 100644
index 0000000..acbe69a
--- /dev/null
+++ b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l0x/subdir.mk
@@ -0,0 +1,9 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+
+# Each subdirectory must supply rules for building sources it contributes
+
diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/modules/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/modules/subdir.mk
new file mode 100644
index 0000000..acbe69a
--- /dev/null
+++ b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/modules/subdir.mk
@@ -0,0 +1,9 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+
+# Each subdirectory must supply rules for building sources it contributes
+
diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/porting/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/porting/subdir.mk
new file mode 100644
index 0000000..acbe69a
--- /dev/null
+++ b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/porting/subdir.mk
@@ -0,0 +1,9 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+
+# Each subdirectory must supply rules for building sources it contributes
+
diff --git a/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/subdir.mk b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/subdir.mk
new file mode 100644
index 0000000..acbe69a
--- /dev/null
+++ b/STM32CubeIDE/Release/Application/User/STS/TOF/vl53l1cb/subdir.mk
@@ -0,0 +1,9 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+
+# Each subdirectory must supply rules for building sources it contributes
+
diff --git a/STM32CubeIDE/Release/Drivers/BSP/53L8A1/subdir.mk b/STM32CubeIDE/Release/Drivers/BSP/53L8A1/subdir.mk
new file mode 100644
index 0000000..6e429c3
--- /dev/null
+++ b/STM32CubeIDE/Release/Drivers/BSP/53L8A1/subdir.mk
@@ -0,0 +1,27 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+C_SRCS += \
+/53l8a1_ranging_sensor.c 
+
+OBJS += \
+./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.o 
+
+C_DEPS += \
+./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.d 
+
+
+# Each subdirectory must supply rules for building sources it contributes
+Drivers/BSP/53L8A1/53l8a1_ranging_sensor.o: /53l8a1_ranging_sensor.c Drivers/BSP/53L8A1/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+
+clean: clean-Drivers-2f-BSP-2f-53L8A1
+
+clean-Drivers-2f-BSP-2f-53L8A1:
+	-$(RM) ./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.cyclo ./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.d ./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.o ./Drivers/BSP/53L8A1/53l8a1_ranging_sensor.su
+
+.PHONY: clean-Drivers-2f-BSP-2f-53L8A1
+
diff --git a/STM32CubeIDE/Release/Drivers/BSP/Components/subdir.mk b/STM32CubeIDE/Release/Drivers/BSP/Components/subdir.mk
new file mode 100644
index 0000000..781778a
--- /dev/null
+++ b/STM32CubeIDE/Release/Drivers/BSP/Components/subdir.mk
@@ -0,0 +1,52 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+# Toolchain: GNU Tools for STM32 (12.3.rel1)
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+C_SRCS += \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/vl53l8cx.c \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_api.c \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_detection_thresholds.c \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_motion_indicator.c \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_xtalk.c \
+D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/porting/wle5cc_platform.c 
+
+OBJS += \
+./Drivers/BSP/Components/vl53l8cx.o \
+./Drivers/BSP/Components/vl53l8cx_api.o \
+./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.o \
+./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.o \
+./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.o \
+./Drivers/BSP/Components/wle5cc_platform.o 
+
+C_DEPS += \
+./Drivers/BSP/Components/vl53l8cx.d \
+./Drivers/BSP/Components/vl53l8cx_api.d \
+./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.d \
+./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.d \
+./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.d \
+./Drivers/BSP/Components/wle5cc_platform.d 
+
+
+# Each subdirectory must supply rules for building sources it contributes
+Drivers/BSP/Components/vl53l8cx.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/vl53l8cx.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+Drivers/BSP/Components/vl53l8cx_api.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_api.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_detection_thresholds.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_motion_indicator.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+Drivers/BSP/Components/vl53l8cx_plugin_xtalk.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/modules/vl53l8cx_plugin_xtalk.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+Drivers/BSP/Components/wle5cc_platform.o: D:/ONEDRIVE/STM32WLV13/Drivers/BSP/Components/vl53l8cx/porting/wle5cc_platform.c Drivers/BSP/Components/subdir.mk
+	arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DSTS_R4 -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
+
+clean: clean-Drivers-2f-BSP-2f-Components
+
+clean-Drivers-2f-BSP-2f-Components:
+	-$(RM) ./Drivers/BSP/Components/vl53l8cx.cyclo ./Drivers/BSP/Components/vl53l8cx.d ./Drivers/BSP/Components/vl53l8cx.o ./Drivers/BSP/Components/vl53l8cx.su ./Drivers/BSP/Components/vl53l8cx_api.cyclo ./Drivers/BSP/Components/vl53l8cx_api.d ./Drivers/BSP/Components/vl53l8cx_api.o ./Drivers/BSP/Components/vl53l8cx_api.su ./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.cyclo ./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.d ./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.o ./Drivers/BSP/Components/vl53l8cx_plugin_detection_thresholds.su ./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.cyclo ./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.d ./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.o ./Drivers/BSP/Components/vl53l8cx_plugin_motion_indicator.su ./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.cyclo ./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.d ./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.o ./Drivers/BSP/Components/vl53l8cx_plugin_xtalk.su ./Drivers/BSP/Components/wle5cc_platform.cyclo ./Drivers/BSP/Components/wle5cc_platform.d ./Drivers/BSP/Components/wle5cc_platform.o ./Drivers/BSP/Components/wle5cc_platform.su
+
+.PHONY: clean-Drivers-2f-BSP-2f-Components
+