diff --git a/README.md b/README.md index e17ab51..1d1c456 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,15 @@ git clone --recursive https://github.com/Superhouse/esp-open-rtos.git cd esp-open-rtos ``` -* To build any examples that use WiFi, create a file "local.h" in the top-level directory and add two macro defines to it: +* To build any examples that use WiFi, edit `include/ssid_config.h` and change the two macro defines: + ```c #define WIFI_SSID "mywifissid" #define WIFI_PASS "my secret password" ``` +Remove the `#warning` and follow the git ignore instructions to keep your credentials from being pushed to Github. + * Build an example project (found in the 'examples' directory) and flash it to a serial port: ``` diff --git a/common.mk b/common.mk index e93942a..323d13d 100644 --- a/common.mk +++ b/common.mk @@ -305,12 +305,6 @@ $(BUILD_DIR)sdklib/%.a: $(BUILD_DIR)sdklib/%_stage1.a $(BUILD_DIR)sdklib/allsymb PROGRAM_SRC_DIR ?= $(PROGRAM_DIR) PROGRAM_ROOT ?= $(PROGRAM_DIR) PROGRAM_MAKEFILE = $(firstword $(MAKEFILE_LIST)) -# if there's a local.h file in either the program dir or the -# root dir, load macros from it (for WIFI_SSID,WIFI_PASS, etc.) -PROGRAM_LOCAL_H = $(lastword $(wildcard $(ROOT)local.h $(PROGRAM_DIR)local.h)) -ifneq ($(PROGRAM_LOCAL_H),) -PROGRAM_CFLAGS = $(CFLAGS) -imacros $(PROGRAM_LOCAL_H) -endif $(eval $(call component_compile_rules,PROGRAM)) ## Include other components (this is where the actual compiler sections are generated) diff --git a/examples/http_get/http_get.c b/examples/http_get/http_get.c index 996849d..408b462 100644 --- a/examples/http_get/http_get.c +++ b/examples/http_get/http_get.c @@ -18,14 +18,12 @@ #include "lwip/netdb.h" #include "lwip/dns.h" +#include "ssid_config.h" + #define WEB_SERVER "chainxor.org" #define WEB_PORT 80 #define WEB_URL "http://chainxor.org/" -#if !defined(WIFI_SSID) || !defined(WIFI_PASS) -#error "Please define macros WIFI_SSID & WIFI_PASS (here, or better in a local.h file at root level or in program dir." -#endif - void http_get_task(void *pvParameters) { int successes = 0, failures = 0; diff --git a/examples/http_get_ssl/http_get_ssl.c b/examples/http_get_ssl/http_get_ssl.c index 23362d6..22351b9 100644 --- a/examples/http_get_ssl/http_get_ssl.c +++ b/examples/http_get_ssl/http_get_ssl.c @@ -22,14 +22,12 @@ #include "ssl.h" +#include "ssid_config.h" + #define WEB_SERVER "192.168.0.18" #define WEB_PORT "8000" #define WEB_URL "/test" -#if !defined(WIFI_SSID) || !defined(WIFI_PASS) -#error "Please define macros WIFI_SSID & WIFI_PASS (here, or better in a local.h file at root level or in program dir." -#endif - static void display_cipher(SSL *ssl); static void display_session_id(SSL *ssl); diff --git a/include/ssid_config.h b/include/ssid_config.h new file mode 100644 index 0000000..edad5a9 --- /dev/null +++ b/include/ssid_config.h @@ -0,0 +1,31 @@ +// +// Why this file? +// +// We all need to add our personal SSID/password to each ESP project but we +// do not want that information pushed to Github. This file solves that +// problem. +// +// First tell git to ignore changes to this file: +// +// git update-index --assume-unchanged include/ssid_config.h +// +// Then, enter your SSID and passphrase below and it will never be committed +// to Github. +// +// Change password on project basis? Copy the default version this file to your +// project directory, redo the instructions and you have separate wifi settings +// for that project. +// +// For reference, see +// https://www.kernel.org/pub/software/scm/git/docs/git-update-index.html +// + +#warning "You need to enter your wifi credentials in this file and follow the instructions here to keep the password safe from Github commits." + +#ifndef __SSID_CONFIG_H__ +#define __SSID_CONFIG_H__ + +#define WIFI_SSID "mywifissid" +#define WIFI_PASS "my secret password" + +#endif // __SSID_CONFIG_H__