mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Merge pull request #662 from No-Signal/feature/user_secrets
Improvement: Moving secrets from USER_SETTINGS.cpp to platformio config
This commit is contained in:
commit
d28c59ccfc
11 changed files with 47 additions and 15 deletions
4
.github/workflows/compile-all-batteries.yml
vendored
4
.github/workflows/compile-all-batteries.yml
vendored
|
@ -86,6 +86,10 @@ jobs:
|
||||||
# First we clone the repo using the `checkout` action.
|
# First we clone the repo using the `checkout` action.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
|
||||||
|
|
||||||
# We use the `arduino/setup-arduino-cli` action to install and
|
# We use the `arduino/setup-arduino-cli` action to install and
|
||||||
# configure the Arduino CLI on the system.
|
# configure the Arduino CLI on the system.
|
||||||
|
|
|
@ -92,6 +92,10 @@ jobs:
|
||||||
# First we clone the repo using the `checkout` action.
|
# First we clone the repo using the `checkout` action.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
|
||||||
|
|
||||||
# We use the `arduino/setup-arduino-cli` action to install and
|
# We use the `arduino/setup-arduino-cli` action to install and
|
||||||
# configure the Arduino CLI on the system.
|
# configure the Arduino CLI on the system.
|
||||||
|
|
|
@ -93,6 +93,10 @@ jobs:
|
||||||
# First we clone the repo using the `checkout` action.
|
# First we clone the repo using the `checkout` action.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
|
||||||
|
|
||||||
# We use the `arduino/setup-arduino-cli` action to install and
|
# We use the `arduino/setup-arduino-cli` action to install and
|
||||||
# configure the Arduino CLI on the system.
|
# configure the Arduino CLI on the system.
|
||||||
|
|
4
.github/workflows/compile-all-inverters.yml
vendored
4
.github/workflows/compile-all-inverters.yml
vendored
|
@ -78,6 +78,10 @@ jobs:
|
||||||
# First we clone the repo using the `checkout` action.
|
# First we clone the repo using the `checkout` action.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
- name: Copy USER_SECRETS.TEMPLATE.h to USER_SECRETS.h
|
||||||
|
run: cp ./Software/USER_SECRETS.TEMPLATE.h ./Software/USER_SECRETS.h
|
||||||
|
|
||||||
# We use the `arduino/setup-arduino-cli` action to install and
|
# We use the `arduino/setup-arduino-cli` action to install and
|
||||||
# configure the Arduino CLI on the system.
|
# configure the Arduino CLI on the system.
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -22,3 +22,6 @@ compile.bat
|
||||||
|
|
||||||
# Ignore binary files
|
# Ignore binary files
|
||||||
*.bin
|
*.bin
|
||||||
|
|
||||||
|
# Ignore secret file
|
||||||
|
USER_SECRETS.h
|
|
@ -54,7 +54,8 @@ For more examples showing wiring, see each battery types own Wiki page. For inst
|
||||||
5. The Arduino board should be set to `ESP32 Dev Module` (under `Tools` -> `Board` -> `ESP32 Arduino`) with the following settings:
|
5. The Arduino board should be set to `ESP32 Dev Module` (under `Tools` -> `Board` -> `ESP32 Arduino`) with the following settings:
|
||||||

|

