diff --git a/.arduino-ci.yml b/.arduino-ci.yml new file mode 100644 index 0000000..36a132e --- /dev/null +++ b/.arduino-ci.yml @@ -0,0 +1,8 @@ +compile: + platforms: + - uno + - leonardo + +unittest: + platforms: + - uno diff --git a/.gitignore b/.gitignore index 4b2ab85..0abb443 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.skip examples/FONA_SMS_Response/.esp8266.test.skip +unittest*.bin diff --git a/.travis.yml b/.travis.yml index 6b62611..f8b1382 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ -language: c sudo: false -before_install: - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) +language: ruby script: - - build_main_platforms + - bundle install + - bundle exec arduino_ci_remote.rb notifications: email: on_success: change diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..202729d --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'arduino_ci', '~> 0.1.6' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..956b84d --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,15 @@ +GEM + remote: https://rubygems.org/ + specs: + arduino_ci (0.1.6) + os (~> 1.0) + os (1.0.0) + +PLATFORMS + ruby + +DEPENDENCIES + arduino_ci (~> 0.1.6) + +BUNDLED WITH + 1.16.0 diff --git a/examples/FONA3G_setbaud/.esp8266.test.skip b/examples/FONA3G_setbaud/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/FONAtest/.esp8266.test.skip b/examples/FONAtest/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/FONAtest_KEY_mod.zip b/examples/FONAtest_KEY_mod.zip deleted file mode 100644 index 5128e18..0000000 Binary files a/examples/FONAtest_KEY_mod.zip and /dev/null differ diff --git a/examples/GPS/.esp8266.test.skip b/examples/GPS/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/IncomingCall/.esp8266.test.skip b/examples/IncomingCall/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/includes/platform/FONAPlatStd.h b/includes/platform/FONAPlatStd.h index 85bc8fe..39699c6 100644 --- a/includes/platform/FONAPlatStd.h +++ b/includes/platform/FONAPlatStd.h @@ -30,7 +30,8 @@ #if (ARDUINO >= 100) #include "Arduino.h" - #if !defined(__SAM3X8E__) && !defined(ARDUINO_ARCH_SAMD) // Arduino Due doesn't support #include + #if !defined(__SAM3X8E__) && !defined(ARDUINO_ARCH_SAMD) // Arduino Due doesn't support + #include #endif #else #include "WProgram.h" diff --git a/test/comms.cpp b/test/comms.cpp new file mode 100644 index 0000000..917f609 --- /dev/null +++ b/test/comms.cpp @@ -0,0 +1,113 @@ +#include +#include +#include +#include +#include "../Adafruit_FONA.h" + +#define FONA_RX 2 +#define FONA_TX 3 +#define FONA_RST 4 + +bool bigEndian = false; // RS232 says so + +// DeviceUsingBytes extends DataStreamObserver, +// so we will be able to attach this class to an +// ObservableDataStream object, of which the pin +// history (soft-serial) and HardwareSerial +// objects are. +class FakeFona : public DeviceUsingBytes { + public: + String mLast; + + FakeFona() : DeviceUsingBytes() { + mLast = ""; + addResponseCRLF("AT", "OK"); + addResponseCRLF("ATE0", "OK"); + addResponseCRLF("AT+CVHU=0", "OK"); + addResponseCRLF("ATI", "OK"); + addResponseCRLF("AT+CPMS=\"SM\",\"SM\",\"SM\"", "OK"); + addResponseCRLF("AT+GSN", "1234567890abcde\r\nOK"); + } + + virtual ~FakeFona() {} + + virtual void onMatchInput(String output) { + mLast = output; + state->digitalPin[FONA_TX].fromAscii(output, bigEndian); + } +}; + + +class Adafruit_FONA_debug : public Adafruit_FONA { + public: + Adafruit_FONA_debug(int8_t r) : Adafruit_FONA(r) {} + + + String debug_replybuffer() const { + return String(replybuffer); + } + + uint8_t debug_readline(uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS, boolean multiline = false) { return readline(timeout, multiline); } + +}; + +unittest(ARDUINO_100) +{ + assertEqual(100, ARDUINO); +} + +// basic test of the readline capability +unittest(fona_readline) { + + GodmodeState* state = GODMODE(); + state->reset(); + + Adafruit_FONA_debug fona = Adafruit_FONA_debug(FONA_RST); + SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX); + SoftwareSerial *fonaSerial = &fonaSS; + fonaSerial->begin(115200); + fona.begin(*fonaSerial); + + assertTrue(fonaSS.isListening()); + + assertEqual(0, fonaSS.available()); + state->digitalPin[FONA_TX].fromAscii("You were over the line, Smokey\nMark it 8, Dude", bigEndian); + assertNotEqual(0, fonaSS.available()); + + uint8_t rl = fona.debug_readline(300, false); + assertNotEqual(0, rl); + assertEqual("You were over the line, Smokey", fona.debug_replybuffer()); +} + +// retrieve the IMEI from a serial device faked by the FakeFona class +unittest(fona_imei) { + + GodmodeState* state = GODMODE(); + state->reset(); + + // set up FONA on serial port + Adafruit_FONA_debug fona = Adafruit_FONA_debug(FONA_RST); + SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX); + SoftwareSerial *fonaSerial = &fonaSS; + fonaSerial->begin(115200); + + // set up our fake modem on the other end. + // note that the digitalPin we attach to is an ObservableDataStream + FakeFona fakeFona; + fakeFona.attach(&state->digitalPin[FONA_RX]); + + // fire it up + assertTrue(fona.begin(*fonaSerial)); + + // These asserts will just dump out the input/output log as a test failure + // assertEqual("", state->digitalPin[FONA_RX].toAscii(1, bigEndian)); + // assertEqual("", state->digitalPin[FONA_TX].toAscii(1, bigEndian)); + + char imei[16] = {0}; // MUST use a 16 character buffer for IMEI! + uint8_t imeiLen = fona.getIMEI(imei); + assertNotEqual(0, imeiLen); + //assertEqual("AT+GSN\n", state->digitalPin[FONA_RX].toAscii(1, bigEndian)); + assertEqual("1234567890abcde", imei); +} + +unittest_main()