Closed Idahowalker closed 2 years ago
The library seems to have an issue with the 12th month.
void fparseMQTT( void *pvParameters ) { struct stu_message px_message; for (;;) { if ( xQueueReceive(xQ_Message, &px_message, portMAX_DELAY) == pdTRUE ) { xSemaphoreTake( sema_mqttOK, portMAX_DELAY ); mqttOK = 0; xSemaphoreGive( sema_mqttOK ); if ( px_message.topic == topicRemainingMoisture_0 ) { x_eData.RM0 = String(px_message.payload).toFloat(); } if ( px_message.topic == topicWindSpeed ) { x_eData.WS = String(px_message.payload).toFloat(); } if ( px_message.topic == topicWindDirection ) { x_eData.WD = ""; x_eData.WD = String(px_message.payload); } if ( px_message.topic == topicRainfall ) { x_eData.RF = String(px_message.payload).toFloat(); } if ( px_message.topic == topicWSVolts ) { x_eData.WSV = String(px_message.payload).toFloat(); } if ( px_message.topic == topicWSCurrent ) { x_eData.WSC = String(px_message.payload).toFloat(); } if ( px_message.topic == topicWSPower ) { x_eData.WSP = String(px_message.payload).toFloat(); } if ( px_message.topic == topicDPnWI ) { xQueueSend( xQ_WindChillDewPoint, (void *) &px_message, 1 ); } if ( String(px_message.topic) == topicOK ) { if ( !TimeSet) { String temp = ""; temp.reserve(50); temp.concat( String(px_message.payload[0]) ); temp.concat( String(px_message.payload[1]) ); temp.concat( String(px_message.payload[2]) ); temp.concat( String(px_message.payload[3]) ); int year = temp.toInt(); temp = ""; //temp.concat( String(px_message.payload[5]) + String(px_message.payload[6]) ); temp.concat( "12" ); log_i( "%s %s%s", temp.c_str(), String(px_message.payload[5]).c_str(), String(px_message.payload[6]).c_str() ); int month = 12; temp = ""; temp.concat(String(px_message.payload[8]) + String(px_message.payload[9]) ); int day = temp.toInt(); temp = ""; temp.concat( String(px_message.payload[11]) + String(px_message.payload[12]) ); int hour = temp.toInt(); temp = ""; temp.concat( String(px_message.payload[14]) + String(px_message.payload[15]) ); int min = temp.toInt(); rtc.setTime( 0, min, hour, day, month, year ); log_i( "rtc %s Year %d month %d day %d", rtc.getTime(), rtc.getYear(), rtc.getMonth(), rtc.getDay() ); TimeSet = true; } } } //if ( xQueueReceive(xQ_Message, &px_message, portMAX_DELAY) == pdTRUE ) } //for(;;) vTaskDelete( NULL ); } // void fparseMQTT( void *pvParameters )
As may be seen, I hard coded a 12 into the month.
Here is the printout:
[I][ESP32_Chappie_Inside_THP_1.ino:366] fparseMQTT(): rtc 08:40:00 Year 2021 month 11 day 6
Notice the month is 11, even though a 12 was hardcoded.
t.tm_mon = mt - 1; << might be the issue?
https://www.cplusplus.com/reference/ctime/tm/
tm_mon range is 0 - 11
tm_mon
The library seems to have an issue with the 12th month.
As may be seen, I hard coded a 12 into the month.
Here is the printout:
[I][ESP32_Chappie_Inside_THP_1.ino:366] fparseMQTT(): rtc 08:40:00 Year 2021 month 11 day 6
Notice the month is 11, even though a 12 was hardcoded.