Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Open
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
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"engines": {
"node": ">=4.3.2"
}
}
}
6 changes: 6 additions & 0 deletions src/AppWatchdogWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -22,3 +26,5 @@ void AppWatchdogWrapper::watchdogCallback() {
ConnectionEvents::addEvent(ConnectionEvents::CONNECTION_EVENT_APP_WATCHDOG);
System.reset();
}

#endif // Wiring_Cellular
6 changes: 6 additions & 0 deletions src/AppWatchdogWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -15,4 +19,6 @@ class AppWatchdogWrapper {

};

#endif // Wiring_Cellular

#endif // __APPWATCHDOGWRAPPER_H
5 changes: 5 additions & 0 deletions src/BatteryCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -36,3 +40,4 @@ void BatteryCheck::checkAndSleepIfNecessary() {

}

#endif // Wiring_Cellular
6 changes: 6 additions & 0 deletions src/BatteryCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -22,4 +26,6 @@ class BatteryCheck {
unsigned long lastCheckMs = 0;
};

#endif // Wiring_Cellular

#endif // __BATTERYCHECK_H
5 changes: 5 additions & 0 deletions src/ConnectionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,3 +147,4 @@ void ConnectionCheck::fullModemReset() {
System.sleep(SLEEP_MODE_DEEP, 10);
}

#endif // Wiring_Cellular
5 changes: 5 additions & 0 deletions src/ConnectionCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,4 +47,5 @@ class ConnectionCheck {
static ConnectionCheckRetainedData connectionCheckRetainedData;
};

#endif /* Wiring_Cellular */
#endif /* __CONNECTIONCHECK_H */
6 changes: 4 additions & 2 deletions src/ConnectionEvents.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -127,5 +130,4 @@ void ConnectionEvents::addEvent(int eventCode, int data) {
}
}



#endif // Wiring_Cellular
6 changes: 5 additions & 1 deletion src/ConnectionEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,5 +105,5 @@ class ConnectionEvents {
static ConnectionEvents *instance;
};


#endif /* Wiring_Cellular */
#endif /* __CONNECTIONEVENTS_H */
5 changes: 5 additions & 0 deletions src/SessionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -113,3 +117,4 @@ void SessionCheck::waitForResponseState() {
}
}

#endif // Wiring_Cellular
5 changes: 5 additions & 0 deletions src/SessionCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -40,4 +44,5 @@ class SessionCheck {
static SessionRetainedData sessionRetainedData;
};

#endif /* Wiring_Cellular */
#endif /* __SESSIONCHECK_H */
6 changes: 6 additions & 0 deletions src/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -176,3 +180,5 @@ void Tester::processOptions(char *mutableData) {
}

}

#endif // Wiring_Cellular
6 changes: 5 additions & 1 deletion src/Tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -25,5 +29,5 @@ class Tester {
int pingCounter = 0;
};

#endif // Wiring_Cellular
#endif // __TESTER_H