[DISC] reorder UVI for correct auto-discovery (#1968)
To avoid auto-discovery issues due to substring comparison at https://github.com/1technophile/OpenMQTTGateway/blob/development/main/ZgatewayRTL_433.ino#L128 strcmp instead of substring only strstr
This commit is contained in:
1 parent
57d1105ba8
commit
4bb7c5502d
2 files changed
+7
-2
No files matched your search
@@ -125,7 +125,12 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
|
|||||||
if (overrideDiscovery || !isDiscovered(pdevice)) {
|
if (overrideDiscovery || !isDiscovered(pdevice)) {
|
||||||
size_t numRows = sizeof(parameters) / sizeof(parameters[0]);
|
size_t numRows = sizeof(parameters) / sizeof(parameters[0]);
|
||||||
for (int i = 0; i < numRows; i++) {
|
for (int i = 0; i < numRows; i++) {
|
||||||
if (strstr(pdevice->uniqueId, parameters[i][0]) != 0) {
|
char deviceKeyParameter[25];
|
||||||
|
memcpy(deviceKeyParameter, &pdevice->uniqueId[strlen(pdevice->uniqueId) - strlen(parameters[i][0])], strlen(parameters[i][0]));
|
||||||
|
deviceKeyParameter[strlen(parameters[i][0])] = '\0';
|
||||||
|
Log.trace(F("deviceKeyParameter: %s" CR), deviceKeyParameter);
|
||||||
|
|
||||||
|
if (strcmp(deviceKeyParameter, parameters[i][0]) == 0) {
|
||||||
// Remove the key from the unique id to extract the device id
|
// Remove the key from the unique id to extract the device id
|
||||||
String idWoKey = pdevice->uniqueId;
|
String idWoKey = pdevice->uniqueId;
|
||||||
idWoKey.remove(idWoKey.length() - (strlen(parameters[i][0]) + 1));
|
idWoKey.remove(idWoKey.length() - (strlen(parameters[i][0]) + 1));
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ struct RTL_433device {
|
|||||||
bool isDisc;
|
bool isDisc;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char parameters[53][4][24] = {
|
const char parameters[51][4][24] = {
|
||||||
// RTL_433 key, name, unit, device_class
|
// RTL_433 key, name, unit, device_class
|
||||||
{"alarm", "Alarm", "", ""},
|
{"alarm", "Alarm", "", ""},
|
||||||
{"battery_mV", "Battery Voltage", "mV", "voltage"},
|
{"battery_mV", "Battery Voltage", "mV", "voltage"},
|
||||||
|
|||||||
Reference in new issue
Block a user