Send UDP String Ethercard - Arduino Leonardo


I am new in Arduino.

Now I am running UDPListener Ethercard example, and I tried to use sendUDP command to answer a message, but it doesn’t work. I am using my PC to send the UDP message with the app Packet Sender, and it has an UDP listener to receive my answer. In my PC I don’t receive the answer. I wonder if anybody can tell me if I have an error on my code. Thanks.

Here my code:

// Demonstrates usage of the new udpServer feature.
//You can register the same function to multiple ports, and multiple functions to the same port.
// 2013-4-7 Brian Lee

#include <EtherCard.h>
#include <IPAddress.h>

#define STATIC 1 // set to 1 to disable DHCP (adjust myip/gwip values below)

// ethernet interface ip address
static byte myip = { 192,168,0,200 };
// gateway ip address
static byte gwip = { 192,168,0,1 };

// ethernet mac address - must be unique on your network
static byte mymac = { 0x70,0x69,0x69,0x2D,0x30,0x31 };

char textToSend = “OK - RECIBIDO”;

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

//callback that prints received packets to the serial port
void udpSerialPrint(uint16_t dest_port, uint8_t src_ip[4], uint16_t src_port, const char *data, uint16_t len){
IPAddress src(src_ip[0],src_ip[1],src_ip[2],src_ip[3]);

ether.printIp("SRV: ", ether.hisip);
Serial.print("dest_port: ");
Serial.print("src_port: ");

Serial.print(“src_ip: “);
Serial.println("data: ");
Serial.print("Lenght: ");

//static void sendUdp (char *data,uint8_t len,uint16_t sport, uint8_t *dip, uint16_t dport);
//ether.sendUdp(textToSend, sizeof(textToSend), srcPort, ether.hisip, dstPort );
ether.sendUdp(textToSend, sizeof(textToSend), dest_port, src_ip, src_port );

void setup(){

if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F(“Failed to access Ethernet controller”));
ether.staticSetup(myip, gwip);
if (!ether.dhcpSetup())
Serial.println(F(“DHCP failed”));

ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);

//register udpSerialPrint() to port 1337
ether.udpServerListenOnPort(&udpSerialPrint, 1337);

//register udpSerialPrint() to port 42.
ether.udpServerListenOnPort(&udpSerialPrint, 42);

void loop(){
//this must be called for ethercard functions to work.