SparkFun Iridium 9604  v1.0.0
Library for the Iridium 9604 Hybrid LTE-M Cellular + Iridium Satellite (SBD) + GNSS IoT module
Loading...
Searching...
No Matches
urcUUMQTTC.h
Go to the documentation of this file.
1
19#pragma once
20
21#include "../urcHandler.h"
22
24{
25
27 class urcUUMQTTC : public urcHandler
28 {
29 public:
30 typedef void (*callback_t)(int, int);
31
33
34 bool process(urcHandlerInterface &device, const char *params)
35 {
36 int command, result;
37 int qos = -1;
38 int scanNum = sscanf(params, "%d,%d", &command, &result);
39 if ((scanNum == 2) && (command == IRIDIUM_9604_MQTT_COMMAND_SUBSCRIBE))
40 {
41 char topicC[100] = "";
42 scanNum = sscanf(params, "%*d,%*d,%d,\"%99[^\"]\"", &qos, topicC);
43 if (scanNum < 2) // Subscribe URC without QoS and topic? Still report the command and result
44 scanNum = 2;
45 }
46 if (scanNum != 2)
47 return false;
48
49 device.urcDebug().debugPrintln("processURCEvent: MQTT command result");
50
51 if (_callbackPtr[0] != nullptr)
52 ((callback_t)_callbackPtr[0])(command, result);
53
54 return true;
55 }
56 };
57
59
60} // namespace SparkFun_Iridium_9604
const char IRIDIUM_9604_MQTT_COMMAND_URC[]
The +UUMQTTC: URC.
Definition: Iridium_9604_AT_commands.h:153
@ IRIDIUM_9604_MQTT_COMMAND_SUBSCRIBE
Definition: Iridium_9604_typedefs.h:375
void debugPrintln(const char *message, bool important=false)
Print a debug message followed by a newline, if debugging is enabled.
Definition: sfe_debug.cpp:76
The base class for the URC handlers. See the file description for how to add a new URC.
Definition: urcHandler.h:92
urcCallback_t _callbackPtr[URC_MAX_CALLBACKS]
The user's callbacks, stored generically.
Definition: urcHandler.h:168
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 SfeDebugPrint & urcDebug(void)=0
The debug printer.
The URC handler for +UUMQTTC: - MQTT Command Result. See the file description for the callback(s).
Definition: urcUUMQTTC.h:28
void(* callback_t)(int, int)
The callback signature. See the file description.
Definition: urcUUMQTTC.h:30
bool process(urcHandlerInterface &device, const char *params)
Parse the URC parameters and act on them.
Definition: urcUUMQTTC.h:34
urcUUMQTTC(void)
Definition: urcUUMQTTC.h:32
Definition: nmeaMessage.h:30
#define urcRegisterHandler(kHandler)
Declare a file-scope static builder that self-registers a URC handler class.
Definition: urcHandler.h:238