108 void addURC(
const char *urcPrefix,
bool keepInBacklog =
true)
115 bool amI(
const char *urcPrefix)
const
117 return ((
_urcPrefix !=
nullptr) && (urcPrefix !=
nullptr) && (strcmp(
_urcPrefix, urcPrefix) == 0));
127 const char *
match(
const char *event)
const
129 if ((
_urcPrefix ==
nullptr) || (event ==
nullptr))
131 const char *searchPtr = strstr(event,
_urcPrefix);
132 if (searchPtr ==
nullptr)
135 while (*searchPtr ==
' ')
197 for (
auto existing : _factories)
198 if (existing == factory)
200 _factories.push_back(factory);
204 void buildAll(std::vector<urcHandler *> &handlers)
const
206 for (
auto factory : _factories)
207 handlers.push_back(factory());
212 std::vector<urcHandlerFactoryFn> _factories;
215 template <
typename HandlerType>
228 return new HandlerType();
238#define urcRegisterHandler(kHandler) static urcHandlerBuilder<kHandler> global_##kHandler##Builder;
IRIDIUM_9604_error_t
The library error codes.
Definition: Iridium_9604_typedefs.h:129
Debug printing: replaces the SARA-R5 library _debugPort prints. A base class of DevIridium9604 and th...
Definition: sfe_debug.h:38
Declared (by urcRegisterHandler) at the bottom of each URC handler header. Registers the handler clas...
Definition: urcHandler.h:218
static urcHandler * create(void)
Create one instance of the handler.
Definition: urcHandler.h:226
urcHandlerBuilder(void)
Definition: urcHandler.h:220
The base class for the URC handlers. See the file description for how to add a new URC.
Definition: urcHandler.h:92
const char * _urcPrefix
e.g. "+UUSORD:"
Definition: urcHandler.h:166
urcCallback_t _callbackPtr[URC_MAX_CALLBACKS]
The user's callbacks, stored generically.
Definition: urcHandler.h:168
bool _keepInBacklog
Keep this URC in the backlog for the next bufferedPoll.
Definition: urcHandler.h:167
bool amI(const char *urcPrefix) const
Does this object handle this URC prefix? (Exact match, e.g. "+UUSORD:")
Definition: urcHandler.h:115
bool setCallback(urcCallback_t callback, uint8_t index=0)
Set (or clear, with nullptr) callback 'index' for this URC.
Definition: urcHandler.h:152
const char * match(const char *event) const
Does this event contain this handler's URC?
Definition: urcHandler.h:127
virtual ~urcHandler(void)
Definition: urcHandler.h:99
urcHandler(void)
Definition: urcHandler.h:94
bool hasCallback(uint8_t index=0) const
true if callback 'index' has been registered.
Definition: urcHandler.h:161
virtual bool process(urcHandlerInterface &device, const char *params)=0
Parse the URC parameters and act on them.
void addURC(const char *urcPrefix, bool keepInBacklog=true)
Register this handler's identity. Called once, from the subclass's own constructor.
Definition: urcHandler.h:108
urcHandlerInterface: the services DevIridium9604 provides to the URC handlers. DevIridium9604 inherit...
Definition: urcHandler.h:70
virtual ~urcHandlerInterface()
Definition: urcHandler.h:72
virtual IRIDIUM_9604_error_t urcSocketReadIndicationUDP(int socket, int length)=0
Read UDP data and pass it to the socket read callback(s)
virtual SfeDebugPrint & urcDebug(void)=0
The debug printer.
virtual void urcProcessNMEA(const char *sentence, size_t length)=0
Process one NMEA sentence.
virtual int urcGetLastSocketProtocol(int socket)=0
IRIDIUM_9604_TCP, IRIDIUM_9604_UDP or 0.
virtual void urcIndicatorEvent(int indicator, int value)=0
Record the latest +CIEV indicator value.
virtual void urcSocketListenIndication(sfe_ip_address_t localIP, sfe_ip_address_t remoteIP)=0
Record the IP addresses (lastRemoteIP())
virtual IRIDIUM_9604_error_t urcSocketReadIndication(int socket, int length)=0
Read TCP data and pass it to the socket read callback(s)
The registry of URC handler classes - mirrors the GNSS v4 message registries.
Definition: urcHandler.h:177
urcHandler *(* urcHandlerFactoryFn)(void)
The factory function type.
Definition: urcHandler.h:179
static urcHandlerRegistry & get(void)
Get the single, lazily-constructed urcHandlerRegistry instance.
Definition: urcHandler.h:182
void registerHandler(urcHandlerFactoryFn factory)
Register one URC handler class's factory function, if not already registered.
Definition: urcHandler.h:195
void buildAll(std::vector< urcHandler * > &handlers) const
Construct one instance of every currently-registered URC handler class.
Definition: urcHandler.h:204
Definition: nmeaMessage.h:30
void(* urcCallback_t)(void)
The generic URC callback type. Cast your callback to this for setURCCallback().
Definition: urcHandler.h:59
const uint8_t URC_MAX_CALLBACKS
The maximum number of user callbacks per URC.
Definition: urcHandler.h:63