reformat prepare send tx data from if else to switch case

This commit is contained in:
Yunhorn 2023-07-03 14:08:33 +08:00
parent ae918aa783
commit cf057722a9
1 changed files with 74 additions and 62 deletions

View File

@ -732,79 +732,91 @@ static uint8_t PrepareSendTxData(void)
// For occupancy over time process // For occupancy over time process
switch (sts_work_mode) {
case STS_WIRED_MODE:
if (sts_work_mode == STS_WIRED_MODE) AppData.Buffer[i++] = sts_mtmcode1;
{ AppData.Buffer[i++] = sts_mtmcode2;
AppData.Buffer[i++] = sts_mtmcode1; AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //01 Sensor head #1 status
AppData.Buffer[i++] = sts_mtmcode2; AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.battery_Pct); //02 Battery Level %
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor1_on_off); //01 Sensor head #1 status AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.battery_Pct); //02 Battery Level % AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1 BAT % BAT mV |"
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB "\r\n######| %1d %1d %2d% %4d mV|\r\n",
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1 BAT % BAT mV |" sts_work_mode, AppData.Buffer[2], AppData.Buffer[3], batteryLevelmV);
"\r\n######| %1d %1d %2d% %4d mV|\r\n",
sts_work_mode, AppData.Buffer[2], AppData.Buffer[3], batteryLevelmV);
} else break;
{
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.lamp_bar_color); //01 case STS_NETWORK_MODE:
AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.workmode); //02 WORK 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
if (sts_work_mode == STS_NETWORK_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_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_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_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 AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor4_on_off); //06 Sensor head #4 status
APP_LOG(TS_OFF, VLEVEL_L, APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color Mode S1 S2 S3 S4 |" "\r\n######| Color Mode S1 S2 S3 S4 |"
"\r\n######| %1d %1d %1d %1d %1d %1d |\r\n", "\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]); AppData.Buffer[0], AppData.Buffer[1], AppData.Buffer[2],AppData.Buffer[3], AppData.Buffer[4],AppData.Buffer[5]);
} else if (sts_work_mode == STS_REEDSWITCH_MODE) break;
{
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);
} else if (sts_work_mode == STS_RSS_MODE) 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)
{ {
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.rss_presence_distance>>8); //07 MSB distance
//AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.state_sensor3_on_off); // Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(0xFF & o6_data.rss_presence_distance); //08 LSB distance
//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_score >>8); //09 MSB score
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_score); //10 LSB score
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);
} else {
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)
{
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);
} }
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; return i;
} }