From b9876c5834845421de4e0282a8b88b515cce0d1f Mon Sep 17 00:00:00 2001
From: DTTerastar
Date: Sat, 25 Sep 2021 10:46:19 -0400
Subject: [PATCH] Add adafruit-huzzah32 firmware flavor
---
.github/workflows/main.yml | 3 ++-
lib/BleFingerprint/BleFingerprint.cpp | 17 +++++++++++++++++
lib/BleFingerprint/BleFingerprint.h | 16 +---------------
platformio.ini | 4 ++--
4 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 62b3699..fb45275 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -30,11 +30,12 @@ jobs:
run: echo "PLATFORMIO_BUILD_FLAGS=-DVERSION='\"${GITHUB_REF#refs/*/}\"'" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Run PlatformIO
- run: pio run -e esp32 -e esp32-verbose -e m5stickc -e m5stickc-plus -e m5atom-matrix -e macchina-a0
+ run: pio run -e esp32 -e esp32-verbose -e adafruit-huzzah32 -e m5stickc -e m5stickc-plus -e m5atom-matrix -e macchina-a0
- name: Rename firmware
run: |
cp .pio/build/esp32/firmware.bin esp32.bin
cp .pio/build/esp32-verbose/firmware.bin esp32-verbose.bin
+ cp .pio/build/adafruit-huzzah32/firmware.bin adafruit-huzzah32.bin
cp .pio/build/m5stickc/firmware.bin m5stickc.bin
cp .pio/build/m5stickc-plus/firmware.bin m5stickc-plus.bin
cp .pio/build/m5atom-matrix/firmware.bin m5atom-matrix.bin
diff --git a/lib/BleFingerprint/BleFingerprint.cpp b/lib/BleFingerprint/BleFingerprint.cpp
index 417b209..7da7272 100644
--- a/lib/BleFingerprint/BleFingerprint.cpp
+++ b/lib/BleFingerprint/BleFingerprint.cpp
@@ -1,6 +1,21 @@
#include "BleFingerprint.h"
#include "util.h"
+#define Sprintf(f, ...) ( \
+ { \
+ char *s; \
+ asprintf(&s, f, __VA_ARGS__); \
+ String r = s; \
+ free(s); \
+ r; \
+ })
+
+#define SMacf(f) ( \
+ { \
+ auto nativeAddress = f.getNative(); \
+ Sprintf("%02x%02x%02x%02x%02x%02x", nativeAddress[5], nativeAddress[4], nativeAddress[3], nativeAddress[2], nativeAddress[1], nativeAddress[0]); \
+ })
+
static std::string hexStr(const char *data, int len)
{
constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
@@ -19,6 +34,8 @@ static std::string hexStr(std::string s)
return hexStr(s.c_str(), s.length());
}
+String BleFingerprint::getMac() { return SMacf(address); }
+
BleFingerprint::BleFingerprint(BLEAdvertisedDevice *advertisedDevice, float fcmin, float beta, float dcutoff) : oneEuro{one_euro_filter(1, fcmin, beta, dcutoff)}
{
if (advertisedDevice->getAddressType() == BLE_ADDR_PUBLIC)
diff --git a/lib/BleFingerprint/BleFingerprint.h b/lib/BleFingerprint/BleFingerprint.h
index 50f7192..44bfadb 100644
--- a/lib/BleFingerprint/BleFingerprint.h
+++ b/lib/BleFingerprint/BleFingerprint.h
@@ -17,20 +17,6 @@ static const int defaultTxPower = TX_DEFAULT;
static const int defaultTxPower = -59;
#endif
-#define Sprintf(f, ...) ( \
- { \
- char *s; \
- asprintf(&s, f, __VA_ARGS__); \
- String r = s; \
- free(s); \
- r; \
- })
-#define SMacf(f) ( \
- { \
- auto nativeAddress = f.getNative(); \
- Sprintf("%02x%02x%02x%02x%02x%02x", nativeAddress[5], nativeAddress[4], nativeAddress[3], nativeAddress[2], nativeAddress[1], nativeAddress[0]); \
- })
-
class BleFingerprint
{
@@ -47,7 +33,7 @@ public:
if (!sid.isEmpty()) return sid;
return getMac();
}
- String getMac() { return SMacf(address); }
+ String getMac();
int get1mRssi()
{
if (calRssi != NO_RSSI) return calRssi;
diff --git a/platformio.ini b/platformio.ini
index d648b76..1e6bc75 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -32,7 +32,7 @@ monitor_filters = esp32_exception_decoder
build_flags =
-D FIRMWARE='"esp32"'
-[env:esp32-huzzah32]
+[env:adafruit-huzzah32]
platform = espressif32
framework = arduino
board = esp32dev
@@ -41,7 +41,7 @@ board_build.partitions = partitions_singleapp.csv
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_flags =
- -D FIRMWARE='"esp32-huzzah32"'
+ -D FIRMWARE='"adafruit-huzzah32"'
-D HUZZAH32
[env:esp32-verbose]