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
urcCIEV.h
Go to the documentation of this file.
1
26#pragma once
27
28#include "../urcHandler.h"
29
31{
32
34 class urcCIEV : public urcHandler
35 {
36 public:
37 typedef void (*signalCallback_t)(int);
38 typedef void (*serviceCallback_t)(bool);
40
41 static const int ciev9604Offset = 50;
42
44
45 bool process(urcHandlerInterface &device, const char *params)
46 {
47 int indicator, value;
48 int scanNum = sscanf(params, "%d,%d", &indicator, &value);
49 if (scanNum != 2)
50 return false;
51
52 // The manual documents indicators 0, 1, 2 and 3. But the 9604 (network stack version 03.00.10) reports
53 // +CIEV:50,<rssi> and +CIEV:51,<value>. Accept both: 5x is treated as x
54 if ((indicator >= ciev9604Offset) && (indicator <= (ciev9604Offset + IRIDIUM_9604_CIEV_SV_BEAM_COORDINATES)))
55 indicator -= ciev9604Offset;
56
57 if (indicator == IRIDIUM_9604_CIEV_SIGNAL_QUALITY)
58 {
59 device.urcDebug().debugPrintln("processURCEvent: satellite signal quality");
60 device.urcIndicatorEvent(indicator, value);
61 if (_callbackPtr[0] != nullptr)
62 ((signalCallback_t)_callbackPtr[0])(value);
63 return true;
64 }
65 else if (indicator == IRIDIUM_9604_CIEV_SERVICE_AVAILABILITY)
66 {
67 device.urcDebug().debugPrintln("processURCEvent: satellite service availability");
68 device.urcIndicatorEvent(indicator, value);
69 if (_callbackPtr[1] != nullptr)
70 ((serviceCallback_t)_callbackPtr[1])(value != 0);
71 return true;
72 }
73 else if (indicator == IRIDIUM_9604_CIEV_SV_BEAM_COORDINATES)
74 {
76 scanNum = sscanf(params, "%*d,%d,%d,%d,%d,%d,%d", &coords.svId, &coords.beamId, &coords.svBm, &coords.x, &coords.y, &coords.z);
77 if (scanNum != 6)
78 return false;
79 device.urcDebug().debugPrintln("processURCEvent: satellite SV and beam coordinates");
80 if (_callbackPtr[2] != nullptr)
81 ((svBeamCallback_t)_callbackPtr[2])(coords);
82 return true;
83 }
84
85 // Deprecated (antenna) or unknown indicator
86 device.urcIndicatorEvent(indicator, value);
87 return true;
88 }
89 };
90
92
93} // namespace SparkFun_Iridium_9604
const char IRIDIUM_9604_SAT_INDICATOR_EVENT_URC[]
Satellite indicator event (signal quality, service availability, SV/beam). New for the 9604.
Definition: Iridium_9604_AT_commands.h:160
@ IRIDIUM_9604_CIEV_SV_BEAM_COORDINATES
+CIEV:3,<sv_id>,<beam_id>,<sv_bm>,<x>,<y>,<z>
Definition: Iridium_9604_typedefs.h:593
@ IRIDIUM_9604_CIEV_SIGNAL_QUALITY
+CIEV:0,<rssi> (0-5 bars)
Definition: Iridium_9604_typedefs.h:590
@ IRIDIUM_9604_CIEV_SERVICE_AVAILABILITY
+CIEV:1,<value> (0 = unavailable, 1 = available)
Definition: Iridium_9604_typedefs.h:591
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 URC handler for +CIEV: - Satellite Indicator Event. See the file description for the callback(s).
Definition: urcCIEV.h:35
static const int ciev9604Offset
The 9604 reports indicator 0 as 50, 1 as 51 etc.
Definition: urcCIEV.h:41
bool process(urcHandlerInterface &device, const char *params)
Parse the URC parameters and act on them.
Definition: urcCIEV.h:45
void(* signalCallback_t)(int)
Callback 0: signal quality.
Definition: urcCIEV.h:37
void(* serviceCallback_t)(bool)
Callback 1: service availability.
Definition: urcCIEV.h:38
void(* svBeamCallback_t)(IRIDIUM_9604_sv_beam_coords_t)
Callback 2: SV and beam coordinates.
Definition: urcCIEV.h:39
urcCIEV(void)
Definition: urcCIEV.h:43
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.
virtual void urcIndicatorEvent(int indicator, int value)=0
Record the latest +CIEV indicator value.
Definition: nmeaMessage.h:30
The +CIEV:3 SV and beam coordinates.
Definition: Iridium_9604_typedefs.h:600
int x
Grid coordinates in 1km units, range approx. -7160..+7160.
Definition: Iridium_9604_typedefs.h:604
int z
Z coordinate (km).
Definition: Iridium_9604_typedefs.h:606
int svBm
0: the coordinates are of the beam centre landing position; 1: the coordinates are of the SV
Definition: Iridium_9604_typedefs.h:603
int y
Y coordinate (km).
Definition: Iridium_9604_typedefs.h:605
int svId
ID of the SV, range 1..127.
Definition: Iridium_9604_typedefs.h:601
int beamId
ID of the spot beam received, range 1..48.
Definition: Iridium_9604_typedefs.h:602
#define urcRegisterHandler(kHandler)
Declare a file-scope static builder that self-registers a URC handler class.
Definition: urcHandler.h:238