Skip to content

Commit

Permalink
add network device name to sysinfo page
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Feb 5, 2023
1 parent 8580857 commit ff62368
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ bool Network::encryptionSupported()
return _device->supportsEncryption();
}

const String Network::networkDeviceName() const
{
return _device->deviceName();
}

void Network::publishFloat(const char* prefix, const char* topic, const float value, const uint8_t precision)
{
char str[30];
Expand Down
1 change: 1 addition & 0 deletions Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Network

int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
bool encryptionSupported();
const String networkDeviceName() const;

const NetworkDeviceType networkDeviceType();

Expand Down
4 changes: 4 additions & 0 deletions WebCfgServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ void WebCfgServer::buildInfoHtml(String &response)
response.concat(_nukiOpener->isPaired() ? _nukiOpener->isPinSet() ? "Yes\n" : "No\n" : "-\n");
}

response.concat("Network device: ");
response.concat(_network->networkDeviceName());
response.concat("\n");

response.concat("Heap: ");
response.concat(esp_get_free_heap_size());
response.concat("\n");
Expand Down
2 changes: 2 additions & 0 deletions networkDevices/NetworkDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class NetworkDevice
: _hostname(hostname)
{}

virtual const String deviceName() const = 0;

virtual void initialize() = 0;
virtual ReconnectStatus reconnect() = 0;
virtual void reconfigure() = 0;
Expand Down
5 changes: 5 additions & 0 deletions networkDevices/W5500Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ W5500Device::W5500Device(const String &hostname, Preferences* preferences, int v
W5500Device::~W5500Device()
{}

const String W5500Device::deviceName() const
{
return "Wiznet W5500";
}

void W5500Device::initialize()
{
WiFi.mode(WIFI_OFF);
Expand Down
2 changes: 2 additions & 0 deletions networkDevices/W5500Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class W5500Device : public NetworkDevice
explicit W5500Device(const String& hostname, Preferences* _preferences, int variant);
~W5500Device();

const String deviceName() const override;

virtual void initialize();
virtual ReconnectStatus reconnect();
virtual void reconfigure();
Expand Down
5 changes: 5 additions & 0 deletions networkDevices/WifiDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
}
}

const String WifiDevice::deviceName() const
{
return "Built-in Wifi";
}

void WifiDevice::initialize()
{
std::vector<const char *> wm_menu;
Expand Down
2 changes: 2 additions & 0 deletions networkDevices/WifiDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class WifiDevice : public NetworkDevice
public:
WifiDevice(const String& hostname, Preferences* _preferences);

const String deviceName() const override;

virtual void initialize();
virtual void reconfigure();
virtual ReconnectStatus reconnect();
Expand Down

0 comments on commit ff62368

Please sign in to comment.