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

Commit 19e9e9c

Browse files
committed
Merge pull request #84 from ed7coyne/modem-example
Add modem example (serialhost)
2 parents 7f62a32 + 804b1b7 commit 19e9e9c

File tree

10 files changed

+84
-1
lines changed

10 files changed

+84
-1
lines changed

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ env:
1313
install:
1414
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
1515
- ( cd ${HOME} && curl -O https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz && tar xvf arduino-${ARDUINO_VERSION}-linux64.tar.xz )
16+
- ( cd ${HOME} && wget -q -O SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/097712eb07f5b3a70ef419b6e7a7ed2ada5aab85.zip && unzip -q SoftwareSerial.zip
17+
&& rm -rf SoftwareSerial.zip && mv espsoftwareserial-* SoftwareSerial)
1618
- git clone --branch ${ARDUINO_ESP8266_VERSION} https://github.com/esp8266/Arduino.git ${ARDUINO_ESP8266_ROOT}
1719
- git submodule init && git submodule update
1820
- ( cd ${ARDUINO_ESP8266_ROOT}/tools && python get.py )
1921
before_script:
2022
- mkdir -p ${ARDUINO_HOME}/libraries
21-
- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.2 ArduinoJson )
23+
- ( 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 )
2224
script:
2325
- ${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
26+
- ${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
2427
- (cd test && make check)
2528
- (cd test/modem/ && make test)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BEGIN $YOUR_HOST $YOUR_SECRET
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BEGIN_STREAM /serial/test
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
END_STREAM
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /serial/test
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GET /serial/push_test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PUSH /seria/push_test "this is a test string \ "
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REMOVE /serial/test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SET /serial/test this is a test string \ "
2+

0 commit comments

Comments
 (0)