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);
|
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
|
uint16_t DevInfoParser::getFwBootloaderVersion() const
|
||||||
{
|
{
|
||||||
HOY_SEMAPHORE_TAKE();
|
HOY_SEMAPHORE_TAKE();
|
||||||
@ -254,4 +262,4 @@ time_t DevInfoParser::timegm(const struct tm* t)
|
|||||||
result -= 3600;
|
result -= 3600;
|
||||||
/*@ -matchanyintegral @*/
|
/*@ -matchanyintegral @*/
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public:
|
|||||||
|
|
||||||
uint16_t getFwBuildVersion() const;
|
uint16_t getFwBuildVersion() const;
|
||||||
time_t getFwBuildDateTime() const;
|
time_t getFwBuildDateTime() const;
|
||||||
|
String getFwBuildDateTimeStr() const;
|
||||||
uint16_t getFwBootloaderVersion() const;
|
uint16_t getFwBootloaderVersion() const;
|
||||||
|
|
||||||
uint32_t getHwPartNumber() const;
|
uint32_t getHwPartNumber() const;
|
||||||
@ -43,4 +44,4 @@ private:
|
|||||||
|
|
||||||
uint8_t _payloadDevInfoSimple[DEV_INFO_SIZE] = {};
|
uint8_t _payloadDevInfoSimple[DEV_INFO_SIZE] = {};
|
||||||
uint8_t _devInfoSimpleLength = 0;
|
uint8_t _devInfoSimpleLength = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -68,10 +68,7 @@ void MqttHandleInverterClass::loop()
|
|||||||
MqttSettings.publish(subtopic + "/device/fwbuildversion", String(inv->DevInfo()->getFwBuildVersion()));
|
MqttSettings.publish(subtopic + "/device/fwbuildversion", String(inv->DevInfo()->getFwBuildVersion()));
|
||||||
|
|
||||||
// Firmware Build DateTime
|
// Firmware Build DateTime
|
||||||
char timebuffer[32];
|
MqttSettings.publish(subtopic + "/device/fwbuilddatetime", inv->DevInfo()->getFwBuildDateTimeStr());
|
||||||
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));
|
|
||||||
|
|
||||||
// Hardware part number
|
// Hardware part number
|
||||||
MqttSettings.publish(subtopic + "/device/hwpartnumber", String(inv->DevInfo()->getHwPartNumber()));
|
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_version"] = inv->DevInfo()->getHwVersion();
|
||||||
root["hw_model_name"] = inv->DevInfo()->getHwModelName();
|
root["hw_model_name"] = inv->DevInfo()->getHwModelName();
|
||||||
root["max_power"] = inv->DevInfo()->getMaxPower();
|
root["max_power"] = inv->DevInfo()->getMaxPower();
|
||||||
|
root["fw_build_datetime"] = inv->DevInfo()->getFwBuildDateTimeStr();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user