Skip to content

Commit

Permalink
utils: simplify version + revision into just version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Jan 4, 2021
1 parent 3ba6011 commit f0f6f1b
Show file tree
Hide file tree
Showing 27 changed files with 24,788 additions and 24,772 deletions.
Binary file modified code/espurna/data/index.all.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.curtain.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.garland.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.light.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.lightfox.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.rfbridge.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.rfm69.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.sensor.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.small.html.gz
Binary file not shown.
Binary file modified code/espurna/data/index.thermostat.html.gz
Binary file not shown.
26 changes: 15 additions & 11 deletions code/espurna/homeassistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ struct ha_config_t {
jsonBuffer(size),
deviceConfig(jsonBuffer.createObject()),
root(jsonBuffer.createObject()),
identifier(getIdentifier()),
name(getSetting("desc", getSetting("hostname"))),
version(String(APP_NAME " " APP_VERSION " (") + getCoreVersion() + ")")
identifier(getIdentifier().c_str()),
version(getVersion().c_str()),
manufacturer(getManufacturer().c_str()),
device(getDevice().c_str())
{
deviceConfig.createNestedArray("identifiers").add(identifier.c_str());
deviceConfig.createNestedArray("identifiers").add(identifier);
deviceConfig["name"] = name.c_str();
deviceConfig["sw_version"] = version.c_str();
deviceConfig["manufacturer"] = getManufacturer().c_str();
deviceConfig["model"] = getDevice().c_str();
deviceConfig["sw_version"] = version;
deviceConfig["manufacturer"] = manufacturer;
deviceConfig["model"] = device;
}

ha_config_t() : ha_config_t(DEFAULT_BUFFER_SIZE) {}
Expand All @@ -94,9 +96,11 @@ struct ha_config_t {
JsonObject& deviceConfig;
JsonObject& root;

const String identifier;
const String name;
const String version;
String name;
const char* identifier;
const char* version;
const char* manufacturer;
const char* device;
};

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -396,11 +400,11 @@ void _haSensorYaml(unsigned char index, JsonObject& root) {
#endif // SENSOR_SUPPORT

void _haGetDeviceConfig(JsonObject& config) {
config.createNestedArray("identifiers").add(getIdentifier());
config.createNestedArray("identifiers").add(getIdentifier().c_str());
config["name"] = getSetting("desc", getSetting("hostname"));
config["manufacturer"] = getManufacturer().c_str();
config["model"] = getDevice().c_str();
config["sw_version"] = String(APP_NAME) + " " + APP_VERSION + " (" + getCoreVersion() + ")";
config["sw_version"] = getVersion().c_str();
}

void _haSend() {
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void mdnsServerSetup() {

// Public ESPurna related txt for OTA discovery
MDNS.addServiceTxt("arduino", "tcp", "app_name", APP_NAME);
MDNS.addServiceTxt("arduino", "tcp", "app_version", APP_VERSION);
MDNS.addServiceTxt("arduino", "tcp", "app_version", getVersion());
MDNS.addServiceTxt("arduino", "tcp", "build_date", buildTime());
MDNS.addServiceTxt("arduino", "tcp", "mac", WiFi.macAddress());
MDNS.addServiceTxt("arduino", "tcp", "target_board", getBoardName());
Expand Down
6,198 changes: 3,106 additions & 3,092 deletions code/espurna/static/index.all.html.gz.h

Large diffs are not rendered by default.

4,314 changes: 2,157 additions & 2,157 deletions code/espurna/static/index.curtain.html.gz.h

Large diffs are not rendered by default.

4,825 changes: 2,412 additions & 2,413 deletions code/espurna/static/index.garland.html.gz.h

Large diffs are not rendered by default.

5,056 changes: 2,528 additions & 2,528 deletions code/espurna/static/index.light.html.gz.h

Large diffs are not rendered by default.

4,862 changes: 2,431 additions & 2,431 deletions code/espurna/static/index.lightfox.html.gz.h

Large diffs are not rendered by default.

4,318 changes: 2,159 additions & 2,159 deletions code/espurna/static/index.rfbridge.html.gz.h

Large diffs are not rendered by default.

7,012 changes: 3,506 additions & 3,506 deletions code/espurna/static/index.rfm69.html.gz.h

Large diffs are not rendered by default.

4,408 changes: 2,204 additions & 2,204 deletions code/espurna/static/index.sensor.html.gz.h

Large diffs are not rendered by default.

4,214 changes: 2,107 additions & 2,107 deletions code/espurna/static/index.small.html.gz.h

Large diffs are not rendered by default.

4,288 changes: 2,144 additions & 2,144 deletions code/espurna/static/index.thermostat.html.gz.h

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions code/espurna/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const String& getManufacturer() {
}

String getBoardName() {
static const String defaultValue(F(DEVICE_NAME));
return getSetting("boardName", defaultValue);
return getSetting("boardName", F(DEVICE_NAME));
}

void setBoardName() {
Expand Down Expand Up @@ -107,6 +106,15 @@ const String& getCoreRevision() {
return revision;
}

const String& getVersion() {
#if defined(APP_REVISION)
static const String value(F(APP_VERSION " (" APP_REVISION ")"));
#else
static const String value(F(APP_VERSION));
#endif
return value;
}

int getHeartbeatMode() {
return getSetting("hbMode", HEARTBEAT_MODE);
}
Expand Down Expand Up @@ -341,7 +349,7 @@ void heartbeat() {
mqttSend(MQTT_TOPIC_APP, APP_NAME);

if (hb_cfg & Heartbeat::Version)
mqttSend(MQTT_TOPIC_VERSION, APP_VERSION);
mqttSend(MQTT_TOPIC_VERSION, getVersion().c_str());

if (hb_cfg & Heartbeat::Board)
mqttSend(MQTT_TOPIC_BOARD, getBoardName().c_str());
Expand Down Expand Up @@ -544,19 +552,15 @@ void info(bool first) {

// -------------------------------------------------------------------------

#if defined(APP_REVISION)
DEBUG_MSG_P(PSTR("[MAIN] " APP_NAME " " APP_VERSION " (" APP_REVISION ")\n"));
#else
DEBUG_MSG_P(PSTR("[MAIN] " APP_NAME " " APP_VERSION "\n"));
#endif
DEBUG_MSG_P(PSTR("[MAIN] " APP_NAME " %s\n"), getVersion().c_str());
DEBUG_MSG_P(PSTR("[MAIN] " APP_AUTHOR "\n"));
DEBUG_MSG_P(PSTR("[MAIN] " APP_WEBSITE "\n\n"));
DEBUG_MSG_P(PSTR("[MAIN] CPU chip ID: 0x%06X\n"), ESP.getChipId());
DEBUG_MSG_P(PSTR("[MAIN] CPU frequency: %u MHz\n"), ESP.getCpuFreqMHz());
DEBUG_MSG_P(PSTR("[MAIN] SDK version: %s\n"), ESP.getSdkVersion());
DEBUG_MSG_P(PSTR("[MAIN] Core version: %s\n"), getCoreVersion().c_str());
DEBUG_MSG_P(PSTR("[MAIN] Core revision: %s\n"), getCoreRevision().c_str());
DEBUG_MSG_P(PSTR("[MAIN] Build time: %lu\n"), __UNIX_TIMESTAMP__);
DEBUG_MSG_P(PSTR("[MAIN] Built: %s\n"), buildTime().c_str());
DEBUG_MSG_P(PSTR("\n"));

// -------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions code/espurna/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const String& getDevice();
const String& getManufacturer();
const String& getCoreVersion();
const String& getCoreRevision();
const String& getVersion();

int getHeartbeatMode();
unsigned long getHeartbeatInterval();
Expand Down
6 changes: 3 additions & 3 deletions code/espurna/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void _onDiscover(AsyncWebServerRequest *request) {
StaticJsonBuffer<JSON_OBJECT_SIZE(4)> jsonBuffer;
JsonObject &root = jsonBuffer.createObject();
root["app"] = APP_NAME;
root["version"] = APP_VERSION;
root["version"] = getVersion().c_str();
root["device"] = device.c_str();
root["hostname"] = hostname.c_str();

Expand All @@ -267,8 +267,8 @@ void _onGetConfig(AsyncWebServerRequest *request) {
response->addHeader("X-Content-Type-Options", "nosniff");
response->addHeader("X-Frame-Options", "deny");

response->printf("{\n\"app\": \"%s\"", APP_NAME);
response->printf(",\n\"version\": \"%s\"", APP_VERSION);
response->printf("{\n\"app\": \"" APP_NAME "\"");
response->printf(",\n\"version\": \"%s\"", getVersion().c_str());
response->printf(",\n\"backup\": \"1\"");
#if NTP_SUPPORT
response->printf(",\n\"timestamp\": \"%s\"", ntpDateTime().c_str());
Expand Down
5 changes: 1 addition & 4 deletions code/espurna/ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,8 @@ void _wsOnConnected(JsonObject& root) {
root["webMode"] = WEB_MODE_NORMAL;

root["app_name"] = APP_NAME;
root["app_version"] = APP_VERSION;
root["app_version"] = getVersion().c_str();
root["app_build"] = buildTime();
#if defined(APP_REVISION)
root["app_revision"] = APP_REVISION;
#endif
root["device"] = getDevice().c_str();
root["manufacturer"] = getManufacturer().c_str();
root["chipid"] = getChipId().c_str();
Expand Down
3 changes: 0 additions & 3 deletions code/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ <h2>Current configuration</h2>
<div class="pure-u-1-2">Firmware version</div>
<div class="pure-u-11-24"><span class="right" name="app_version"></span></div>

<div class="pure-u-1-2">Firmware revision</div>
<div class="pure-u-11-24"><span class="right" name="app_revision"></span></div>

<div class="pure-u-1-2">Firmware build date</div>
<div class="pure-u-11-24"><span class="right" name="app_build"></span></div>

Expand Down

0 comments on commit f0f6f1b

Please sign in to comment.