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

Add modem example (serialhost) #84

Merged
merged 8 commits into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ env:
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
- ( cd ${HOME} && curl -O https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz && tar xvf arduino-${ARDUINO_VERSION}-linux64.tar.xz )
- ( cd ${HOME} && wget -q -O SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/097712eb07f5b3a70ef419b6e7a7ed2ada5aab85.zip && unzip -q SoftwareSerial.zip
&& rm -rf SoftwareSerial.zip && mv espsoftwareserial-* SoftwareSerial)
- git clone --branch ${ARDUINO_ESP8266_VERSION} https://github.com/esp8266/Arduino.git ${ARDUINO_ESP8266_ROOT}
- git submodule init && git submodule update
- ( cd ${ARDUINO_ESP8266_ROOT}/tools && python get.py )
before_script:
- mkdir -p ${ARDUINO_HOME}/libraries
- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.2 ArduinoJson )
- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.2 ArduinoJson && ln -s ${HOME}/SoftwareSerial SoftwareSerial )
script:
- ${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/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino
- ${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/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino
- (cd test && make check)
- (cd test/modem/ && make test)
67 changes: 67 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


// A sample that will start our serial transciever listening on a software
// port and allow debug over the main serial port.
//
// A suggested setup for testing this example would be a USB to TTL cable
// with the green wire connected to pin 5 and the white wire connected to
// pin 4 (on the huzzah feather esp8266).
// First edit begin.txt and put in your host and secret.
// Then run the following commands to setup the serial port in linux:
// stty -F /dev/ttyUSB0 9600 raw -echo -echoe -echok
// Then on one console do:
// cat /dev/ttyUSB0 &
// This console will now read all responses from the modem. Then do:
// cat begin.txt > /dev/ttyUSB0
// You should see +OK and you can now feed in the other example commmands.

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

#include <Firebase.h>
#include <SerialTransceiver.h>

SoftwareSerial data_serial(5 /*RX*/, 4/*TX*/);
firebase::modem::SerialTransceiver transceiver;

void setup() {
Serial.begin(9600);

// connect to wifi.
WiFi.begin("SSID", "PASSWORD");
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());

data_serial.begin(9600);
while (!data_serial) {
Serial.println("Error initilizing serial.");
delay(5000);
}

transceiver.begin(&data_serial);
}

void loop() {
transceiver.loop();
}
2 changes: 2 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/begin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BEGIN $YOUR_HOST $YOUR_SECRET

2 changes: 2 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/begin_stream.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BEGIN_STREAM /serial/test

2 changes: 2 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/end_stream.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
END_STREAM

2 changes: 2 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/get.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GET /serial/test

1 change: 1 addition & 0 deletions examples/FirebaseSerialHost_ESP8266/get_push.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET /serial/push_test
1 change: 1 addition & 0 deletions examples/FirebaseSerialHost_ESP8266/push.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUSH /seria/push_test "this is a test string \ "
1 change: 1 addition & 0 deletions examples/FirebaseSerialHost_ESP8266/remove.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REMOVE /serial/test
2 changes: 2 additions & 0 deletions examples/FirebaseSerialHost_ESP8266/set.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SET /serial/test this is a test string \ "