Start of removing NimBLEAddress from fingerprint
This commit is contained in:
parent
24c7fbb2fe
commit
83b1622fc9
|
@ -74,7 +74,10 @@ int BleFingerprint::get1mRssi() const {
|
|||
|
||||
BleFingerprint::BleFingerprint(BLEAdvertisedDevice *advertisedDevice, float fcmin, float beta, float dcutoff) : oneEuro{OneEuroFilter<float, unsigned long>(1, fcmin, beta, dcutoff)} {
|
||||
firstSeenMillis = millis();
|
||||
address = NimBLEAddress(advertisedDevice->getAddress());
|
||||
|
||||
auto native = advertisedDevice->getAddress().getNative();
|
||||
memcpy(address, native, 6);
|
||||
|
||||
addressType = advertisedDevice->getAddressType();
|
||||
newest = recent = oldest = rssi = advertisedDevice->getRSSI();
|
||||
seenCount = 1;
|
||||
|
@ -91,10 +94,10 @@ void BleFingerprint::fingerprint(NimBLEAdvertisedDevice *advertisedDevice) {
|
|||
if (advertisedDevice->getAdvType() > 0)
|
||||
connectable = true;
|
||||
|
||||
size_t serviceAdvCount = advertisedDevice->getServiceUUIDCount();
|
||||
size_t serviceDataCount = advertisedDevice->getServiceDataCount();
|
||||
bool haveTxPower = advertisedDevice->haveTXPower();
|
||||
int8_t txPower = advertisedDevice->getTXPower();
|
||||
const size_t serviceAdvCount = advertisedDevice->getServiceUUIDCount();
|
||||
const size_t serviceDataCount = advertisedDevice->getServiceDataCount();
|
||||
const bool haveTxPower = advertisedDevice->haveTXPower();
|
||||
const int8_t txPower = advertisedDevice->getTXPower();
|
||||
|
||||
if (serviceAdvCount > 0) fingerprintServiceAdvertisements(advertisedDevice, serviceAdvCount, haveTxPower, txPower);
|
||||
if (serviceDataCount > 0) fingerprintServiceData(advertisedDevice, serviceDataCount, haveTxPower, txPower);
|
||||
|
@ -167,7 +170,7 @@ void BleFingerprint::fingerprintAddress() {
|
|||
break;
|
||||
case BLE_ADDR_RANDOM:
|
||||
case BLE_ADDR_RANDOM_ID: {
|
||||
const auto *naddress = address.getNative();
|
||||
const auto *naddress = address;
|
||||
if ((naddress[5] & 0xc0) == 0xc0)
|
||||
setId(mac, ID_TYPE_RAND_STATIC_MAC);
|
||||
else {
|
||||
|
@ -460,7 +463,7 @@ void BleFingerprint::fill(JsonObject *doc) {
|
|||
(*doc)[F("raw")] = serialized(String(raw, 2));
|
||||
(*doc)[F("distance")] = serialized(String(output.value.position, 2));
|
||||
(*doc)[F("speed")] = serialized(String(output.value.speed * 1e3f, 2));
|
||||
(*doc)[F("mac")] = SMacf(address);
|
||||
(*doc)[F("mac")] = getMac();
|
||||
if (close) (*doc)[F("close")] = true;
|
||||
|
||||
(*doc)[F("interval")] = (millis() - firstSeenMillis) / seenCount;
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
void setInitial(int rssi, float distance);
|
||||
|
||||
String getMac() const { return SMacf(address); }
|
||||
const String getMac() const { return Sprintf("%02x%02x%02x%02x%02x%02x", address[0], address[1], address[2], address[3], address[4], address[5]); }
|
||||
|
||||
short getIdType() const { return idType; }
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
void set1mRssi(int8_t rssi) { this->calRssi = rssi; }
|
||||
|
||||
NimBLEAddress const getAddress() { return address; }
|
||||
const uint8_t* getAddress() const { return reinterpret_cast<const uint8_t*>(address); }
|
||||
|
||||
unsigned long getMsSinceLastSeen() const { return lastSeenMillis ? millis() - lastSeenMillis : 4294967295; };
|
||||
|
||||
|
@ -136,7 +136,7 @@ private:
|
|||
static bool shouldHide(const String &s);
|
||||
|
||||
bool hasValue = false, added = false, close = false, reported = false, ignore = false, allowQuery = false, isQuerying = false, hidden = false, connectable = false, countable = false, counting = false;
|
||||
NimBLEAddress address;
|
||||
uint8_t address[6];
|
||||
String id, name, disc;
|
||||
short int idType = NO_ID_TYPE;
|
||||
int rssi = NO_RSSI, newest = NO_RSSI, recent = NO_RSSI, oldest = NO_RSSI;
|
||||
|
|
|
@ -184,7 +184,7 @@ void CleanupOldFingerprints() {
|
|||
}
|
||||
|
||||
BleFingerprint *getFingerprintInternal(BLEAdvertisedDevice *advertisedDevice) {
|
||||
auto mac = advertisedDevice->getAddress();
|
||||
auto mac = advertisedDevice->getAddress().getNative();
|
||||
|
||||
auto it = std::find_if(fingerprints.rbegin(), fingerprints.rend(), [mac](BleFingerprint *f) { return f->getAddress() == mac; });
|
||||
if (it != fingerprints.rend())
|
||||
|
|
Loading…
Reference in New Issue