@@ -30,6 +30,7 @@ extern "C"
30
30
31
31
#define ETH_HDR ((struct uip_eth_hdr *)&uip_buf[0 ])
32
32
33
+ bool UIPEthernetClass::initialized = false ;
33
34
memhandle UIPEthernetClass::in_packet (NOBLOCK);
34
35
memhandle UIPEthernetClass::uip_packet (NOBLOCK);
35
36
uint8_t UIPEthernetClass::uip_hdrlen (0 );
@@ -131,13 +132,14 @@ int UIPEthernetClass::maintain(){
131
132
132
133
EthernetLinkStatus UIPEthernetClass::linkStatus ()
133
134
{
134
- if (!Enc28J60Network::getrev ())
135
+ if (!(initialized && Enc28J60Network::getrev () ))
135
136
return Unknown;
136
137
return Enc28J60Network::linkStatus () ? LinkON : LinkOFF;
137
138
}
138
139
139
- EthernetHardwareStatus UIPEthernetClass::hardwareStatus () {
140
- if (!Enc28J60Network::getrev ())
140
+ EthernetHardwareStatus UIPEthernetClass::hardwareStatus ()
141
+ {
142
+ if (!(initialized && Enc28J60Network::getrev ()))
141
143
return EthernetNoHardware;
142
144
return EthernetENC28J60;
143
145
}
@@ -174,6 +176,8 @@ IPAddress UIPEthernetClass::dnsServerIP()
174
176
void
175
177
UIPEthernetClass::tick ()
176
178
{
179
+ if (!initialized)
180
+ return ;
177
181
if (in_packet == NOBLOCK)
178
182
{
179
183
in_packet = Enc28J60Network::receivePacket ();
@@ -331,7 +335,7 @@ boolean UIPEthernetClass::network_send()
331
335
void UIPEthernetClass::init (const uint8_t * mac) {
332
336
periodic_timer = millis () + UIP_PERIODIC_TIMER;
333
337
334
- Enc28J60Network::init ((uint8_t *)mac);
338
+ initialized = Enc28J60Network::init ((uint8_t *)mac);
335
339
uip_seteth_addr (mac);
336
340
337
341
uip_init ();
@@ -353,9 +357,6 @@ void UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway,
353
357
_dnsServerAddress = dns;
354
358
}
355
359
356
- UIPEthernetClass Ethernet;
357
- #define UIPEthernet Ethernet
358
-
359
360
/* ---------------------------------------------------------------------------*/
360
361
uint16_t
361
362
UIPEthernetClass::chksum (uint16_t sum, const uint8_t *data, uint16_t len)
@@ -480,21 +481,23 @@ uip_tcpchksum(void)
480
481
uint16_t
481
482
uip_ipchksum (void )
482
483
{
483
- return UIPEthernet. ipchksum ();
484
+ return UIPEthernetClass:: ipchksum ();
484
485
}
485
486
486
487
#if UIP_UDP
487
488
uint16_t
488
489
uip_tcpchksum (void )
489
490
{
490
- uint16_t sum = UIPEthernet. upper_layer_chksum (UIP_PROTO_TCP);
491
+ uint16_t sum = UIPEthernetClass:: upper_layer_chksum (UIP_PROTO_TCP);
491
492
return sum;
492
493
}
493
494
494
495
uint16_t
495
496
uip_udpchksum (void )
496
497
{
497
- uint16_t sum = UIPEthernet. upper_layer_chksum (UIP_PROTO_UDP);
498
+ uint16_t sum = UIPEthernetClass:: upper_layer_chksum (UIP_PROTO_UDP);
498
499
return sum;
499
500
}
500
501
#endif
502
+
503
+ UIPEthernetClass Ethernet;
0 commit comments