Move the conversation from time_t to String into DevInfoParser
This commit is contained in:
parent
dcc157261e
commit
e66060e769
@ -137,6 +137,14 @@ time_t DevInfoParser::getFwBuildDateTime() const
|
||||
return timegm(&timeinfo);
|
||||
}
|
||||
|
||||
String DevInfoParser::getFwBuildDateTimeStr() const
|
||||
{
|
||||
char timebuffer[32];
|
||||
const time_t t = getFwBuildDateTime();
|
||||
std::strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S", gmtime(&t));
|
||||
return timebuffer;
|
||||
}
|
||||
|
||||
uint16_t DevInfoParser::getFwBootloaderVersion() const
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
@ -254,4 +262,4 @@ time_t DevInfoParser::timegm(const struct tm* t)
|
||||
result -= 3600;
|
||||
/*@ -matchanyintegral @*/
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ public:
|
||||
|
||||
uint16_t getFwBuildVersion() const;
|
||||
time_t getFwBuildDateTime() const;
|
||||
String getFwBuildDateTimeStr() const;
|
||||
uint16_t getFwBootloaderVersion() const;
|
||||
|
||||
uint32_t getHwPartNumber() const;
|
||||
@ -43,4 +44,4 @@ private:
|
||||
|
||||
uint8_t _payloadDevInfoSimple[DEV_INFO_SIZE] = {};
|
||||
uint8_t _devInfoSimpleLength = 0;
|
||||
};
|
||||
};
|
||||
|
||||
@ -68,10 +68,7 @@ void MqttHandleInverterClass::loop()
|
||||
MqttSettings.publish(subtopic + "/device/fwbuildversion", String(inv->DevInfo()->getFwBuildVersion()));
|
||||
|
||||
// Firmware Build DateTime
|
||||
char timebuffer[32];
|
||||
const time_t t = inv->DevInfo()->getFwBuildDateTime();
|
||||
std::strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S", gmtime(&t));
|
||||
MqttSettings.publish(subtopic + "/device/fwbuilddatetime", String(timebuffer));
|
||||
MqttSettings.publish(subtopic + "/device/fwbuilddatetime", inv->DevInfo()->getFwBuildDateTimeStr());
|
||||
|
||||
// Hardware part number
|
||||
MqttSettings.publish(subtopic + "/device/hwpartnumber", String(inv->DevInfo()->getHwPartNumber()));
|
||||
|
||||
@ -46,13 +46,9 @@ void WebApiDevInfoClass::onDevInfoStatus(AsyncWebServerRequest* request)
|
||||
root["hw_version"] = inv->DevInfo()->getHwVersion();
|
||||
root["hw_model_name"] = inv->DevInfo()->getHwModelName();
|
||||
root["max_power"] = inv->DevInfo()->getMaxPower();
|
||||
|
||||
char timebuffer[32];
|
||||
const time_t t = inv->DevInfo()->getFwBuildDateTime();
|
||||
std::strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S", gmtime(&t));
|
||||
root["fw_build_datetime"] = String(timebuffer);
|
||||
root["fw_build_datetime"] = inv->DevInfo()->getFwBuildDateTimeStr();
|
||||
}
|
||||
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user