-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'netmindz/WLED-discovery' into main
- Loading branch information
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
@title StarMod | ||
@file UserModWLEDDiscovery.h | ||
@date 20230730 | ||
@repo https://github.com/ewoudwijma/StarMod | ||
@Authors https://github.com/ewoudwijma/StarMod/commits/main | ||
@Copyright (c) 2023 Github StarMod Commit Authors | ||
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 | ||
*/ | ||
|
||
#include <Dictionary.h> | ||
|
||
|
||
class UserModWLEDDiscovery:public Module { | ||
|
||
public: | ||
|
||
Dictionary<IPAddress, String> nodes; | ||
|
||
UserModWLEDDiscovery() :Module("WLED Discovery") { | ||
print->print("%s %s\n", __PRETTY_FUNCTION__, name); | ||
|
||
print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); | ||
}; | ||
|
||
//setup filesystem | ||
void setup() { | ||
Module::setup(); | ||
print->print("%s %s\n", __PRETTY_FUNCTION__, name); | ||
|
||
print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); | ||
} | ||
|
||
void connected() { | ||
isConnected = true; | ||
udp.begin(65506); | ||
} | ||
|
||
void loop(){ | ||
// Module::loop(); | ||
if(!isConnected) return; | ||
|
||
int packetSize = udp.parsePacket(); | ||
|
||
if (packetSize) { | ||
IPAddress remoteIp = udp.remoteIP(); | ||
// TODO: actually look at the contents of the packet to fetch version, name etc | ||
print->print("WLED: %s (%u)\n", remoteIp.toString().c_str(), packetSize); | ||
udp.read(packetBuffer, packetSize); | ||
nodes.set(remoteIp, remoteIp.toString().c_str()); | ||
} | ||
} | ||
|
||
private: | ||
bool isConnected = false; | ||
char packetBuffer[255]; | ||
WiFiUDP udp; | ||
|
||
}; | ||
|
||
static UserModWLEDDiscovery *wledDiscoveryMod; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters