I think that was actually it. I changed the send code and it works fine:
- Code: Select all
static void send_data(void)
{
char str[5];
sprintf(str, "%d", potValue);
Serial.println((const char*)str);
memcpy(uip_appdata, str, 5);
uip_send(uip_appdata, 5);
}
However, I am still having trouble on the receiving side. When potValue reaches its max (1023) the data flowing through the Serial Monitor halts. I think this could be causing a buffer overflow due to my use of atoi. Unfortunately, I do not know how to convert a string to int using something like sprintf. The following code samples yield the same result (halting on receiving 1023):
- Code: Select all
void udpapp_appcall(void)
{
//receive incoming data
if(0 != uip_newdata()) {
char str[5];
memcpy(str, uip_appdata, 5);
ledValue= atoi((const char*)str);
Serial.println(ledValue);
}
}
- Code: Select all
void udpapp_appcall(void)
{
//receive incoming data
if(0 != uip_newdata()) {
ledValue= atoi((const char*)uip_appdata);
Serial.println(ledValue);
}
}
If I get rid of the if statement, it keeps receiving 1023, but will not recognize any changes in potValue after that.
On another note, I also need the data on the receiving end to be picked up by an iPad app I am writing. Even if I could broadcast to two IP addresses, I cannot expect the user to manually set their IP address in the iPad settings. Is there a way to either broadcast to the entire network or set the IP address of the iPad from the Arduino and broadcast to both that and the other Arduino?
Thanks!
-Zach