[HA Discovery] Fix RMAC discovery of unwanted devices (#1557)

This commit is contained in:
Florian authored and GitHub committed 2023-03-20 14:36:47 -05:00
1 parent 9299ee7970
commit 80e00883fb
1 file changed
+6 -1
+6 -1
View File
@@ -482,6 +482,7 @@ void updateDevicesStatus() {
}
void dumpDevices() {
# if LOG_LEVEL > 4 // > NOTICE LOG LEVEL
for (vector<BLEdevice*>::iterator it = devices.begin(); it != devices.end(); ++it) {
BLEdevice* p = *it;
Log.trace(F("macAdr %s" CR), p->macAdr);
@@ -493,6 +494,7 @@ void dumpDevices() {
Log.trace(F("sensorModel_id %d" CR), p->sensorModel_id);
Log.trace(F("LastUpdate %u" CR), p->lastUpdate);
}
# endif
}
void strupp(char* beg) {
@@ -1118,7 +1120,8 @@ void process_bledata(JsonObject& BLEdata) {
const char* mac = BLEdata["id"].as<const char*>();
int model_id = BTConfig.extDecoderEnable ? -1 : decoder.decodeBLEJson(BLEdata);
int mac_type = BLEdata["mac_type"].as<int>();
if (model_id >= 0 && model_id != TheengsDecoder::BLE_ID_NUM::IBEACON && (BLEdata["type"].as<string>()).compare("RMAC") != 0) { // Broadcaster devices, excluding random macs
if ((BLEdata["type"].as<string>()).compare("RMAC") != 0 && model_id != TheengsDecoder::BLE_ID_NUM::IBEACON) { // Do not store in memory the random mac devices and iBeacons
if (model_id >= 0) { // Broadcaster devices
Log.trace(F("Decoder found device: %s" CR), BLEdata["model_id"].as<const char*>());
if (model_id == TheengsDecoder::BLE_ID_NUM::HHCCJCY01HHCC || model_id == TheengsDecoder::BLE_ID_NUM::BM2) {
createOrUpdateDevice(mac, device_flags_connect, model_id, mac_type); // Device that broadcast and can be connected
@@ -1172,6 +1175,8 @@ void process_bledata(JsonObject& BLEdata) {
}
}
}
Log.trace(F("Random MAC or iBeacon device filtered" CR));
}
if (!BTConfig.extDecoderEnable && model_id < 0) {
Log.trace(F("No eligible device found " CR));
}