Skip to content

Commit 0209f80

Browse files
committed
Merge branch 'dev' into Arduino_1.5.x
Conflicts: README
2 parents 57a1447 + f5c84d4 commit 0209f80

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is UIPEthernet version 1.58
1+
This is UIPEthernet version 1.59
22

33
An plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS.
44
Just include 'UIPEthernet.h' instead of 'Ethernet.h' and use all your code written for the stock Arduino Ethernet lib!
@@ -28,7 +28,7 @@ On a Mac, you will want to create a folder named "libraries" in in the "Document
2828

2929
Or you download the zipped version of the library from https://github.com/ntruchsess/arduino_uip/releases, and copy the contained directory UIPEthernet to [path to Arduino distribution]\libraries\UIPEthernet.
3030

31-
If you are running Arduino-IDE 1.5.x use release-version 1.57 or checkout branch 'Arduino_1.5.5'
31+
If you are running Arduino-IDE 1.5.x use release-version 1.59 or checkout branch 'Arduino_1.5.x'
3232

3333
Additional information can be found on the Arduino website: http://www.arduino.cc/en/Hacking/Libraries
3434

UIPEthernet/src/UIPClient.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ UIPClient::flush()
329329
void
330330
uipclient_appcall(void)
331331
{
332+
uint16_t send_len = 0;
332333
uip_userdata_t *u = (uip_userdata_t*)uip_conn->appstate;
333334
if (!u && uip_connected())
334335
{
@@ -360,17 +361,16 @@ uipclient_appcall(void)
360361
#endif
361362
if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
362363
{
363-
memhandle newPacket = Enc28J60Network::allocBlock(uip_len);
364-
if (newPacket != NOBLOCK)
364+
for (uint8_t i=0; i < UIP_SOCKET_NUMPACKETS; i++)
365365
{
366-
for (uint8_t i=0; i < UIP_SOCKET_NUMPACKETS; i++)
366+
if (u->packets_in[i] == NOBLOCK)
367367
{
368-
if (u->packets_in[i] == NOBLOCK)
368+
u->packets_in[i] = Enc28J60Network::allocBlock(uip_len);
369+
if (u->packets_in[i] != NOBLOCK)
369370
{
371+
Enc28J60Network::copyPacket(u->packets_in[i],0,UIPEthernetClass::in_packet,((uint8_t*)uip_appdata)-uip_buf,uip_len);
370372
if (i == UIP_SOCKET_NUMPACKETS-1)
371373
uip_stop();
372-
Enc28J60Network::copyPacket(newPacket,0,UIPEthernetClass::in_packet,((uint8_t*)uip_appdata)-uip_buf,uip_len);
373-
u->packets_in[i] = newPacket;
374374
goto finish_newdata;
375375
}
376376
}
@@ -407,7 +407,7 @@ uipclient_appcall(void)
407407
UIPClient::_dumpAllData();
408408
#endif
409409
uip_conn->appstate = NULL;
410-
goto nodata;
410+
goto finish;
411411
}
412412
if (uip_acked())
413413
{
@@ -425,26 +425,25 @@ uipclient_appcall(void)
425425
{
426426
if (u->packets_out[1] == NOBLOCK)
427427
{
428-
uip_len = u->out_pos;
429-
if (uip_len > 0)
428+
send_len = u->out_pos;
429+
if (send_len > 0)
430430
{
431-
Enc28J60Network::resizeBlock(u->packets_out[0],0,uip_len);
431+
Enc28J60Network::resizeBlock(u->packets_out[0],0,send_len);
432432
}
433433
}
434434
else
435-
uip_len = Enc28J60Network::blockSize(u->packets_out[0]);
436-
if (uip_len > 0)
435+
send_len = Enc28J60Network::blockSize(u->packets_out[0]);
436+
if (send_len > 0)
437437
{
438438
UIPEthernetClass::uip_hdrlen = ((uint8_t*)uip_appdata)-uip_buf;
439-
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+uip_len);
439+
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+send_len);
440440
if (UIPEthernetClass::uip_packet != NOBLOCK)
441441
{
442-
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,uip_len);
442+
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,send_len);
443443
UIPEthernetClass::packetstate |= UIPETHERNET_SENDPACKET;
444-
uip_send(uip_appdata,uip_len);
445444
}
446-
return;
447445
}
446+
goto finish;
448447
}
449448
}
450449
// don't close connection unless all outgoing packets are sent
@@ -473,9 +472,9 @@ uipclient_appcall(void)
473472
}
474473
}
475474
}
476-
nodata:
477-
UIPEthernetClass::uip_packet = NOBLOCK;
478-
uip_len=0;
475+
finish:
476+
uip_send(uip_appdata,send_len);
477+
uip_len = send_len;
479478
}
480479

481480
uip_userdata_t *

UIPEthernet/src/UIPEthernet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ UIPEthernetClass::tick()
183183
Enc28J60Network::readPacket(in_packet,0,(uint8_t*)uip_buf,UIP_BUFSIZE);
184184
if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_IP))
185185
{
186-
uip_packet = in_packet;
186+
uip_packet = in_packet; //required for upper_layer_checksum of in_packet!
187187
#ifdef UIPETHERNET_DEBUG
188188
Serial.print(F("readPacket type IP, uip_len: "));
189189
Serial.println(uip_len);
@@ -220,7 +220,7 @@ UIPEthernetClass::tick()
220220
}
221221
}
222222

223-
unsigned long now = millis();
223+
unsigned long now = millis();
224224

225225
#if UIP_CLIENT_TIMER >= 0
226226
boolean periodic = (long)( now - periodic_timer ) >= 0;
@@ -291,6 +291,7 @@ boolean UIPEthernetClass::network_send()
291291
Serial.println(uip_hdrlen);
292292
#endif
293293
Enc28J60Network::writePacket(uip_packet,0,uip_buf,uip_hdrlen);
294+
packetstate &= ~ UIPETHERNET_SENDPACKET;
294295
goto sendandfree;
295296
}
296297
uip_packet = Enc28J60Network::allocBlock(uip_len);

UIPEthernet/src/utility/Enc28J60Network.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ Enc28J60Network::blockSize(memhandle handle)
243243
void
244244
Enc28J60Network::sendPacket(memhandle handle)
245245
{
246-
if (handle == NOBLOCK)
247-
return;
248246
memblock *packet = &blocks[handle];
249247
uint16_t start = packet->begin-1;
250248
uint16_t end = start + packet->size;

0 commit comments

Comments
 (0)