diff --git a/library.properties b/library.properties index 13bd6d0..793bda1 100644 --- a/library.properties +++ b/library.properties @@ -1,11 +1,11 @@ # Fill in information about your library then remove # from the start of lines # https://docs.particle.io/guide/tools-and-features/libraries/#library-properties-fields name=electronsample -version=0.2.3 +version=0.2.4 author=rickkas7@rickkas7.com license=MIT sentence=Utilities for Electron fault tolerance # paragraph=a longer description of this library url=https://github.com/rickkas7/electronsample repository=https://github.com/rickkas7/electronsample.git -architectures=electron +architectures=electron,photon diff --git a/package.json b/package.json index 41f58ff..7765f35 100644 --- a/package.json +++ b/package.json @@ -16,4 +16,4 @@ "engines": { "node": ">=4.3.2" } -} \ No newline at end of file +} diff --git a/src/AppWatchdogWrapper.cpp b/src/AppWatchdogWrapper.cpp index 5ea1549..aed6bbe 100644 --- a/src/AppWatchdogWrapper.cpp +++ b/src/AppWatchdogWrapper.cpp @@ -4,6 +4,10 @@ #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + // Note: The 1800 parameter is because the default stack size is too small in 0.7.0 AppWatchdogWrapper::AppWatchdogWrapper(unsigned long timeoutMs) : wd(timeoutMs, watchdogCallback, 1800) { @@ -22,3 +26,5 @@ void AppWatchdogWrapper::watchdogCallback() { ConnectionEvents::addEvent(ConnectionEvents::CONNECTION_EVENT_APP_WATCHDOG); System.reset(); } + +#endif // Wiring_Cellular diff --git a/src/AppWatchdogWrapper.h b/src/AppWatchdogWrapper.h index 4128cdf..e173740 100644 --- a/src/AppWatchdogWrapper.h +++ b/src/AppWatchdogWrapper.h @@ -3,6 +3,10 @@ #include "Particle.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + class AppWatchdogWrapper { public: AppWatchdogWrapper(unsigned long timeoutMs = 60000); @@ -15,4 +19,6 @@ class AppWatchdogWrapper { }; +#endif // Wiring_Cellular + #endif // __APPWATCHDOGWRAPPER_H diff --git a/src/BatteryCheck.cpp b/src/BatteryCheck.cpp index 0fe72b8..39aab19 100644 --- a/src/BatteryCheck.cpp +++ b/src/BatteryCheck.cpp @@ -2,6 +2,10 @@ #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + static FuelGauge fuel; static PMIC pmic; @@ -36,3 +40,4 @@ void BatteryCheck::checkAndSleepIfNecessary() { } +#endif // Wiring_Cellular diff --git a/src/BatteryCheck.h b/src/BatteryCheck.h index c8250be..d1c4d32 100644 --- a/src/BatteryCheck.h +++ b/src/BatteryCheck.h @@ -3,6 +3,10 @@ #include "Particle.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + class BatteryCheck { public: BatteryCheck(float minimumSoC = 15.0, long sleepTimeSecs = 3600); @@ -22,4 +26,6 @@ class BatteryCheck { unsigned long lastCheckMs = 0; }; +#endif // Wiring_Cellular + #endif // __BATTERYCHECK_H diff --git a/src/ConnectionCheck.cpp b/src/ConnectionCheck.cpp index 79f9b75..d0e18a2 100644 --- a/src/ConnectionCheck.cpp +++ b/src/ConnectionCheck.cpp @@ -2,6 +2,10 @@ #include "ConnectionCheck.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + ConnectionCheck *ConnectionCheck::instance; retained ConnectionCheckRetainedData ConnectionCheck::connectionCheckRetainedData; @@ -143,3 +147,4 @@ void ConnectionCheck::fullModemReset() { System.sleep(SLEEP_MODE_DEEP, 10); } +#endif // Wiring_Cellular diff --git a/src/ConnectionCheck.h b/src/ConnectionCheck.h index 15b9456..35357ce 100644 --- a/src/ConnectionCheck.h +++ b/src/ConnectionCheck.h @@ -3,6 +3,10 @@ #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + // This structure is what's stored in retained memory typedef struct { uint32_t magic; @@ -43,4 +47,5 @@ class ConnectionCheck { static ConnectionCheckRetainedData connectionCheckRetainedData; }; +#endif /* Wiring_Cellular */ #endif /* __CONNECTIONCHECK_H */ diff --git a/src/ConnectionEvents.cpp b/src/ConnectionEvents.cpp index 0a798a4..e0c4aaa 100644 --- a/src/ConnectionEvents.cpp +++ b/src/ConnectionEvents.cpp @@ -1,6 +1,9 @@ #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular // This is where the retained memory is allocated. Currently 522 bytes. // There are checks in ConnectionsEvents::setup() to initialize it on first @@ -127,5 +130,4 @@ void ConnectionEvents::addEvent(int eventCode, int data) { } } - - +#endif // Wiring_Cellular diff --git a/src/ConnectionEvents.h b/src/ConnectionEvents.h index c314a86..571d6a8 100644 --- a/src/ConnectionEvents.h +++ b/src/ConnectionEvents.h @@ -3,6 +3,10 @@ #include "Particle.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + // This code is used to track connection events, used mainly for debugging // and making sure this code works properly. const size_t CONNECTION_EVENTS_MAX_EVENTS = 32; @@ -101,5 +105,5 @@ class ConnectionEvents { static ConnectionEvents *instance; }; - +#endif /* Wiring_Cellular */ #endif /* __CONNECTIONEVENTS_H */ diff --git a/src/SessionCheck.cpp b/src/SessionCheck.cpp index 1f316a3..4a9ffab 100644 --- a/src/SessionCheck.cpp +++ b/src/SessionCheck.cpp @@ -2,6 +2,10 @@ #include "SessionCheck.h" #include "ConnectionCheck.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + retained SessionRetainedData SessionCheck::sessionRetainedData; @@ -113,3 +117,4 @@ void SessionCheck::waitForResponseState() { } } +#endif // Wiring_Cellular diff --git a/src/SessionCheck.h b/src/SessionCheck.h index b899956..800de0e 100644 --- a/src/SessionCheck.h +++ b/src/SessionCheck.h @@ -3,6 +3,10 @@ #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + // This structure is what's stored in retained memory typedef struct { uint32_t magic; @@ -40,4 +44,5 @@ class SessionCheck { static SessionRetainedData sessionRetainedData; }; +#endif /* Wiring_Cellular */ #endif /* __SESSIONCHECK_H */ diff --git a/src/Tester.cpp b/src/Tester.cpp index bb877b7..5362504 100644 --- a/src/Tester.cpp +++ b/src/Tester.cpp @@ -5,6 +5,10 @@ #include "ConnectionCheck.h" #include "ConnectionEvents.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + Tester::Tester(const char *functionName, int sleepTestPin) : functionName(functionName), sleepTestPin(sleepTestPin) { @@ -176,3 +180,5 @@ void Tester::processOptions(char *mutableData) { } } + +#endif // Wiring_Cellular diff --git a/src/Tester.h b/src/Tester.h index 8f91b28..f2b79a9 100644 --- a/src/Tester.h +++ b/src/Tester.h @@ -3,6 +3,10 @@ #include "Particle.h" +// This check is here so it can be a library dependency for a library that's compiled for both +// cellular and Wi-Fi. +#if Wiring_Cellular + class Tester { public: Tester(const char *functionName, int sleepTestPin = -1); @@ -25,5 +29,5 @@ class Tester { int pingCounter = 0; }; +#endif // Wiring_Cellular #endif // __TESTER_H -