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() : NodeStruct::NodeStruct() :
age(0), nodeType(0) age(0), nodeType(0), build(0)
{ {
for (uint8_t i = 0; i < 4; ++i) { ip[i] = 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 unit;
uint8_t age; uint8_t age;
uint8_t nodeType; uint8_t nodeType;
uint32_t build;
}; };
typedef std::map<uint8_t, NodeStruct> NodesMap; typedef std::map<uint8_t, NodeStruct> NodesMap;

View File

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

View File

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

View File

@ -542,7 +542,7 @@ function populateNodes(i)
var o = i.nodes[x]; var o = i.nodes[x];
if (o.name) { if (o.name) {
var url = `<button class="btn btna-icon tab" onclick="location.assign('http://${o.ip}');">${o.name}</button>`; 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) { 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; if (isThisUnit) continue;
JsonObject node = nodes.createNestedObject(); JsonObject node = nodes.createNestedObject();
node[F("name")] = it->second.nodeName; node[F("name")] = it->second.nodeName;
node[F("type")] = getNodeTypeDisplayString(it->second.nodeType); node[F("type")] = getNodeTypeDisplayString(it->second.nodeType);
node[F("ip")] = it->second.ip.toString(); node[F("ip")] = it->second.ip.toString();
node[F("age")] = it->second.age; 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 = tmpNodeName;
it->second.nodeName.trim(); it->second.nodeName.trim();
it->second.nodeType = udpIn[38]; 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; return;
} }
@ -421,7 +426,8 @@ void sendSysInfoUDP(uint8_t repeats)
// 6: 32 char name // 6: 32 char name
// 38: 1 byte node type id // 38: 1 byte node type id
// 39: 1 byte node id // 39: 1 byte node id
// 40 bytes total // 40: 4 byte version ID
// 44 bytes total
// send my info to the world... // send my info to the world...
for (;repeats--;) for (;repeats--;)
@ -430,7 +436,7 @@ void sendSysInfoUDP(uint8_t repeats)
escapedMac // mac address escapedMac // mac address
*/ */
uint8_t data[40] = {0}; uint8_t data[44] = {0};
data[0] = 255; data[0] = 255;
data[1] = 1; data[1] = 1;
@ -447,9 +453,13 @@ void sendSysInfoUDP(uint8_t repeats)
#endif #endif
data[39] = ip[3]; // unit ID == last IP number 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); IPAddress broadcastIP(255, 255, 255, 255);
notifier2Udp.beginPacket(broadcastIP, udpPort2); notifier2Udp.beginPacket(broadcastIP, udpPort2);
notifier2Udp.write(data, 40); notifier2Udp.write(data, sizeof(data));
notifier2Udp.endPacket(); notifier2Udp.endPacket();
if (repeats) delay(500); if (repeats) delay(500);
@ -474,5 +484,6 @@ void sendSysInfoUDP(uint8_t repeats)
it->second.nodeType = NODE_TYPE_ID_UNDEFINED; it->second.nodeType = NODE_TYPE_ID_UNDEFINED;
#endif #endif
it->second.unit = ip[3]; it->second.unit = ip[3];
it->second.build = VERSION;
} }
} }

View File

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