From db522548bd57aa1b3274a5df0961525b98072efa Mon Sep 17 00:00:00 2001 From: Maakbaas <57539443+maakbaas@users.noreply.github.com> Date: Sat, 6 Mar 2021 08:58:39 +0100 Subject: [PATCH] 1.7.1 (#93) * Added German language * PYTHONEXE bugfix in case of spaces in path * add openssl path as a build flag * projectVersion in configuration * fixed fallback in index.js * Updated docs Co-authored-by: Lars Weimar Co-authored-by: Jacek Banaszczyk --- docs/config-manager.md | 6 ++-- docs/fetch.md | 13 ++------ docs/installation-guide.md | 7 ++--- gui/js/index.js | 6 ++-- gui/js/lang/de.json | 55 +++++++++++++++++++++++++++++++++ platformio.ini | 3 +- scripts/preBuild.py | 8 +++-- scripts/preBuildCertificates.py | 7 +++-- 8 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 gui/js/lang/de.json diff --git a/docs/config-manager.md b/docs/config-manager.md index 54af299..02372da 100644 --- a/docs/config-manager.md +++ b/docs/config-manager.md @@ -130,9 +130,11 @@ An example of how this file could look is shown below: Supported data types are: bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, float and char. The length argument is mandatory for datatype char to indicate the length of the string. Variable length strings are not supported. Also, arrays are not supported for now. -The configuration parameter `projectName` is unique in this framework. You can remove it, but if you use a parameter with this name, it will be shown as the header title in the web interface :). +There are a few unique parameters: -The parameter named `language` is also unique and can be used to change the language of the web interface. Supported languages are placed in the folder `gui/js/lang`. Change the language code and rebuild the HTML interface to change the language. If your language is not yet supported, feel free to create a pull request for it. +* The configuration parameter `projectName` is unique in this framework. You can remove it, but if you use a parameter with this name, it will be shown as the header title in the web interface :). +* The parameter named `language` is also unique and can be used to change the language of the web interface. Supported languages are placed in the folder `gui/js/lang`. Change the language code and rebuild the HTML interface to change the language. If your language is not yet supported, feel free to create a pull request for it. +* The parameter named `projectVersion` can be added to the configuration file, and will add this version string to the header of the web interface, and can of course be used in your code as well. For this example, the pre-build python script `preBuildConfig.py` will generate the following two files. These should be fairly self explanatory and show how the JSON file is translated into a C struct. diff --git a/docs/fetch.md b/docs/fetch.md index fc0b40a..9b6d4fb 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -147,18 +147,11 @@ As mentioned earlier a full certificate store is saved in PROGMEM as part of the If you ever want to update or rebuild the certificate store, you can do this by enabling or running the pre-build script `preBuildCertificates.py`. This script will read in all root certificates from the Mozilla certificate store and process these into a format that is compatible with the ESP8266 Arduino layer. -For this step OpenSSL is needed. On Linux this is probably available by default, on Windows this comes as part of something like MinGW, or Cygwin, but is also installed with the Windows Git client. If needed you can edit the path to OpenSSL at the top of the `preBuildCertificates.py` file: +For this step OpenSSL is needed. On Linux this is probably available by default, on Windows this comes as part of something like MinGW, or Cygwin, but is also installed with the Windows Git client. If needed you can edit the path to OpenSSL by adding the build flag below to `platformio.ini`: -```c++ -#path to openssl -openssl = "C:\\msys32\\usr\\bin\\openssl" -``` - -Another prerequisite is that you need the Python module asn1crypto. Since currently PlatformIO uses its own internal Python version, this means you need to open a new PlatformIO terminal, and then execute the command: +**-DOPENSSL="C:/Program Files/Git/usr/bin/openssl.exe"** Path to openssl executable. The location shown here is the default location. If your openssl is in a different location, change this flag accordingly -``` -pip install asn1crypto -``` +Another prerequisite is the Python module asn1crypto. If this module is not available, the script will attempt to install it using `pip`. ## Certificate Store Size diff --git a/docs/installation-guide.md b/docs/installation-guide.md index d6c6807..35be756 100644 --- a/docs/installation-guide.md +++ b/docs/installation-guide.md @@ -79,12 +79,9 @@ The build flags are optional, since all default generated artefacts are already **-DREBUILD_CERTS:** This build step generates `certificates.h` containing a full root certificate store to enable arbitrary HTTPS requests with the ESP8266. More info on this process can be found [here](https://github.com/maakbaas/esp8266-iot-framework/blob/master/docs/fetch.md). -For this step OpenSSL is needed. On Linux this is probably available by default, on Windows this comes as part of something like MinGW, or Cygwin, but is also installed with the Windows Git client. If needed you can edit the path to OpenSSL at the top of the file: +For this step OpenSSL is needed. On Linux this is probably available by default, on Windows this comes as part of something like MinGW, or Cygwin, but is also installed with the Windows Git client. If needed you can edit the path to OpenSSL with the next build flag -```python -#path to openssl -openssl = "C:\\msys32\\usr\\bin\\openssl" -``` +**-DOPENSSL="C:/Program Files/Git/usr/bin/openssl.exe"** Path to openssl executable. The location shown here is the default location. If your openssl is in a different location, change this flag accordingly **-DCONFIG_PATH=configuration.json:** This option defines a custom location for your configuration JSON file. This is needed when using the framework as a library, to allow you to define a JSON file in your project folder. The path is relative to the PlatformIO project root folder. More detail on the JSON file can be found [here](https://github.com/maakbaas/esp8266-iot-framework/blob/master/docs/config-manager.md). diff --git a/gui/js/index.js b/gui/js/index.js index 5230df8..fd88200 100644 --- a/gui/js/index.js +++ b/gui/js/index.js @@ -63,13 +63,15 @@ function Root() { }); } - const projectName = configData["projectName"] || Config.find(entry => entry.name === "projectName").value || "ESP8266"; + const projectName = configData["projectName"] || Config.find(entry => entry.name === "projectName") ? Config.find(entry => entry.name === "projectName").value : "ESP8266"; + const projectVersion = configData["projectVersion"] || Config.find(entry => entry.name === "projectVersion") ? Config.find(entry => entry.name === "projectVersion").value : ""; + return <>
-

{projectName}

+

{projectName} {projectVersion}

setMenu(!menu)} /> diff --git a/gui/js/lang/de.json b/gui/js/lang/de.json new file mode 100644 index 0000000..ee91c7b --- /dev/null +++ b/gui/js/lang/de.json @@ -0,0 +1,55 @@ +{ + "titleWifi": "WiFi Einstellungen", + "titleDash": "Dashboard", + "titleConf": "Konfiguration", + "titleFile": "Datei Manager", + "titleFw": "Firmware Update", + "globalSave": "Speichern", + "globalCancel": "Abbrechen", + "globalContinue": "Weiter", + "globalOk": "OK", + "globalStatus": "Status", + "globalBack": "Zurück", + "wifiIP": "IP Addresse", + "wifiSub": "Subnetz", + "wifiGW": "Gateway", + "wifiSSID": "SSID", + "wifiPass": "Passwort", + "wifiDNS": "DNS", + "wifiDHCP": "DHCP", + "wifiConn": "Verbunden mit", + "wifiForget": "Zurücksetzen", + "wifiUpdate": "Kennwort aktualisieren", + "wifiCP": "Captive portal ist aktiv", + "wifiModal1": "Bist du dir sicher? Beim fortsetzen wird ein Captive Portal gestartet.", + "wifiModal2": "Bist du dir sicher? Beim fortsetzen wird die vorhandene Verbindung zum Netzwerk getrennt.", + "dashEmpty": "Es sind keine Inhalte in der JSON-Datei definiert.", + "dashLive": "LIVE", + "dashConn": "VERBINDE", + "dashDisconn": "GETRENNT", + "filesEmpty": "Keine Dateien verfügbar", + "filesDl": "Datei herunterladen", + "filesRm": "Datei löschen", + "filesFwTitle": "Datei auswählen", + "filesTitle": "Datei Liste", + "filesUsed": "Datei ausgewählt", + "filesBtn": "Hochladen", + "filesMsg1": "Das Hochladen ist fehlgeschlagen. Die Datei ist entweder zu groß oder der Dateiname ist zu lang (>32).", + "filesMsg2": "Die ausgewählte Datei hat ein falsches Format.", + "fwSelect": "Auswählen", + "fwFlash": "Schreiben", + "fwReboot": "Neustart", + "fwBtn": "Firmware aktualisieren", + "fwBtn2": "Neu starten", + "fwStep1a_preFilename": "Ausgewählte Datei", + "fwStep1b_postFilename": "wird verwendet", + "fwStep2a_preFilename": "Die Firmware", + "fwStep2b_postFilename": "wurde hochgeladen", + "fwStep2c": "Bitte warten, der Vorgang kann ein paar Minuten dauern. Gerät nicht ausschalten!", + "fwStep3a_preFilename": "Die Firmware", + "fwStep3b_postFilename": "wurde erfolgreich aktualisiert.", + "fwStep3c": "Bitte das Gerät neu starten, damit die Firmware aktiv wird.", + "fwModal1": "Bist du dir sicher? Beim Fortsetzen wird die aktuelle Firmware überschrieben.", + "fwModal2": "Das Firmware update ist fehlgeschlagen.", + "fwModal3": "Das Gerät startet neu. Bitte ein paar Sekunden warten und die Seite neu laden." +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index ab774ea..ae35e1a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,8 +26,9 @@ extra_scripts = scripts/preBuild.py #available build flags: #-DREBUILD_HTML forces a rebuild of the html.h, this is needed if you make modifications to the GUI, or the configuration or dashboard JSON files #-DREBUILD_CERTS forces a rebuild of the root certificate store +#-DOPENSSL="C:/Program Files/Git/usr/bin/openssl.exe" Path to openssl executable #-DREBUILD_CONFIG forces a rebuild of the configuration manager cpp files based on the JSON #-DREBUILD_DASHBOARD forces a rebuild of the dashboard cpp files based on the JSON #-DDOMAIN_LIST=google.com,maakbaas.com comma separated list of domain names to limit the certificates included #-DCONFIG_PATH=configuration.json defines a custom location for your JSON file -#-DDASHBOARD_PATH=dashboard.json defines a custom location for your JSON file +#-DDASHBOARD_PATH=dashboard.json defines a custom location for your JSON file \ No newline at end of file diff --git a/scripts/preBuild.py b/scripts/preBuild.py index d73f270..d9d72c7 100644 --- a/scripts/preBuild.py +++ b/scripts/preBuild.py @@ -2,7 +2,6 @@ from shutil import copyfile import subprocess import inspect, os.path -from os.path import join, realpath #auto install asn1crypto if not defined try: @@ -11,7 +10,7 @@ Import('env') env.Execute( env.VerboseAction( - '$PYTHONEXE -m pip install "asn1crypto" ', + '"$PYTHONEXE" -m pip install "asn1crypto" ', "ASN1 crypto import failed, installing.", ) ) @@ -29,6 +28,7 @@ config = False dash = False certs = False +openssl = None # private library flags domains = '' @@ -49,6 +49,8 @@ copyfile(env.get("PROJECT_DIR") + '/' + item[1], '../gui/js/dashboard.json') elif isinstance(item, tuple) and item[0] == "DOMAIN_LIST": domains = item[1] + elif isinstance(item, tuple) and item[0].lower() == "openssl": + openssl = item[1] if html: preBuildHTMLFun() @@ -57,6 +59,6 @@ if dash: preBuildDashFun() if certs: - preBuildCertificatesFun(domains) + preBuildCertificatesFun(domains, openssl) diff --git a/scripts/preBuildCertificates.py b/scripts/preBuildCertificates.py index 441e321..4605b39 100644 --- a/scripts/preBuildCertificates.py +++ b/scripts/preBuildCertificates.py @@ -24,9 +24,9 @@ from ssl import SSLContext # Modern SSL? from ssl import HAS_SNI # Has SNI? -def preBuildCertificatesFun(domains): +def preBuildCertificatesFun(domains, openssl): - print('Start building certificate store', flush=True) + print('Start building certificate store', flush=True) allDomains = True @@ -43,7 +43,8 @@ def preBuildCertificatesFun(domains): dir_path = os.path.dirname(os.path.abspath(filename)) #path to openssl - openssl = "C:/msys32/usr/bin/openssl" + if openssl is None: + openssl = "C:/Program Files/Git/usr/bin/openssl.exe" # below script content is adapted from: # https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/BearSSL_CertStore/certs-from-mozilla.py