diff --git a/.travis.yml b/.travis.yml index 0d5661c1..3383cf12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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) diff --git a/examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino b/examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino new file mode 100644 index 00000000..62bd6121 --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino @@ -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 +#include + +#include +#include + +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(); +} diff --git a/examples/FirebaseSerialHost_ESP8266/begin.txt b/examples/FirebaseSerialHost_ESP8266/begin.txt new file mode 100644 index 00000000..d0b9a4a9 --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/begin.txt @@ -0,0 +1,2 @@ +BEGIN $YOUR_HOST $YOUR_SECRET + diff --git a/examples/FirebaseSerialHost_ESP8266/begin_stream.txt b/examples/FirebaseSerialHost_ESP8266/begin_stream.txt new file mode 100644 index 00000000..54cf97b3 --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/begin_stream.txt @@ -0,0 +1,2 @@ +BEGIN_STREAM /serial/test + diff --git a/examples/FirebaseSerialHost_ESP8266/end_stream.txt b/examples/FirebaseSerialHost_ESP8266/end_stream.txt new file mode 100644 index 00000000..173d7c2c --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/end_stream.txt @@ -0,0 +1,2 @@ +END_STREAM + diff --git a/examples/FirebaseSerialHost_ESP8266/get.txt b/examples/FirebaseSerialHost_ESP8266/get.txt new file mode 100644 index 00000000..067a78ce --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/get.txt @@ -0,0 +1,2 @@ +GET /serial/test + diff --git a/examples/FirebaseSerialHost_ESP8266/get_push.txt b/examples/FirebaseSerialHost_ESP8266/get_push.txt new file mode 100644 index 00000000..f7eba497 --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/get_push.txt @@ -0,0 +1 @@ +GET /serial/push_test diff --git a/examples/FirebaseSerialHost_ESP8266/push.txt b/examples/FirebaseSerialHost_ESP8266/push.txt new file mode 100644 index 00000000..9878dd3c --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/push.txt @@ -0,0 +1 @@ +PUSH /seria/push_test "this is a test string \ " diff --git a/examples/FirebaseSerialHost_ESP8266/remove.txt b/examples/FirebaseSerialHost_ESP8266/remove.txt new file mode 100644 index 00000000..911f86a3 --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/remove.txt @@ -0,0 +1 @@ +REMOVE /serial/test diff --git a/examples/FirebaseSerialHost_ESP8266/set.txt b/examples/FirebaseSerialHost_ESP8266/set.txt new file mode 100644 index 00000000..8810bf0f --- /dev/null +++ b/examples/FirebaseSerialHost_ESP8266/set.txt @@ -0,0 +1,2 @@ +SET /serial/test this is a test string \ " +