Skip to content

Commit 3e11bbb

Browse files
committed
Merge branch 'master' into Arduino_1.5.5
2 parents 1cec7c6 + 9fbcf47 commit 3e11bbb

File tree

4 files changed

+44
-31
lines changed

4 files changed

+44
-31
lines changed

UIPEthernet/src/UIPClient.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,13 @@ UIPClient::_eatBlock(memhandle* block)
520520
memhandle* start = block;
521521
Serial.print(F("eatblock("));
522522
Serial.print(*block);
523-
Serial.print("): ");
523+
Serial.print(F("): "));
524524
for (uint8_t i = 0; i < UIP_SOCKET_NUMPACKETS; i++)
525525
{
526526
Serial.print(start[i]);
527-
Serial.print(" ");
527+
Serial.print(F(" "));
528528
}
529-
Serial.print("-> ");
529+
Serial.print(F("-> "));
530530
#endif
531531
memhandle* end = block+(UIP_SOCKET_NUMPACKETS-1);
532532
UIPEthernet.network.freeBlock(*block);

UIPEthernet/src/UIPEthernet.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "HardwareSerial.h"
2626
#endif
2727

28+
#include "UIPUdp.h"
29+
2830
extern "C"
2931
{
3032
#include "utility/uip-conf.h"
@@ -234,7 +236,7 @@ UIPEthernetClass::tick()
234236
// uip_len is set to a value > 0. */
235237
if (uip_len > 0)
236238
{
237-
network_send();
239+
UIPUDP::_send((uip_udp_userdata_t *)(uip_udp_conns[i].appstate));
238240
}
239241
}
240242
#endif /* UIP_UDP */
@@ -281,6 +283,7 @@ void UIPEthernetClass::init(const uint8_t* mac) {
281283
uip_seteth_addr(mac);
282284

283285
uip_init();
286+
uip_arp_init();
284287
}
285288

286289
void UIPEthernetClass::configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) {

UIPEthernet/src/UIPUdp.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ UIPUDP::endPacket()
187187
uip_udp_periodic_conn(_uip_udp_conn);
188188
if (uip_len > 0)
189189
{
190-
UIPEthernet.network_send();
190+
_send(&appdata);
191191
return 1;
192192
}
193193
}
@@ -352,7 +352,7 @@ uipudp_appcall(void) {
352352

353353
void
354354
UIPUDP::uip_callback() {
355-
if (appdata_t *data = (appdata_t *)(uip_udp_conn->appstate))
355+
if (uip_udp_userdata_t *data = (uip_udp_userdata_t *)(uip_udp_conn->appstate))
356356
{
357357
if (uip_newdata())
358358
{
@@ -396,29 +396,34 @@ UIPUDP::uip_callback() {
396396
Serial.println(UIPEthernet.network.blockSize(data->packet_out));
397397
#endif
398398
UIPEthernet.uip_packet = data->packet_out;
399-
data->packet_out = NOBLOCK;
400399
UIPEthernet.uip_hdrlen = UIP_UDP_PHYH_LEN;
401-
UIPEthernet.packetstate |= UIPETHERNET_SENDPACKET;
402400
uip_udp_send(data->out_pos - (UIP_UDP_PHYH_LEN));
403-
uip_process(UIP_UDP_SEND_CONN); //generate udp + ip headers
404-
uip_arp_out(); //add arp
405-
if (uip_len == UIP_ARPHDRSIZE)
406-
{
407-
UIPEthernet.packetstate &= ~UIPETHERNET_SENDPACKET;
401+
}
402+
}
403+
}
404+
405+
void
406+
UIPUDP::_send(uip_udp_userdata_t *data) {
407+
uip_arp_out(); //add arp
408+
if (uip_len == UIP_ARPHDRSIZE)
409+
{
410+
UIPEthernet.uip_packet = NOBLOCK;
411+
UIPEthernet.packetstate &= ~UIPETHERNET_SENDPACKET;
408412
#ifdef UIPETHERNET_DEBUG_UDP
409-
Serial.println(F("udp, uip_poll results in ARP-packet"));
413+
Serial.println(F("udp, uip_poll results in ARP-packet"));
410414
#endif
411-
}
412-
else
413-
//arp found ethaddr for ip (otherwise packet is replaced by arp-request)
414-
{
415-
data->send = false;
415+
}
416+
else
417+
//arp found ethaddr for ip (otherwise packet is replaced by arp-request)
418+
{
419+
data->send = false;
420+
data->packet_out = NOBLOCK;
421+
UIPEthernet.packetstate |= UIPETHERNET_SENDPACKET;
416422
#ifdef UIPETHERNET_DEBUG_UDP
417-
Serial.print(F("udp, uip_packet to send: "));
418-
Serial.println(UIPEthernet.uip_packet);
423+
Serial.print(F("udp, uip_packet to send: "));
424+
Serial.println(UIPEthernet.uip_packet);
419425
#endif
420-
}
421-
}
422426
}
427+
UIPEthernet.network_send();
423428
}
424429
#endif

UIPEthernet/src/UIPUdp.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ extern "C" {
3535
#define UIP_UDP_NUMPACKETS 5
3636
#endif
3737

38+
typedef struct {
39+
memaddress out_pos;
40+
memhandle packets_in[UIP_UDP_NUMPACKETS];
41+
memhandle packet_in;
42+
memhandle packet_out;
43+
boolean send;
44+
} uip_udp_userdata_t;
45+
3846
class UIPUDP : public UDP
3947
{
4048

4149
private:
4250
struct uip_udp_conn *_uip_udp_conn;
4351

44-
struct appdata_t
45-
{
46-
memaddress out_pos;
47-
memhandle packets_in[UIP_UDP_NUMPACKETS];
48-
memhandle packet_in;
49-
memhandle packet_out;
50-
boolean send;
51-
} appdata;
52+
uip_udp_userdata_t appdata;
5253

5354
public:
5455
UIPUDP(); // Constructor
@@ -121,6 +122,10 @@ class UIPUDP : public UDP
121122
friend void uipudp_appcall(void);
122123

123124
static void uip_callback();
125+
126+
friend class UIPEthernetClass;
127+
static void _send(uip_udp_userdata_t *data);
128+
124129
};
125130

126131
#endif

0 commit comments

Comments
 (0)