WIP
This commit is contained in:
parent
106220646e
commit
b8625588cd
|
@ -90,9 +90,9 @@ BleFingerprint::BleFingerprint(BLEAdvertisedDevice *advertisedDevice, float fcmi
|
|||
int major = ENDIAN_CHANGE_U16(oBeacon.getMajor());
|
||||
int minor = ENDIAN_CHANGE_U16(oBeacon.getMinor());
|
||||
|
||||
id = "iBeacon:" + proximityUUID + "-" + String(major) + "-" + String(minor);
|
||||
id = "iBeacon:" + proximityUUID;
|
||||
Serial.printf(", ID: %s", id.c_str());
|
||||
calRssi = oBeacon.getSignalPower();
|
||||
calRssi = -oBeacon.getSignalPower();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,16 +197,16 @@ bool BleFingerprint::report(JsonDocument *doc, int maxDistance)
|
|||
String mac = SMacf(address);
|
||||
if (output.value.position < 0.5)
|
||||
{
|
||||
if (!enroll)
|
||||
if (!close)
|
||||
{
|
||||
Serial.printf("%d Enter | MAC: %s, ID: %-50s %lu %5.1f %5.1f %5.1f\n", xPortGetCoreID(), mac.c_str(), id.c_str(), output.timestamp, output.value.position, output.value.speed * 1e6, output.value.acceleration * 1e12);
|
||||
enroll = true;
|
||||
Display.close(mac.c_str(), id.c_str());
|
||||
close = true;
|
||||
}
|
||||
}
|
||||
else if (enroll && output.value.position > 1.5)
|
||||
else if (close && output.value.position > 1.5)
|
||||
{
|
||||
Serial.printf("%d Left | MAC: %s, ID: %-50s %lu %5.1f %5.1f %5.1f\n", xPortGetCoreID(), mac.c_str(), id.c_str(), output.timestamp, output.value.position, output.value.speed * 1e6, output.value.acceleration * 1e12);
|
||||
enroll = false;
|
||||
Display.left(mac.c_str(), id.c_str());
|
||||
close = false;
|
||||
}
|
||||
|
||||
if (id != nullptr)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _BLEFINGERPRINT_
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <GUI.h>
|
||||
#include <NimBLEAdvertisedDevice.h>
|
||||
#include <NimBLEBeacon.h>
|
||||
#include <NimBLEDevice.h>
|
||||
|
@ -30,7 +31,7 @@ public:
|
|||
long getLastSeen() { return lastSeenMicros; };
|
||||
|
||||
private:
|
||||
bool hasValue = false, enroll = false, reported = false;
|
||||
bool hasValue = false, close = false, reported = false;
|
||||
NimBLEAddress address;
|
||||
String id, name, url;
|
||||
int rssi = -100, calRssi = 0;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#include "GUI.h"
|
||||
|
||||
GUI Display;
|
||||
|
||||
void GUI::connected(bool wifi = false, bool mqtt = false)
|
||||
{
|
||||
status("Wifi: %s Mqtt: %s", (wifi ? "no" : "yes"), (wifi ? "no" : "yes"));
|
||||
}
|
||||
|
||||
void GUI::close(const char *mac, const char *id)
|
||||
{
|
||||
Serial.printf("%d Close | MAC: %s, ID: %-50s\n", xPortGetCoreID(), mac, id);
|
||||
status("C: %s", id);
|
||||
}
|
||||
|
||||
void GUI::left(const char *mac, const char *id)
|
||||
{
|
||||
Serial.printf("%d Left | MAC: %s, ID: %-50s\n", xPortGetCoreID(), mac, id);
|
||||
status("L: %s", id);
|
||||
}
|
||||
|
||||
void GUI::status(const char *format, ...)
|
||||
{
|
||||
#ifdef M5STICK
|
||||
sprite.fillSprite(TFT_BLACK);
|
||||
sprite.setTextDatum(MC_DATUM);
|
||||
#ifdef PLUS
|
||||
char *message;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vasprintf(&message, format, args);
|
||||
va_end(args);
|
||||
sprite.drawString(message, sprite.width() / 2, sprite.height() / 2, 4);
|
||||
#else
|
||||
sprite.drawString(message, sprite.width() / 2, sprite.height() / 2, 1);
|
||||
#endif
|
||||
free(message);
|
||||
dirty = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GUI::update()
|
||||
{
|
||||
#ifdef M5STICK
|
||||
if (!init)
|
||||
{
|
||||
M5.begin(true, true, false);
|
||||
M5.Lcd.setRotation(3);
|
||||
sprite.createSprite(M5.Lcd.width(), M5.Lcd.height());
|
||||
sprite.setSwapBytes(true);
|
||||
init = true;
|
||||
}
|
||||
if (dirty)
|
||||
{
|
||||
sprite.pushSprite(0, 0);
|
||||
M5.Axp.ScreenBreath(12);
|
||||
dirty = false;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef GUI_h
|
||||
#define GUI_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef M5STICK
|
||||
#ifdef PLUS
|
||||
#include <M5StickCPlus.h>
|
||||
#else
|
||||
#include <M5StickC.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class GUI
|
||||
{
|
||||
public:
|
||||
void close(const char *mac, const char *id);
|
||||
void left(const char *mac, const char *id);
|
||||
void status(const char *message, ...);
|
||||
void connected(bool wifi, bool mqtt);
|
||||
void update();
|
||||
|
||||
private:
|
||||
bool init;
|
||||
bool dirty;
|
||||
#ifdef M5STICK
|
||||
TFT_eSprite sprite = TFT_eSprite(&M5.Lcd);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
extern GUI Display;
|
|
@ -28,9 +28,11 @@ board = esp32dev
|
|||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-D FIRMWARE='"esp32"'
|
||||
-Wall
|
||||
|
||||
[env:esp32-noupdate]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
|
@ -42,6 +44,7 @@ build_flags =
|
|||
-D FIRMWARE='"esp32-noupdate"'
|
||||
-D NOUPDATE
|
||||
-Wall
|
||||
|
||||
[env:esp32-verbose]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
|
@ -49,10 +52,12 @@ board = esp32dev
|
|||
lib_deps = ${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-D FIRMWARE='"esp32-verbose"'
|
||||
-D VERBOSE
|
||||
-Wall
|
||||
|
||||
[env:m5stickc]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
|
@ -62,10 +67,12 @@ lib_deps =
|
|||
${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-D M5STICK
|
||||
-D FIRMWARE='"m5stickc"'
|
||||
-Wall
|
||||
|
||||
[env:m5stickc-plus]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
|
@ -75,11 +82,13 @@ lib_deps =
|
|||
${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-D M5STICK
|
||||
-D PLUS
|
||||
-D FIRMWARE='"m5stickc-plus"'
|
||||
-Wall
|
||||
|
||||
[env:m5atom-matrix]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
|
@ -88,6 +97,7 @@ lib_deps =
|
|||
${common_env_data.lib_deps_external}
|
||||
board_build.partitions = partitions_singleapp.csv
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-D M5ATOM
|
||||
-D MATRIX
|
||||
|
|
|
@ -39,7 +39,7 @@ bool sendTelemetry(int totalSeen = -1, int totalReported = -1, int totalAdverts
|
|||
initial = false;
|
||||
if (mqttClient.publish(availabilityTopic.c_str(), 0, 1, "online") == true)
|
||||
{
|
||||
Serial.println("Connected to MQTT");
|
||||
Display.status("Connected to MQTT");
|
||||
reconnectTries = 0;
|
||||
}
|
||||
else
|
||||
|
@ -295,12 +295,6 @@ void setup()
|
|||
setClock();
|
||||
connectToMqtt();
|
||||
xTaskCreatePinnedToCore(scanForDevices, "BLE Scan", 4096, nullptr, 1, &scannerTask, 1);
|
||||
|
||||
#ifdef M5STICK
|
||||
M5.begin();
|
||||
M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
#endif
|
||||
|
||||
configureOTA();
|
||||
}
|
||||
|
||||
|
@ -308,4 +302,5 @@ void loop()
|
|||
{
|
||||
ArduinoOTA.handle();
|
||||
firmwareUpdate();
|
||||
Display.update();
|
||||
}
|
||||
|
|
|
@ -22,14 +22,6 @@
|
|||
#include "BleFingerprint.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#ifdef M5STICK
|
||||
#ifdef PLUS
|
||||
#include <M5StickCPlus.h>
|
||||
#else
|
||||
#include <M5StickC.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AsyncMqttClient mqttClient;
|
||||
TimerHandle_t reconnectTimer;
|
||||
TaskHandle_t scannerTask;
|
||||
|
|
Loading…
Reference in New Issue