Skip to content

Commit

Permalink
merged pr-18 thanks to blenk92
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Lukas committed Jan 21, 2023
2 parents 7869998 + 96dead2 commit 91f11a6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Bluetti_ESP32/BTooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ void handleBluetooth(){

if ((millis() - lastBTMessage) > (MAX_DISCONNECTED_TIME_UNTIL_REBOOT * 60000)){
Serial.println(F("BT is disconnected over allowed limit, reboot device"));
ESP.restart();
#ifdef SLEEP_TIME_ON_BT_NOT_AVAIL
esp_deep_sleep_start();
#else
ESP.restart();
#endif
}

if (connected) {
Expand Down
3 changes: 3 additions & 0 deletions Bluetti_ESP32/Bluetti_ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ void setup() {
#endif
digitalWrite(RELAIS_PIN, RELAIS_LOW);
#endif
#ifdef SLEEP_TIME_ON_BT_NOT_AVAIL
esp_sleep_enable_timer_wakeup(SLEEP_TIME_ON_BT_NOT_AVAIL * 60 * 1000000ULL);
#endif
initBWifi(false);
initBluetooth();
initMQTT();
Expand Down
2 changes: 2 additions & 0 deletions Bluetti_ESP32/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define RELAIS_HIGH HIGH

#define MAX_DISCONNECTED_TIME_UNTIL_REBOOT 5 //device will reboot when wlan/BT/MQTT is not connectet within x Minutes
#define SLEEP_TIME_ON_BT_NOT_AVAIL 2 //device will sleep x minutes if restarted is triggered by bluetooth error
//set to 0 to disable
#define DEVICE_STATE_UPDATE 5
#define MSG_VIEWER_ENTRY_COUNT 20 //number of lines for web message viewer
#define MSG_VIEWER_REFRESH_CYCLE 5 //refresh time for website data in seconds
Expand Down
4 changes: 4 additions & 0 deletions Bluetti_ESP32/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ const char index_html[] PROGMEM = R"rawliteral(
.card { background-color: white; box-shadow: 2px 2px 12px 1px rgba(135, 105, 105, 0.5); }
.cards { max-width: 800px; margin: 0 auto; display: grid; grid-gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.reading { font-size: 1.4rem; }
.version { margin-bottom: 1em; }
</style>
</head>
<body>
<div class="topnav">
<h1>Bluetti MQTT Bridge web server</h1>
<div class="version">
Firmware Version: 0.1.0 (<a href='/update' target='_blank'>Update</a>)
</div>
</div>
<div class="content">
<div class="cards">
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You will need to install a board support package for your ESP32. Additionally th

* https://github.com/tzapu/WiFiManager
* https://github.com/knolleary/pubsubclient
* https://github.com/ayushsharma82/ElegantOTA
* https://github.com/ayushsharma82/AsyncElegantOTA
* https://github.com/me-no-dev/ESPAsyncWebServer
* https://github.com/me-no-dev/AsyncTCP/archive

Expand Down

0 comments on commit 91f11a6

Please sign in to comment.