Report unique hostname in wifi api

This commit is contained in:
Martin Bauer 2021-07-26 14:35:25 +02:00
parent faa9b3324f
commit 1673dae523
3 changed files with 3 additions and 2 deletions

View File

@ -41,6 +41,7 @@ public:
State state() const { return state_; } State state() const { return state_; }
const char *stateStr() const { return stateToString(state_); } const char *stateStr() const { return stateToString(state_); }
const String & hostname() const { return hostname_; }
static const char *stateToString(State state); static const char *stateToString(State state);
private: private:

View File

@ -83,7 +83,6 @@ template <typename T>
bool SessionAPI<T>::handleMessage(websockets::WebsocketsClient &client, MessageCode code, bool SessionAPI<T>::handleMessage(websockets::WebsocketsClient &client, MessageCode code,
const char *payload, size_t size) const char *payload, size_t size)
{ {
Serial.println("Handling message in SessionAPI");
switch (code) switch (code)
{ {
case MessageCode::START_SESSION: case MessageCode::START_SESSION:

View File

@ -7,7 +7,8 @@ void WifiAPI::sendWifiState(websockets::WebsocketsClient &client)
{ {
StaticJsonDocument<128> data; StaticJsonDocument<128> data;
data["state"] = wifiManager_.stateStr(); data["state"] = wifiManager_.stateStr();
sendToClient<64>(client, MessageCode::WIFI_STATE_RESPONSE, data); data["hostname"] = wifiManager_.hostname();
sendToClient<192>(client, MessageCode::WIFI_STATE_RESPONSE, data);
} }
void WifiAPI::onClientConnect(websockets::WebsocketsClient &client) void WifiAPI::onClientConnect(websockets::WebsocketsClient &client)