Fix all sorts of errors that prevented compiling.

This commit is contained in:
Starbeamrainbowlabs 2016-10-16 11:02:31 +01:00
parent 939ff443b4
commit 09e57a6ec1

22
PixelHub-Client/PixelHub-Client.ino Executable file → Normal file
View file

@ -6,6 +6,7 @@
*/ */
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <WiFiUdp.h>
char ssid[] = "ssid"; char ssid[] = "ssid";
char password[] = "password"; char password[] = "password";
@ -16,10 +17,9 @@ IPAddress beaconAddress(239, 62, 148, 30);
unsigned int beaconPort = 5050; unsigned int beaconPort = 5050;
// A UDP Client to allow us to recieve UDP datagrams. // A UDP Client to allow us to recieve UDP datagrams.
WiFiUdp UdpClient; WiFiUDP UdpClient;
// A buffer to store recieved datagrams in. // The size of the datagram buffer that is used to buffer incoming messages.
int datagramBufferSize = 256; int datagramBufferSize = 256;
byte datagramBuffer[datagramBufferSize];
void setup() void setup()
{ {
@ -62,7 +62,8 @@ void printWiFiInfoLocal()
void findServer() void findServer()
{ {
Serial.print("Initialising PixelHub auto detection system - "); Serial.print("Initialising PixelHub auto detection system - ");
Udp.beginMulticast(WiFi.localIP(), beaconAddress, beaconPort); byte datagramBuffer[datagramBufferSize];
UdpClient.beginMulticast(WiFi.localIP(), beaconAddress, beaconPort);
Serial.println("success!"); Serial.println("success!");
Serial.println("Listening for PixelHub beacon pings."); Serial.println("Listening for PixelHub beacon pings.");
@ -73,23 +74,26 @@ void findServer()
Serial.print("Received datagram #"); Serial.print("Received datagram #");
Serial.print(datagramSize); Serial.print(datagramSize);
Serial.print(" bytes in size from "); Serial.print(" bytes in size from ");
Serial.print(Udp.remoteIP()); Serial.print(UdpClient.remoteIP());
Serial.print(":"); Serial.print(":");
Serial.print(Udp.remotePort()); Serial.print(UdpClient.remotePort());
if(datagramSize > datagramBufferSize) { if(datagramSize > datagramBufferSize) {
Serial.println(", but the message is larger than the datagram buffer size."); Serial.println(", but the message is larger than the datagram buffer size.");
continue; continue;
} }
Serial.println("."); Serial.println(".");
Udp.read(datagramBuffer, datagramSize); UdpClient.read(datagramBuffer, datagramSize);
Serial.print("Content: "); Serial.print("Content as hex: ");
for(int i = 0; i < datagramSize; i++) { for(int i = 0; i < datagramSize; i++) {
Serial.print(datagramBuffer[i], HEX); Serial.print(datagramBuffer[i], HEX);
Serial.print(" "); Serial.print(" ");
} }
Serial.print("\n"); Serial.println();
Serial.print("Raw content: ");
Serial.write(datagramBuffer, datagramSize);
Serial.println();
} }
} }