Refactor Wi-Fi management / separated from webserver logic and add support for fixed IP configuration

This commit is contained in:
amarofarinha 2024-09-18 03:07:29 +01:00
parent 1a3ee00a4b
commit be9d993b44
9 changed files with 266 additions and 168 deletions

View file

@ -1,6 +1,7 @@
#include "USER_SETTINGS.h"
#include <string>
#include "src/devboard/hal/hal.h"
/* This file contains all the battery settings and limits */
/* They can be defined here, or later on in the WebUI */
/* Most important is to select which CAN interface each component is connected to */
@ -18,22 +19,34 @@ volatile CAN_Configuration can_config = {
.charger = CAN_NATIVE // (OPTIONAL) Which CAN is your charger connected to?
};
#ifdef WEBSERVER
#ifdef WIFI
volatile uint8_t AccessPointEnabled = true; //Set to either true/false to enable direct wifi access point
std::string ssid = "REPLACE_WITH_YOUR_SSID"; // Maximum of 63 characters
std::string password = "REPLACE_WITH_YOUR_PASSWORD"; // Minimum of 8 characters
const char* ssidAP = "Battery Emulator"; // Maximum of 63 characters, also used for device name on web interface
const char* passwordAP = "123456789"; // Minimum of 8 characters; set to NULL if you want the access point to be open
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
#ifdef WIFICONFIG
// Set your Static IP address
IPAddress local_IP(192, 168, 10, 150);
// Set your Gateway IP address
IPAddress gateway(192, 168, 10, 1);
// Set your Subnet IP address
IPAddress subnet(255, 255, 255, 0);
#endif
#ifdef WEBSERVER
const char* http_username = "admin"; // username to webserver authentication;
const char* http_password = "admin"; // password to webserver authentication;
const char* http_password = "admin"; // password to webserver authentication;
// MQTT
#ifdef MQTT
const char* mqtt_user = "REDACTED"; // Set NULL for no username
const char* mqtt_user = "REDACTED"; // Set NULL for no username
const char* mqtt_password = "REDACTED"; // Set NULL for no password
#endif // USE_MQTT
#endif // WEBSERVER
#endif // USE_MQTT
#endif // WEBSERVER
#endif // WIFI
/* Charger settings (Optional, when using generator charging) */
volatile float CHARGER_SET_HV = 384; // Reasonably appropriate 4.0v per cell charging of a 96s pack