mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2025-12-11 01:10:20 +01:00
Use the right format string on a lot of locations
This helps for a future support of arduino framework 3
This commit is contained in:
@@ -33,7 +33,7 @@ float CpuTemperatureClass::read()
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
uint8_t raw = temprature_sens_read();
|
||||
ESP_LOGV(TAG, "Raw temperature value: %d", raw);
|
||||
ESP_LOGV(TAG, "Raw temperature value: %" PRIu8, raw);
|
||||
temperature = (raw - 32) / 1.8f;
|
||||
success = (raw != 128);
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
@@ -52,7 +52,7 @@ float CpuTemperatureClass::read()
|
||||
if (success && std::isfinite(temperature)) {
|
||||
return temperature;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Ignoring invalid temperature (success=%d, value=%.1f)", success, temperature);
|
||||
ESP_LOGD(TAG, "Ignoring invalid temperature (success=%" PRId8 ", value=%.1f)", success, temperature);
|
||||
return NAN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ void HoymilesClass::loop()
|
||||
iv->resendPowerControlRequest();
|
||||
}
|
||||
|
||||
_messageOutput->printf("Queue size - NRF: %" PRId32 " CMT: %" PRId32 "\r\n", _radioNrf->getQueueSize(), _radioCmt->getQueueSize());
|
||||
_messageOutput->printf("Queue size - NRF: %" PRIu32 " CMT: %" PRIu32 "\r\n", _radioNrf->getQueueSize(), _radioCmt->getQueueSize());
|
||||
_lastPoll = millis();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ uint32_t HoymilesRadio_CMT::getFrequencyFromChannel(const uint8_t channel) const
|
||||
uint8_t HoymilesRadio_CMT::getChannelFromFrequency(const uint32_t frequency) const
|
||||
{
|
||||
if ((frequency % getChannelWidth()) != 0) {
|
||||
Hoymiles.getMessageOutput()->printf("%.3f MHz is not divisible by %" PRId32 " kHz!\r\n", frequency / 1000000.0, getChannelWidth());
|
||||
Hoymiles.getMessageOutput()->printf("%.3f MHz is not divisible by %" PRIu32 " kHz!\r\n", frequency / 1000000.0, getChannelWidth());
|
||||
return 0xFF; // ERROR
|
||||
}
|
||||
if (frequency < getMinFrequency() || frequency > getMaxFrequency()) {
|
||||
@@ -43,7 +43,7 @@ uint8_t HoymilesRadio_CMT::getChannelFromFrequency(const uint32_t frequency) con
|
||||
return 0xFF; // ERROR
|
||||
}
|
||||
if (frequency < countryDefinition.at(_countryMode).Freq_Legal_Min || frequency > countryDefinition.at(_countryMode).Freq_Legal_Max) {
|
||||
Hoymiles.getMessageOutput()->printf("!!! caution: %.2f MHz is out of region legal range! (%" PRId32 " - %" PRId32 " MHz)\r\n",
|
||||
Hoymiles.getMessageOutput()->printf("!!! caution: %.2f MHz is out of region legal range! (%" PRIu32 " - %" PRIu32 " MHz)\r\n",
|
||||
frequency / 1000000.0,
|
||||
static_cast<uint32_t>(countryDefinition.at(_countryMode).Freq_Legal_Min / 1e6),
|
||||
static_cast<uint32_t>(countryDefinition.at(_countryMode).Freq_Legal_Max / 1e6));
|
||||
|
||||
@@ -75,7 +75,7 @@ void HoymilesRadio_NRF::loop()
|
||||
|
||||
if (nullptr != inv) {
|
||||
// Save packet in inverter rx buffer
|
||||
Hoymiles.getMessageOutput()->printf("RX Channel: %" PRId8 " --> ", f.channel);
|
||||
Hoymiles.getMessageOutput()->printf("RX Channel: %" PRIu8 " --> ", f.channel);
|
||||
dumpBuf(f.fragment, f.len, false);
|
||||
Hoymiles.getMessageOutput()->printf("| %" PRId8 " dBm\r\n", f.rssi);
|
||||
|
||||
@@ -182,7 +182,7 @@ void HoymilesRadio_NRF::sendEsbPacket(CommandAbstract& cmd)
|
||||
openWritingPipe(s);
|
||||
_radio->setRetries(3, 15);
|
||||
|
||||
Hoymiles.getMessageOutput()->printf("TX %s Channel: %" PRId8 " --> ",
|
||||
Hoymiles.getMessageOutput()->printf("TX %s Channel: %" PRIu8 " --> ",
|
||||
cmd.getCommandName().c_str(), _radio->getChannel());
|
||||
cmd.dumpDataPayload(Hoymiles.getMessageOutput());
|
||||
_radio->write(cmd.getDataPayload(), cmd.getDataSize());
|
||||
|
||||
@@ -48,7 +48,7 @@ bool RealTimeRunDataCommand::handleResponse(const fragment_t fragment[], const u
|
||||
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
||||
const uint8_t expectedSize = _inv->Statistics()->getExpectedByteCount();
|
||||
if (fragmentsSize < expectedSize) {
|
||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %" PRId8 ", min expected size: %" PRId8 "\r\n",
|
||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %" PRIu8 ", min expected size: %" PRIu8 "\r\n",
|
||||
getCommandName().c_str(), fragmentsSize, expectedSize);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -48,7 +48,7 @@ bool SystemConfigParaCommand::handleResponse(const fragment_t fragment[], const
|
||||
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
||||
const uint8_t expectedSize = _inv->SystemConfigPara()->getExpectedByteCount();
|
||||
if (fragmentsSize < expectedSize) {
|
||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %" PRId8 ", min expected size: %" PRId8 "\r\n",
|
||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %" PRIu8 ", min expected size: %" PRIu8 "\r\n",
|
||||
getCommandName().c_str(), fragmentsSize, expectedSize);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -13,7 +13,7 @@ InverterAbstract::InverterAbstract(HoymilesRadio* radio, const uint64_t serial)
|
||||
_radio = radio;
|
||||
|
||||
char serial_buff[sizeof(uint64_t) * 8 + 1];
|
||||
snprintf(serial_buff, sizeof(serial_buff), "%0x%08x",
|
||||
snprintf(serial_buff, sizeof(serial_buff), "%0" PRIx32 "%08" PRIx32,
|
||||
static_cast<uint32_t>((serial >> 32) & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(serial & 0xFFFFFFFF));
|
||||
_serialString = serial_buff;
|
||||
@@ -215,7 +215,7 @@ void InverterAbstract::addRxFragment(const uint8_t fragment[], const uint8_t len
|
||||
}
|
||||
|
||||
if (fragmentId >= MAX_RF_FRAGMENT_COUNT) {
|
||||
Hoymiles.getMessageOutput()->printf("ERROR: fragment id %" PRId8 " is too large for buffer and ignored\r\n", fragmentId);
|
||||
Hoymiles.getMessageOutput()->printf("ERROR: fragment id %" PRIu8 " is too large for buffer and ignored\r\n", fragmentId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX, uint8_t xPos
|
||||
if (maxWatts > 999) {
|
||||
snprintf(fmtText, sizeof(fmtText), "%2.1fkW", maxWatts / 1000);
|
||||
} else {
|
||||
snprintf(fmtText, sizeof(fmtText), "%" PRId16 "W", static_cast<uint16_t>(maxWatts));
|
||||
snprintf(fmtText, sizeof(fmtText), "%" PRIu16 "W", static_cast<uint16_t>(maxWatts));
|
||||
}
|
||||
|
||||
if (isFullscreen) {
|
||||
|
||||
@@ -226,7 +226,7 @@ void NetworkSettingsClass::loop()
|
||||
if (_adminEnabled && _adminTimeoutCounterMax > 0) {
|
||||
_adminTimeoutCounter++;
|
||||
if (_adminTimeoutCounter % 10 == 0) {
|
||||
MessageOutput.printf("Admin AP remaining seconds: %" PRId32 " / %" PRId32 "\r\n", _adminTimeoutCounter, _adminTimeoutCounterMax);
|
||||
MessageOutput.printf("Admin AP remaining seconds: %" PRIu32 " / %" PRIu32 "\r\n", _adminTimeoutCounter, _adminTimeoutCounterMax);
|
||||
}
|
||||
}
|
||||
_connectTimeoutTimer++;
|
||||
|
||||
@@ -61,7 +61,7 @@ int Utils::getTimezoneOffset()
|
||||
bool Utils::checkJsonAlloc(const JsonDocument& doc, const char* function, const uint16_t line)
|
||||
{
|
||||
if (doc.overflowed()) {
|
||||
MessageOutput.printf("Alloc failed: %s, %" PRId16 "\r\n", function, line);
|
||||
MessageOutput.printf("Alloc failed: %s, %" PRIu16 "\r\n", function, line);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ bool WebApiClass::sendJsonResponse(AsyncWebServerRequest* request, AsyncJsonResp
|
||||
root["code"] = WebApiError::GenericInternalServerError;
|
||||
root["type"] = "danger";
|
||||
response->setCode(500);
|
||||
MessageOutput.printf("WebResponse failed: %s, %" PRId16 "\r\n", function, line);
|
||||
MessageOutput.printf("WebResponse failed: %s, %" PRIu16 "\r\n", function, line);
|
||||
ret_val = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,19 +44,19 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
|
||||
|
||||
stream->print("# HELP opendtu_heap_size System memory size\n");
|
||||
stream->print("# TYPE opendtu_heap_size gauge\n");
|
||||
stream->printf("opendtu_heap_size %" PRId32 "\n", ESP.getHeapSize());
|
||||
stream->printf("opendtu_heap_size %" PRIu32 "\n", ESP.getHeapSize());
|
||||
|
||||
stream->print("# HELP opendtu_free_heap_size System free memory\n");
|
||||
stream->print("# TYPE opendtu_free_heap_size gauge\n");
|
||||
stream->printf("opendtu_free_heap_size %" PRId32 "\n", ESP.getFreeHeap());
|
||||
stream->printf("opendtu_free_heap_size %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
|
||||
stream->print("# HELP opendtu_biggest_heap_block Biggest free heap block\n");
|
||||
stream->print("# TYPE opendtu_biggest_heap_block gauge\n");
|
||||
stream->printf("opendtu_biggest_heap_block %" PRId32 "\n", ESP.getMaxAllocHeap());
|
||||
stream->printf("opendtu_biggest_heap_block %" PRIu32 "\n", ESP.getMaxAllocHeap());
|
||||
|
||||
stream->print("# HELP opendtu_heap_min_free Minimum free memory since boot\n");
|
||||
stream->print("# TYPE opendtu_heap_min_free gauge\n");
|
||||
stream->printf("opendtu_heap_min_free %" PRId32 "\n", ESP.getMinFreeHeap());
|
||||
stream->printf("opendtu_heap_min_free %" PRIu32 "\n", ESP.getMinFreeHeap());
|
||||
|
||||
stream->print("# HELP wifi_rssi WiFi RSSI\n");
|
||||
stream->print("# TYPE wifi_rssi gauge\n");
|
||||
@@ -75,14 +75,14 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
|
||||
stream->print("# HELP opendtu_last_update last update from inverter in s\n");
|
||||
stream->print("# TYPE opendtu_last_update gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_last_update{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\"} %" PRId32 "\n",
|
||||
stream->printf("opendtu_last_update{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\"} %" PRIu32 "\n",
|
||||
serial.c_str(), i, name, inv->Statistics()->getLastUpdate() / 1000);
|
||||
|
||||
if (i == 0) {
|
||||
stream->print("# HELP opendtu_inverter_limit_relative current relative limit of the inverter\n");
|
||||
stream->print("# TYPE opendtu_inverter_limit_relative gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_inverter_limit_relative{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\"} %f\n",
|
||||
stream->printf("opendtu_inverter_limit_relative{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\"} %f\n",
|
||||
serial.c_str(), i, name, inv->SystemConfigPara()->getLimitPercent() / 100.0);
|
||||
|
||||
if (inv->DevInfo()->getMaxPower() > 0) {
|
||||
@@ -90,7 +90,7 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
|
||||
stream->print("# HELP opendtu_inverter_limit_absolute current relative limit of the inverter\n");
|
||||
stream->print("# TYPE opendtu_inverter_limit_absolute gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_inverter_limit_absolute{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\"} %f\n",
|
||||
stream->printf("opendtu_inverter_limit_absolute{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\"} %f\n",
|
||||
serial.c_str(), i, name, inv->SystemConfigPara()->getLimitPercent() * inv->DevInfo()->getMaxPower() / 100.0);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void WebApiPrometheusClass::addField(AsyncResponseStream* stream, const String&
|
||||
stream->printf("# HELP opendtu_%s in %s\n", chanName, inv->Statistics()->getChannelFieldUnit(type, channel, fieldId));
|
||||
stream->printf("# TYPE opendtu_%s %s\n", chanName, metricName);
|
||||
}
|
||||
stream->printf("opendtu_%s{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\",type=\"%s\",channel=\"%d\"} %s\n",
|
||||
stream->printf("opendtu_%s{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\",type=\"%s\",channel=\"%d\"} %s\n",
|
||||
chanName,
|
||||
serial.c_str(),
|
||||
idx,
|
||||
@@ -156,7 +156,7 @@ void WebApiPrometheusClass::addPanelInfo(AsyncResponseStream* stream, const Stri
|
||||
stream->print("# HELP opendtu_PanelInfo panel information\n");
|
||||
stream->print("# TYPE opendtu_PanelInfo gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_PanelInfo{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\",channel=\"%d\",panelname=\"%s\"} 1\n",
|
||||
stream->printf("opendtu_PanelInfo{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\",channel=\"%" PRIu8 "\",panelname=\"%s\"} 1\n",
|
||||
serial.c_str(),
|
||||
idx,
|
||||
inv->name(),
|
||||
@@ -167,7 +167,7 @@ void WebApiPrometheusClass::addPanelInfo(AsyncResponseStream* stream, const Stri
|
||||
stream->print("# HELP opendtu_MaxPower panel maximum output power\n");
|
||||
stream->print("# TYPE opendtu_MaxPower gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_MaxPower{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\",channel=\"%d\"} %d\n",
|
||||
stream->printf("opendtu_MaxPower{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\",channel=\"%" PRIu8 "\"} %" PRIu16 "\n",
|
||||
serial.c_str(),
|
||||
idx,
|
||||
inv->name(),
|
||||
@@ -178,7 +178,7 @@ void WebApiPrometheusClass::addPanelInfo(AsyncResponseStream* stream, const Stri
|
||||
stream->print("# HELP opendtu_YieldTotalOffset panel yield offset (for used inverters)\n");
|
||||
stream->print("# TYPE opendtu_YieldTotalOffset gauge\n");
|
||||
}
|
||||
stream->printf("opendtu_YieldTotalOffset{serial=\"%s\",unit=\"%" PRId8 "\",name=\"%s\",channel=\"%" PRId16 "\"} %f\n",
|
||||
stream->printf("opendtu_YieldTotalOffset{serial=\"%s\",unit=\"%" PRIu8 "\",name=\"%s\",channel=\"%" PRIu16 "\"} %f\n",
|
||||
serial.c_str(),
|
||||
idx,
|
||||
inv->name(),
|
||||
|
||||
@@ -237,9 +237,9 @@ void WebApiWsLiveClass::addTotalField(JsonObject& root, const String& name, cons
|
||||
void WebApiWsLiveClass::onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len)
|
||||
{
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
MessageOutput.printf("Websocket: [%s][%u] connect\r\n", server->url(), client->id());
|
||||
MessageOutput.printf("Websocket: [%s][%" PRIu32 "] connect\r\n", server->url(), client->id());
|
||||
} else if (type == WS_EVT_DISCONNECT) {
|
||||
MessageOutput.printf("Websocket: [%s][%u] disconnect\r\n", server->url(), client->id());
|
||||
MessageOutput.printf("Websocket: [%s][%" PRIu32 "] disconnect\r\n", server->url(), client->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user