60 explicit WT32_ETH01(uint8_t ethmode) {
70 if (thisWtEth ==
this) {
75 static void networkEventHandler(arduino_event_id_t event) {
77 case ARDUINO_EVENT_ETH_GOT_IP: {
78 Serial.print(F(
"[Ethernet] local IP: "));
79 Serial.println(ETH.localIP());
80 Serial.print(F(
"subnetMask: "));
81 Serial.println(ETH.subnetMask());
82 Serial.print(F(
"gatewayIP: "));
83 Serial.println(ETH.gatewayIP());
84 Serial.print(F(
"ETH MAC: "));
85 Serial.println(ETH.macAddress());
86 if (ETH.fullDuplex()) {
87 Serial.print(F(
"FULL_DUPLEX , "));
89 Serial.print(ETH.linkSpeed());
90 Serial.println(F(
"Mbps"));
92 thisWtEth->setIpv4Addr(ETH.localIP());
96 case ARDUINO_EVENT_ETH_DISCONNECTED: {
97 Serial.println(F(
"[Ethernet] Disconnected"));
99 thisWtEth->setIpv4Addr(0);
106 void setup()
override {
112 Serial.println(F(
"[Ethernet] establishing LAN connection"));
113 ::Network.onEvent(WT32_ETH01::networkEventHandler);
122 char newHostname[32] = {};
123 generateHostname(hostname, macSizeForHostname, newHostname);
124 strncpy(hostname, newHostname,
sizeof(hostname) - 1);
125 SUPLA_LOG_DEBUG(
"[%s] Network AP/hostname: %s", getIntfName(), hostname);
126 ETH.setHostname(hostname);
129 void disable()
override {
134 allowDisable =
false;
135 SUPLA_LOG_DEBUG(
"[%s] disabling ETH connection", getIntfName());
136 DisconnectProtocols();
140 bool getMacAddr(uint8_t *mac)
override {
147 void setHostname(
const char *prefix,
int macSize)
override {
148 macSizeForHostname = macSize;
149 strncpy(hostname, prefix,
sizeof(hostname) - 1);
150 SUPLA_LOG_DEBUG(
"[%s] Network AP/hostname: %s", getIntfName(), hostname);
154 uint8_t ETH_ADDRESS = {};
155 bool allowDisable =
false;
156 int macSizeForHostname = 0;
157 bool initDone =
false;