From 95b5be0fb8ab6cbb3b9f8d6fbe05a3712bd0e2a1 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Fri, 20 Sep 2024 14:23:29 +0800 Subject: [PATCH] almost all CMD FINISHED --- LoRaWAN/App/lora_app.c | 4 +-- STS/Core/Inc/yunhorn_sts_sensors.h | 2 +- STS/Core/Src/yunhorn_sts_process.c | 41 ++++++++++++++++++++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index ca1243f..d16fb73 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -280,7 +280,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context); * @brief Yunhorn STS Heart Beat Periodicity Chagne function * @param duration of periodicty in ms (1/1000 sec) */ -static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity); +//static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity); @@ -1230,7 +1230,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context) STS_SENSOR_Upload_Message(appHeartBeatDataPort, appHeartBeatBufferSize, (uint8_t*)appHeartBeatDataBuffer); #endif - if (rfac_timer <100) + if (rfac_timer <20) { STS_YunhornSTSEventRFAC_Process(); rfac_timer ++; diff --git a/STS/Core/Inc/yunhorn_sts_sensors.h b/STS/Core/Inc/yunhorn_sts_sensors.h index 8238cf3..06e5b6b 100644 --- a/STS/Core/Inc/yunhorn_sts_sensors.h +++ b/STS/Core/Inc/yunhorn_sts_sensors.h @@ -243,7 +243,7 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8 void STS_SENSOR_MEMS_Get_ID(uint16_t *devID); - +void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity); void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_size); void STS_SENSOR_Function_Test_Process(void); diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index bd60a52..13eea4e 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -98,7 +98,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; @@ -110,6 +110,9 @@ static uint8_t outbuf[128]={0x0}; extern volatile hmac_result_t hmac_result; extern uint16_t sensor_id; extern UTIL_TIMER_Time_t TxPeriodicity; +extern UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer; +static void STS_Show_STS_CFG_NVM(uint8_t * nvm_store_value); + #if 0 volatile uint8_t sts_reed_hall_result, last_sts_reed_hall_result,sts_reed_hall_changed_flag; volatile uint32_t event_start_time, event_stop_time; @@ -167,7 +170,7 @@ extern volatile float sts_presence_rss_distance; /* External variables ---------------------------------------------------------*/ /* USER CODE BEGIN EV */ -extern UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer; +//extern UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer; /* USER CODE END EV */ /* Private typedef -----------------------------------------------------------*/ @@ -219,11 +222,13 @@ void STS_YunhornAuthenticationCode_Process(void) /* initiated by Heart-beat timer */ void STS_YunhornSTSEventRFAC_Process(void) { - - if ((rfac_timer >= STS_BURN_IN_RFAC) && (rfac_timer < (STS_BURN_IN_RFAC +3))) + if ((sts_cfg_nvm.ac[0]==0x0)&&(sts_cfg_nvm.ac[19]==0x0)) { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n -RFAC Process\r\n"); - STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, 4, (uint8_t*)"RFAC"); + if ((rfac_timer >= STS_BURN_IN_RFAC) && (rfac_timer < (STS_BURN_IN_RFAC +3))) + { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n -RFAC Process\r\n"); + STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, 4, (uint8_t*)"RFAC"); + } } #if 0 if ((rfac_timer > (STS_BURN_IN_RFAC + 3))) @@ -1145,7 +1150,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s STS_HeartBeatTimerPeriod_sec = heart_beat_or_sampling_periodicity_length; #ifdef STS_P2 - //OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000); + OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec*1000); #endif #ifdef YUNHORN_STS_E0_ENABLED @@ -1454,7 +1459,7 @@ void STS_REBOOT_CONFIG_Init(void) } } - + STS_Show_STS_CFG_NVM((uint8_t*)nvm_store_value); OnRestoreSTSCFGContextProcess(); /* USER CODE END OnRestoreContextRequest_Last */ @@ -1472,7 +1477,7 @@ void OnRestoreSTSCFGContextProcess(void) } periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit - //TxPeriodicity= periodicity*1000; // to ms + TxPeriodicity= periodicity*1000; // to ms uint32_t sampling_heartbeat_periodicity = (sts_cfg_nvm.sampling); //Heart-beat or Sampling interval if ((char)sts_cfg_nvm.s_unit =='M') { @@ -1495,8 +1500,11 @@ void OnRestoreSTSCFGContextProcess(void) //OnTxPeriodicityChanged(TxPeriodicity); // in msec unit //OnTxPeriodicityChanged(periodicity*1000); //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; + //sampling_heartbeat_periodicity = (sampling_heartbeat_periodicity > 0)? sampling_heartbeat_periodicity : 1; // in seconds unit + //sampling_heartbeat_periodicity = sampling_heartbeat_periodicity*1000; +#ifdef STS_P2 + STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity; +#endif #if defined(YUNHORN_STS_O6_ENABLED) ||defined(YUNHORN_STS_O5_ENABLED) OnYunhornSTSSamplingPeriodicityChanged(sampling_heartbeat_periodicity); // in m-sec unit #endif @@ -1534,6 +1542,17 @@ void OnRestoreSTSCFGContextProcess(void) } +static void STS_Show_STS_CFG_NVM(uint8_t * nvm_store_value) +{ + APP_LOG(TS_OFF, VLEVEL_M, "\n *** STS_CFG_NVM ***\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