fix nitpicks from coderabbit
This commit is contained in:
@@ -5,8 +5,6 @@ class UdpNameSync : public Usermod {
|
||||
private:
|
||||
|
||||
bool enabled = false;
|
||||
bool initDone = false;
|
||||
unsigned long lastTime = 0;
|
||||
char segmentName[WLED_MAX_SEGNAME_LEN] = {0};
|
||||
static const char _name[];
|
||||
static const char _enabled[];
|
||||
@@ -15,15 +13,14 @@ class UdpNameSync : public Usermod {
|
||||
/**
|
||||
* Enable/Disable the usermod
|
||||
*/
|
||||
inline void enable(bool enable) { enabled = enable; }
|
||||
inline void enable(bool value) { enabled = value; }
|
||||
|
||||
/**
|
||||
* Get usermod enabled/disabled state
|
||||
*/
|
||||
inline bool isEnabled() { return enabled; }
|
||||
inline bool isEnabled() const { return enabled; }
|
||||
|
||||
void setup() override {
|
||||
initDone = true;
|
||||
}
|
||||
|
||||
void loop() override {
|
||||
@@ -32,10 +29,9 @@ class UdpNameSync : public Usermod {
|
||||
Segment& mainseg = strip.getMainSegment();
|
||||
if (!strlen(segmentName) && !mainseg.name) return; //name was never set, do nothing
|
||||
|
||||
IPAddress broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
||||
IPAddress broadcastIp = uint32_t(Network.localIP()) | ~uint32_t(Network.subnetMask());
|
||||
byte udpOut[WLED_MAX_SEGNAME_LEN + 2];
|
||||
udpOut[0] = 200; // 0: wled notifier protocol, 1: warls protocol, 2 is free
|
||||
|
||||
udpOut[0] = 200; // custom usermod packet type (avoid 0..5 used by core protocols)
|
||||
if (strlen(segmentName) && !mainseg.name) { // name cleared
|
||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||
segmentName[0] = '\0';
|
||||
@@ -52,7 +48,6 @@ class UdpNameSync : public Usermod {
|
||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
||||
DEBUG_PRINTLN(mainseg.name);
|
||||
size_t length = strlen(mainseg.name);
|
||||
strlcpy(segmentName, mainseg.name, sizeof(segmentName));
|
||||
strlcpy((char *)&udpOut[1], segmentName, sizeof(udpOut) - 1); // leave room for header byte
|
||||
notifierUdp.write(udpOut, 2 + strnlen((char *)&udpOut[1], sizeof(udpOut) - 1));
|
||||
|
||||
Reference in New Issue
Block a user