Copy all statistics values when a device's MAC address changes (#1098)
When a device's MAC address changes we attempt to keep old distance measurements. This can be improved by also copying the filter state and a few more related values.
This commit is contained in:
parent
6eb2347e6e
commit
a6e5a18dae
|
@ -449,10 +449,16 @@ bool BleFingerprint::seen(BLEAdvertisedDevice *advertisedDevice) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void BleFingerprint::setInitial(int initalRssi, float initalDistance) {
|
||||
newest = recent = oldest = rssi = initalRssi;
|
||||
raw = initalDistance;
|
||||
hasValue = filter() || filter();
|
||||
void BleFingerprint::setInitial(const BleFingerprint &other) {
|
||||
newest = other.newest;
|
||||
recent = other.recent;
|
||||
oldest = other.oldest;
|
||||
rssi = other.rssi;
|
||||
raw = other.rssi;
|
||||
output = other.output;
|
||||
oneEuro = other.oneEuro;
|
||||
diffFilter = other.diffFilter;
|
||||
hasValue = other.hasValue;
|
||||
}
|
||||
|
||||
void BleFingerprint::fill(JsonObject *doc) {
|
||||
|
|
|
@ -80,7 +80,7 @@ class BleFingerprint {
|
|||
|
||||
bool setId(const String &newId, short int newIdType, const String &newName = "");
|
||||
|
||||
void setInitial(int rssi, float distance);
|
||||
void setInitial(const BleFingerprint &other);
|
||||
|
||||
const String getMac() const;
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ BleFingerprint *getFingerprintInternal(BLEAdvertisedDevice *advertisedDevice) {
|
|||
if (it2 != fingerprints.end()) {
|
||||
auto found = *it2;
|
||||
// Serial.printf("Detected mac switch for fingerprint id %s\r\n", found->getId().c_str());
|
||||
created->setInitial(found->getRssi(), found->getDistance());
|
||||
created->setInitial(*found);
|
||||
if (found->getIdType() > ID_TYPE_UNIQUE)
|
||||
found->expire();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue