Hi,
how can I receive a string on the CC3000 shield via UDP? All the examples I find are using TCP.
CC3000 shield - simple UDP read example?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: CC3000 shield - simple UDP read example?
Take a look at the InternetTime example: https://github.com/adafruit/Adafruit_CC ... etTime.ino
-
- Posts: 3
- Joined: Sun Mar 23, 2014 7:27 pm
Re: CC3000 shield - simple UDP read example?
Thanks,
is there a way to wait for incoming messages, instead of connecting to a remote ip, like in the EthernetUdp library there's the Udp.parsePacket(); method.
I want to be able to send a string over UPD from an unknown ip to the CC3000, so that the CC3000 just sits and listens to a port for incoming messages.
like in the EthernetUdp lib it would be something like this:
is there an equivalent to this in the CC3000? I'm looking to translate my code from ethernet to wifi...
Cheers,
G
is there a way to wait for incoming messages, instead of connecting to a remote ip, like in the EthernetUdp library there's the Udp.parsePacket(); method.
I want to be able to send a string over UPD from an unknown ip to the CC3000, so that the CC3000 just sits and listens to a port for incoming messages.
like in the EthernetUdp lib it would be something like this:
Code: Select all
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip); //the mac and ip of the ethernet shield
Udp.begin(localPort);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
IPAddress remote = Udp.remoteIP();
Serial.print(remote[0], DEC);
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
value = "";
for (int i=0; i < packetSize; i++)
{
if (i < 3) // the first 3 characters
{
command[i]=packetBuffer[i];
}
else // the last caracters are the value
{
value += (char)packetBuffer[i];
}
}
is there an equivalent to this in the CC3000? I'm looking to translate my code from ethernet to wifi...
Cheers,
G
-
- Posts: 3
- Joined: Sun Mar 23, 2014 7:27 pm
Re: CC3000 shield - simple UDP read example?
Ok, I found out using the code in this topic.
http://forum.pjrc.com/threads/24897-und ... ient-works
http://forum.pjrc.com/threads/24897-und ... ient-works
Please be positive and constructive with your questions and comments.