Hi everyone,
I am working on using UDPSendReceiveString example to receive message from the UDPClient and send reply. I am using Ethernet shield to provide UDPServer and wifi2866-12E working as UDPClient. The UDPclient send Hello message to the server but it does not receive any response! the code for UDPClient is :
/*
- 31 mar 2015
- This sketch sends UDP packets to an UDP server.
- On a Mac the NC command can be used to receive the messages. ( sudo nc -lu 888 ).
- Configuration : Enter the ssid and password of your Wifi AP. Enter the IP number and Udp number of your receiving UDP server.
*/
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
const char* ssid = "";
const char password = "***";
char packetBuffer[20];
// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Udp.beginPacket("192.168.1.59", 8888);
Udp.write("hello");
Udp.endPacket();
}
void loop() {
int packetSize = Udp.parsePacket();
if (packetSize) {
int len = Udp.read(packetBuffer, 20);
if (len > 0) packetBuffer[len] = 0;
Serial.println(packetBuffer);
}
}