Skip to content

Commit

Permalink
USER LED flashes when abort
Browse files Browse the repository at this point in the history
  • Loading branch information
matsujirushi committed Jan 8, 2025
1 parent 66089a7 commit 5e9d7f4
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 5 deletions.
11 changes: 11 additions & 0 deletions examples/application/soracom-gps-tracker/soracom-gps-tracker.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// http://librarymanager#ArduinoJson 7.0.4

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>
#include <ArduinoJson.h>

Expand All @@ -28,6 +29,15 @@ static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static uint32_t MeasureTime = -INTERVAL;
static String LatestGpsData;

Expand All @@ -36,6 +46,7 @@ static constexpr int SOCKET_ID = 0;
static JsonDocument JsonDoc;

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/basic/flash/flash.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@
// http://librarymanager#SdFat%20-%20Adafruit%20Fork 2.2.3

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <Adafruit_SPIFlash.h>

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static const SPIFlash_Device_t SPIFLASH_DEVICE = FERAM_DEVICE_CONFIG;

static SPIClass FlashSpi(FERAM_SPI, PIN_FERAM_SO, PIN_FERAM_SCK, PIN_FERAM_SI);
static Adafruit_FlashTransport_SPI FlashTransport(PIN_FERAM_CS, FlashSpi);
static Adafruit_SPIFlash Flash(&FlashTransport);

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/cellular/cellular-status/cellular-status.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
*/

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>

static constexpr int INTERVAL = 1000 * 5; // [ms]
static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/cellular/shell/shell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// https://github.com/matsujirushi/ntshell 0.3.1

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <nrfx_power.h>
#include <ntshell.h> // Natural Tiny Shell
#include <util/ntopt.h> // Natural Tiny Shell
Expand All @@ -21,6 +22,15 @@ static const char APN[] = "soracom.io";
static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]
static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static constexpr int SOCKET_ID = 0;

static ntshell_t Shell;
Expand Down Expand Up @@ -71,6 +81,7 @@ static const CommandType CommandList[] = {
};

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/cellular/transparent/transparent.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@
*/

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>

static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>

static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]
Expand All @@ -23,6 +24,15 @@ static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static WioCellularResult queryCommand(const char *command, int timeout) {
CONSOLE.print("> ");
CONSOLE.println(command);
Expand Down Expand Up @@ -162,6 +172,7 @@ static void pingToSoracomNetwork(void) {
}

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// http://librarymanager#ArduinoHttpClient 0.6.1

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <map>
#include <WioCellular.h>
#include <ArduinoJson.h>
Expand All @@ -27,24 +28,34 @@ static constexpr int INTERVAL = 1000 * 60 * 5; // [ms]
static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]
static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]

#define ABORT_IF_FAILED(result) \
do { \
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

struct HttpResponse {
int statusCode;
std::map<std::string, std::string> headers;
std::string body;
};

#define ABORT_IF_FAILED(result) \
do { \
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static constexpr int PDP_CONTEXT_ID = 1;
static constexpr int SOCKET_ID = 0;

static JsonDocument JsonDoc;
static WioCellularTcpClient<WioCellularModule> TcpClient{ WioCellular, PDP_CONTEXT_ID, SOCKET_ID };

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/soracom/soracom-uptime-lp/soracom-uptime-lp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// http://librarymanager#ArduinoJson 7.0.4

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>
#include <ArduinoJson.h>

Expand All @@ -31,6 +32,15 @@ static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static SemaphoreHandle_t CellularWorkSem;
static SemaphoreHandle_t CellularStartSem;
static SemaphoreHandle_t MeasureSem;
Expand All @@ -39,6 +49,7 @@ static QueueSetHandle_t QueueSet;
static JsonDocument JsonDoc;

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// http://librarymanager#ArduinoJson 7.0.4

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>
#include <ArduinoJson.h>

Expand All @@ -28,13 +29,23 @@ static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]
if ((result) != WioCellularResult::Ok) abort(); \
} while (0)

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static constexpr int PDP_CONTEXT_ID = 1;
static constexpr int SOCKET_ID = 0;

static JsonDocument JsonDoc;
static WioCellularTcpClient<WioCellularModule> TcpClient{ WioCellular, PDP_CONTEXT_ID, SOCKET_ID };

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down
11 changes: 11 additions & 0 deletions examples/soracom/soracom-uptime/soracom-uptime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// http://librarymanager#ArduinoJson 7.0.4

#include <Adafruit_TinyUSB.h>
#include <csignal>
#include <WioCellular.h>
#include <ArduinoJson.h>

Expand All @@ -23,9 +24,19 @@ static constexpr int INTERVAL = 1000 * 60 * 5; // [ms]
static constexpr int POWER_ON_TIMEOUT = 1000 * 20; // [ms]
static constexpr int RECEIVE_TIMEOUT = 1000 * 10; // [ms]

static void abortHandler(int sig) {
while (true) {
ledOn(LED_BUILTIN);
delay(100);
ledOff(LED_BUILTIN);
delay(100);
}
}

static JsonDocument JsonDoc;

void setup(void) {
signal(SIGABRT, abortHandler);
Serial.begin(115200);
{
const auto start = millis();
Expand Down

0 comments on commit 5e9d7f4

Please sign in to comment.