Add network information

Add network information to display start screen (#3704)
This commit is contained in:
Theo Arends 2018-09-05 15:38:48 +02:00
parent eaff296262
commit 36242e0e02
4 changed files with 26 additions and 9 deletions

View File

@ -2,6 +2,7 @@
* Rewrite energy monitoring using energy sensor driver modules
* Add Wifi channel number to state message (#3664)
* Add support for Shelly 1 and basic support for Shelly 2 - No energy monitoring yet (#2789)
* Add network information to display start screen (#3704)
*
* 6.2.1 20180905
* Fix possible ambiguity on command parameters if StateText contains numbers only (#3656)

View File

@ -204,7 +204,7 @@ enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MA
enum XsnsFunctions {FUNC_PRE_INIT, FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND, FUNC_PREP_BEFORE_TELEPERIOD,
FUNC_JSON_APPEND, FUNC_WEB_APPEND, FUNC_SAVE_BEFORE_RESTART, FUNC_COMMAND, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SHOW_SENSOR,
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM};
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_DISPLAY, FUNC_FREE_MEM};
const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 };

View File

@ -2540,19 +2540,19 @@ void setup()
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
AddLog(LOG_LEVEL_DEBUG);
GpioInit();
SetSerialBaudrate(baudrate);
Format(mqtt_client, Settings.mqtt_client, sizeof(mqtt_client));
Format(mqtt_topic, Settings.mqtt_topic, sizeof(mqtt_topic));
if (strstr(Settings.hostname, "%")) {
strlcpy(Settings.hostname, WIFI_HOSTNAME, sizeof(Settings.hostname));
snprintf_P(my_hostname, sizeof(my_hostname)-1, Settings.hostname, mqtt_topic, ESP.getChipId() & 0x1FFF);
} else {
snprintf_P(my_hostname, sizeof(my_hostname)-1, Settings.hostname);
}
GpioInit();
SetSerialBaudrate(baudrate);
WifiConnect();
if (MOTOR == Settings.module) Settings.poweronstate = POWER_ALL_ON; // Needs always on else in limbo!

View File

@ -626,11 +626,24 @@ void DisplayLogBufferInit()
DisplayReAllocLogBuffer();
char buffer[20];
char buffer[40];
snprintf_P(buffer, sizeof(buffer), PSTR(D_VERSION " %s"), my_version);
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR("Display mode %d"), Settings.display_mode);
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR(D_CMND_HOSTNAME " %s"), my_hostname);
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_SSID " %s"), Settings.sta_ssid[Settings.sta_active]);
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_MAC " %s"), WiFi.macAddress().c_str());
DisplayLogBufferAdd(buffer);
if (!global_state.wifi_down && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
snprintf_P(buffer, sizeof(buffer), PSTR("IP %s"), WiFi.localIP().toString().c_str());
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_RSSI " %d%%"), WifiGetRssiAsQuality(WiFi.RSSI()));
DisplayLogBufferAdd(buffer);
}
}
}
@ -915,8 +928,8 @@ boolean DisplayCommand()
if (last_display_mode && !Settings.display_mode) { // Switch to mode 0
DisplayInit(DISPLAY_INIT_MODE);
DisplayClear();
}
if (!last_display_mode && Settings.display_mode) { // Switch to non mode 0
} else {
// if (!last_display_mode && Settings.display_mode) { // Switch to non mode 0
DisplayLogBufferInit();
DisplayInit(DISPLAY_INIT_MODE);
}
@ -1047,6 +1060,9 @@ boolean Xdrv13(byte function)
case FUNC_PRE_INIT:
DisplayInitDriver();
break;
case FUNC_DISPLAY:
DisplayLogBufferAdd(log_data);
break;
case FUNC_EVERY_50_MSECOND:
if (Settings.display_model) { XdspCall(FUNC_DISPLAY_EVERY_50_MSECOND); }
break;