Sorry I'm new on here , cannot find an edit option, just read how to ad tags, so let me try again.
will this work !
#include <analogWrite.h>
#include "WiFi.h"
#include "AsyncUDP.h"
#include <ESP32Tone.h>
const char * ssid = "Paul2";
const char * password = "abcdeabcde";
String header;
const int buzzer = 4;
const int GarR = 2;
const int GarG = 5;
char received[50] = "";
char test[100];
AsyncUDP udp;
IPAddress local_IP(192, 168, 0, 32);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(GarR, OUTPUT);
pinMode(GarG, OUTPUT);
Serial.begin(9600);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
Serial.println(received);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
while(1) {
delay(1000);
}
}
if(udp.listen(1234)) {
Serial.print("UDP Listening on IP: ");
Serial.println(WiFi.localIP());
udp.onPacket([](AsyncUDPPacket packet) {
Serial.print("UDP Packet Type: ");
Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast");
Serial.print(", From: ");
Serial.print(packet.remoteIP());
Serial.print(":");
Serial.print(packet.remotePort());
Serial.print(", To: ");
Serial.print(packet.localIP());
Serial.print(":");
Serial.print(packet.localPort());
Serial.print(", Length: ");
Serial.print(packet.length());
Serial.print(", Data: ");
Serial.write(packet.data(), packet.length());
// received == (packet.data()); doesnt like this laks cast ? i dont understand the explanation
// received == (packet.data(), packet.length()); forbids compariton between pointer and intiger mmmm
});
}
}
void loop()
{
//received == ((packet.data()); packet not declared in this scope
// if ((packet.data()) == "Heartbeat") packet not declared in this scope
// Serial.println("Heartbeat returned");
// }