|
||||||
6. Select which battery type you will use, along with other optional settings. This is done in the `USER_SETTINGS.h` file.
|
6. Select which battery type you will use, along with other optional settings. This is done in the `USER_SETTINGS.h` file.
|
||||||
7. Press `Verify` and `Upload` to send the sketch to the board.
|
7. Copy the `USER_SECRETS.TEMPLATE.h` file to `USER_SECRETS.h` and update relevant secrets.
|
||||||
|
8. Press `Verify` and `Upload` to send the sketch to the board.
|
||||||
NOTE: In some cases, the LilyGo must be powered through the main power connector instead of USB-C
|
NOTE: In some cases, the LilyGo must be powered through the main power connector instead of USB-C
|
||||||
when performing the initial firmware upload.
|
when performing the initial firmware upload.
|
||||||
NOTE: On Mac, the following USB driver may need to be installed: https://github.com/WCHSoftGroup/ch34xser_macos
|
NOTE: On Mac, the following USB driver may need to be installed: https://github.com/WCHSoftGroup/ch34xser_macos
|
||||||
|
|
13
Software/USER_SECRETS.TEMPLATE.h
Normal file
13
Software/USER_SECRETS.TEMPLATE.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#define WIFI_SSID "REPLACE_WITH_YOUR_SSID" // Maximum of 63 characters
|
||||||
|
#define WIFI_PASSWORD "REPLACE_WITH_YOUR_PASSWORD" // Minimum of 8 characters
|
||||||
|
#define AP_PASSWORD "123456789" // Minimum of 8 characters; set to blank if you want the access point to be open
|
||||||
|
|
||||||
|
#define WEBSERVER_AUTH_REQUIRED \
|
||||||
|
false //Set this line to true to activate webserver authentication (this line must not be commented).
|
||||||
|
#define HTTP_USERNAME "admin" // username to webserver authentication;
|
||||||
|
#define HTTP_PASSWORD "admin" // password to webserver authentication;
|
||||||
|
|
||||||
|
#define MQTT_SERVER "192.168.xxx.yyy" // mqtt server address
|
||||||
|
#define MQTT_PORT 1883 // mqtt server port
|
||||||
|
#define MQTT_USER NULL // mqtt username, leave blank for no authentication
|
||||||
|
#define MQTT_PASSWORD NULL // mqtt password, leave blank for no authentication
|
|
@ -1,5 +1,6 @@
|
||||||
#include "USER_SETTINGS.h"
|
#include "USER_SETTINGS.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "USER_SECRETS.h"
|
||||||
#include "src/devboard/hal/hal.h"
|
#include "src/devboard/hal/hal.h"
|
||||||
|
|
||||||
/* This file contains all the battery settings and limits */
|
/* This file contains all the battery settings and limits */
|
||||||
|
@ -21,12 +22,12 @@ volatile CAN_Configuration can_config = {
|
||||||
|
|
||||||
#ifdef WIFI
|
#ifdef WIFI
|
||||||
|
|
||||||
volatile uint8_t AccessPointEnabled = true; //Set to either true/false to enable direct wifi access point
|
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 ssid = WIFI_SSID; // Set in USER_SECRETS.h
|
||||||
std::string password = "REPLACE_WITH_YOUR_PASSWORD"; // Minimum of 8 characters
|
std::string password = WIFI_PASSWORD; // Set in USER_SECRETS.h
|
||||||
const char* ssidAP = "Battery Emulator"; // Maximum of 63 characters, also used for device name on web interface
|
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 char* passwordAP = AP_PASSWORD; // Set in USER_SECRETS.h
|
||||||
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
|
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
|
||||||
|
|
||||||
#ifdef WIFICONFIG
|
#ifdef WIFICONFIG
|
||||||
// Set your Static IP address
|
// Set your Static IP address
|
||||||
|
@ -37,14 +38,14 @@ IPAddress gateway(192, 168, 10, 1);
|
||||||
IPAddress subnet(255, 255, 255, 0);
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
const char* http_username = "admin"; // username to webserver authentication;
|
const char* http_username = HTTP_USERNAME; // Set in USER_SECRETS.h
|
||||||
const char* http_password = "admin"; // password to webserver authentication;
|
const char* http_password = HTTP_PASSWORD; // Set in USER_SECRETS.h
|
||||||
|
|
||||||
#endif // WEBSERVER
|
#endif // WEBSERVER
|
||||||
// MQTT
|
// MQTT
|
||||||
#ifdef MQTT
|
#ifdef MQTT
|
||||||
const char* mqtt_user = "REDACTED"; // Set NULL for no username
|
const char* mqtt_user = MQTT_USER; // Set in USER_SECRETS.h
|
||||||
const char* mqtt_password = "REDACTED"; // Set NULL for no password
|
const char* mqtt_password = MQTT_PASSWORD; // Set in USER_SECRETS.h
|
||||||
#ifdef MQTT_MANUAL_TOPIC_OBJECT_NAME
|
#ifdef MQTT_MANUAL_TOPIC_OBJECT_NAME
|
||||||
const char* mqtt_topic_name =
|
const char* mqtt_topic_name =
|
||||||
"BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX"
|
"BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX"
|
||||||
|
|
|
@ -87,8 +87,6 @@
|
||||||
#define WIFI
|
#define WIFI
|
||||||
//#define WIFICONFIG //Enable this line to set a static IP address / gateway /subnet mask for the device. see USER_SETTINGS.cpp for the settings
|
//#define WIFICONFIG //Enable this line to set a static IP address / gateway /subnet mask for the device. see USER_SETTINGS.cpp for the settings
|
||||||
#define WEBSERVER //Enable this line to enable WiFi, and to run the webserver. See USER_SETTINGS.cpp for the Wifi settings.
|
#define WEBSERVER //Enable this line to enable WiFi, and to run the webserver. See USER_SETTINGS.cpp for the Wifi settings.
|
||||||
#define WEBSERVER_AUTH_REQUIRED \
|
|
||||||
false //Set this line to true to activate webserver authentication (this line must not be commented). Refer to USER_SETTINGS.cpp for setting the credentials.
|
|
||||||
#define WIFIAP //Disable this line to permanently disable WIFI AP mode (make sure to hardcode ssid and password of you home wifi network). When enabled WIFI AP can still be disabled by a setting in the future.
|
#define WIFIAP //Disable this line to permanently disable WIFI AP mode (make sure to hardcode ssid and password of you home wifi network). When enabled WIFI AP can still be disabled by a setting in the future.
|
||||||
#define MDNSRESPONDER //Enable this line to enable MDNS, allows battery monitor te be found by .local address. Requires WEBSERVER to be enabled.
|
#define MDNSRESPONDER //Enable this line to enable MDNS, allows battery monitor te be found by .local address. Requires WEBSERVER to be enabled.
|
||||||
#define LOAD_SAVED_SETTINGS_ON_BOOT //Enable this line to read settings stored via the webserver on boot (overrides Wifi/battery settings set below)
|
#define LOAD_SAVED_SETTINGS_ON_BOOT //Enable this line to read settings stored via the webserver on boot (overrides Wifi/battery settings set below)
|
||||||
|
@ -97,8 +95,6 @@
|
||||||
|
|
||||||
/* MQTT options */
|
/* MQTT options */
|
||||||
// #define MQTT // Enable this line to enable MQTT
|
// #define MQTT // Enable this line to enable MQTT
|
||||||
#define MQTT_SERVER "192.168.xxx.yyy"
|
|
||||||
#define MQTT_PORT 1883
|
|
||||||
#define MQTT_MANUAL_TOPIC_OBJECT_NAME // Enable this to use custom MQTT topic, object ID prefix, and device name. \
|
#define MQTT_MANUAL_TOPIC_OBJECT_NAME // Enable this to use custom MQTT topic, object ID prefix, and device name. \
|
||||||
// WARNING: If this is not defined, the previous default naming format \
|
// WARNING: If this is not defined, the previous default naming format \
|
||||||
// 'battery-emulator_esp32-XXXXXX' (based on hardware ID) will be used. \
|
// 'battery-emulator_esp32-XXXXXX' (based on hardware ID) will be used. \
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include "../../../USER_SECRETS.h"
|
||||||
#include "../../../USER_SETTINGS.h"
|
#include "../../../USER_SETTINGS.h"
|
||||||
#include "../../battery/BATTERIES.h"
|
#include "../../battery/BATTERIES.h"
|
||||||
#include "../../datalayer/datalayer.h"
|
#include "../../datalayer/datalayer.h"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include "../../../USER_SECRETS.h"
|
||||||
#include "../../datalayer/datalayer.h"
|
#include "../../datalayer/datalayer.h"
|
||||||
#include "../../datalayer/datalayer_extended.h"
|
#include "../../datalayer/datalayer_extended.h"
|
||||||
#include "../../lib/bblanchon-ArduinoJson/ArduinoJson.h"
|
#include "../../lib/bblanchon-ArduinoJson/ArduinoJson.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue