Don't Query until device is <= maxDistance
This commit is contained in:
parent
db439fbe3c
commit
c5333849cd
|
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.0.2]
|
||||
|
||||
- Don't Query until device is <= maxDistance
|
||||
|
||||
## [2.0.1]
|
||||
|
||||
- Query bugs squashed! Needs a bit more testing, but it's MUCH better than 2.0
|
||||
|
|
|
@ -256,7 +256,7 @@ void BleFingerprint::setInitial(int initalRssi, float initalDistance)
|
|||
hasValue = filter() || filter();
|
||||
}
|
||||
|
||||
bool BleFingerprint::report(JsonDocument *doc, float maxDistance)
|
||||
bool BleFingerprint::report(JsonDocument *doc)
|
||||
{
|
||||
if (ignore || (idType == 0 && !macPublic))
|
||||
return false;
|
||||
|
@ -264,6 +264,7 @@ bool BleFingerprint::report(JsonDocument *doc, float maxDistance)
|
|||
if (reported || !hasValue)
|
||||
return false;
|
||||
|
||||
auto maxDistance = _parent->getMaxDistance();
|
||||
if (maxDistance > 0 && output.value.position > maxDistance)
|
||||
return false;
|
||||
|
||||
|
@ -298,11 +299,20 @@ bool BleFingerprint::report(JsonDocument *doc, float maxDistance)
|
|||
bool BleFingerprint::query()
|
||||
{
|
||||
if (!shouldQuery || didQuery) return false;
|
||||
|
||||
auto maxDistance = _parent->getMaxDistance();
|
||||
if (!maxDistance) maxDistance = 16;
|
||||
|
||||
if (!hasValue || output.value.position > maxDistance)
|
||||
return false;
|
||||
|
||||
auto now = millis();
|
||||
if (now - lastQryMillis < 500) return false;
|
||||
didQuery = true;
|
||||
lastQryMillis = now;
|
||||
auto pClient = NimBLEDevice::getDisconnectedClient();
|
||||
|
||||
NimBLEClient *pClient = NimBLEDevice::getClientListSize() ? NimBLEDevice::getClientByPeerAddress(address) : nullptr;
|
||||
if (!pClient) pClient = NimBLEDevice::getDisconnectedClient();
|
||||
if (!pClient) pClient = NimBLEDevice::createClient();
|
||||
pClient->setConnectTimeout(5);
|
||||
if (pClient->connect(address))
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
BleFingerprint(BleFingerprintCollection *parent, BLEAdvertisedDevice *advertisedDevice, float fcmin, float beta, float dcutoff);
|
||||
|
||||
bool seen(BLEAdvertisedDevice *advertisedDevice);
|
||||
bool report(JsonDocument *doc, float maxDistance);
|
||||
bool report(JsonDocument *doc);
|
||||
bool query();
|
||||
|
||||
String getId()
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
int getSkipMs() { return _skipMs; }
|
||||
float getSkipDistance() { return _skipDistance; }
|
||||
int getRefRssi() { return _refRssi; }
|
||||
float getMaxDistance() { return _maxDistance; }
|
||||
|
||||
private:
|
||||
bool _disable = false;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
default_envs = esp32
|
||||
|
||||
[common_env_data]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
lib_deps_external =
|
||||
haimoz/SoftFilters@^0.1.0
|
||||
marvinroger/AsyncMqttClient@^0.9.0
|
||||
|
@ -27,8 +29,8 @@ build_flags =
|
|||
-D CONFIG_BT_NIMBLE_PINNED_TO_CORE=1
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = esp32dev
|
||||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
|
@ -39,8 +41,8 @@ build_flags =
|
|||
-D FIRMWARE='"esp32"'
|
||||
|
||||
[env:adafruit-huzzah32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = esp32dev
|
||||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
|
@ -51,8 +53,8 @@ build_flags =
|
|||
-D HUZZAH32
|
||||
|
||||
[env:esp32-verbose]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = esp32dev
|
||||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
|
@ -65,8 +67,8 @@ build_flags =
|
|||
-D VERBOSE
|
||||
|
||||
[env:m5stickc]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = m5stick-c
|
||||
lib_deps =
|
||||
m5stack/M5StickC@^0.2.0
|
||||
|
@ -79,8 +81,8 @@ build_flags =
|
|||
-D FIRMWARE='"m5stickc"'
|
||||
|
||||
[env:m5stickc-plus]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = m5stick-c
|
||||
lib_deps =
|
||||
m5stack/M5StickCPlus@^0.0.2
|
||||
|
@ -94,8 +96,8 @@ build_flags =
|
|||
-D FIRMWARE='"m5stickc-plus"'
|
||||
|
||||
[env:m5atom-matrix]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = m5stack-atom
|
||||
lib_deps =
|
||||
fastled/FastLED@^3.4.0
|
||||
|
@ -110,8 +112,8 @@ build_flags =
|
|||
-D FIRMWARE='"m5atom-matrix"'
|
||||
|
||||
[env:macchina-a0]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
platform = ${common_env_data.platform}
|
||||
framework = ${common_env_data.framework}
|
||||
board = esp32dev
|
||||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
|
|
|
@ -273,7 +273,7 @@ void connectToMqtt()
|
|||
bool reportDevice(BleFingerprint *f)
|
||||
{
|
||||
StaticJsonDocument<512> doc;
|
||||
if (!f->report(&doc, maxDistance))
|
||||
if (!f->report(&doc))
|
||||
return false;
|
||||
|
||||
char JSONmessageBuffer[512];
|
||||
|
|
Loading…
Reference in New Issue