So in the udpapp_init() function you call uip_udp_new() and provide it with the remote client's address. This means that your Arduino/WiShield must know beforehand the IP address of the single machine/device that will connect to it via UDP. Thats pretty limiting and will break in a DHCP environment where the connecting client's IP address could change.
The workaround is to use an IP address of 255.255.255.255 in the call to uip_udp_new(). This allows, or should allow, any client device/machine to connect to the Arduino/WiShield regardless of its IP address and allows the UDP sample sketch + PC code to work (on the first time and every time as far as I saw). The unintended side effect here is that your Arduino/WiShield is now sending broadcast UDP packets (I think this addr sets broadcast). Maybe not a problem unless you have some other device on your network sitting out there listening on that port for broadcast UDP packets. WireShark tells me that port 12345, which the Arduino/WiShield is broadcasting on in my setup, is a known port for "italk" (italk appears to be a chat service). So use at your own risk (or find some unused ports!)
I chased this down through the WiServer and uIP code and stopped when I got into the ZeroG driver code. WiServer/uIP code appear to be working correctly but the send seems to be getting dropped somewhere in the ZeroG driver. I don't really know, this is just a guess based upon some simple debugging...
Original udpapp_init() from the UDPApp sample
- Code: Select all
void udpapp_init(void)
{
uip_ipaddr_t addr;
struct uip_udp_conn *c;
uip_ipaddr(&addr, 192,168,1,100);
c = uip_udp_new(&addr, HTONS(0));
if(c != NULL) {
uip_udp_bind(c, HTONS(12344));
}
s.state = STATE_INIT;
PT_INIT(&s.pt);
}
Updated udpapp_init() that seems to work (but broadcasts)
- Code: Select all
void udpapp_init(void)
{
uip_ipaddr_t addr;
struct uip_udp_conn *c;
//uip_ipaddr(&addr, 192,168,1,100);
uip_ipaddr(&addr, 255,255,255,255);
c = uip_udp_new(&addr, HTONS(0));
if(c != NULL) {
uip_udp_bind(c, HTONS(12344));
}
s.state = STATE_INIT;
PT_INIT(&s.pt);
}
IMO one of the only reasons to use UDP is for broadcast (as well as fast connectionless unack'ed packets). Maybe TCP sockets would work for you as they seem a little more usable/stable?
Greg