@@ -51,6 +51,7 @@ NetManagerTask::NetManagerTask(LcdTask &lcd, LedManagerTask &led, TimeManager &t
51
51
_apClients(0 ),
52
52
_state(NetState::Starting),
53
53
_ipaddress(" " ),
54
+ _macaddress(" " ),
54
55
_clientDisconnects(0 ),
55
56
_clientRetry(false ),
56
57
_clientRetryTime(0 ),
@@ -118,6 +119,7 @@ void NetManagerTask::wifiStartAccessPoint()
118
119
char tmpStr[40 ];
119
120
sprintf (tmpStr, " %d.%d.%d.%d" , myIP[0 ], myIP[1 ], myIP[2 ], myIP[3 ]);
120
121
_ipaddress = tmpStr;
122
+ _macaddress = WiFi.macAddress ();
121
123
122
124
DEBUG.printf (" AP IP Address: %s\n " , tmpStr);
123
125
DEBUG.printf (" Channel: %d\n " , WiFi.channel ());
@@ -187,6 +189,7 @@ void NetManagerTask::haveNetworkConnection(IPAddress myAddress)
187
189
char tmpStr[40 ];
188
190
sprintf (tmpStr, " %d.%d.%d.%d" , myAddress[0 ], myAddress[1 ], myAddress[2 ], myAddress[3 ]);
189
191
_ipaddress = tmpStr;
192
+ _macaddress = WiFi.macAddress ();
190
193
191
194
DEBUG.print (" Connected, IP: " );
192
195
DEBUG.println (tmpStr);
@@ -210,11 +213,13 @@ void NetManagerTask::wifiOnStationModeConnected(const WiFiEventStationModeConnec
210
213
void NetManagerTask::wifiOnStationModeGotIP (const WiFiEventStationModeGotIP &event)
211
214
{
212
215
haveNetworkConnection (WiFi.localIP ());
216
+ _macaddress = WiFi.macAddress ();
213
217
StaticJsonDocument<128 > doc;
214
218
doc[" wifi_client_connected" ] = (int )net.isWifiClientConnected ();
215
219
doc[" eth_connected" ] = (int )net.isWiredConnected ();
216
220
doc[" net_connected" ] = (int )net.isWifiClientConnected ();
217
221
doc[" ipaddress" ] = net.getIp ();
222
+ doc[" macaddress" ] = net.getMac ();
218
223
event_send (doc);
219
224
220
225
// Clear any error state
@@ -467,6 +472,7 @@ void NetManagerTask::onNetEvent(WiFiEvent_t event, arduino_event_info_t &info)
467
472
DBUG (ETH.linkSpeed ());
468
473
DBUGLN (" Mbps" );
469
474
haveNetworkConnection (ETH.localIP ());
475
+ _macaddress = ETH.macAddress ();
470
476
_ethConnected = true ;
471
477
wifiStop ();
472
478
break ;
0 commit comments