I recently received the CC3000 BoB and am trying to port over arduino code that used to use an arduino ethernet shield for communicating on the network. However, the UDP related code doesn't seem to be working very well with the CC3000 library. So my question is, how do I set up the CC3000 in arduino to listen for incoming UDP packets? Basically I want it to listen for simple information passed in a UDP packet and then read that packet into a buffer, below is how i currently do it just fine:
Code: Select all
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 88, 200);
unsigned int localPort = 6001; // local port to listen on
unsigned int RemotePort = 6000;
IPAddress RemoteIP;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
EthernetUDP Udp;
int packetSize;
void setup()
{
Serial.begin(57600);
Ethernet.begin(mac,ip);
Udp.begin(localPort);
}
void loop()
{
packetSize = Udp.parsePacket();
if(packetSize)
{
RemoteIP = Udp.remoteIP();
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
command_udp();
}
}
void command_udp()
{
//parsing of packetBuffer
}