From 7eb963563a067f822d24f89a23403ba94650d809 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Mon, 13 May 2024 22:16:02 +0800 Subject: [PATCH] optimized upload message content --- Core/Src/yunhorn_sts_process.c | 9 ++++++++- LoRaWAN/App/lora_app.c | 33 +++------------------------------ 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 7339d02..034baf4 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -696,8 +696,12 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) sts_o7_sensorData.state_sensor2_on_off = sts_rss_result; sts_o7_sensorData.state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result; + APP_LOG(TS_OFF, VLEVEL_M, "\r\nPrepare Upload Message............\r\n"); + if (sts_rss_result == STS_RESULT_MOTION) { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_RESULT MOTION............\r\n"); + sts_o7_sensorData.rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF; sts_o7_sensorData.rss_presence_score = (uint16_t)(sts_presence_rss_score)&0xFFFF; // uint8_t sts_unconcious_state; @@ -710,12 +714,14 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) sts_o7_sensorData.unconcious_state = 0; } } else { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_NO MOTION............\r\n"); sts_o7_sensorData.rss_presence_distance = 0x0; sts_o7_sensorData.rss_presence_score = 0x0; } + sts_o7_sensorData.fall_state = sts_fall_rising_detected_result; if (sts_fall_rising_detected_result != STS_PRESENCE_NONE) - { + { APP_LOG(TS_OFF, VLEVEL_M, "\r\n......FALL DETECTION............\r\n"); sts_o7_sensorData.fall_speed = (uint8_t)sts_fall_rising_pattern_factor1; sts_o7_sensorData.fall_gravity = (uint8_t)sts_roc_acc_standard_variance; } @@ -730,6 +736,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) if (check_time_tmp > sts_occupancy_overtime_threshold*60) { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n......OVER STAY............\r\n"); sts_occupancy_overtime_state = 1U; sts_o7_sensorData.overtime = sts_occupancy_overtime_state; sts_o7_sensorData.over_stay_duration = check_time_tmp; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 877b20c..c079e8f 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -948,45 +948,18 @@ static void SendTxData(void) AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status + AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status #if 1 - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status -#endif - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status - //if (o7_data.state_sensor2_on_off != 0) - // REF: AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm >>8)&0xff; //#05 - // REF: AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm)&0xff; - //{ -#if 0 - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status - - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status - - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor1_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor2_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor3_on_off)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status - - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.fall_state)&0xff; //06 Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_distance)&0xff; //08 LSB distance - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score>>8)&0xff; //09 MSB score - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.rss_presence_score)&0xff; //10 LSB score - //} + #endif -#if 0 +#if 1 AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.unconcious_state)&0xff; //11 unconcious state detected or not AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.fall_state)&0xff; //12 fall detected or not - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.overtime)&0xff; //13 occupancy over time or not - AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration>>8)&0xff; //13 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration)&0xff; //13 occupancy over time or not #endif