-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconnectionEthernet.cpp
More file actions
57 lines (44 loc) · 1.03 KB
/
Copy pathconnectionEthernet.cpp
File metadata and controls
57 lines (44 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "connectionEthernet.h"
#include "UIPEthernet.h"
#include "debug.h"
/*
Wiring for ENC28J60 to NodeMCU Lolin V3 CH340
ENC ... NodeMCU
GND ... GND
VCC ... 3V3
RESET ... RST
CS ... D0 (GPIO16, WAKE)
SCK ... D5 (GPIO14, HSPI SCLK)
SO ... D6 (GPIO12, HSPI MISO)
SI ... D7 (GPIO13, HSPI MOSI)
*/
constexpr int PIN_CS = D0;
constexpr uint8_t g_ethMac[] = {0x5e,0xc0,0xde,0xba,0x5e,0x01};
bool ConnectionEthernet::initialize()
{
debug("Initialize Ethernet, CS Pin = ");
debugln(String(PIN_CS));
Ethernet.init(PIN_CS);
if(!Ethernet.begin(g_ethMac))
{
debugln("Ethernet.begin() failed");
if(Ethernet.hardwareStatus() == EthernetNoHardware)
{
debugln("No Ethernet hardware found");
return false;
}
debugln("Failed to get address via DHCP");
return false;
}
debug("My IP: ");
debugln(Ethernet.localIP().toString());
return Connection::initialize();
}
Client* ConnectionEthernet::getClient()
{
return new EthernetClient();
}
void ConnectionEthernet::loop()
{
Ethernet.maintain();
}