Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 0bc751e

Browse files
authored
Update Ethernet3 Library Patch
1 parent 8789cde commit 0bc751e

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

LibraryPatches/Ethernet2/src/Ethernet2.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ int EthernetClass::maintain(){
210210
return rc;
211211
}
212212

213+
// KH add to report link status
214+
uint8_t EthernetClass::link()
215+
{
216+
return bitRead(w5500.getPHYCFGR(), 0);
217+
}
218+
219+
const char* EthernetClass::linkReport()
220+
{
221+
if (bitRead(w5500.getPHYCFGR(), 0) == 1)
222+
return "LINK";
223+
else
224+
return "NO LINK";
225+
}
226+
//////
227+
213228
IPAddress EthernetClass::localIP()
214229
{
215230
IPAddress ret;

LibraryPatches/Ethernet2/src/Ethernet2.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class EthernetClass {
6262
#endif
6363

6464
int maintain();
65+
66+
// KH add to report link status
67+
uint8_t link(); // returns the linkstate, 1 = linked, 0 = no link
68+
const char* linkReport(); // returns the linkstate as a string
69+
//////
6570

6671
// KH add to have similar function to Ethernet lib
6772
// Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00.

LibraryPatches/Ethernet3/src/Ethernet3.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void EthernetClass::phyMode(phyMode_t mode) {
297297
w5500.setPHYCFGR(val);
298298
}
299299

300-
void EthernetClass::setHostname(char* hostname) {
300+
void EthernetClass::setHostname(const char* hostname) {
301301
memset(_customHostname, 0, 32);
302302
memcpy((void*)_customHostname, (void*)hostname, strlen(hostname) >= 31 ? 31 : strlen(hostname));
303303
}
@@ -327,12 +327,9 @@ uint8_t EthernetClass::speed()
327327

328328
if (bitRead(w5500.getPHYCFGR(), 1) == 0)
329329
return 10;
330-
331-
// KH add to fix compile error in some boards
332-
return 0;
333330
}
334-
else
335-
return 0;
331+
332+
return 0;
336333
}
337334

338335
const char* EthernetClass::speedReport()
@@ -344,12 +341,9 @@ const char* EthernetClass::speedReport()
344341

345342
if (bitRead(w5500.getPHYCFGR(), 1) == 0)
346343
return "10 MB";
347-
348-
// KH add to fix compile error in some boards
349-
return "NO LINK";
350344
}
351-
else
352-
return "NO LINK";
345+
346+
return "NO LINK";
353347
}
354348

355349
uint8_t EthernetClass::duplex()
@@ -361,12 +355,9 @@ uint8_t EthernetClass::duplex()
361355

362356
if (bitRead(w5500.getPHYCFGR(), 2) == 0)
363357
return 1;
364-
365-
// KH add to fix compile error in some boards
366-
return 0;
367358
}
368-
else
369-
return 0;
359+
360+
return 0;
370361
}
371362

372363
const char* EthernetClass::duplexReport()
@@ -378,12 +369,9 @@ const char* EthernetClass::duplexReport()
378369

379370
if (bitRead(w5500.getPHYCFGR(), 2) == 0)
380371
return "HALF DUPLEX";
381-
382-
// KH add to fix compile error in some boards
383-
return "NO LINK";
384372
}
385-
else
386-
return "NO LINK";
373+
374+
return "NO LINK";
387375
}
388376

389377
void EthernetClass::setRtTimeOut(uint16_t timeout) {

LibraryPatches/Ethernet3/src/Ethernet3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class EthernetClass {
103103
void macAddress(uint8_t mac[]); // get the MAC Address
104104
const char* macAddressReport(); // returns the the MAC Address as a string
105105

106-
void setHostname(char* hostname);
106+
void setHostname(const char* hostname);
107107

108108
// KH add to have similar function to Ethernet lib
109109
// Certainly we can use void macAddress(uint8_t mac[]) to read from W5x00.

0 commit comments

Comments
 (0)