mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
WEB and MQTT settings are actually run-time variables
This commit is contained in:
parent
1c8802b6a7
commit
5f8eedbacb
10 changed files with 62 additions and 53 deletions
|
@ -1,13 +1,10 @@
|
|||
#include "NISSAN-LEAF-BATTERY.h"
|
||||
#include "../include.h"
|
||||
#ifdef MQTT
|
||||
#include "../devboard/mqtt/mqtt.h"
|
||||
#endif
|
||||
#include "../communication/can/comm_can.h"
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../datalayer/datalayer_extended.h" //For "More battery info" webpage
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "../devboard/utils/logging.h"
|
||||
#include "../include.h"
|
||||
|
||||
#include "../charger/CanCharger.h"
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ void init_stored_settings() {
|
|||
settings.putBool("EQUIPMENT_STOP", datalayer.system.settings.equipment_stop_active);
|
||||
#endif // LOAD_SAVED_SETTINGS_ON_BOOT
|
||||
|
||||
#ifdef WIFI
|
||||
char tempSSIDstring[63]; // Allocate buffer with sufficient size
|
||||
size_t lengthSSID = settings.getString("SSID", tempSSIDstring, sizeof(tempSSIDstring));
|
||||
if (lengthSSID > 0) { // Successfully read the string from memory. Set it to SSID!
|
||||
|
@ -40,7 +39,6 @@ void init_stored_settings() {
|
|||
password = tempPasswordString;
|
||||
} else { // Reading from settings failed. Do nothing with SSID. Raise event?
|
||||
}
|
||||
#endif // WIFI
|
||||
|
||||
temp = settings.getUInt("BATTERY_WH_MAX", false);
|
||||
if (temp != 0) {
|
||||
|
@ -128,14 +126,12 @@ void store_settings() {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef WIFI
|
||||
if (!settings.putString("SSID", String(ssid.c_str()))) {
|
||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 1);
|
||||
}
|
||||
if (!settings.putString("PASSWORD", String(password.c_str()))) {
|
||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!settings.putUInt("BATTERY_WH_MAX", datalayer.battery.info.total_capacity_Wh)) {
|
||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 3);
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
#include "../utils/timer.h"
|
||||
#include "mqtt_client.h"
|
||||
|
||||
#ifdef MQTT
|
||||
const bool mqtt_enabled_default = true;
|
||||
#else
|
||||
const bool mqtt_enabled_default = false;
|
||||
#endif
|
||||
|
||||
bool mqtt_enabled = mqtt_enabled_default;
|
||||
|
||||
esp_mqtt_client_config_t mqtt_cfg;
|
||||
esp_mqtt_client_handle_t client;
|
||||
char mqtt_msg[MQTT_MSG_BUFFER_SIZE];
|
||||
|
|
|
@ -55,4 +55,6 @@ void init_mqtt(void);
|
|||
void mqtt_loop(void);
|
||||
bool mqtt_publish(const char* topic, const char* mqtt_msg, bool retain);
|
||||
|
||||
extern bool mqtt_enabled;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
|
||||
void transmit_can_frame(CAN_frame* tx_frame, int interface);
|
||||
|
||||
#ifdef WEBSERVER
|
||||
const bool webserver_enabled_default = true;
|
||||
#else
|
||||
const bool webserver_enabled_default = false;
|
||||
#endif
|
||||
|
||||
bool webserver_enabled = webserver_enabled_default; // Global flag to enable or disable the webserver
|
||||
|
||||
// Create AsyncWebServer object on port 80
|
||||
AsyncWebServer server(80);
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "../../lib/ayushsharma82-ElegantOTA/src/ElegantOTA.h"
|
||||
#include "../../lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.h"
|
||||
|
||||
extern bool webserver_enabled;
|
||||
|
||||
extern const char* version_number; // The current software version, shown on webserver
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
#include "../../include.h"
|
||||
#include "../utils/events.h"
|
||||
|
||||
#ifdef WIFI
|
||||
const bool wifi_enabled_default = true;
|
||||
#else
|
||||
const bool wifi_enabled_default = false;
|
||||
#endif
|
||||
|
||||
bool wifi_enabled = wifi_enabled_default;
|
||||
|
||||
// Configuration Parameters
|
||||
static const uint16_t WIFI_CHECK_INTERVAL = 2000; // 1 seconds normal check interval when last connected
|
||||
static const uint16_t STEP_WIFI_CHECK_INTERVAL = 2000; // 3 seconds wait step increase in checks for normal reconnects
|
||||
|
|
|
@ -23,13 +23,11 @@ void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
|||
void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
|
||||
#ifdef WIFIAP
|
||||
void init_WiFi_AP();
|
||||
#endif // WIFIAP
|
||||
|
||||
#ifdef MDNSRESPONDER
|
||||
// Initialise mDNS
|
||||
void init_mDNS();
|
||||
#endif // MDNSRESPONDER
|
||||
|
||||
extern bool wifi_enabled;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue