-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathEthernetC33.h
77 lines (61 loc) · 2.35 KB
/
EthernetC33.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef ARDUINO_C_ETHERNET_H
#define ARDUINO_C_ETHERNET_H
#ifndef ARDUINO_PORTENTA_C33
// force discovering wth shield library
// this doesn't work ATM
// a check and a bailout should be added to all the other files too
#include "utility/w5100.h"
#endif
#include <inttypes.h>
#include "IPAddress.h"
#include "EthernetClient.h"
#include "EthernetServer.h"
#include "CNetIf.h"
#include "lwipMem.h"
enum EthernetLinkStatus {
Unknown,
LinkON,
LinkOFF
};
enum EthernetHardwareStatus {
EthernetNoHardware,
EthernetLwip = 7
};
class CEthernet {
private:
CNetIf *ni;
uint8_t mac_address[6];
public:
// Initialise the Ethernet with the internal provided MAC address and gain the rest of the
// configuration through DHCP.
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
int begin(unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
EthernetLinkStatus linkStatus();
int begin(IPAddress local_ip);
int begin(IPAddress local_ip, IPAddress subnet);
int begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway);
int begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server);
// Initialise the Ethernet shield to use the provided MAC address and gain the rest of the
// configuration through DHCP.
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
int begin(uint8_t *mac_address, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
int begin(uint8_t *mac_address, IPAddress local_ip);
int begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
int begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
int begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
EthernetHardwareStatus hardwareStatus();
void setDNS(IPAddress dns_server);
void setDNS(IPAddress dns_server1, IPAddress dns_server2);
int disconnect(void);
int maintain();
void schedule(void);
uint8_t *MACAddress(void);
IPAddress localIP();
IPAddress subnetMask();
IPAddress gatewayIP();
IPAddress dnsServerIP();
friend class EthernetClient;
friend class EthernetServer;
};
extern CEthernet Ethernet;
#endif