From 3a1071e0565cd2f1a1d1bccf2ab7e42c95146ab8 Mon Sep 17 00:00:00 2001 From: Felix Storm Date: Mon, 3 Feb 2020 14:46:09 +0100 Subject: [PATCH 1/4] extract WiFi credentials to separate configuration file (currently ESP32 only) --- .gitignore | 3 +++ Marlin/Configuration_adv.h | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5728e1f065f1..88ce2e17d108 100755 --- a/.gitignore +++ b/.gitignore @@ -146,6 +146,9 @@ Marlin/*/*/readme.txt Marlin/*/*/*/readme.txt Marlin/*/*/*/*/readme.txt +# WiFi Credentials +Marlin/Configuration_creds.h + #Visual Studio *.sln *.vcxproj diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9a979f2528f7..23f76efb739d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3023,11 +3023,18 @@ //#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib) #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) - #define WIFI_SSID "Wifi SSID" - #define WIFI_PWD "Wifi Password" - //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) - //#define OTASUPPORT // Support over-the-air firmware updates - //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host + /** + * To hard-code WiFi SSID and password, put the following two #define-lines into a file called + * 'Configuration_creds.h', replace 'WiFi SSID' and 'WiFi Password' with your own respective SSID and password + * and uncomment the #include-line in this file below. 'Configuration_creds.h' is included in .gitignore to prevent + * accidental publishing of WiFi credentials to a (public) Git repository. + #define WIFI_SSID "WiFi SSID" + #define WIFI_PWD "WiFi Password" + */ + //#include "Configuration_creds.h" // Include file with hard-coded WiFi SSID and password + //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) + //#define OTASUPPORT // Support over-the-air firmware updates + //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host #endif /** From 00d354097c711e1f1313b39cf6871fd19bb625bf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 3 Feb 2020 21:52:58 -0600 Subject: [PATCH 2/4] Prepare for merge --- .gitignore | 4 ++-- Marlin/Configuration_adv.h | 21 +++++++++++---------- buildroot/bin/opt_set | 3 ++- buildroot/share/tests/esp32-tests | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 88ce2e17d108..f6859bc4e810 100755 --- a/.gitignore +++ b/.gitignore @@ -146,8 +146,8 @@ Marlin/*/*/readme.txt Marlin/*/*/*/readme.txt Marlin/*/*/*/*/readme.txt -# WiFi Credentials -Marlin/Configuration_creds.h +# Secure Credentials +Configuration_Secure.h #Visual Studio *.sln diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 23f76efb739d..416566c94059 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3023,18 +3023,19 @@ //#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib) #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) + //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) + //#define OTASUPPORT // Support over-the-air firmware updates + //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host + /** - * To hard-code WiFi SSID and password, put the following two #define-lines into a file called - * 'Configuration_creds.h', replace 'WiFi SSID' and 'WiFi Password' with your own respective SSID and password - * and uncomment the #include-line in this file below. 'Configuration_creds.h' is included in .gitignore to prevent - * accidental publishing of WiFi credentials to a (public) Git repository. - #define WIFI_SSID "WiFi SSID" - #define WIFI_PWD "WiFi Password" + * To set a default WiFi SSID / Password, create a file called Configuration_Secure.h with + * the following defines, customized for your network. This specific file is excluded via + * .gitignore to prevent it from accidentally leaking to the public. + * + * #define WIFI_SSID "WiFi SSID" + * #define WIFI_PWD "WiFi Password" */ - //#include "Configuration_creds.h" // Include file with hard-coded WiFi SSID and password - //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) - //#define OTASUPPORT // Support over-the-air firmware updates - //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host + //#include "Configuration_Secure.h" // External file with WiFi SSID / Password #endif /** diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set index 2f6c253c9c16..f23a1d3d0764 100755 --- a/buildroot/bin/opt_set +++ b/buildroot/bin/opt_set @@ -8,4 +8,5 @@ SED=$(which gsed || which sed) # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || -(echo "ERROR: opt_set Can't find ${1}" >&2 && exit 9) +eval "echo '#define ${@}' >>Marlin/Configuration_adv.h" || +(echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9) diff --git a/buildroot/share/tests/esp32-tests b/buildroot/share/tests/esp32-tests index 123d5c320c6d..47f5d8176144 100755 --- a/buildroot/share/tests/esp32-tests +++ b/buildroot/share/tests/esp32-tests @@ -12,8 +12,8 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_ESPRESSIF_ESP32 opt_enable WIFISUPPORT GCODE_MACROS BAUD_RATE_GCODE -opt_set WIFI_SSID "\"ssid\"" -opt_set WIFI_PWD "\"password\"" +opt_add WIFI_SSID "\"ssid\"" +opt_add WIFI_PWD "\"password\"" opt_set TX_BUFFER_SIZE 64 opt_add WEBSUPPORT exec_test $1 $2 "ESP32 with WIFISUPPORT and WEBSUPPORT" From 421866c2b816f16b10409f93c81cf36742216e9c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 3 Feb 2020 23:03:12 -0600 Subject: [PATCH 3/4] Tweak ProbePtRaise labels --- Marlin/src/module/probe.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index af01e208cda2..455a937f2db2 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -28,6 +28,19 @@ #include "../inc/MarlinConfig.h" #if HAS_BED_PROBE + + extern xyz_pos_t probe_offset; + + #if HAS_PROBE_XY_OFFSET + extern xyz_pos_t &probe_offset_xy; + #else + constexpr xy_pos_t probe_offset_xy{0}; + #endif + + bool set_probe_deployed(const bool deploy); + #ifdef Z_AFTER_PROBING + void move_z_after_probing(); + #endif enum ProbePtRaise : uint8_t { PROBE_PT_NONE, // No raise or stow after run_z_probe PROBE_PT_STOW, // Do a complete stow after run_z_probe From f685a601feb1da486dd92d511751732bbc99ad8f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 3 Feb 2020 23:14:03 -0600 Subject: [PATCH 4/4] Undo --- Marlin/src/module/probe.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 986e6759ff1c..35fb8ceb264e 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -28,19 +28,6 @@ #include "../inc/MarlinConfig.h" #if HAS_BED_PROBE - - extern xyz_pos_t probe_offset; - - #if HAS_PROBE_XY_OFFSET - extern xyz_pos_t &probe_offset_xy; - #else - constexpr xy_pos_t probe_offset_xy{0}; - #endif - - bool set_probe_deployed(const bool deploy); - #ifdef Z_AFTER_PROBING - void move_z_after_probing(); - #endif enum ProbePtRaise : uint8_t { PROBE_PT_NONE, // No raise or stow after run_z_probe PROBE_PT_STOW, // Do a complete stow after run_z_probe