Skip to content

Commit

Permalink
[DISC] reorder UVI for correct auto-discovery
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DigiH committed Jun 13, 2024
1 parent 57d1105 commit 8b1dc7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion main/ZgatewayRTL_433.ino
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
if (overrideDiscovery || !isDiscovered(pdevice)) {
size_t numRows = sizeof(parameters) / sizeof(parameters[0]);
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
String idWoKey = pdevice->uniqueId;
idWoKey.remove(idWoKey.length() - (strlen(parameters[i][0]) + 1));
Expand Down
2 changes: 1 addition & 1 deletion main/config_RF.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct RTL_433device {
bool isDisc;
};

const char parameters[53][4][24] = {
const char parameters[51][4][24] = {
// RTL_433 key, name, unit, device_class
{"alarm", "Alarm", "", ""},
{"battery_mV", "Battery Voltage", "mV", "voltage"},
Expand Down

0 comments on commit 8b1dc7c

Please sign in to comment.