big dependency tidy up
This commit is contained in:
parent
66f10445a4
commit
278d40af33
|
@ -90,6 +90,7 @@
|
|||
#include "src/cfg/pins.h"
|
||||
#include "src/RTC/Timers.h"
|
||||
#include "src/RTC/Clock.h"
|
||||
#include "src/WiFi/BTCWifi.h"
|
||||
#include "src/WiFi/BTCWebServer.h"
|
||||
#include "src/WiFi/BTCota.h"
|
||||
#include "src/Protocol/Protocol.h"
|
||||
|
@ -322,7 +323,7 @@ void setup() {
|
|||
DebugPort.printf("SPIFFS usage: %d/%d\r\n", SPIFFS.usedBytes(), SPIFFS.totalBytes());
|
||||
DebugPort.println("Listing SPIFFS contents:");
|
||||
String report;
|
||||
listDir(SPIFFS, "/", 2, report);
|
||||
listSPIFFS("/", 2, report);
|
||||
}
|
||||
|
||||
NVstore.init();
|
||||
|
@ -363,7 +364,6 @@ void setup() {
|
|||
|
||||
#endif // USE_WIFI
|
||||
|
||||
// pinMode(ListenOnlyPin, INPUT_PULLUP); // pin to enable passive mode
|
||||
pinMode(LED_Pin, OUTPUT); // On board LED indicator
|
||||
digitalWrite(LED_Pin, LOW);
|
||||
|
||||
|
@ -631,15 +631,10 @@ void loop()
|
|||
|
||||
case CommStates::HeaterReport1:
|
||||
if(CommState.delayExpired()) {
|
||||
/* if(digitalRead(ListenOnlyPin)) { // pin open, pulled high (STANDARD OPERATION)*/
|
||||
bool isBTCmaster = false;
|
||||
TxManage.PrepareFrame(OEMCtrlFrame, isBTCmaster); // parrot OEM parameters, but block NV modes
|
||||
TxManage.Start(timenow);
|
||||
CommState.set(CommStates::BTC_Tx);
|
||||
/* }
|
||||
else { // pin shorted to ground
|
||||
CommState.set(CommStates::TemperatureRead); // "Listen Only" input is held low, don't send our Tx
|
||||
}*/
|
||||
bool isBTCmaster = false;
|
||||
TxManage.PrepareFrame(OEMCtrlFrame, isBTCmaster); // parrot OEM parameters, but block NV modes
|
||||
TxManage.Start(timenow);
|
||||
CommState.set(CommStates::BTC_Tx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1371,7 +1366,7 @@ void doStreaming()
|
|||
bBTconnected = false;
|
||||
}
|
||||
// manage changes in number of wifi clients
|
||||
if(isWebServerClientChange()) {
|
||||
if(isWebSocketClientChange()) {
|
||||
resetJSONmoderator(); // force full send upon number of Wifi clients change
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
#ifndef __BLUETOOTHABSTRACT_H__
|
||||
#define __BLUETOOTHABSTRACT_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/DebugPort.h"
|
||||
//#include "../Utility/DebugPort.h"
|
||||
#include "../Utility/helpers.h"
|
||||
|
||||
class CProtocol;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
Purpose: Perform an OTA update from a bin located on a webserver (HTTP Only)
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "esp32fota.h"
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef esp32fota_h
|
||||
#define esp32fota_h
|
||||
|
||||
#include <Arduino.h>
|
||||
//#include <Arduino.h>
|
||||
|
||||
class esp32FOTA
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "128x64OLED.h"
|
||||
#include "../Utility/DebugPort.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
|
||||
#define DBG DebugPort.print
|
||||
#define DBGln DebugPort.println
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
#endif
|
||||
|
||||
#include "fonts/FontTypes.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
//#include "../Utility/UtilClasses.h"
|
||||
|
||||
struct CRect;
|
||||
|
||||
class C128x64_OLED : public OLED_BASE_CLASS {
|
||||
const FONT_INFO* m_pFontInfo;
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "128x64OLED.h"
|
||||
#include "fonts/Tahoma16.h"
|
||||
#include <Arduino.h>
|
||||
#include "fonts/Tahoma24.h"
|
||||
#include "fonts/Icons.h"
|
||||
#include "BasicScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
|
@ -32,7 +30,6 @@
|
|||
|
||||
|
||||
#define MAXIFONT tahoma_24ptFontInfo
|
||||
//#define MAXIFONT tahoma_16ptFontInfo
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -71,7 +68,6 @@ CBasicScreen::show()
|
|||
{
|
||||
CTransientFont AF(_display, &MAXIFONT); // temporarily use a large font
|
||||
_printMenuText(_display.xCentre(), 23, msg, false, eCentreJustify);
|
||||
// _printMenuText(_display.xCentre(), 25, msg, false, eCentreJustify);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "ClockScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "fonts/Tahoma16.h"
|
||||
#include "fonts/Tahoma24.h"
|
||||
#include "../RTC/Clock.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
#include "128x64OLED.h"
|
||||
#include "fonts/MiniFont.h"
|
||||
#include "fonts/Icons.h"
|
||||
#include "../Bluetooth/BluetoothAbstract.h"
|
||||
#include "DetailedScreen.h"
|
||||
#include "../WiFi/BTCWifi.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "FuelMixtureScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../WiFi/BTCWifi.h"
|
||||
#include "../Utility/DebugPort.h"
|
||||
#include "../Utility/macros.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include "128x64OLED.h"
|
||||
#include "GPIOScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Utility/BTC_GPIO.h"
|
||||
#include "fonts/Icons.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "HeaterSettingsScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/macros.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@
|
|||
#include "128x64OLED.h"
|
||||
#include "HomeMenuSelScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Utility/BTC_GPIO.h"
|
||||
#include "fonts/Icons.h"
|
||||
|
||||
|
||||
|
@ -64,7 +60,6 @@ CHomeMenuSelScreen::show()
|
|||
else {
|
||||
_printInverted(_display.xCentre(), 0, " Home Menu Actions ", true, eCentreJustify);
|
||||
|
||||
// _printMenuText(66, 14, "On timeout:", false, eRightJustify);
|
||||
_drawBitmap(30, 14, TimeoutIconInfo);
|
||||
switch(_action.onTimeout) {
|
||||
case 0: strcpy(msg, "Default"); break;
|
||||
|
@ -74,7 +69,6 @@ CHomeMenuSelScreen::show()
|
|||
}
|
||||
_printMenuText(50, 14, msg, _rowSel == 3);
|
||||
|
||||
// _printMenuText(66, 26, "On start:", false, eRightJustify);
|
||||
_drawBitmap(32, 26, StartIconInfo);
|
||||
switch(_action.onStart) {
|
||||
case 0: strcpy(msg, "Default"); break;
|
||||
|
@ -84,7 +78,6 @@ CHomeMenuSelScreen::show()
|
|||
}
|
||||
_printMenuText(50, 26, msg, _rowSel == 2);
|
||||
|
||||
// _printMenuText(66, 38, "On stop:", false, eRightJustify);
|
||||
_drawBitmap(31, 38, StopIconInfo);
|
||||
switch(_action.onStop) {
|
||||
case 0: strcpy(msg, "Default"); break;
|
||||
|
@ -94,13 +87,6 @@ CHomeMenuSelScreen::show()
|
|||
}
|
||||
_printMenuText(50, 38, msg, _rowSel == 1);
|
||||
|
||||
/* if(_rowSel == 0)
|
||||
_printMenuText(_display.xCentre(), 53, " \021 \030Edit Exit \020 ", true, eCentreJustify);
|
||||
else {
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
_printMenuText(_display.xCentre(), 56, "\030\031Sel \033\032 Adj", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), 56, "Save", false, eCentreJustify);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
|
||||
|
||||
class CHomeMenuSelScreen : public CPasswordScreen
|
||||
{
|
||||
int _rowSel;
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
#include "128x64OLED.h"
|
||||
#include "OtherOptionsScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Utility/BTC_GPIO.h"
|
||||
#include "fonts/Icons.h"
|
||||
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "PasswordScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../WiFi/BTCWifi.h"
|
||||
#include "fonts/Arial.h"
|
||||
#include "../Utility/macros.h"
|
||||
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@
|
|||
#ifndef __SCREEN_H__
|
||||
#define __SCREEN_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "128x64OLED.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "fonts/FontTypes.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
|
||||
struct BITMAP_INFO {
|
||||
uint8_t width;
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
#ifndef __SCREEN_HEADER_H__
|
||||
#define __SCREEN_HEADER_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Screen.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "fonts/FontTypes.h"
|
||||
|
||||
struct sScreenholdoff {
|
||||
int holdon;
|
||||
|
|
|
@ -22,11 +22,9 @@
|
|||
#ifndef __SCREEN_MANAGER_H__
|
||||
#define __SCREEN_MANAGER_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <vector>
|
||||
#include "../Utility/UtilClasses.h"
|
||||
|
||||
//class CProtocol;
|
||||
class C128x64_OLED;
|
||||
class CScreen;
|
||||
class CRebootScreen;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "SetTimerScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Libraries/RTClib/RTClib.h"
|
||||
#include "../RTC/TimerManager.h"
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "SettingsScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../WiFi/BTCWifi.h"
|
||||
#include "../Utility/macros.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "128x64OLED.h"
|
||||
//#include "128x64OLED.h"
|
||||
#include "ThermostatModeScreen.h"
|
||||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "fonts/Icons.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -24,13 +24,11 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "ScreenHeader.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
class CProtocol;
|
||||
|
||||
//class CTimerChartScreen : public CScreenHeader {
|
||||
class CTimerChartScreen : public CScreen {
|
||||
int _rowSel;
|
||||
int _colSel;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Utility/BTC_GPIO.h"
|
||||
#include "../WiFi/BTCWifi.h"
|
||||
#include "../Utility/BoardDetect.h"
|
||||
#include "fonts/Icons.h"
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef _CPROTOCOL_H_
|
||||
#define _CPROTOCOL_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../Utility/UtilClasses.h"
|
||||
|
||||
class CProtocol {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Protocol.h"
|
||||
|
||||
class CTxManage
|
||||
|
|
|
@ -405,7 +405,7 @@ void updateJSONclients(bool report)
|
|||
if (report) {
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
|
@ -417,7 +417,7 @@ void updateJSONclients(bool report)
|
|||
if (report) {
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
|
@ -434,7 +434,7 @@ void updateJSONclients(bool report)
|
|||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
tStart = millis();
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
unsigned long tWF = millis() - tStart;
|
||||
tStart = millis();
|
||||
std::string expand = jsonStr;
|
||||
|
@ -458,7 +458,7 @@ void updateJSONclients(bool report)
|
|||
root.printTo(jsonStr, 800);
|
||||
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
|
@ -470,7 +470,7 @@ void updateJSONclients(bool report)
|
|||
if (report) {
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
|
@ -482,7 +482,7 @@ void updateJSONclients(bool report)
|
|||
if (report) {
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
sendWebSocketString( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../Libraries/TelnetSpy/TelnetSpy.h"
|
||||
|
||||
#ifndef __DEBUGPORT_H__
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
#ifndef __UTIL_CLASSES_H__
|
||||
#define __UTIL_CLASSES_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <string.h>
|
||||
//#include <string.h>
|
||||
#include "DebugPort.h"
|
||||
#include "../cfg/BTCConfig.h"
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
//
|
||||
|
||||
#ifdef USEMQTT
|
||||
#include <Arduino.h>
|
||||
#include "ABMqtt.h"
|
||||
#include "../Libraries/PubSubClient/src/PubSubClient.h"
|
||||
#include "BTCWifi.h"
|
||||
#include "BTCWebServer.h"
|
||||
|
||||
|
||||
void MqttCallback(char* topic, byte* payload, unsigned int length) {
|
||||
|
|
|
@ -3,20 +3,14 @@
|
|||
#ifndef _ABMQTT_h
|
||||
#define _ABMQTT_h
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "../Libraries/PubSubClient/src/PubSubClient.h"
|
||||
#include "BTCWifi.h""
|
||||
#include "BTCWebServer.h"
|
||||
// #include "../Libraries/PubSubClient/src/PubSubClient.h"
|
||||
// #include "BTCWifi.h""
|
||||
// #include "BTCWebServer.h"
|
||||
|
||||
|
||||
void MqttCallback(char* topic, byte* payload, unsigned int length);
|
||||
void MqttSetup();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -22,18 +22,23 @@
|
|||
|
||||
#define USE_EMBEDDED_WEBUPDATECODE
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "BTCWifi.h"
|
||||
#include "BTCWebServer.h"
|
||||
#include "../Utility/DebugPort.h"
|
||||
#include "../Protocol/TxManage.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "../cfg/pins.h"
|
||||
#include "../cfg/BTCConfig.h"
|
||||
//#include "Index.h"
|
||||
#include "../Utility/BTC_JSON.h"
|
||||
#include "../Utility/Moderator.h"
|
||||
#include "../Libraries/WiFiManager-dev/WiFiManager.h"
|
||||
#include <SPIFFS.h>
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include <WiFiClient.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <Update.h>
|
||||
|
||||
extern WiFiManager wm;
|
||||
extern const char* stdHeader;
|
||||
|
@ -53,18 +58,19 @@ bool bUpdateAccessed = false; // flag used to ensure web update always starts v
|
|||
bool bFormatAccessed = false;
|
||||
long _SuppliedFileSize = 0;
|
||||
|
||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length);
|
||||
bool checkFile(File &file);
|
||||
void addTableData(String& HTML, String dta);
|
||||
void rootRedirect();
|
||||
String getContentType(String filename);
|
||||
bool handleFileRead(String path);
|
||||
void handleBTCNotFound();
|
||||
void onSPIFFSErase();
|
||||
void onNotFound();
|
||||
void onErase();
|
||||
void onFormatSPIFFS();
|
||||
void onFormatNow();
|
||||
void onFormatDone();
|
||||
void onWMConfig();
|
||||
void onWebReset();
|
||||
void onResetWifi();
|
||||
void onUploadBegin();
|
||||
void onUploadCompletion();
|
||||
void onUploadProgression();
|
||||
|
@ -87,8 +93,8 @@ void initWebServer(void) {
|
|||
}
|
||||
|
||||
server.on("/wmconfig", onWMConfig);
|
||||
server.on("/resetwifi", onWebReset);
|
||||
server.on("/erase", HTTP_POST, onSPIFFSErase); // erase file from SPIFFS
|
||||
server.on("/resetwifi", onResetWifi);
|
||||
server.on("/erase", HTTP_POST, onErase); // erase file from SPIFFS
|
||||
|
||||
// Magical code originally shamelessly lifted from Arduino WebUpdate example, then greatly modified
|
||||
// This allows pushing new firmware to the ESP from a WEB BROWSER!
|
||||
|
@ -117,7 +123,7 @@ void initWebServer(void) {
|
|||
server.onNotFound([]()
|
||||
{ // If the client requests any URI
|
||||
if (!handleFileRead(server.uri())) { // send it if it exists
|
||||
handleBTCNotFound();
|
||||
onNotFound();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -311,7 +317,7 @@ void onWMConfig()
|
|||
wifiEnterConfigPortal(true, false, 3000);
|
||||
}
|
||||
|
||||
void onWebReset()
|
||||
void onResetWifi()
|
||||
{
|
||||
DebugPort.println("WEB: GET /resetwifi");
|
||||
server.send(200, "text/plain", "Start Config Portal - Resetting Wifi credentials!");
|
||||
|
@ -324,7 +330,7 @@ void onWebReset()
|
|||
//<p><a href="/update"> <button type="button">Add</button></a>
|
||||
//<p><a href="/"><button type="button">Home</button></a>
|
||||
|
||||
void handleBTCNotFound()
|
||||
void onNotFound()
|
||||
{
|
||||
String path = server.uri();
|
||||
if (path.endsWith("/")) path += "index.html"; // If a folder is requested, send the index file
|
||||
|
@ -341,20 +347,7 @@ void rootRedirect()
|
|||
server.send(303);
|
||||
}
|
||||
|
||||
bool isWebServerClientChange()
|
||||
{
|
||||
static int prevNumClients = -1;
|
||||
|
||||
int numClients = webSocket.connectedClients();
|
||||
if(numClients != prevNumClients) {
|
||||
prevNumClients = numClients;
|
||||
DebugPort.println("Changed number of web clients, should reset JSON moderator");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool sendWebServerString(const char* Str)
|
||||
bool sendWebSocketString(const char* Str)
|
||||
{
|
||||
CProfile profile;
|
||||
if(webSocket.connectedClients()) {
|
||||
|
@ -382,6 +375,19 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length
|
|||
}
|
||||
}
|
||||
|
||||
bool isWebSocketClientChange()
|
||||
{
|
||||
static int prevNumClients = -1;
|
||||
|
||||
int numClients = webSocket.connectedClients();
|
||||
if(numClients != prevNumClients) {
|
||||
prevNumClients = numClients;
|
||||
DebugPort.println("Changed number of web clients, should reset JSON moderator");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasWebClientSpoken(bool reset)
|
||||
{
|
||||
bool retval = bRxWebData;
|
||||
|
@ -428,10 +434,10 @@ bool checkFile(File &file)
|
|||
return bOK;
|
||||
}
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels, String& HTMLreport, int withHTMLanchors)
|
||||
void listSPIFFS(const char * dirname, uint8_t levels, String& HTMLreport, int withHTMLanchors)
|
||||
{
|
||||
char msg[128];
|
||||
File root = fs.open(dirname);
|
||||
File root = SPIFFS.open(dirname);
|
||||
if (!root) {
|
||||
sprintf(msg, "Failed to open directory \"%s\"", dirname);
|
||||
DebugPort.println(msg);
|
||||
|
@ -469,7 +475,7 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels, String& HTMLrepor
|
|||
DebugPort.println(msg);
|
||||
|
||||
if (levels) {
|
||||
listDir(fs, file.name(), levels - 1, HTMLreport);
|
||||
listSPIFFS(file.name(), levels - 1, HTMLreport);
|
||||
}
|
||||
} else {
|
||||
String fn = file.name();
|
||||
|
@ -501,7 +507,7 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels, String& HTMLrepor
|
|||
int used = SPIFFS.usedBytes();
|
||||
int total = SPIFFS.totalBytes();
|
||||
float percent = used * 100. / total;
|
||||
sprintf(usage, "<p><b>Usage</b><br> %d/%d bytes (%.1f%%)\n<p>", used, total, percent);
|
||||
sprintf(usage, "<p><b>Usage</b><br> %d / %d bytes (%.1f%%)\n<p>", used, total, percent);
|
||||
HTMLreport += usage;
|
||||
}
|
||||
}
|
||||
|
@ -514,12 +520,12 @@ void addTableData(String& HTML, String dta)
|
|||
}
|
||||
|
||||
// erase a file from SPIFFS partition
|
||||
void onSPIFFSErase()
|
||||
void onErase()
|
||||
{
|
||||
String filename = server.arg("filename"); // get request argument value by name
|
||||
|
||||
if(filename.length() != 0) {
|
||||
DebugPort.printf("onSPIFFSErase: %s ", filename.c_str());
|
||||
DebugPort.printf("onErase: %s ", filename.c_str());
|
||||
if(SPIFFS.exists(filename.c_str())) {
|
||||
SPIFFS.remove(filename.c_str());
|
||||
DebugPort.println("ERASED\r\n");
|
||||
|
@ -573,7 +579,7 @@ void onUploadBegin()
|
|||
bFormatAccessed = false;
|
||||
#ifdef USE_EMBEDDED_WEBUPDATECODE
|
||||
String SPIFFSinfo;
|
||||
listDir(SPIFFS, "/", 2, SPIFFSinfo, 2);
|
||||
listSPIFFS("/", 2, SPIFFSinfo, 2);
|
||||
String content = stdHeader;
|
||||
content += updateIndex + SPIFFSinfo;
|
||||
content += "<p><button onclick=window.location.assign('/formatspiffs')>Format SPIFFS</button>";
|
||||
|
@ -614,7 +620,7 @@ void onUploadProgression()
|
|||
if(upload.totalSize) {
|
||||
char JSON[64];
|
||||
sprintf(JSON, "{\"progress\":%d}", upload.totalSize);
|
||||
sendWebServerString(JSON); // feedback proper byte count of update to browser via websocket
|
||||
sendWebSocketString(JSON); // feedback proper byte count of update to browser via websocket
|
||||
}
|
||||
int percent = 0;
|
||||
if(_SuppliedFileSize)
|
||||
|
@ -785,7 +791,7 @@ If OK please try uploading the file from the web content.
|
|||
)=====";
|
||||
|
||||
String SPIFFSinfo;
|
||||
listDir(SPIFFS, "/", 2, SPIFFSinfo, 1);
|
||||
listSPIFFS("/", 2, SPIFFSinfo, 1);
|
||||
content += SPIFFSinfo;
|
||||
content += "</body>";
|
||||
content += "</html>";
|
||||
|
|
|
@ -25,34 +25,14 @@
|
|||
#ifndef _BTCWEBSERVER_h
|
||||
#define _BTCWEBSERVER_h
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
|
||||
#include "BTCWifi.h"
|
||||
#include <WiFiClient.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <Update.h>
|
||||
#include "../Libraries/arduinoWebSockets/src/WebSocketsServer.h"
|
||||
|
||||
void initWebServer();
|
||||
bool doWebServer();
|
||||
|
||||
|
||||
bool sendWebSocketString(const char* Str);
|
||||
bool isWebSocketClientChange();
|
||||
void listSPIFFS(const char * dirname, uint8_t levels, String& HTMLreport, int withHTMLanchors=0);
|
||||
|
||||
#endif
|
||||
|
||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length);
|
||||
void initWebServer();
|
||||
bool doWebServer();
|
||||
void handleWMConfig();
|
||||
void handleRoot();
|
||||
void handleReset();
|
||||
void handleNotFound();
|
||||
void webturnOn();
|
||||
void webturnOff();
|
||||
|
||||
bool sendWebServerString(const char* Str);
|
||||
bool isWebServerClientChange();
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels, String& HTMLreport, int withHTMLanchors=0);
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include "../Utility/DebugPort.h"
|
||||
#include <DNSServer.h>
|
||||
#include "../OLED/ScreenManager.h"
|
||||
|
||||
#include "esp_system.h"
|
||||
#include <Preferences.h>
|
||||
#include "../Utility/NVStorage.h"
|
||||
#include "../Libraries/WiFiManager-dev/WiFiManager.h"
|
||||
|
||||
#define USE_AP
|
||||
|
||||
|
|
|
@ -22,27 +22,25 @@
|
|||
#ifndef __BTCWIFI_H__
|
||||
#define __BTCWIFI_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../Libraries/WiFiManager-dev/WiFiManager.h"
|
||||
#include <WiFi.h>
|
||||
|
||||
void doWiFiManager();
|
||||
bool initWifi(int initpin,const char *failedssid, const char *failedpassword);
|
||||
const char* getWifiAPAddrStr();
|
||||
const char* getWifiSTAAddrStr();
|
||||
const char* getWifiAPMACStr();
|
||||
const char* getWifiSTAMACStr();
|
||||
void doWiFiManager();
|
||||
bool initWifi(int initpin,const char *failedssid, const char *failedpassword);
|
||||
const char* getWifiAPAddrStr();
|
||||
const char* getWifiSTAAddrStr();
|
||||
const char* getWifiAPMACStr();
|
||||
const char* getWifiSTAMACStr();
|
||||
|
||||
bool isWifiConnected();
|
||||
bool isWifiAP();
|
||||
bool isWifiSTA();
|
||||
bool isWifiConfigPortal();
|
||||
bool isWebClientConnected();
|
||||
bool hasWebClientSpoken(bool reset = false);
|
||||
bool hasWebServerSpoken(bool reset = false);
|
||||
void wifiEnterConfigPortal(bool state, bool erase = false, long timeout = 7000);
|
||||
void wifiDisable(long rebootDelay = 7000);
|
||||
void wifiFactoryDefault();
|
||||
int isWifiButton();
|
||||
bool isWifiConnected();
|
||||
bool isWifiAP();
|
||||
bool isWifiSTA();
|
||||
bool isWifiConfigPortal();
|
||||
bool isWebClientConnected();
|
||||
bool hasWebClientSpoken(bool reset = false);
|
||||
bool hasWebServerSpoken(bool reset = false);
|
||||
void wifiEnterConfigPortal(bool state, bool erase = false, long timeout = 7000);
|
||||
void wifiDisable(long rebootDelay = 7000);
|
||||
void wifiFactoryDefault();
|
||||
int isWifiButton();
|
||||
|
||||
#endif // __BTCWIFI_H__
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "BTCWifi.h"
|
||||
#include "BTCota.h"
|
||||
#include "../cfg/BTCConfig.h"
|
||||
#include <SPIFFS.h>
|
||||
#include "../Libraries/esp32FOTA/src/esp32fota.h" // local copy used due to a couple of issues
|
||||
#include "../Utility/helpers.h"
|
||||
#include <SPIFFS.h>
|
||||
#include <Update.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
|
||||
esp32FOTA FOTA("afterburner-fota-http", int(getVersion()*1000));
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <ArduinoOTA.h>
|
||||
#include <Arduino.h>
|
||||
#include "BTCWifi.h"
|
||||
#include "../Utility/DebugPort.h"
|
||||
#ifndef __BTC_OTA_H
|
||||
#define __BTC_OTA_H
|
||||
|
||||
void initOTA();
|
||||
void DoOTA();
|
||||
|
||||
#endif
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
||||
* Copyright (C) 2018 James Clark
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
extern const char* MAIN_PAGE PROGMEM;
|
||||
|
|
@ -51,6 +51,5 @@ const uint8_t keyCentre_pin = 35; // input only, no chip pullup
|
|||
const uint8_t keyRight_pin = 36; // input only, no chip pullup
|
||||
const uint8_t keyLeft_pin = 39; // input only, no chip pullup
|
||||
|
||||
//const uint8_t ListenOnlyPin = 33;
|
||||
const uint8_t WiFi_TriggerPin = 0; // BOOT switch!
|
||||
|
||||
|
|
Loading…
Reference in a new issue