fix comments for usermod hooks "onUdpPacket"
This commit is contained in:
@@ -34,7 +34,7 @@ class UdpNameSync : public Usermod {
|
|||||||
|
|
||||||
IPAddress broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
IPAddress broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
||||||
byte udpOut[WLED_MAX_SEGNAME_LEN + 2];
|
byte udpOut[WLED_MAX_SEGNAME_LEN + 2];
|
||||||
udpOut[0] = 2; // 0: wled notifier protocol, 1: warls protocol, 2 is free
|
udpOut[0] = 200; // 0: wled notifier protocol, 1: warls protocol, 2 is free
|
||||||
|
|
||||||
if (strlen(segmentName) && !mainseg.name) { // name cleared
|
if (strlen(segmentName) && !mainseg.name) { // name cleared
|
||||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||||
@@ -46,8 +46,13 @@ class UdpNameSync : public Usermod {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* curName = mainseg.name ? mainseg.name : "";
|
char checksumSegName = 0;
|
||||||
if (strcmp(curName, segmentName) == 0) return; // same name, do nothing
|
char checksumCurName = 0;
|
||||||
|
for(int i=0; i++; mainseg.name[i]==0 || segmentName[i]==0) {
|
||||||
|
checksumSegName+=segmentName[i];
|
||||||
|
checksumCurName+=mainseg.name[i];
|
||||||
|
}
|
||||||
|
if (checksumCurName == checksumSegName) return; // same name, do nothing
|
||||||
|
|
||||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||||
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
||||||
@@ -61,9 +66,10 @@ class UdpNameSync : public Usermod {
|
|||||||
DEBUG_PRINTLN(segmentName);
|
DEBUG_PRINTLN(segmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onUdpPacket(uint8_t * payload, uint8_t len) override {
|
bool onUdpPacket(uint8_t * payload, size_t len) override {
|
||||||
DEBUG_PRINT(F("UdpNameSync: Received packet"));
|
DEBUG_PRINT(F("UdpNameSync: Received packet"));
|
||||||
if (payload[0] != 2) return false;
|
if (receiveDirect) return false;
|
||||||
|
if (payload[0] != 200) return false;
|
||||||
//else
|
//else
|
||||||
Segment& mainseg = strip.getMainSegment();
|
Segment& mainseg = strip.getMainSegment();
|
||||||
mainseg.setName((char *)&payload[1]);
|
mainseg.setName((char *)&payload[1]);
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ class Usermod {
|
|||||||
virtual void onMqttConnect(bool sessionPresent) {} // fired when MQTT connection is established (so usermod can subscribe)
|
virtual void onMqttConnect(bool sessionPresent) {} // fired when MQTT connection is established (so usermod can subscribe)
|
||||||
virtual bool onMqttMessage(char* topic, char* payload) { return false; } // fired upon MQTT message received (wled topic)
|
virtual bool onMqttMessage(char* topic, char* payload) { return false; } // fired upon MQTT message received (wled topic)
|
||||||
virtual bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len) { return false; } // fired upon ESP-NOW message received
|
virtual bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len) { return false; } // fired upon ESP-NOW message received
|
||||||
virtual bool onUdpPacket(uint8_t* payload, uint8_t len) { return false; } //fired upon UDP packet received
|
virtual bool onUdpPacket(uint8_t* payload, size_t len) { return false; } //fired upon UDP packet received
|
||||||
virtual void onUpdateBegin(bool) {} // fired prior to and after unsuccessful firmware update
|
virtual void onUpdateBegin(bool) {} // fired prior to and after unsuccessful firmware update
|
||||||
virtual void onStateChange(uint8_t mode) {} // fired upon WLED state change
|
virtual void onStateChange(uint8_t mode) {} // fired upon WLED state change
|
||||||
virtual uint16_t getId() {return USERMOD_ID_UNSPECIFIED;}
|
virtual uint16_t getId() {return USERMOD_ID_UNSPECIFIED;}
|
||||||
@@ -482,7 +482,7 @@ namespace UsermodManager {
|
|||||||
#ifndef WLED_DISABLE_ESPNOW
|
#ifndef WLED_DISABLE_ESPNOW
|
||||||
bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len);
|
bool onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len);
|
||||||
#endif
|
#endif
|
||||||
bool onUdpPacket(uint8_t* payload, uint8_t len);
|
bool onUdpPacket(uint8_t* payload, size_t len);
|
||||||
void onUpdateBegin(bool);
|
void onUpdateBegin(bool);
|
||||||
void onStateChange(uint8_t);
|
void onStateChange(uint8_t);
|
||||||
Usermod* lookup(uint16_t mod_id);
|
Usermod* lookup(uint16_t mod_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user