![]() |
SparkFun Iridium 9604
v1.0.0
Library for the Iridium 9604 Hybrid LTE-M Cellular + Iridium Satellite (SBD) + GNSS IoT module
|
#include "sfe_platform.h"#include "sfe_ip_address.h"#include "sfe_debug.h"#include "Iridium_9604_typedefs.h"#include <string.h>#include <vector>Go to the source code of this file.
Classes | |
| class | SparkFun_Iridium_9604::urcHandlerInterface |
| urcHandlerInterface: the services DevIridium9604 provides to the URC handlers. DevIridium9604 inherits (implements) this interface. More... | |
| class | SparkFun_Iridium_9604::urcHandler |
| The base class for the URC handlers. See the file description for how to add a new URC. More... | |
| class | SparkFun_Iridium_9604::urcHandlerRegistry |
| The registry of URC handler classes - mirrors the GNSS v4 message registries. More... | |
| class | SparkFun_Iridium_9604::urcHandlerBuilder< HandlerType > |
| Declared (by urcRegisterHandler) at the bottom of each URC handler header. Registers the handler class with the urcHandlerRegistry. More... | |
Namespaces | |
| namespace | SparkFun_Iridium_9604 |
Macros | |
| #define | urcRegisterHandler(kHandler) static urcHandlerBuilder<kHandler> global_##kHandler##Builder; |
| Declare a file-scope static builder that self-registers a URC handler class. More... | |
Typedefs | |
| typedef void(* | SparkFun_Iridium_9604::urcCallback_t) (void) |
| The generic URC callback type. Cast your callback to this for setURCCallback(). More... | |
Variables | |
| const uint8_t | SparkFun_Iridium_9604::URC_MAX_CALLBACKS = 3 |
| The maximum number of user callbacks per URC. More... | |
SPDX-License-Identifier: MIT
Please see LICENSE.md for more details
https://github.com/sparkfun/SparkFun_Iridium_9604_Library
Support for Unsolicited Result Codes (URCs): the urcHandler base class, the urcHandlerInterface (the parts of DevIridium9604 a handler is allowed to use) and the self-registration machinery.
In the original SARA-R5 library, every URC was decoded by one large function: processURCEvent(). Adding a URC meant editing processURCEvent() and pruneBacklog(). Here, each URC has its own class, in its own header file in src/urcHandlers/. Each class:
DevIridium9604 owns a urcHandlerVector (see urcHandlerVector.h) which builds one instance of every registered handler. bufferedPoll() / poll() pass each event to urcHandlerVector::processEvent(); pruneBacklog() asks urcHandlerVector::isURC() which events to keep.
User callbacks are registered with DevIridium9604::setURCCallback(urcPrefix, callback, index) - or with the typed helpers which call it (setSocketReadCallback(), setPingCallback(), etc.). The callback pointer is stored in the handler as a generic function pointer (urcCallback_t) and cast back to the handler's own typed signature when it is called. (Converting a function pointer to another function pointer type and back again is well defined in C++.) This means DevIridium9604 does not need to know the handler class - so a handler header can be commented out of urcHandlerVector.h to save memory without breaking the build.
Adding a new URC:
| #define urcRegisterHandler | ( | kHandler | ) | static urcHandlerBuilder<kHandler> global_##kHandler##Builder; |
Declare a file-scope static builder that self-registers a URC handler class.
Placed at the bottom of each per-URC header (e.g. urcUUSORD.h), inside namespace SparkFun_Iridium_9604.