bportaluri / WiFiEsp

Arduino WiFi library for ESP8266 modules
GNU General Public License v3.0
551 stars 210 forks source link

Error sending UPD packets #178

Open RhizomaticNomad opened 5 years ago

RhizomaticNomad commented 5 years ago

I would like to send OSC Messages via UDP to a remote host. But I am stucked already with sending UDP Messages.

I made a sketch with the necessary information but get [WiFiEsp] TIMEOUT >>> [WiFiEsp] Data packet send error (1) after the Arduino with ESP connected successfully to the WPA Network.

Did I miss anything in my code to send a package?

include "WiFiEsp.h"

include

// Emulate Serial1 on pins 6/7 if not present

ifndef HAVE_HWSERIAL1

include "SoftwareSerial.h"

SoftwareSerial Serial1(6, 7); // RX, TX

endif

// Setup WiFi char ssid[] = "ssid"; // your network SSID (name) char pass[] = "sec_pw"; // your network password int status = WL_IDLE_STATUS; // the Wifi radio's status

WiFiEspUDP Udp; // A UDP instance to let us send and receive packets over UDP const IPAddress remoteIP(192,168,2,1); // remote IP of your computer const unsigned int remotePort = 8000; // remote port to receive OSC

void setup() {

// initialize serial for debugging Serial.begin(115200); // initialize serial for ESP module Serial1.begin(9600);

// initialize ESP module WiFi.init(&Serial1);

// check for the presence of the shield if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); // don't continue while (true); }

// attempt to connect to WiFi network while ( status != WL_CONNECTED) { Serial.print("Attempting to connect ... "); // Connect to WPA/WPA2 network status = WiFi.begin(ssid, pass); }

// print your WiFi shield's IP address IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip);

// print your MAC address byte mac[6]; WiFi.macAddress(mac); char buf[20]; sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); Serial.print("MAC address: "); Serial.println(buf);

// print the MAC address of the router you're attached to byte bssid[6]; WiFi.BSSID(bssid); char buffer[20]; sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X", bssid[5], bssid[4], bssid[3], bssid[2], bssid[1], bssid[0]); Serial.print("BSSID: "); Serial.println(buf);

// print the received signal strength long rssi = WiFi.RSSI(); Serial.print("Signal strength (RSSI): "); Serial.println(rssi); }

void loop() {

Udp.beginPacket(remoteIP, remotePort);
char ReplyBuffer[] = "ACK"; 
Udp.write(ReplyBuffer);
Udp.endPacket();

delay(200);
}

JAndrassy commented 5 years ago

set ESPLOGLEVEL in debug.h to 4 to see the response of the esp8266

inxy-n commented 3 years ago

设置在调试中的_埃斯普洛格尔_到4,看看esp8266的反应

But where is the file "debug.h"? Thank you!

JAndrassy commented 3 years ago

But where is the file "debug.h"? Thank you!

it is usually in something like Documents/Arduino/libraries/WiFiEsp/src/utility