Compare commits

...

13 Commits

11 changed files with 25 additions and 13 deletions

View File

@ -50,12 +50,12 @@ extern "C" {
* #define VLEVEL_M 2 functional traces
* #define VLEVEL_H 3 all traces
*/
#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
@ -78,7 +78,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 1
#define DEBUGGER_ENABLED 0
/**
* @brief Disable Low Power mode

View File

@ -127,6 +127,7 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
{
HAL_Delay(10); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
STS_WS2812B_Set_RGB(color_rgb[color][0]*lum_level,color_rgb[color][1]*lum_level, color_rgb[color][2]*lum_level, i);
STS_WS2812B_Refresh();
}
@ -198,6 +199,7 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
STS_Lamp_Bar_Set_RGB_Color(lum, lum, lum);
break;
}
}
}

View File

@ -58,6 +58,7 @@
// 2024-08-15 volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 2, 63, 2, 10, 0.5, 1.3, 0.2};
//volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.5, 1.3, 0.2};
volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.4, 1.2, 0.2};
//volatile distance_measure_cfg_t distance_cfg={1.5, 3.3, 2, 63, 4, 10, 0.8182f, 0.4, 0.2};
extern volatile uint16_t sts_distance_rss_distance, sts_sensor_install_height;
@ -115,6 +116,7 @@ int sts_distance_rss_detector_distance(void)
bool success = true;
const int iterations = 5; //5;
uint16_t number_of_peaks = 1; // FSB first significant Bin
acc_detector_distance_result_t result[number_of_peaks];
acc_detector_distance_result_info_t result_info;
float tmp_distance = 0.0f;
@ -139,6 +141,7 @@ int sts_distance_rss_detector_distance(void)
sts_sensor_install_height = (uint16_t)sts_distance_rss_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance =%u mm --- Assume Sensor Install Height = %u mm\r\n", (uint16_t)sts_distance_rss_distance, (uint16_t)sts_sensor_install_height);
bool deactivated = acc_detector_distance_deactivate(distance_handle);
acc_detector_distance_destroy(&distance_handle);

View File

@ -109,7 +109,6 @@ extern volatile uint8_t detected_hs_zone;
extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
volatile uint32_t cnt=0;
volatile uint8_t sts_tof_result_changed_flag = 0;
volatile uint8_t sts_rss_result_changed_flag = 0;
@ -234,6 +233,7 @@ void STS_YunhornSTSEventP1_Process(void)
if (sts_reed_hall_1_result != last_sts_reed_hall_1_result)
{
sts_reed_hall_changed_flag |= 0x01;
}
last_sts_reed_hall_1_result = sts_reed_hall_1_result;
@ -241,6 +241,7 @@ void STS_YunhornSTSEventP1_Process(void)
if (sts_reed_hall_2_result != last_sts_reed_hall_2_result)
{
sts_reed_hall_changed_flag |= 0x02;
}
last_sts_reed_hall_2_result = sts_reed_hall_2_result;

View File

@ -95,7 +95,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
'M', //Uplink data interval for heart-beat uplink
0x03,
'S', //Sampling sensor interval for real-time sensing of MEMS
0x04, // dual mode=4, uni_mode =5
0x03, // dual mode=4, uni_mode =5, RSS mode =3
0x00, // sts service mask
0x00, //sts_ioc_mask
0x20, //32 bytes, below start of p[0] 20 BYTES AND 12 BYTES FALL DOWN CFG
@ -940,6 +940,7 @@ static void SendTxData(void)
{
AppData.Port = (uint8_t)YUNHORN_STS_O7_LORA_APP_DATA_PORT;
} else if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_REEDSWITCH_MODE)||(sts_work_mode == STS_NETWORK_MODE)||(sts_work_mode == STS_WIRED_MODE))
{
AppData.Port = (uint8_t)YUNHORN_STS_O2_LORA_APP_DATA_PORT;
}
@ -955,6 +956,7 @@ static void SendTxData(void)
else if (sts_work_mode == STS_UNI_MODE)
AppData.Port = (uint8_t)YUNHORN_STS_O7_LORA_APP_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
else if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_REEDSWITCH_MODE)||(sts_work_mode == STS_NETWORK_MODE)||(sts_work_mode == STS_WIRED_MODE))
AppData.Port = (uint8_t)YUNHORN_STS_O2_LORA_APP_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
//AppData.Port = (uint8_t)sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1;
@ -977,6 +979,7 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status reed switch
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status reed switch
} else if (sts_work_mode == STS_RSS_MODE)
{
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status reed switch
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //04 Sensor head #3 status RSS motion
@ -2129,10 +2132,10 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
{
//STS_SENSOR_Power_ON((uint8_t)(tlv_buf[CFG_CMD3]-0x30));
PME_ON;
// 2024-07-31
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf,tlv_buf_size);
i = tlv_buf_size;
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
} else {
@ -2346,6 +2349,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
} else if (tlv_buf_size == 7 && tlv_buf[CFG_CMD4]=='F') // Change fall detection
{
invalid_flag = 0; // P 1 1 F A B C
if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0'))
&& ((tlv_buf[CFG_CMD7]<='9') && (tlv_buf[CFG_CMD7]>='0'))) //&& ((tlv_buf[CFG_CMD8]<='9') && (tlv_buf[CFG_CMD8]>='0')))
{
@ -2386,14 +2390,14 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
}else if (tlv_buf_size == 8 && tlv_buf[CFG_CMD4]=='O') // Change occupancy/motionless/ unconscious overtime threshold
{
invalid_flag = 0; // P 1 1 O A B C D
invalid_flag = 0; // P 1 1 O M O U A
if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0'))
&& ((tlv_buf[CFG_CMD7]<='9') && (tlv_buf[CFG_CMD7]>='0'))&& ((tlv_buf[CFG_CMD8]<='9') && (tlv_buf[CFG_CMD8]>='0')))
{
sts_motionless_duration_threshold_in_min = (uint8_t)(tlv_buf[CFG_CMD5] - 0x30); //Motionless duration in min
sts_occupancy_overtime_threshold_in_10min = (uint8_t)(tlv_buf[CFG_CMD6] - 0x30)*10; //Long occupation in min
sts_unconscious_level_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30+1)*128; //motion level threshold less than 1280
sts_alarm_mute_reset_timer_in_10sec = (uint8_t)(tlv_buf[CFG_CMD8] - 0x30)*10; //alarm mute reset timer in 10 sec
sts_motionless_duration_threshold_in_min = (uint8_t)(tlv_buf[CFG_CMD5] - 0x30); //M: Motionless duration in min
sts_occupancy_overtime_threshold_in_10min = (uint8_t)(tlv_buf[CFG_CMD6] - 0x30)*10; //O: Long occupation in min
sts_unconscious_level_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30+1)*128; //U: motion level threshold less than 1280
sts_alarm_mute_reset_timer_in_10sec = (uint8_t)(tlv_buf[CFG_CMD8] - 0x30)*10; //A: alarm mute reset timer in 10 sec
sts_cfg_nvm.motionless_duration_threshold_in_min = (uint8_t)(tlv_buf[CFG_CMD5] - 0x30);
sts_cfg_nvm.occupancy_overtime_threshold_in_10min = (uint8_t)(tlv_buf[CFG_CMD6] - 0x30);
@ -2555,8 +2559,10 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
{
if ((tlv_buf[CFG_CMD4+j] >='0') && (tlv_buf[CFG_CMD4+j]<='9'))
{
//sts_cfg_nvm.p[j] = (uint8_t)((tlv_buf[CFG_CMD4+j] - 0x30)&0xff);
//APP_LOG(TS_OFF,VLEVEL_H,"\r\n tlv_buf %d = %02x cfg->p[%d]=%02x \r\n",j,tlv_buf[CFG_CMD4+j], j, sts_cfg_nvm.p[j]);
} else {
invalid_flag = 1;
}
@ -2577,6 +2583,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
i = tlv_buf_size;
APP_LOG(TS_OFF, VLEVEL_M, "###### RSS Simple CFG=%s\r\n",(char*)outbuf);
// Step 2: Save valid config to NVM
sts_cfg_nvm.mtmcode1 = sts_mtmcode1;
sts_cfg_nvm.mtmcode2 = sts_mtmcode2;
@ -3035,7 +3042,7 @@ uint32_t STS_Get_Date_Time_Stamp(void)
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
SysTimeLocalTime(UnixEpoch.Seconds, &localtime);
APP_LOG(TS_OFF, VLEVEL_M, "UTC TIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n",
APP_LOG(TS_OFF, VLEVEL_L, "UTC TIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n",
localtime.tm_hour, localtime.tm_min, localtime.tm_sec,
localtime.tm_mday, localtime.tm_mon + 1, localtime.tm_year + 1900);

View File

@ -154,7 +154,6 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1119592399" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.2024044405" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CORE_CM4"/>
<listOptionValue builtIn="false" value="STS_BAT"/>
<listOptionValue builtIn="false" value="CLOCK_SYNC"/>
<listOptionValue builtIn="false" value="RM2_1"/>
<listOptionValue builtIn="false" value="STS_O7"/>