2021-03-22 14:11:42 +01:00
|
|
|
#ifndef _BLEFINGERPRINT_
|
|
|
|
#define _BLEFINGERPRINT_
|
|
|
|
|
2021-04-05 04:12:46 +02:00
|
|
|
#include <ArduinoJson.h>
|
2021-08-23 15:48:40 +02:00
|
|
|
#include <GUI.h>
|
2021-03-22 14:11:42 +01:00
|
|
|
#include <NimBLEAdvertisedDevice.h>
|
|
|
|
#include <NimBLEBeacon.h>
|
2021-04-05 04:12:46 +02:00
|
|
|
#include <NimBLEDevice.h>
|
|
|
|
#include <NimBLEEddystoneTLM.h>
|
|
|
|
#include <NimBLEEddystoneURL.h>
|
2021-03-22 23:56:29 +01:00
|
|
|
#include <SoftFilters.h>
|
2021-03-22 14:11:42 +01:00
|
|
|
|
|
|
|
class BleFingerprint
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2021-04-05 04:12:46 +02:00
|
|
|
BleFingerprint(BLEAdvertisedDevice *advertisedDevice, float fcmin, float beta, float dcutoff);
|
2021-03-30 00:12:59 +02:00
|
|
|
~BleFingerprint();
|
2021-03-22 14:11:42 +01:00
|
|
|
|
|
|
|
void seen(BLEAdvertisedDevice *advertisedDevice);
|
2021-03-31 19:36:20 +02:00
|
|
|
bool report(JsonDocument *doc, int maxDistance);
|
2021-03-22 14:11:42 +01:00
|
|
|
|
2021-03-30 00:12:59 +02:00
|
|
|
String getId() { return id; }
|
|
|
|
|
2021-04-07 02:13:13 +02:00
|
|
|
float getDistance() { return output.value.position; }
|
|
|
|
int getRSSI() { return rssi; }
|
|
|
|
|
|
|
|
void setInitial(int rssi, float distance);
|
2021-03-22 14:11:42 +01:00
|
|
|
|
2021-03-28 20:35:54 +02:00
|
|
|
NimBLEAddress getAddress() { return address; }
|
2021-04-02 21:16:30 +02:00
|
|
|
long getLastSeen() { return lastSeenMicros; };
|
2021-03-22 14:11:42 +01:00
|
|
|
|
|
|
|
private:
|
2021-09-09 14:16:40 +02:00
|
|
|
bool hasValue = false, close = false, reported = false, macPublic = false;
|
2021-03-28 20:35:54 +02:00
|
|
|
NimBLEAddress address;
|
2021-03-29 20:50:23 +02:00
|
|
|
String id, name, url;
|
2021-04-07 02:13:13 +02:00
|
|
|
int rssi = -100, calRssi = 0;
|
|
|
|
int newest = -100;
|
|
|
|
int recent = -100;
|
|
|
|
int oldest = -100;
|
2021-04-02 13:56:27 +02:00
|
|
|
float raw, lastReported = 0;
|
|
|
|
long firstSeenMicros, lastSeenMicros = 0, lastReportedMicros = 0;
|
2021-03-29 20:50:23 +02:00
|
|
|
|
2021-03-22 23:56:29 +01:00
|
|
|
Reading<Differential<float>> output;
|
|
|
|
|
|
|
|
TimestampFilter<float> tsFilter;
|
2021-04-05 04:12:46 +02:00
|
|
|
one_euro_filter<double, unsigned long> oneEuro;
|
2021-03-22 23:56:29 +01:00
|
|
|
DifferentialFilter<float> diffFilter;
|
2021-04-07 02:13:13 +02:00
|
|
|
|
|
|
|
bool filter();
|
2021-03-22 14:11:42 +01:00
|
|
|
};
|
|
|
|
#endif
|