mcci-catena / Catena-Arduino-Platform

Arduino platform library for MCCI Catena IoT Systems
MIT License
12 stars 11 forks source link

Centralize application framework #323

Open terrillmoore opened 2 years ago

terrillmoore commented 2 years ago

This is a roll-up ticket for centralizing the application framework material that is now scattered all over the place. This gives a ticket to reference for the development branch.

The application framework handles the following.

In addition, we want to centralize some common things:

You must do the following:

Then in loop(), call gCatena.loop().

We're going to need to add some slots on the various concrete Catenas. For convenience, we should consider adding a vanilla Catena that allows use of the command-line interface and some other things on any Arduino.

New classes

class Catena_SpiFlash: the abstract wrapper for the concrete flash drivers.

Methods

SPIClass *Catena::getExternalSpi() const;

Return pointer to the external SPI that's driving MOSI, MISO and SCK. By default, it's SPI, but on MCCI Catenas using the Murata module, it may be gSPI2.

Globals from the application framework

SPIClass gSPI2; for the second SPI bus, on MCCI Catenas -- this is because the primary SPI interface, SPI, is not brought to pins and is used with the LoRaWAN radio.

Catena_SpiFlash gFlash;
cDownload McciCatena::gDownload;
cBootloaderApi McciCatena::gBootloaderApi;
cSerial<decltype(Serial)> McciCatena::gSerial;
StatusLed McciCatena::gLed;
cLog McciCatena::gLog;

These are all set up (and exported) by Catena::setup(), which calls Catena::begin() for legacy use.