Skip to content

Instantly share code, notes, and snippets.

@ansarid
Last active April 1, 2018 02:02
Show Gist options
  • Save ansarid/d32a17152219611f8dab6f85091e4ebe to your computer and use it in GitHub Desktop.
Save ansarid/d32a17152219611f8dab6f85091e4ebe to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <WiFi.h>
char wifi_name[] = "WI-FI DSTR Data";
char wifi_password[] = "dstrdstr";
unsigned int localPort = 3553; // local port to listen on
WiFiUDP Udp;
char packetBuffer[255]; //buffer to hold incoming packet
char ReplyBuffer[] = "acknowledged"; // a string to send back
char brightness = 0;
void setup(){
Serial.begin(115200);
Serial.print("Starting network...");
WiFi.beginNetwork(wifi_name, wifi_password);
Serial.println("done.");
Udp.begin(localPort);
}
void loop(){
int packetSize = Udp.parsePacket();
if (packetSize)
{
// read the packet into packetBufffer
int len = Udp.read(packetBuffer, 255);
if (len > 0) packetBuffer[len] = 0;
Serial.print(packetBuffer[0], DEC);Serial.print(" , ");Serial.print(packetBuffer[1], DEC);Serial.print(" , ");Serial.print(packetBuffer[2], DEC);Serial.print(" , ");Serial.println(packetBuffer[3], DEC);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment