@@ -21,60 +21,33 @@ class EthernetClass: public NetworkInterface
2121 EthernetClass () {}
2222 virtual ~EthernetClass () {}
2323
24- int begin (bool blocking = true , uint32_t additional_event_mask = 0 ) {
25- hardwareStatus ();
26- return NetworkInterface::begin (blocking, additional_event_mask);
27- }
28-
29- int begin (uint8_t *mac, unsigned long timeout = 60000 , unsigned long responseTimeout = 4000 ) {
30- hardwareStatus ();
31- if (mac != nullptr ) {
32- NetworkInterface::setMACAddress (mac);
33- }
34- return NetworkInterface::begin (true , 0 );
35- }
36-
37- int maintain (); // TODO
38-
39- EthernetLinkStatus linkStatus () {
40- hardwareStatus ();
41- if (net_if_is_up (netif)) {
42- return LinkON;
43- } else {
44- return LinkOFF;
45- }
46- }
47-
48- EthernetHardwareStatus hardwareStatus () {
49- const struct device *const dev = DEVICE_DT_GET (DT_COMPAT_GET_ANY_STATUS_OKAY (ethernet_phy));
50- if (device_is_ready (dev)) {
51- for (int i = 1 ; i < 3 ; i++) {
52- auto _if = net_if_get_by_index (i);
53- if (!net_eth_type_is_wifi (_if)) {
54- netif = _if;
55- break ;
56- }
57- }
58- return EthernetOk;
59- } else {
60- return EthernetNoHardware;
61- }
62- }
63-
64- int begin (uint8_t *mac, IPAddress ip) {
65- return begin (); // TODO
66- }
67- int begin (uint8_t *mac, IPAddress ip, IPAddress dns) {
68- return begin (); // TODO
69- }
70- int begin (uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway) {
71- return begin (); // TODO
72- }
73- int begin (uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) {
74- return begin (); // TODO
75- }
76- void init (uint8_t sspin = 10 ); // TODO
24+ int begin (uint8_t *mac, unsigned long timeout = 60000 , unsigned long responseTimeout = 4000 );
25+ int maintain ();
26+ EthernetLinkStatus linkStatus ();
27+ EthernetHardwareStatus hardwareStatus ();
28+
29+ // Manual configuration
30+ int begin (uint8_t *mac, IPAddress ip);
31+ int begin (uint8_t *mac, IPAddress ip, IPAddress dns);
32+ int begin (uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
33+ int begin (uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, unsigned long timeout = 60000 , unsigned long responseTimeout = 4000 );
34+ void init (uint8_t sspin = 10 );
35+
36+ void MACAddress (uint8_t *mac_address);
37+ IPAddress localIP ();
38+ IPAddress subnetMask ();
39+ IPAddress gatewayIP ();
40+ IPAddress dnsServerIP ();
41+
42+ void setMACAddress (const uint8_t *mac_address);
43+ void setLocalIP (const IPAddress local_ip);
44+ void setSubnetMask (const IPAddress subnet);
45+ void setGatewayIP (const IPAddress gateway);
46+ void setDnsServerIP (const IPAddress dns_server);
47+ void setRetransmissionTimeout (uint16_t milliseconds);
48+ void setRetransmissionCount (uint8_t num);
7749};
50+
7851extern EthernetClass Ethernet;
7952
8053#endif
0 commit comments