Skip to content

Commit

Permalink
Merge branch 'dev' into Arduino_1.5.x
Browse files Browse the repository at this point in the history
Conflicts:
	README
  • Loading branch information
ntruchsess committed Oct 13, 2014
2 parents 57a1447 + f5c84d4 commit 0209f80
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is UIPEthernet version 1.58
This is UIPEthernet version 1.59

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.
Just include 'UIPEthernet.h' instead of 'Ethernet.h' and use all your code written for the stock Arduino Ethernet lib!
Expand Down Expand Up @@ -28,7 +28,7 @@ On a Mac, you will want to create a folder named "libraries" in in the "Document

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.

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

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

Expand Down
37 changes: 18 additions & 19 deletions UIPEthernet/src/UIPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ UIPClient::flush()
void
uipclient_appcall(void)
{
uint16_t send_len = 0;
uip_userdata_t *u = (uip_userdata_t*)uip_conn->appstate;
if (!u && uip_connected())
{
Expand Down Expand Up @@ -360,17 +361,16 @@ uipclient_appcall(void)
#endif
if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
{
memhandle newPacket = Enc28J60Network::allocBlock(uip_len);
if (newPacket != NOBLOCK)
for (uint8_t i=0; i < UIP_SOCKET_NUMPACKETS; i++)
{
for (uint8_t i=0; i < UIP_SOCKET_NUMPACKETS; i++)
if (u->packets_in[i] == NOBLOCK)
{
if (u->packets_in[i] == NOBLOCK)
u->packets_in[i] = Enc28J60Network::allocBlock(uip_len);
if (u->packets_in[i] != NOBLOCK)
{
Enc28J60Network::copyPacket(u->packets_in[i],0,UIPEthernetClass::in_packet,((uint8_t*)uip_appdata)-uip_buf,uip_len);
if (i == UIP_SOCKET_NUMPACKETS-1)
uip_stop();
Enc28J60Network::copyPacket(newPacket,0,UIPEthernetClass::in_packet,((uint8_t*)uip_appdata)-uip_buf,uip_len);
u->packets_in[i] = newPacket;
goto finish_newdata;
}
}
Expand Down Expand Up @@ -407,7 +407,7 @@ uipclient_appcall(void)
UIPClient::_dumpAllData();
#endif
uip_conn->appstate = NULL;
goto nodata;
goto finish;
}
if (uip_acked())
{
Expand All @@ -425,26 +425,25 @@ uipclient_appcall(void)
{
if (u->packets_out[1] == NOBLOCK)
{
uip_len = u->out_pos;
if (uip_len > 0)
send_len = u->out_pos;
if (send_len > 0)
{
Enc28J60Network::resizeBlock(u->packets_out[0],0,uip_len);
Enc28J60Network::resizeBlock(u->packets_out[0],0,send_len);
}
}
else
uip_len = Enc28J60Network::blockSize(u->packets_out[0]);
if (uip_len > 0)
send_len = Enc28J60Network::blockSize(u->packets_out[0]);
if (send_len > 0)
{
UIPEthernetClass::uip_hdrlen = ((uint8_t*)uip_appdata)-uip_buf;
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+uip_len);
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+send_len);
if (UIPEthernetClass::uip_packet != NOBLOCK)
{
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,uip_len);
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,send_len);
UIPEthernetClass::packetstate |= UIPETHERNET_SENDPACKET;
uip_send(uip_appdata,uip_len);
}
return;
}
goto finish;
}
}
// don't close connection unless all outgoing packets are sent
Expand Down Expand Up @@ -473,9 +472,9 @@ uipclient_appcall(void)
}
}
}
nodata:
UIPEthernetClass::uip_packet = NOBLOCK;
uip_len=0;
finish:
uip_send(uip_appdata,send_len);
uip_len = send_len;
}

uip_userdata_t *
Expand Down
5 changes: 3 additions & 2 deletions UIPEthernet/src/UIPEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ UIPEthernetClass::tick()
Enc28J60Network::readPacket(in_packet,0,(uint8_t*)uip_buf,UIP_BUFSIZE);
if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_IP))
{
uip_packet = in_packet;
uip_packet = in_packet; //required for upper_layer_checksum of in_packet!
#ifdef UIPETHERNET_DEBUG
Serial.print(F("readPacket type IP, uip_len: "));
Serial.println(uip_len);
Expand Down Expand Up @@ -220,7 +220,7 @@ UIPEthernetClass::tick()
}
}

unsigned long now = millis();
unsigned long now = millis();

#if UIP_CLIENT_TIMER >= 0
boolean periodic = (long)( now - periodic_timer ) >= 0;
Expand Down Expand Up @@ -291,6 +291,7 @@ boolean UIPEthernetClass::network_send()
Serial.println(uip_hdrlen);
#endif
Enc28J60Network::writePacket(uip_packet,0,uip_buf,uip_hdrlen);
packetstate &= ~ UIPETHERNET_SENDPACKET;
goto sendandfree;
}
uip_packet = Enc28J60Network::allocBlock(uip_len);
Expand Down
2 changes: 0 additions & 2 deletions UIPEthernet/src/utility/Enc28J60Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ Enc28J60Network::blockSize(memhandle handle)
void
Enc28J60Network::sendPacket(memhandle handle)
{
if (handle == NOBLOCK)
return;
memblock *packet = &blocks[handle];
uint16_t start = packet->begin-1;
uint16_t end = start + packet->size;
Expand Down

0 comments on commit 0209f80

Please sign in to comment.