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

Commit 5f1be82

Browse files
authored
Update Ethernet3 Library Patch
1 parent f9a8100 commit 5f1be82

File tree

5 files changed

+65
-22
lines changed

5 files changed

+65
-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.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Server.h - Base class that provides Server
3+
Copyright (c) 2011 Adrian McEwen. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef server_h
21+
#define server_h
22+
23+
#include "Print.h"
24+
25+
class Server: public Print
26+
{
27+
public:
28+
// KH, change to fix compiler error for EthernetWebServer
29+
// error: cannot declare field 'EthernetWebServer::_server' to be of abstract type 'EthernetServer'
30+
// virtual void begin(uint16_t port=0) =0;
31+
//virtual void begin() = 0;
32+
void begin() {};
33+
};
34+
35+
#endif

0 commit comments

Comments
 (0)