diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h
index 241072d..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,7 +75,7 @@ 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
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 6db5514..3809503 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -29,6 +29,7 @@
#include "usart.h"
#include "sys_app.h"
#include "tim.h"
+#include "yunhorn_sts_sensors.h"
#ifdef STS_P2
#include "app_tof.h"
#include "app_tof_peoplecount.h"
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index dc9228e..1d2a9bb 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -58,14 +58,16 @@ volatile uint8_t heart_beat_timer =0;
extern volatile uint8_t sensor_data_ready;
extern uint8_t sts_door_jam_profile;
extern uint8_t sts_color_occupy_vacant;
-
+extern volatile uint16_t sts_sensor_install_height;
#ifdef STS_T6
volatile uint8_t PIRValue =0, prev_sts_pir_state=0, sts_pir_state_changed=0;
extern volatile uint8_t sts_tof_presence_state;
uint32_t lowIn=0;
volatile bool lockLow = true, takeLowTime;
#endif
+
static uint32_t sts_warm_up_count = 0;
+
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
extern volatile uint32_t rfac_timer;
extern volatile uint32_t STS_TOFScanPeriod_msec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
@@ -85,7 +87,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
sts_version,
sts_hardware_ver,
0x0A, //Regular TxPeriodicity interval
- 'M', //Uplink data interval unit, for heart-beat uplink
+ 'S', //Uplink data interval unit, for heart-beat uplink
#if defined(STS_P2)||defined(L8)||defined(STS_O6T)||defined(STS_T6)
0x1E, //Heart-beat interval or Sampling interval
'M', //Sampling sensor interval unit, for real-time sensing of MEMS
@@ -704,6 +706,7 @@ void STS_Sensor_Init(void)
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
//UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
+ ppc_cfg_parameter_update();
// UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
@@ -724,7 +727,6 @@ void STS_Sensor_Init(void)
void STS_Sensor_Prepare(void)
{
-
//STS_TOF_VL53LX_PresenceDetection_Process_Init();
UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
@@ -1371,7 +1373,7 @@ static void OnTxTimerEvent(void *context)
#elif (defined(STS_P2)||defined(STS_T6))
UTIL_TIMER_Stop(&YunhornSTSWakeUpScanTimer);
- APP_LOG(TS_OFF, VLEVEL_M, "\r\nTxTimer Event \r\n");
+ APP_LOG(TS_OFF, VLEVEL_M, "\r\n### Warm-up TxTimer Event : %d ###\r\n", sts_warm_up_count);
#endif
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
@@ -1847,13 +1849,13 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
}
/* Update timer YunhornSTSHeartBeatTimer */
-
+ APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (msec)\r\n", periodicity );
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
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", periodicity/1000 );
+ APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (msec)\r\n", periodicity );
/* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
}
@@ -2097,9 +2099,9 @@ void OnRestoreSTSCFGContextProcess(void)
} else if ((char) sts_cfg_nvm.unit =='S') {
periodicity *= 1;
}
- periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit
+ //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_M, "\n\n Tx periodicity in NVM =%u sec\n",periodicity);
TxPeriodicity= periodicity*1000; // to ms
@@ -2115,7 +2117,7 @@ void OnRestoreSTSCFGContextProcess(void)
}
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);
@@ -2143,8 +2145,9 @@ void OnRestoreSTSCFGContextProcess(void)
#endif
#if defined(STS_T6)
- STS_HeartBeatTimerPeriod_sec = periodicity;
- OnYunhornSTSHeartBeatPeriodicityChanged(STS_HeartBeatTimerPeriod_sec);
+ //STS_HeartBeatTimerPeriod_sec = periodicity;
+ OnYunhornSTSHeartBeatPeriodicityChanged(1000*STS_HeartBeatTimerPeriod_sec);
+
#endif
#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)||defined(STS_O5)||defined(STS_M1)
@@ -2155,9 +2158,12 @@ void OnRestoreSTSCFGContextProcess(void)
sts_work_mode = sts_cfg_nvm.work_mode;
sts_service_mask = sts_cfg_nvm.sts_service_mask;
sts_door_jam_profile = sts_cfg_nvm.sts_door_jam_profile;
+ sts_sensor_install_height = sts_cfg_nvm.sensor_install_height_in_10cm*100;
sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant;
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Color Occupy =%02x, VACANT =%02x \r\n",((sts_color_occupy_vacant>>4)&0x0f), sts_color_occupy_vacant&0x0f );
+ ppc_cfg_parameter_update();
+
#ifdef YUNHORN_STS_O6_ENABLED
sts_lamp_bar_color = STS_COLOR_DEFAULT_VACANT;
sts_fall_detection_acc_threshold = (uint8_t)sts_cfg_nvm.fall_detection_acc_threshold*10;
diff --git a/STM32CubeIDE/.settings/language.settings.xml b/STM32CubeIDE/.settings/language.settings.xml
index 6f79038..d7e3a93 100644
--- a/STM32CubeIDE/.settings/language.settings.xml
+++ b/STM32CubeIDE/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf
index 593b039..ba34634 100644
Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ
diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c
index ea654c6..43990ef 100644
--- a/STS/Core/Src/yunhorn_sts_process.c
+++ b/STS/Core/Src/yunhorn_sts_process.c
@@ -70,7 +70,7 @@ volatile uint8_t sts_work_mode= STS_TOF_DISTANCE_MODE; //4;
volatile uint32_t rfac_timer=0;
volatile uint16_t sts_sensor_install_height=3000;
volatile uint8_t sensor_data_ready=0;
-
+extern volatile int sts_tof_init_status;
#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)||defined(STS_O5)||defined(STS_M1)
volatile uint32_t STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=3600;
#elif defined(STS_L8)||defined(STS_O6T)||defined(STS_T6)
@@ -1059,6 +1059,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
ppc_cfg_parameter_update();
sts_cfg_nvm.sensor_install_height_in_10cm = sts_sensor_install_height/100; //in 10 cm, say 4500mm=450cm=45 dm
sts_cfg_nvm.sts_door_jam_profile = sts_door_jam_profile;
+ sts_tof_init_status = -1;
APP_LOG(TS_OFF, VLEVEL_M, "\n STS CFG NVM -> SENSOR INSTALL HEIGHT STORED = %d dm(10cm)\n", sts_cfg_nvm.sensor_install_height_in_10cm);
OnStoreSTSCFGContextRequest();
@@ -1078,7 +1079,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
break;
case 'D': /* "YZD": Distance/Install height Measure */
- uint16_t range_distance = STS_SENSOR_Distance_Test_Process();
+ uint16_t range_distance_status = STS_SENSOR_Distance_Test_Process();
i = 0;
outbuf[i++] = (uint8_t)'D';
outbuf[i++] = (uint8_t)sts_mtmcode1;
@@ -1087,7 +1088,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
outbuf[i++] = (uint8_t)sts_hardware_ver;
outbuf[i++] = (uint8_t)(99*((GetBatteryLevel()/254)&0xff));
- if (range_distance == 0 )
+ if (range_distance_status == 0 )
{
sts_cfg_nvm.sensor_install_height_in_10cm = sts_sensor_install_height/100; //in 10 cm, say 4500mm=450cm=45 dm
@@ -1106,6 +1107,7 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
#endif
#if defined(STS_T6)
+ sts_tof_init_status = -1; // to enfore config update/init
ppc_cfg_parameter_update();
#endif
@@ -1597,7 +1599,7 @@ void ppc_cfg_parameter_update(void)
ppc_cfg[DOOR_JAM_NOW].front_zone_center = FRONT_ZONE_CENTER;
ppc_cfg[DOOR_JAM_NOW].back_zone_center = BACK_ZONE_CENTER;
sts_door_jam_profile = DOOR_JAM_NOW;
-
+ sts_tof_init_status=-1;
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Door Jam profile updated to %d with Max/Min/Threshold=%d:%d:%d \r\n",
sts_door_jam_profile, ppc_cfg[DOOR_JAM_NOW].max_distance,ppc_cfg[DOOR_JAM_NOW].min_distance, ppc_cfg[DOOR_JAM_NOW].dist_threshold);
}
diff --git a/STS/TOF/App/app_tof_peoplecount.c b/STS/TOF/App/app_tof_peoplecount.c
index aae097d..4a01aba 100644
--- a/STS/TOF/App/app_tof_peoplecount.c
+++ b/STS/TOF/App/app_tof_peoplecount.c
@@ -690,7 +690,7 @@ void STS_TOF_VL53LX_PresenceDetection_Process_Start(void)
LED_GREEN_ON;
sts_lamp_bar_color = (sts_cfg_nvm.color_occupy_vacant)&0x0f; //STS_COLOR_DEFAULT_VACANT; //(sts_cfg_nvm.color_occupy_vacant)&0x0f; //STS_GREEN;
}
- APP_LOG(TS_OFF, VLEVEL_M, "\r\n Lamp Bar Color=%2d \r\n", sts_lamp_bar_color);
+ APP_LOG(TS_OFF, VLEVEL_H, "\r\n Lamp Bar Color=%2d \r\n", sts_lamp_bar_color);
sts_people_count_sensor_data.Count_Valid = (status ==0)? 1:0;
//APP_LOG(TS_OFF, VLEVEL_M,"############### SUB-PROCESS running .... \r\n");
}
@@ -758,7 +758,7 @@ int sts_tof_vl53lx_presence_detection_init(void)
/* Initialize and configure the device according to people counting need */
status = VL53L1X_SensorInit(dev);
-
+ ppc_cfg_parameter_update();
sts_distance_mode = (sts_door_jam_profile ==0)?DISTANCE_MODE_SHORT:DISTANCE_MODE_LONG;
APP_LOG(TS_OFF, VLEVEL_M, "\r\nDistance[ Max=%d, Min=%d Threshold=%d ] [Timing=%d ] [ Mode=%d ]\r\n",
ppc_cfg[sts_door_jam_profile].max_distance,
@@ -1079,7 +1079,7 @@ int sts_tof_vl53lx_range_distance(uint16_t *range_distance)
if (status != 0) {
APP_LOG(TS_OFF, VLEVEL_L,"Error in operating the device\n");
return (-1);
- } else if (Distance != 0 )
+ } else //if (Distance != 0 )
{
APP_LOG(TS_OFF, VLEVEL_M,"\r\nVL53L1X RANGE DISTANCE =%d \r\n", Distance);
*range_distance = Distance;