오류시 재시도 추가

main
Imbis 6 months ago
parent 94c0d7e670
commit b302aea00c

File diff suppressed because one or more lines are too long

@ -53,6 +53,7 @@ typedef struct _control_info
uint16_t Co2_TempValue;
SET_INDEX SetIndex;
uint8_t SensorRetry;
uint16_t Co2_TempMax;
uint16_t Co2_TempMin;
}CONTROL_INFO;
@ -279,6 +280,7 @@ static void Action_Get_SensorReadProcess(void)
if(nowSensorState == KCD_HP100_SUCCESS)
{
KCD_HP100_Get_Co2((uint16_t *)&Control_Info.Co2_Now);
Control_Info.SensorRetry = 0;
Control_Info.Co2_SaveData = Control_Info.Co2_Now;
if(Control_Info.Co2_Now >= Control_Info.Co2_MaxValue)
@ -291,9 +293,17 @@ static void Action_Get_SensorReadProcess(void)
}
}
else if(nowSensorState == KCD_HP100_ERROR_TIMEOUT)
{
Control_Info.SensorRetry++;
if(Control_Info.SensorRetry <= 3)
{
Action_Get_SensorData();
}
else
{
Control_Info.Co2_Now = 0xFFFF;
}
}
if(millis() - Control_Info.GetSensorDataTickCount >= ACTION_SENSOR_READ_INTERVAL)
{
@ -321,36 +331,29 @@ static void Action_SaveSensorData(void)
RTC_TIME nowTime;
nowTime = RTC_Get_Time();
if(SaveCheckSec != nowTime.rtc_Sec)
{
if(SaveCheckSec != nowTime.rtc_Sec){
SaveCheckSec = nowTime.rtc_Sec;
if(nowTime.rtc_Sec == 0)
{
if(nowTime.rtc_Sec == 0){
if(Control_Info.Co2_SaveData != 0xFFFF){
SaveSensorCo2[SaveSensorIndex++] = Control_Info.Co2_SaveData;
}
if(nowTime.rtc_Min % 5 == 0)
{
if(SaveSensorIndex >= 5)
{
if(nowTime.rtc_Min % 5 == 0){
if(SaveSensorIndex >= 5){
uint8_t i;
uint16_t Sum_Co2, Max_Co2, Min_Co2;
Max_Co2 = 0;
Min_Co2 = 0xFFFF;
Sum_Co2 = 0;
for(i = 0 ; i < SaveSensorIndex ; i++)
{
for(i = 0 ; i < SaveSensorIndex ; i++){
Sum_Co2 += SaveSensorCo2[i];
if(SaveSensorCo2[i] >= Max_Co2)
{
if(SaveSensorCo2[i] >= Max_Co2){
Max_Co2 = SaveSensorCo2[i];
}
if(SaveSensorCo2[i] <= Min_Co2)
{
if(SaveSensorCo2[i] <= Min_Co2){
Min_Co2 = SaveSensorCo2[i];
}
}
@ -358,12 +361,10 @@ static void Action_SaveSensorData(void)
Sum_Co2 -= Min_Co2;
Sum_Co2 /= (SaveSensorIndex - 2);
if(Save_SensorData_SDCard(Sum_Co2, Max_Co2, Min_Co2, Control_Info.isRelayOn ? 0xFF : 0x00) == false)
{
if(Save_SensorData_SDCard(Sum_Co2, Max_Co2, Min_Co2, Control_Info.isRelayOn ? 0xFF : 0x00) == false){
printf("Save fail, %04d-%02d-%02d %02d:%02d:%02d, %d, %d, %d, %d\r\n", nowTime.rtc_Year, nowTime.rtc_Month, nowTime.rtc_Date, nowTime.rtc_Hour, nowTime.rtc_Min, nowTime.rtc_Sec, Sum_Co2, Max_Co2, Min_Co2, Control_Info.isRelayOn);
}
else
{
else{
printf("Save, %04d-%02d-%02d %02d:%02d:%02d, %d, %d, %d, %d\r\n", nowTime.rtc_Year, nowTime.rtc_Month, nowTime.rtc_Date, nowTime.rtc_Hour, nowTime.rtc_Min, nowTime.rtc_Sec, Sum_Co2, Max_Co2, Min_Co2, Control_Info.isRelayOn);
}
}

@ -90,7 +90,7 @@ void Gpio_Swtich_Set_Callback(KEY_LIST key, GPIO_SW_CALLBACK_FN Push_Callback, G
static void Gpio_Switch_TestCallback(KEY_LIST key)
{
printf("%d key push\r\n", key);
//printf("%d key push\r\n", key);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save