Added version info in autodiscovery packet.

This commit is contained in:
Blaz Kristan 2021-03-04 14:24:25 +01:00
parent 83452d73bc
commit c4689c3bcc
9 changed files with 1797 additions and 1774 deletions

View File

@ -10,7 +10,7 @@ String getNodeTypeDisplayString(uint8_t nodeType) {
}
NodeStruct::NodeStruct() :
age(0), nodeType(0)
age(0), nodeType(0), build(0)
{
for (uint8_t i = 0; i < 4; ++i) { ip[i] = 0; }
}

View File

@ -27,6 +27,7 @@ struct NodeStruct
uint8_t unit;
uint8_t age;
uint8_t nodeType;
uint32_t build;
};
typedef std::map<uint8_t, NodeStruct> NodesMap;

View File

@ -167,14 +167,17 @@ void deserializeConfig() {
#endif
CJSON(irEnabled, hw[F("ir")][F("type")]);
int hw_relay_pin = hw[F("relay")][F("pin")];
JsonObject relay = hw[F("relay")];
int hw_relay_pin = relay[F("pin")];
if (pinManager.allocatePin(hw_relay_pin,true)) {
rlyPin = hw_relay_pin;
pinMode(rlyPin, OUTPUT);
} else {
rlyPin = -1;
}
CJSON(rlyMde, hw[F("relay")][F("rev")]);
if (relay.containsKey("rev")) {
rlyMde = !relay["rev"];
}
//int hw_status_pin = hw[F("status")][F("pin")]; // -1
@ -496,7 +499,7 @@ void serializeConfig() {
JsonObject hw_relay = hw.createNestedObject("relay");
hw_relay[F("pin")] = rlyPin;
hw_relay[F("rev")] = rlyMde;
hw_relay[F("rev")] = !rlyMde;
//JsonObject hw_status = hw.createNestedObject("status");
//hw_status[F("pin")] = -1;

View File

@ -148,6 +148,10 @@ button {
padding-bottom: 8px;
}
.valtd i {
font-size: small;
}
.slider-icon
{
transform: translate(6px,3px);

View File

@ -542,7 +542,7 @@ function populateNodes(i)
var o = i.nodes[x];
if (o.name) {
var url = `<button class="btn btna-icon tab" onclick="location.assign('http://${o.ip}');">${o.name}</button>`;
urows += inforow(url,o.type);
urows += inforow(url,`${o.type}<br><i>${o.build==0?"N/A":o.build}</i>`);
}
}
if (i.nodes.length>0) {

File diff suppressed because it is too large Load Diff

View File

@ -553,11 +553,12 @@ void serializeInfo(JsonObject root)
if (isThisUnit) continue;
JsonObject node = nodes.createNestedObject();
node[F("name")] = it->second.nodeName;
node[F("type")] = getNodeTypeDisplayString(it->second.nodeType);
node[F("ip")] = it->second.ip.toString();
node[F("age")] = it->second.age;
JsonObject node = nodes.createNestedObject();
node[F("name")] = it->second.nodeName;
node[F("type")] = getNodeTypeDisplayString(it->second.nodeType);
node[F("ip")] = it->second.ip.toString();
node[F("age")] = it->second.age;
node[F("build")] = it->second.build;
}
}

View File

@ -184,6 +184,11 @@ void handleNotifications()
it->second.nodeName = tmpNodeName;
it->second.nodeName.trim();
it->second.nodeType = udpIn[38];
uint32_t build = 0;
if (len >= 44)
for (byte i=0; i<sizeof(uint32_t); i++)
build |= udpIn[40+i]<<(8*i);
it->second.build = build;
}
return;
}
@ -421,7 +426,8 @@ void sendSysInfoUDP(uint8_t repeats)
// 6: 32 char name
// 38: 1 byte node type id
// 39: 1 byte node id
// 40 bytes total
// 40: 4 byte version ID
// 44 bytes total
// send my info to the world...
for (;repeats--;)
@ -430,7 +436,7 @@ void sendSysInfoUDP(uint8_t repeats)
escapedMac // mac address
*/
uint8_t data[40] = {0};
uint8_t data[44] = {0};
data[0] = 255;
data[1] = 1;
@ -447,9 +453,13 @@ void sendSysInfoUDP(uint8_t repeats)
#endif
data[39] = ip[3]; // unit ID == last IP number
uint32_t build = VERSION;
for (byte i=0; i<sizeof(uint32_t); i++)
data[40+i] = (build>>(8*i)) & 0xFF;
IPAddress broadcastIP(255, 255, 255, 255);
notifier2Udp.beginPacket(broadcastIP, udpPort2);
notifier2Udp.write(data, 40);
notifier2Udp.write(data, sizeof(data));
notifier2Udp.endPacket();
if (repeats) delay(500);
@ -474,5 +484,6 @@ void sendSysInfoUDP(uint8_t repeats)
it->second.nodeType = NODE_TYPE_ID_UNDEFINED;
#endif
it->second.unit = ip[3];
it->second.build = VERSION;
}
}

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2103040
#define VERSION 2103041
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -192,8 +192,9 @@ WLED_GLOBAL int8_t rlyPin _INIT(-1);
#else
WLED_GLOBAL int8_t rlyPin _INIT(RLYPIN);
#endif
//Relay mode (1 = active high, 0 = active low, flipped in cfg.json)
#ifndef RLYMDE
WLED_GLOBAL bool rlyMde _INIT(1);
WLED_GLOBAL bool rlyMde _INIT(true);
#else
WLED_GLOBAL bool rlyMde _INIT(RLYMDE);
#endif