add lamp bar code
This commit is contained in:
parent
963ad7c4cc
commit
8be791bb03
|
@ -54,6 +54,12 @@ volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
|
|||
extern hmac_result_t hmac_result;
|
||||
volatile uint8_t sts_work_mode =0;
|
||||
volatile uint8_t sensor_data_ready=0;
|
||||
|
||||
volatile uint32_t event_start_time, event_stop_time;
|
||||
volatile uint8_t sts_occupancy_overtime_state = 0;
|
||||
volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=30, sts_occupancy_overtime_threshold=20;
|
||||
|
||||
|
||||
extern volatile uint8_t sts_soap_level_state;
|
||||
extern volatile uint8_t ToF_EventDetected;
|
||||
extern volatile int sts_tof_distance_data[MAX_TOF_COUNT];
|
||||
|
@ -338,6 +344,11 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity);
|
|||
*/
|
||||
static void OnYunhornSTSHeartBeatTimerEvent(void *context);
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Prepare Send Tx Data
|
||||
* @param none
|
||||
*/
|
||||
static uint8_t YunhornSTSPrepareSendTxData(void);
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Uploading Message periodically
|
||||
|
@ -769,6 +780,131 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
|||
/* USER CODE END OnRxData_1 */
|
||||
}
|
||||
|
||||
static uint8_t YunhornSTSPrepareSendTxData(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
uint8_t batteryLevel = GetBatteryLevel();
|
||||
uint16_t batteryLevelmV = SYS_GetBatteryLevel();
|
||||
SysTime_t occupy_check_time = SysTimeGetMcuTime();
|
||||
//sensor_t sensor_data;
|
||||
STS_OO_SensorStatusDataTypeDef o6_data;
|
||||
|
||||
STS_PRESENCE_SENSOR_Read(&o6_data);
|
||||
o6_data.battery_Pct = (uint8_t)(99*batteryLevel/254);
|
||||
|
||||
|
||||
// For occupancy over time process
|
||||
if ((sts_occupancy_overtime_threshold != 0) && (event_start_time !=0))
|
||||
{
|
||||
uint32_t check_time_tmp = occupy_check_time.Seconds - event_start_time;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Check time at %6u Seconds, time lag =%6u, Started at %6u \r\n", occupy_check_time.Seconds, check_time_tmp, event_start_time);
|
||||
|
||||
if (check_time_tmp > sts_occupancy_overtime_threshold*60)
|
||||
{
|
||||
sts_occupancy_overtime_state = 1U;
|
||||
sts_status_color = STS_RED_BLUE;
|
||||
sts_lamp_bar_color = STS_RED_BLUE;
|
||||
STS_Lamp_Bar_Refresh();
|
||||
}
|
||||
} else
|
||||
{
|
||||
sts_occupancy_overtime_state = 0U;
|
||||
}
|
||||
|
||||
// For occupancy over time process
|
||||
|
||||
|
||||
switch (sts_work_mode) {
|
||||
case STS_WIRED_MODE:
|
||||
|
||||
AppData.Buffer[i++] = sts_mtmcode1;
|
||||
AppData.Buffer[i++] = sts_mtmcode2;
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //01 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.battery_Pct); //02 Battery Level %
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1 BAT % BAT mV |"
|
||||
"\r\n######| %1d %1d %2d% %4d mV|\r\n",
|
||||
sts_work_mode, AppData.Buffer[2], AppData.Buffer[3], batteryLevelmV);
|
||||
|
||||
break;
|
||||
|
||||
case STS_NETWORK_MODE:
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.lamp_bar_color); //01
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.workmode); //02 WORK MODE
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor2_on_off); //04 Sensor head #2 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor3_on_off); //05 Sensor head #3 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor4_on_off); //06 Sensor head #4 status
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| Color Mode S1 S2 S3 S4 |"
|
||||
"\r\n######| %1d %1d %1d %1d %1d %1d |\r\n",
|
||||
AppData.Buffer[0], AppData.Buffer[1], AppData.Buffer[2],AppData.Buffer[3], AppData.Buffer[4],AppData.Buffer[5]);
|
||||
break;
|
||||
|
||||
case STS_REEDSWITCH_MODE:
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.lamp_bar_color); //01
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.workmode); //02 WORK MODE
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.battery_Pct); //02 Battery Level %
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| Color Mode S1 VBAT in mV|"
|
||||
"\r\n######| %1d %1d %1d %2d% %4d mV|\r\n",
|
||||
AppData.Buffer[0], AppData.Buffer[1], AppData.Buffer[2],AppData.Buffer[3], batteryLevelmV);
|
||||
break;
|
||||
|
||||
case STS_RSS_MODE:
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.lamp_bar_color); //01
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.workmode); //02 WORK MODE
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor2_on_off); //03 Sensor head #2 status
|
||||
//AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor3_on_off); // Sensor head #3 status
|
||||
//AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor4_on_off); // Sensor head #4 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_distance>>8); //04 MSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_distance); //05 LSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_score >>8); //06 MSB score
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_score); //07 LSB score
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //08 occupancy over time or not
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| Color Mode S2 |Distance(mm) MotionScore|"
|
||||
"\r\n######| %1d %1d %1d |%04d %04d |\r\n",
|
||||
AppData.Buffer[0], AppData.Buffer[1], AppData.Buffer[2], (uint16_t)o6_data.rss_presence_distance,(uint16_t)o6_data.rss_presence_score);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.lamp_bar_color); //01
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.workmode); //02 WORK MODE
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor2_on_off); //04 Sensor head #2 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor3_on_off); //05 Sensor head #3 status
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor4_on_off); //06 Sensor head #4 status
|
||||
if (o6_data.state_sensor2_on_off !=0) // TODO XXXX bug...
|
||||
{
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_distance>>8); //07 MSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_distance); //08 LSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_score >>8); //09 MSB score
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_score); //10 LSB score
|
||||
}
|
||||
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //11 occupancy over time or not
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| Color Mode S1 S2 S3 S4 |Distance(mm) MotionScore|"
|
||||
"\r\n######| %1d %1d %1d %1d %1d %1d |%04d %04d |\r\n",
|
||||
AppData.Buffer[0], AppData.Buffer[1],AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], (uint16_t)o6_data.rss_presence_distance,(uint16_t)o6_data.rss_presence_score);
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static void SendTxData(void)
|
||||
{
|
||||
/* USER CODE BEGIN SendTxData_1 */
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,7 @@
|
|||
"./Application/User/Core/stm32wlxx_hal_msp.o"
|
||||
"./Application/User/Core/stm32wlxx_it.o"
|
||||
"./Application/User/Core/sts_cmox_hmac_sha.o"
|
||||
"./Application/User/Core/sts_lamp_bar.o"
|
||||
"./Application/User/Core/subghz.o"
|
||||
"./Application/User/Core/sys_app.o"
|
||||
"./Application/User/Core/sys_debug.o"
|
||||
|
|
Loading…
Reference in New Issue