mirror of
https://github.com/Lemonochrme/clover.git
synced 2025-06-08 16:50:50 +02:00
Added password/ssid dotenv management in plateform io.
This commit is contained in:
parent
c9ad92c031
commit
0b63d99510
5 changed files with 31 additions and 2 deletions
1
embedded/.gitignore
vendored
1
embedded/.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.env
|
|
@ -17,3 +17,5 @@ lib_deps =
|
|||
bbx10/DNSServer@^1.1.0
|
||||
ArduinoJson
|
||||
olikraus/U8g2@^2.35.7
|
||||
extra_scripts =
|
||||
pre:scripts/dotenv-var.py
|
4
embedded/readme.MD
Normal file
4
embedded/readme.MD
Normal file
|
@ -0,0 +1,4 @@
|
|||
# .env file
|
||||
|
||||
SSID_CLOVER='"SSID"'
|
||||
PSWD_CLOVER='"PASSWORD"'
|
14
embedded/scripts/dotenv-var.py
Normal file
14
embedded/scripts/dotenv-var.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from os.path import isfile
|
||||
Import("env")
|
||||
assert isfile(".env")
|
||||
try:
|
||||
f = open(".env", "r")
|
||||
lines = f.readlines()
|
||||
envs = []
|
||||
for line in lines:
|
||||
envs.append("-D{}".format(line.strip()))
|
||||
env.Append(BUILD_FLAGS=envs)
|
||||
except IOError:
|
||||
print("File .env not accessible",)
|
||||
finally:
|
||||
f.close()
|
|
@ -7,6 +7,13 @@
|
|||
#include "Component.hpp"
|
||||
#include "Display.hpp"
|
||||
|
||||
#ifdef SSID_CLOVER
|
||||
const char* ssid = SSID_CLOVER;
|
||||
#endif
|
||||
#ifdef PSWD_CLOVER
|
||||
const char* pswd = PSWD_CLOVER;
|
||||
#endif
|
||||
|
||||
DataHandler dataHandler;
|
||||
ServerHandler serverHandler(&dataHandler); // Référence à dataHandler
|
||||
Component humidity(ComponentType::Analog, PIN_A0);
|
||||
|
@ -15,16 +22,17 @@ Display screen;
|
|||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
serverHandler.setup("Iphone de Nicole", "cesthonteux");
|
||||
serverHandler.setup(ssid, pswd);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
screen.loop();
|
||||
dataHandler.updateTemperatureData(random(1800, 2200) / 100.0);
|
||||
// 0 -> air(0), 0-300 -> dry(20), 300-700 -> humid (580), 700-950 -> water(940)
|
||||
dataHandler.updateHumidityData(static_cast<float>(std::any_cast<int>(humidity.getValue())));
|
||||
Serial.println(dataHandler.getJsonData());
|
||||
delay(1000);
|
||||
|
||||
serverHandler.loop();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue