Compare commits
No commits in common. "48d61d74c747e7b586306df65a8c4d51f99dd393" and "09e57a6ec1502106eb070d474d499def7271701f" have entirely different histories.
48d61d74c7
...
09e57a6ec1
4 changed files with 3 additions and 53 deletions
|
@ -8,10 +8,8 @@
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
#include "Utilities.h"
|
|
||||||
|
|
||||||
char ssid[] = "ssid";
|
char ssid[] = "ssid";
|
||||||
char password[] = "pass";
|
char password[] = "password";
|
||||||
|
|
||||||
// The address that the PixelHub beacon is broadcasting on.
|
// The address that the PixelHub beacon is broadcasting on.
|
||||||
IPAddress beaconAddress(239, 62, 148, 30);
|
IPAddress beaconAddress(239, 62, 148, 30);
|
||||||
|
@ -48,7 +46,6 @@ void setup()
|
||||||
Serial.println("success!");
|
Serial.println("success!");
|
||||||
|
|
||||||
printWiFiInfoLocal();
|
printWiFiInfoLocal();
|
||||||
findServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
@ -97,34 +94,6 @@ void findServer()
|
||||||
Serial.print("Raw content: ");
|
Serial.print("Raw content: ");
|
||||||
Serial.write(datagramBuffer, datagramSize);
|
Serial.write(datagramBuffer, datagramSize);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
Serial.print("Parsing datagram - ");
|
|
||||||
|
|
||||||
// Parse the recieved message
|
|
||||||
char* datagramStr = (char*)datagramBuffer;
|
|
||||||
|
|
||||||
// Find the positions of the key characters
|
|
||||||
int atPos = findChar(datagramStr, '@');
|
|
||||||
int colonPos = findChar(datagramStr, ':');
|
|
||||||
|
|
||||||
char* role;
|
|
||||||
char* serverIp;
|
|
||||||
char* portNumberText;
|
|
||||||
|
|
||||||
strncpy(role, datagramStr, atPos);
|
|
||||||
strncpy(serverIp, datagramStr + atPos + 1, colonPos);
|
|
||||||
strncpy(portNumberText, datagramStr + colonPos + 1, datagramSize - 1);
|
|
||||||
|
|
||||||
Serial.println("complete.");
|
|
||||||
|
|
||||||
Serial.print("Role: "); Serial.print(role); Serial.print(" ");
|
|
||||||
Serial.print("Remote IP: "); Serial.print(serverIp); Serial.print(" ");
|
|
||||||
Serial.print("Port number: "); Serial.print(portNumberText);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// If the advertiser isn't playing the role of a server, then we're not interested
|
|
||||||
if(role != "server") continue;
|
|
||||||
|
|
||||||
int portNumber = atoi(portNumberText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int findChar(char* str, char targetChar)
|
|
||||||
{
|
|
||||||
for(int i = 0; strcmp(&str[i], "\0") == 0; i++) {
|
|
||||||
if(str[i] == targetChar) return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
/**
|
|
||||||
* Various useful utility functions for the Arduino
|
|
||||||
*********************************************************
|
|
||||||
* By Starbeamrainbowlabs <bugs@starbeamrainbowlabs.com> - https://starbeamrainbowlabs.com)
|
|
||||||
* Originally written for PixelHub - http://git.starbeamrainbowlabs.com/sbrl/PixelHub
|
|
||||||
*
|
|
||||||
* Thanks to Rob Miles for getting me into this :-)
|
|
||||||
*/
|
|
||||||
|
|
||||||
int findChar(char* str, char targetChar);
|
|
|
@ -153,7 +153,7 @@ namespace PixelHub.Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task emitOnce()
|
private async Task emitOnce()
|
||||||
{
|
{
|
||||||
await Send($"{Role}@{LocalIP}:{Port}");
|
await Send($"{Role}@{LocalIP}:{Port}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Reference in a new issue