Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 4318ab6

Browse files
committed
Merge pull request #119 from ed7coyne/fix-connection-bp
#define standard variables for wifi and firebase and check to ensure all examples conform
2 parents fd0f812 + bd2e663 commit 4318ab6

File tree

9 files changed

+57
-8
lines changed

9 files changed

+57
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ script:
3232
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
3333
- ( cd test && make check )
3434
- ( cd test/modem/ && make test )
35+
- test/travis/check_all_examples_use_standard_init.sh

examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@
2020
#include <ESP8266WiFi.h>
2121
#include <FirebaseArduino.h>
2222

23+
// Set these to run example.
24+
#define FIREBASE_HOST "example.firebaseio.com"
25+
#define FIREBASE_AUTH "token_or_secret"
26+
#define WIFI_SSID "SSID"
27+
#define WIFI_PASSWORD "PASSWORD"
28+
2329
void setup() {
2430
Serial.begin(9600);
2531

2632
// connect to wifi.
27-
WiFi.begin("SSID", "PASSWORD");
33+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
2834
Serial.print("connecting");
2935
while (WiFi.status() != WL_CONNECTED) {
3036
Serial.print(".");
@@ -34,7 +40,7 @@ void setup() {
3440
Serial.print("connected: ");
3541
Serial.println(WiFi.localIP());
3642

37-
Firebase.begin("example.firebaseio.com", "token_or_secret");
43+
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
3844
}
3945

4046
int n = 0;

examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include <ESP8266WiFi.h>
2121
#include <FirebaseArduino.h>
2222

23+
// Set these to run example.
24+
#define FIREBASE_HOST "example.firebaseio.com"
25+
#define FIREBASE_AUTH "token_or_secret"
26+
#define WIFI_SSID "SSID"
27+
#define WIFI_PASSWORD "PASSWORD"
28+
2329
const int grovePowerPin = 15;
2430
const int vibratorPin = 5;
2531
const int lightSensorPin = A0;
@@ -40,7 +46,7 @@ void setup() {
4046
pinMode(fanPin, OUTPUT);
4147

4248
// connect to wifi.
43-
WiFi.begin("SSID", "PASSWORD");
49+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
4450
Serial.print("connecting");
4551
while (WiFi.status() != WL_CONNECTED) {
4652
Serial.print(".");
@@ -50,7 +56,7 @@ void setup() {
5056
Serial.print("connected: ");
5157
Serial.println(WiFi.localIP());
5258

53-
Firebase.begin("example.firebaseio.com", "secret_or_token");
59+
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
5460
Firebase.set("pushbutton", 0);
5561
Firebase.set("sunlight", 0);
5662
Firebase.set("redlight", 0);

examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@
3636
#include <Firebase.h>
3737
#include <SerialTransceiver.h>
3838

39+
// Set these to run example.
40+
#define WIFI_SSID "SSID"
41+
#define WIFI_PASSWORD "PASSWORD"
42+
3943
SoftwareSerial data_serial(5 /*RX*/, 4/*TX*/);
4044
firebase::modem::SerialTransceiver transceiver;
4145

4246
void setup() {
4347
Serial.begin(9600);
4448

4549
// connect to wifi.
46-
WiFi.begin("SSID", "PASSWORD");
50+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
4751
Serial.print("connecting");
4852
while (WiFi.status() != WL_CONNECTED) {
4953
Serial.print(".");

examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <Adafruit_GFX.h>
2323
#include <Adafruit_SSD1306.h>
2424

25+
// Set these to run example.
26+
#define WIFI_SSID "SSID"
27+
#define WIFI_PASSWORD "PASSWORD"
28+
2529
#define OLED_RESET 3
2630
Adafruit_SSD1306 display(OLED_RESET);
2731

@@ -32,7 +36,7 @@ void setup() {
3236
display.display();
3337

3438
// connect to wifi.
35-
WiFi.begin("SSID", "PASSWORD");
39+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
3640
Serial.print("connecting");
3741
while (WiFi.status() != WL_CONNECTED) {
3842
Serial.print(".");

examples/Firebase_ESP8266_LEDs/Firebase_ESP8266_Neopixel/Firebase_ESP8266_Neopixel.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
#include <Adafruit_NeoPixel.h>
2323
#include "colors_ext.h"
2424

25+
// Set these to run example.
26+
#define FIREBASE_HOST "example.firebaseio.com"
27+
#define FIREBASE_AUTH "token_or_secret"
28+
#define WIFI_SSID "SSID"
29+
#define WIFI_PASSWORD "PASSWORD"
30+
2531
const int PIN=13;
2632
Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800);
2733

2834
// TODO: Replace with your own credentials and keep these safe.
29-
Firebase fbase = Firebase("YOUR-PROJECT.firebaseio.com", "YOUR_AUTH_SECRET");
35+
Firebase fbase = Firebase(FIREBASE_HOST, FIREBASE_AUTH);
3036

3137
void setup() {
3238
Serial.begin(9600);
@@ -39,7 +45,7 @@ void setup() {
3945
colorWipe(&strip, 0xFF0000, 50);
4046

4147
// connect to wifi.
42-
WiFi.begin("GoogleGuest", "");
48+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
4349
Serial.print("connecting");
4450

4551
int count = 0;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
FBASE_SNIPPET=test/travis/firebase_init.cc.snip
3+
FBASE_NOAUTH_SNIPPET=test/travis/no_firebase_init.cc.snip
4+
for example in `find examples/ -name *.ino`;
5+
do
6+
echo $example;
7+
(xxd -p $example | tr -d '\n' | grep -q `xxd -p $FBASE_SNIPPET | tr -d '\n'`) ||
8+
(xxd -p $example | tr -d '\n' | grep -q `xxd -p $FBASE_NOAUTH_SNIPPET | tr -d '\n'`) ||
9+
if [ $? -ne 0 ];
10+
then
11+
echo $example does not contain standard defined in test/travis/*_init.cc.snip.
12+
exit 1;
13+
fi;
14+
done;

test/travis/firebase_init.cc.snip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Set these to run example.
2+
#define FIREBASE_HOST "example.firebaseio.com"
3+
#define FIREBASE_AUTH "token_or_secret"
4+
#define WIFI_SSID "SSID"
5+
#define WIFI_PASSWORD "PASSWORD"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Set these to run example.
2+
#define WIFI_SSID "SSID"
3+
#define WIFI_PASSWORD "PASSWORD"

0 commit comments

Comments
 (0)