WiFi credentials

Changed local.h to include/ssid_config.h and added instructions on how
to keep your WiFi credentials safe from Github.
This commit is contained in:
Johan Kanflo 2015-07-28 23:56:47 +02:00
parent 1cb2de5b96
commit 0e521a74a9
5 changed files with 39 additions and 15 deletions

View file

@ -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:
```

View file

@ -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)

View file

@ -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;

View file

@ -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);

31
include/ssid_config.h Normal file
View file

@ -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__