Skip to content

Commit 0cf51c1

Browse files
committed
merged to head
2 parents 1e73e8d + a072cb3 commit 0cf51c1

35 files changed

+307
-187
lines changed

examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ void loop() {
5858

5959
// update value
6060
Firebase.setFloat("number", 43.0);
61+
// handle error
62+
if (Firebase.failed()) {
63+
Serial.print("setting /number failed:");
64+
Serial.println(Firebase.error());
65+
return;
66+
}
6167
delay(1000);
6268

6369
// get value
@@ -71,13 +77,32 @@ void loop() {
7177

7278
// set string value
7379
Firebase.setString("message", "hello world");
80+
// handle error
81+
if (Firebase.failed()) {
82+
Serial.print("setting /message failed:");
83+
Serial.println(Firebase.error());
84+
return;
85+
}
7486
delay(1000);
87+
7588
// set bool value
7689
Firebase.setBool("truth", false);
90+
// handle error
91+
if (Firebase.failed()) {
92+
Serial.print("setting /truth failed:");
93+
Serial.println(Firebase.error());
94+
return;
95+
}
7796
delay(1000);
7897

7998
// append a new value to /logs
8099
String name = Firebase.pushInt("logs", n++);
100+
// handle error
101+
if (Firebase.failed()) {
102+
Serial.print("pushing /logs failed:");
103+
Serial.println(Firebase.error());
104+
return;
105+
}
81106
Serial.print("pushed: /logs/");
82107
Serial.println(name);
83108
delay(1000);

examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@
1818
// A sample that will start our serial transciever listening on a software
1919
// port and allow debug over the main serial port.
2020
//
21-
// A suggested setup for testing this example would be a USB to TTL cable
22-
// with the green wire connected to pin 5 and the white wire connected to
23-
// pin 4 (on the huzzah feather esp8266).
24-
// First edit begin.txt and put in your host and secret.
25-
// Then run the following commands to setup the serial port in linux:
26-
// stty -F /dev/ttyUSB0 9600 raw -echo -echoe -echok
27-
// Then on one console do:
28-
// cat /dev/ttyUSB0 &
29-
// This console will now read all responses from the modem. Then do:
30-
// cat begin.txt > /dev/ttyUSB0
31-
// You should see +OK and you can now feed in the other example commmands.
21+
// A suggested setup for testing this example would be to connect a board
22+
// with integrated usb and open a serial monitor to see debug messages.
23+
// Then connect another board on pin4 and pin5 to communicate over serial.
3224

3325
#include <SoftwareSerial.h>
3426
#include <ESP8266WiFi.h>

examples/FirebaseSerialHost_ESP8266/push.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//
2+
// Copyright 2015 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
18+
// A sample that will start our serial transciever listening on the primary
19+
// Serial port.
20+
//
21+
// A suggested setup for testing this example would be a esp8266 with built
22+
// in usb connected.
23+
// First edit begin.txt and put in your host and secret.
24+
// Then run the following commands to setup the serial port (assuming ttyUSB0)
25+
// in linux:
26+
// stty -F /dev/ttyUSB0 9600 raw -echo -echoe -echok
27+
// Then on one console do:
28+
// cat /dev/ttyUSB0 &
29+
// This console will now read all responses from the modem. Then do:
30+
// cat begin.txt > /dev/ttyUSB0
31+
// You should see +OK and you can now feed in the other example commmands.
32+
33+
#include <ESP8266WiFi.h>
34+
35+
#include <Firebase.h>
36+
#include <SerialTransceiver.h>
37+
38+
// Set these to run example.
39+
#define WIFI_SSID "SSID"
40+
#define WIFI_PASSWORD "PASSWORD"
41+
42+
firebase::modem::SerialTransceiver transceiver;
43+
44+
void setup() {
45+
Serial.begin(9600);
46+
47+
// connect to wifi.
48+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
49+
Serial.print("connecting");
50+
while (WiFi.status() != WL_CONNECTED) {
51+
Serial.print(".");
52+
delay(500);
53+
}
54+
Serial.println();
55+
Serial.print("connected: ");
56+
Serial.println(WiFi.localIP());
57+
58+
transceiver.begin(&Serial);
59+
}
60+
61+
void loop() {
62+
transceiver.loop();
63+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PUSH /serial/push_test "this is a test string \ "

0 commit comments

Comments
 (0)