workable, startup with 5 warm up messages. good.

This commit is contained in:
Yunhorn 2025-05-16 11:04:50 +08:00
parent cda4490d24
commit df1c10b891
23 changed files with 46 additions and 39 deletions

View File

@ -47,7 +47,7 @@ extern "C" {
/** /**
* @brief Verbose level for all trace logs * @brief Verbose level for all trace logs
*/ */
#define VERBOSE_LEVEL VLEVEL_L #define VERBOSE_LEVEL VLEVEL_M
/** /**
* @brief Enable trace logs * @brief Enable trace logs

View File

@ -83,7 +83,7 @@ uint32_t check_time=0;
volatile bool motionDetected =false; volatile bool motionDetected =false;
uint32_t lastMotionTime =0; uint32_t lastMotionTime =0;
const uint32_t ledOnDuration = 10000; const uint32_t ledOnDuration = 10000;
static uint32_t sts_warm_up_count = 0;
/* USER CODE END EV */ /* USER CODE END EV */
@ -541,8 +541,8 @@ void LoRaWAN_Init(void)
LmHandlerJoin(ActivationType, ForceRejoin); LmHandlerJoin(ActivationType, ForceRejoin);
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL); //UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); //UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
if (EventType == TX_ON_TIMER) if (EventType == TX_ON_TIMER)
{ {
@ -728,7 +728,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
if (sts_pir_read != last_sts_pir_read) if (sts_pir_read != last_sts_pir_read)
{ {
last_sts_pir_read = sts_hall3_read; last_sts_pir_read = sts_hall3_read;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); //UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
} }
break; break;
@ -1312,7 +1312,8 @@ static void OnTxTimerEvent(void *context)
/* USER CODE BEGIN OnTxTimerEvent_1 */ /* USER CODE BEGIN OnTxTimerEvent_1 */
/* USER CODE END OnTxTimerEvent_1 */ /* USER CODE END OnTxTimerEvent_1 */
if (sts_warm_up_count < 5)
{
#ifdef STS_R4 #ifdef STS_R4
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0);
#elif defined(STS_M1) #elif defined(STS_M1)
@ -1325,9 +1326,10 @@ static void OnTxTimerEvent(void *context)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
/*Wait for next tx slot*/ /*Wait for next tx slot*/
sts_warm_up_count++;
UTIL_TIMER_Start(&TxTimer); UTIL_TIMER_Start(&TxTimer);
/* USER CODE BEGIN OnTxTimerEvent_2 */ /* USER CODE BEGIN OnTxTimerEvent_2 */
}
/* USER CODE END OnTxTimerEvent_2 */ /* USER CODE END OnTxTimerEvent_2 */
} }

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1759988577722177836" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1364498518074211444" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1759988577722177836" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1364498518074211444" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
-include ../makefile.init -include ../makefile.init

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
USER_OBJS := USER_OBJS :=

View File

@ -1,6 +1,6 @@
################################################################################ ################################################################################
# Automatically-generated file. Do not edit! # Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1) # Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################ ################################################################################
ELF_SRCS := ELF_SRCS :=

View File

@ -1664,7 +1664,7 @@ void OnStoreSTSCFGContextRequest(void)
{ {
/* USER CODE BEGIN OnStoreContextRequest_1 */ /* USER CODE BEGIN OnStoreContextRequest_1 */
uint8_t i=0,j=0; uint8_t i=0,j=0;
uint8_t to_store__value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0}; /* KEEP THIS LOCAL */ uint8_t to_store__value[2*YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0}; /* KEEP THIS LOCAL */
sts_cfg_nvm.length = STS_NVM_CFG_SIZE; sts_cfg_nvm.length = STS_NVM_CFG_SIZE;
to_store__value[i++] = sts_cfg_nvm.mtmcode1; to_store__value[i++] = sts_cfg_nvm.mtmcode1;
to_store__value[i++] = sts_cfg_nvm.mtmcode2; to_store__value[i++] = sts_cfg_nvm.mtmcode2;
@ -1722,10 +1722,11 @@ void OnStoreSTSCFGContextRequest(void)
/* USER CODE END OnStoreContextRequest_1 */ /* USER CODE END OnStoreContextRequest_1 */
/* store nvm in flash */ /* store nvm in flash */
UTIL_MEM_cpy_8((void*)&to_store__value[YUNHORN_STS_MAX_NVM_CFG_SIZE], (void*)to_store__value,YUNHORN_STS_MAX_NVM_CFG_SIZE);
if (FLASH_IF_Erase(STS_CONFIG_NVM_BASE_ADDRESS, FLASH_PAGE_SIZE) == FLASH_IF_OK) 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 *)to_store__value, YUNHORN_STS_MAX_NVM_CFG_SIZE); FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)to_store__value, 2*YUNHORN_STS_MAX_NVM_CFG_SIZE);
} }
/* USER CODE BEGIN OnStoreContextRequest_Last */ /* USER CODE BEGIN OnStoreContextRequest_Last */
@ -1828,11 +1829,10 @@ void OnRestoreSTSCFGContextProcess(void)
} else if ((char) sts_cfg_nvm.unit =='S') { } else if ((char) sts_cfg_nvm.unit =='S') {
periodicity *= 1; periodicity *= 1;
} }
periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit //periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit
//periodicity *= 1000; // to ms
APP_LOG(TS_OFF, VLEVEL_M, "\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
TxPeriodicity= periodicity*1000; // to ms
uint32_t sampling_heartbeat_periodicity = (sts_cfg_nvm.sampling); //Heart-beat or Sampling interval uint32_t sampling_heartbeat_periodicity = (sts_cfg_nvm.sampling); //Heart-beat or Sampling interval
if ((char)sts_cfg_nvm.s_unit =='M') { if ((char)sts_cfg_nvm.s_unit =='M') {
@ -1843,23 +1843,28 @@ void OnRestoreSTSCFGContextProcess(void)
sampling_heartbeat_periodicity *= 1; sampling_heartbeat_periodicity *= 1;
} }
#if defined(STS_L8)
STS_HeartBeatTimerPeriod_sec = periodicity;
APP_LOG(TS_OFF, VLEVEL_M, "\n\n Heartbeat periodicity in NVM =%u sec\n",STS_HeartBeatTimerPeriod_sec);
OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000); //TODO XXXX
#else
STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity; 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);
OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000); //TODO XXXX
#endif
if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0)) if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
{ // ensure it's not in production yet { // ensure it's not in production yet
OnYunhornSTSTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit OnYunhornSTSTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit
OnYunhornSTSHeartBeatPeriodicityChanged(APP_TX_DUTYCYCLE*5); //TODO XXXX //OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000); //TODO XXXX
//OnTxPeriodicityChanged(10000); // APP_TX_DUTYCYCLE in msec unit //OnTxPeriodicityChanged(10000); // APP_TX_DUTYCYCLE in msec unit
TxPeriodicity = APP_TX_DUTYCYCLE; TxPeriodicity = APP_TX_DUTYCYCLE;
} else } else
{ {
OnYunhornSTSTxPeriodicityChanged(TxPeriodicity); // in msec unit //OnYunhornSTSHeartBeatPeriodicityChanged(APP_TX_DUTYCYCLE*5); //TODO XXXX
//OnYunhornSTSTxPeriodicityChanged(TxPeriodicity); // in msec unit
//OnTxPeriodicityChanged(TxPeriodicity); //OnTxPeriodicityChanged(TxPeriodicity);
//Heart-beat or Sampling interval //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 > 0)? sampling_heartbeat_periodicity : 1; // in seconds unit