parent
7c6e5939c8
commit
3a54825c2c
31
CHANGELOG.md
31
CHANGELOG.md
|
@ -4,6 +4,37 @@ 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.15]
|
||||
|
||||
- Allow status led to be disabled (#156)
|
||||
|
||||
## [2.0.14]
|
||||
|
||||
- Add eddystone uid support @DTTerastar (#188)
|
||||
- Add support for alt-beacons @DTTerastar (#187)
|
||||
|
||||
## [2.0.13]
|
||||
|
||||
- Bump NimBLE-Arduino.git to 1.3.3 @DTTerastar (#145)
|
||||
|
||||
## [2.0.11] && [2.0.12]
|
||||
|
||||
- Requery if room assistant broadcast found after query @DTTerastar (#126)
|
||||
- Slight tweaks and logging to try and fix #125
|
||||
|
||||
## [2.0.10]
|
||||
|
||||
- Add trackr support @DTTerastar (#121)
|
||||
|
||||
## [2.0.9]
|
||||
|
||||
- Add support for ATC\_MiThermometer @DTTerastar (#124)
|
||||
- Add initial support for meater @DTTerastar (#124)
|
||||
- Improve msft:cdp fingerprint @DTTerastar (#124)
|
||||
|
||||
## [2.0.7] && [2.0.8]
|
||||
|
||||
- Add entity categories for config items @DTTerastar (#114)
|
||||
|
||||
## [2.0.6]
|
||||
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
#include "GUI.h"
|
||||
|
||||
#if defined M5STICK
|
||||
|
||||
#define LED_BUILTIN 10
|
||||
#define LED_BUILTIN_ON 0
|
||||
|
||||
#define BUTTON 39
|
||||
#define BUTTON_PRESSED 0
|
||||
|
||||
#elif defined M5ATOM
|
||||
|
||||
#define BUTTON 39
|
||||
#define BUTTON_PRESSED 0
|
||||
|
||||
#elif defined HUZZAH32
|
||||
|
||||
#define LED_BUILTIN 13
|
||||
#define LED_BUILTIN_ON 1
|
||||
|
||||
#else //DevKit / generic
|
||||
|
||||
#define LED_BUILTIN 2
|
||||
#define LED_BUILTIN_ON 1
|
||||
|
||||
#endif
|
||||
|
||||
GUI Display;
|
||||
|
||||
void GUI::seenStart()
|
||||
|
@ -8,7 +33,7 @@ void GUI::seenStart()
|
|||
#ifdef M5ATOM
|
||||
M5.dis.drawpix(0, CRGB(15, 15, 15));
|
||||
#else
|
||||
digitalWrite(LED_BUILTIN, LED_BUILTIN_ON);
|
||||
if (_statusLed) digitalWrite(LED_BUILTIN, LED_BUILTIN_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -37,7 +62,7 @@ void GUI::connecting()
|
|||
status("Connecting...");
|
||||
connected(false, false);
|
||||
#ifdef LED_BUILTIN
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
if (_statusLed) digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -107,6 +132,13 @@ void GUI::status(const char *format, ...)
|
|||
#endif
|
||||
}
|
||||
|
||||
void GUI::setup()
|
||||
{
|
||||
#ifdef LED_BUILTIN
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GUI::begin()
|
||||
{
|
||||
if (!init)
|
||||
|
@ -124,7 +156,7 @@ void GUI::begin()
|
|||
}
|
||||
}
|
||||
|
||||
void GUI::update()
|
||||
void GUI::blit()
|
||||
{
|
||||
begin();
|
||||
#ifdef M5STICK
|
||||
|
@ -137,10 +169,17 @@ void GUI::update()
|
|||
#endif
|
||||
}
|
||||
|
||||
void GUI::updateStart()
|
||||
{
|
||||
#ifdef LED_BUILTIN
|
||||
if (_statusLed) digitalWrite(LED_BUILTIN, LED_BUILTIN_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GUI::updateProgress(unsigned int percent)
|
||||
{
|
||||
#ifdef LED_BUILTIN
|
||||
digitalWrite(LED_BUILTIN, percent % 2);
|
||||
if (_statusLed) digitalWrite(LED_BUILTIN, percent % 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -14,36 +14,13 @@
|
|||
#include <M5Atom.h>
|
||||
#endif
|
||||
|
||||
#if defined M5STICK
|
||||
|
||||
#define LED_BUILTIN 10
|
||||
#define LED_BUILTIN_ON 0
|
||||
|
||||
#define BUTTON 39
|
||||
#define BUTTON_PRESSED 0
|
||||
|
||||
#elif defined M5ATOM
|
||||
|
||||
#define BUTTON 39
|
||||
#define BUTTON_PRESSED 0
|
||||
|
||||
#elif defined HUZZAH32
|
||||
|
||||
#define LED_BUILTIN 13
|
||||
#define LED_BUILTIN_ON 1
|
||||
|
||||
#else //DevKit / generic
|
||||
|
||||
#define LED_BUILTIN 2
|
||||
#define LED_BUILTIN_ON 1
|
||||
|
||||
#endif
|
||||
|
||||
class BleFingerprint;
|
||||
|
||||
class GUI
|
||||
{
|
||||
public:
|
||||
void setup();
|
||||
|
||||
void added(BleFingerprint *f);
|
||||
void removed(BleFingerprint *f, long age);
|
||||
void close(BleFingerprint *f);
|
||||
|
@ -55,6 +32,7 @@ public:
|
|||
void seenStart();
|
||||
void seenEnd();
|
||||
|
||||
void updateStart();
|
||||
void updateProgress(unsigned int percent);
|
||||
void updateEnd();
|
||||
|
||||
|
@ -62,9 +40,12 @@ public:
|
|||
void connected(bool wifi, bool mqtt);
|
||||
|
||||
void status(const char *message, ...);
|
||||
void update();
|
||||
void blit();
|
||||
|
||||
void setStatusLed(bool enabled) { _statusLed = enabled; }
|
||||
|
||||
private:
|
||||
bool _statusLed = true;
|
||||
void begin();
|
||||
|
||||
bool init;
|
||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -16,7 +16,7 @@ bool sendTelemetry(int totalSeen, int totalFpSeen, int totalFpQueried, int total
|
|||
|
||||
if (discovery && !sentDiscovery)
|
||||
{
|
||||
if (sendDiscoveryConnectivity() && sendNumberDiscovery("Max Distance", "config") && sendSwitchDiscovery("Active Scan", "config") && sendSwitchDiscovery("Query", "config") && sendDiscoveryMotion() && sendDiscoveryHumidity() && sendDiscoveryTemperature() && sendDiscoveryLux())
|
||||
if (sendDiscoveryConnectivity() && sendSwitchDiscovery("Status LED", "config") && sendNumberDiscovery("Max Distance", "config") && sendSwitchDiscovery("Active Scan", "config") && sendSwitchDiscovery("Query", "config") && sendDiscoveryMotion() && sendDiscoveryHumidity() && sendDiscoveryTemperature() && sendDiscoveryLux())
|
||||
{
|
||||
sentDiscovery = true;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ bool sendTelemetry(int totalSeen, int totalFpSeen, int totalFpQueried, int total
|
|||
void connectToWifi()
|
||||
{
|
||||
Serial.printf("Connecting to WiFi (%s)...\n", WiFi.macAddress().c_str());
|
||||
Display.update();
|
||||
Display.blit();
|
||||
|
||||
WiFiSettings.onConnect = []()
|
||||
{
|
||||
|
@ -118,6 +118,9 @@ void connectToWifi()
|
|||
|
||||
WiFiSettings.heading("Preferences");
|
||||
|
||||
statusLed = WiFiSettings.checkbox("status_led", true, "Status LED");
|
||||
Display.setStatusLed(statusLed);
|
||||
|
||||
autoUpdate = WiFiSettings.checkbox("auto_update", DEFAULT_AUTO_UPDATE, "Automatically Update");
|
||||
otaUpdate = WiFiSettings.checkbox("ota_update", DEFAULT_OTA_UPDATE, "Arduino OTA Update");
|
||||
discovery = WiFiSettings.checkbox("discovery", true, "Home Assistant Discovery");
|
||||
|
@ -231,6 +234,13 @@ void onMqttMessage(char *topic, char *payload, AsyncMqttClientMessageProperties
|
|||
spurt("/query", String(allowQuery));
|
||||
online = false;
|
||||
}
|
||||
else if (top == roomsTopic + "/status_led/set")
|
||||
{
|
||||
statusLed = pay == "ON";
|
||||
spurt("/status_led", String(statusLed));
|
||||
Display.setStatusLed(statusLed);
|
||||
online = false;
|
||||
}
|
||||
|
||||
fingerprints.setParams(refRssi, forgetMs, skipDistance, skipMs, maxDistance);
|
||||
}
|
||||
|
@ -397,9 +407,7 @@ void triggerGetTemp()
|
|||
|
||||
void setup()
|
||||
{
|
||||
#ifdef LED_BUILTIN
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
#endif
|
||||
Display.setup();
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.setDebugOutput(true);
|
||||
|
@ -664,7 +672,7 @@ void loop()
|
|||
if (otaUpdate)
|
||||
ArduinoOTA.handle();
|
||||
firmwareUpdate();
|
||||
Display.update();
|
||||
Display.blit();
|
||||
pirLoop();
|
||||
radarLoop();
|
||||
dhtLoop();
|
||||
|
|
14
src/main.h
14
src/main.h
|
@ -57,7 +57,7 @@ String teleTopic;
|
|||
String roomsTopic;
|
||||
String subTopic;
|
||||
bool autoUpdate, otaUpdate;
|
||||
bool discovery;
|
||||
bool discovery, statusLed;
|
||||
bool activeScan, allowQuery;
|
||||
bool publishTele;
|
||||
bool publishRooms;
|
||||
|
@ -236,11 +236,10 @@ void firmwareUpdate()
|
|||
|
||||
updateInProgress = true;
|
||||
fingerprints.setDisable(updateInProgress);
|
||||
#ifdef LED_BUILTIN
|
||||
httpUpdate.setLedPin(LED_BUILTIN, LED_BUILTIN_ON);
|
||||
#endif
|
||||
Display.updateStart();
|
||||
httpUpdate.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
||||
t_httpUpdate_return ret = httpUpdate.update(client, firmwareUrl);
|
||||
Display.updateEnd();
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
|
@ -297,7 +296,7 @@ void spiffsInit()
|
|||
|
||||
bool sendOnline()
|
||||
{
|
||||
return mqttClient.publish(statusTopic.c_str(), 0, 1, "online") && mqttClient.publish((roomsTopic + "/max_distance").c_str(), 0, 1, String(maxDistance).c_str()) && mqttClient.publish((roomsTopic + "/query").c_str(), 0, 1, String(allowQuery ? "ON" : "OFF").c_str()) && mqttClient.publish((roomsTopic + "/active_scan").c_str(), 0, 1, String(activeScan ? "ON" : "OFF").c_str());
|
||||
return mqttClient.publish(statusTopic.c_str(), 0, 1, "online") && mqttClient.publish((roomsTopic + "/max_distance").c_str(), 0, 1, String(maxDistance).c_str()) && mqttClient.publish((roomsTopic + "/query").c_str(), 0, 1, String(allowQuery ? "ON" : "OFF").c_str()) && mqttClient.publish((roomsTopic + "/status_led").c_str(), 0, 1, String(statusLed ? "ON" : "OFF").c_str()) && mqttClient.publish((roomsTopic + "/active_scan").c_str(), 0, 1, String(activeScan ? "ON" : "OFF").c_str());
|
||||
}
|
||||
|
||||
void commonDiscovery(JsonDocument *doc)
|
||||
|
@ -311,9 +310,10 @@ void commonDiscovery(JsonDocument *doc)
|
|||
(*doc)["dev"]["name"] = "ESPresense " + room;
|
||||
(*doc)["dev"]["sa"] = room;
|
||||
#ifdef VERSION
|
||||
(*doc)["dev"]["sw_version"] = VERSION;
|
||||
(*doc)["dev"]["sw"] = VERSION;
|
||||
#endif
|
||||
(*doc)["dev"]["manufacturer"] = "ESPresense (" FIRMWARE ")";
|
||||
(*doc)["dev"]["mf"] = "ESPresense (" FIRMWARE ")";
|
||||
(*doc)["dev"]["cu"] = "http://" + localIp;
|
||||
(*doc)["dev"]["mdl"] = ESP.getChipModel();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue