diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index b69aa42..4304ab2 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -785,7 +785,7 @@ static uint8_t PrepareSendTxData(void) STS_PRESENCE_SENSOR_Prepare_Send_Data(); //STS_PRESENCE_SENSOR_Read(&o7_data); - o7_data.battery_Pct = (uint8_t)(99*batteryLevel/254); + sts_o7_sensorData.battery_Pct = (uint8_t)(99*batteryLevel/254); // For occupancy over time process @@ -815,8 +815,8 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = sts_mtmcode1; AppData.Buffer[i++] = sts_mtmcode2; - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor1_on_off); //01 Sensor head #1 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.battery_Pct); //02 Battery Level % + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor1_on_off); //01 Sensor head #1 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.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 |" @@ -826,13 +826,13 @@ static uint8_t PrepareSendTxData(void) break; case STS_NETWORK_MODE: - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.lamp_bar_color); //01 - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.workmode); //02 WORK MODE + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.lamp_bar_color); //01 + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.workmode); //02 WORK MODE - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor1_on_off); //03 Sensor head #1 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor2_on_off); //04 Sensor head #2 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor3_on_off); //05 Sensor head #3 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor4_on_off); //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor1_on_off); //03 Sensor head #1 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor2_on_off); //04 Sensor head #2 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor3_on_off); //05 Sensor head #3 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.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######|%10s | %15s | %1d | %1d | %1d | %1d |\r\n", @@ -840,11 +840,11 @@ static uint8_t PrepareSendTxData(void) break; case STS_REEDSWITCH_MODE: - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.lamp_bar_color); //01 - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.workmode); //02 WORK MODE + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.lamp_bar_color); //01 + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.workmode); //02 WORK MODE - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor1_on_off); //03 Sensor head #1 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.battery_Pct); //02 Battery Level % + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor1_on_off); //03 Sensor head #1 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.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, @@ -854,45 +854,45 @@ static uint8_t PrepareSendTxData(void) break; case STS_RSS_MODE: - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.lamp_bar_color); //01 - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.workmode); //02 WORK MODE + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.lamp_bar_color); //01 + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.workmode); //02 WORK MODE - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor2_on_off); //03 Sensor head #2 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor2_on_off); //03 Sensor head #2 status //AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor3_on_off); // Sensor head #3 status //AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor4_on_off); // Sensor head #4 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_distance>>8); //04 MSB distance - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_distance); //05 LSB distance - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_score >>8); //06 MSB score - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_score); //07 LSB score + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance>>8); //04 MSB distance + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance); //05 LSB distance + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score >>8); //06 MSB score + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.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######|%10s | %15s | %1d | %04d | %04d |\r\n", - (char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2], (uint16_t)o7_data.rss_presence_distance,(uint16_t)o7_data.rss_presence_score); + (char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score); break; + case STS_DUAL_MODE: + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.lamp_bar_color); //01 + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.workmode); //02 WORK MODE - default: - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.lamp_bar_color); //01 - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.workmode); //02 WORK MODE - - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor1_on_off); //03 Sensor head #1 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor2_on_off); //04 Sensor head #2 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor3_on_off); //05 Sensor head #3 status - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.state_sensor4_on_off); //06 Sensor head #4 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor1_on_off); //03 Sensor head #1 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor2_on_off); //04 Sensor head #2 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor3_on_off); //05 Sensor head #3 status + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor4_on_off); //06 Sensor head #4 status if (o7_data.state_sensor2_on_off !=0) { - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_distance>>8); //07 MSB distance - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_distance); //08 LSB distance - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_score >>8); //09 MSB score - AppData.Buffer[i++] = (uint8_t)(0xFF & o7_data.rss_presence_score); //10 LSB score + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance>>8); //07 MSB distance + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance); //08 LSB distance + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score >>8); //09 MSB score + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.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######|%10s | %15s | %1d | %1d | %1d | %1d | %04d | %04d |\r\n", - (char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]],AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], (uint16_t)o7_data.rss_presence_distance,(uint16_t)o7_data.rss_presence_score); + (char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]],AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score); + default: break; } diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index 5be7922..ed547fb 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