@@ -51,6 +51,7 @@ NetManagerTask::NetManagerTask(LcdTask &lcd, LedManagerTask &led, TimeManager &t
5151 _apClients(0 ),
5252 _state(NetState::Starting),
5353 _ipaddress(" " ),
54+ _macaddress(" " ),
5455 _clientDisconnects(0 ),
5556 _clientRetry(false ),
5657 _clientRetryTime(0 ),
@@ -118,6 +119,7 @@ void NetManagerTask::wifiStartAccessPoint()
118119 char tmpStr[40 ];
119120 sprintf (tmpStr, " %d.%d.%d.%d" , myIP[0 ], myIP[1 ], myIP[2 ], myIP[3 ]);
120121 _ipaddress = tmpStr;
122+ _macaddress = WiFi.macAddress ();
121123
122124 DEBUG.printf (" AP IP Address: %s\n " , tmpStr);
123125 DEBUG.printf (" Channel: %d\n " , WiFi.channel ());
@@ -187,6 +189,7 @@ void NetManagerTask::haveNetworkConnection(IPAddress myAddress)
187189 char tmpStr[40 ];
188190 sprintf (tmpStr, " %d.%d.%d.%d" , myAddress[0 ], myAddress[1 ], myAddress[2 ], myAddress[3 ]);
189191 _ipaddress = tmpStr;
192+ _macaddress = WiFi.macAddress ();
190193
191194 DEBUG.print (" Connected, IP: " );
192195 DEBUG.println (tmpStr);
@@ -210,11 +213,13 @@ void NetManagerTask::wifiOnStationModeConnected(const WiFiEventStationModeConnec
210213void NetManagerTask::wifiOnStationModeGotIP (const WiFiEventStationModeGotIP &event)
211214{
212215 haveNetworkConnection (WiFi.localIP ());
216+ _macaddress = WiFi.macAddress ();
213217 StaticJsonDocument<128 > doc;
214218 doc[" wifi_client_connected" ] = (int )net.isWifiClientConnected ();
215219 doc[" eth_connected" ] = (int )net.isWiredConnected ();
216220 doc[" net_connected" ] = (int )net.isWifiClientConnected ();
217221 doc[" ipaddress" ] = net.getIp ();
222+ doc[" macaddress" ] = net.getMac ();
218223 event_send (doc);
219224
220225 // Clear any error state
@@ -467,6 +472,7 @@ void NetManagerTask::onNetEvent(WiFiEvent_t event, arduino_event_info_t &info)
467472 DBUG (ETH.linkSpeed ());
468473 DBUGLN (" Mbps" );
469474 haveNetworkConnection (ETH.localIP ());
475+ _macaddress = ETH.macAddress ();
470476 _ethConnected = true ;
471477 wifiStop ();
472478 break ;
0 commit comments