|
| 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 a software |
| 19 | +// port and allow debug over the main serial port. |
| 20 | +// |
| 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. |
| 32 | + |
| 33 | +#include <SoftwareSerial.h> |
| 34 | +#include <ESP8266WiFi.h> |
| 35 | + |
| 36 | +#include <Firebase.h> |
| 37 | +#include <SerialTransceiver.h> |
| 38 | + |
| 39 | +SoftwareSerial data_serial(5 /*RX*/, 4/*TX*/); |
| 40 | +firebase::modem::SerialTransceiver transceiver; |
| 41 | + |
| 42 | +void setup() { |
| 43 | + Serial.begin(9600); |
| 44 | + |
| 45 | + // connect to wifi. |
| 46 | + WiFi.begin("SSID", "PASSWORD"); |
| 47 | + Serial.print("connecting"); |
| 48 | + while (WiFi.status() != WL_CONNECTED) { |
| 49 | + Serial.print("."); |
| 50 | + delay(500); |
| 51 | + } |
| 52 | + Serial.println(); |
| 53 | + Serial.print("connected: "); |
| 54 | + Serial.println(WiFi.localIP()); |
| 55 | + |
| 56 | + data_serial.begin(9600); |
| 57 | + while (!data_serial) { |
| 58 | + Serial.println("Error initilizing serial."); |
| 59 | + delay(5000); |
| 60 | + } |
| 61 | + |
| 62 | + transceiver.begin(&data_serial); |
| 63 | +} |
| 64 | + |
| 65 | +void loop() { |
| 66 | + transceiver.loop(); |
| 67 | +} |
0 commit comments