Browse Source

Build-time default value for hostname

rfm69
Maxim Prokhorov 6 years ago
parent
commit
922096e9da
3 changed files with 14 additions and 1 deletions
  1. +5
    -0
      code/espurna/config/defaults.h
  2. +1
    -1
      code/espurna/espurna.ino
  3. +8
    -0
      code/espurna/utils.ino

+ 5
- 0
code/espurna/config/defaults.h View File

@ -399,6 +399,11 @@
// General
// -----------------------------------------------------------------------------
// Default hostname will be ESPURNA_XXXXXX, where XXXXXX is last 3 octets of chipID
#ifndef HOSTNAME
#define HOSTNAME ""
#endif
// Needed for ESP8285 boards under Windows using PlatformIO (?)
#ifndef BUTTON_PUSHBUTTON
#define BUTTON_PUSHBUTTON 0


+ 1
- 1
code/espurna/espurna.ino View File

@ -50,7 +50,7 @@ void setup() {
// Hostname & board name initialization
if (getSetting("hostname").length() == 0) {
setSetting("hostname", getIdentifier());
setDefaultHostname();
}
setBoardName();


+ 8
- 0
code/espurna/utils.ino View File

@ -15,6 +15,14 @@ String getIdentifier() {
return String(buffer);
}
void setDefaultHostname() {
if (strlen(HOSTNAME) > 0) {
setSetting("hostname", HOSTNAME);
} else {
setSetting("hostname", getIdentifier());
}
}
void setBoardName() {
#ifndef ESPURNA_CORE
setSetting("boardName", DEVICE_NAME);


Loading…
Cancel
Save