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
urcUULOC.h
Go to the documentation of this file.
1
21#pragma once
22
23#include "../urcHandler.h"
24
26{
27
29 class urcUULOC : public urcHandler
30 {
31 public:
32 typedef void (*callback_t)(ClockData, PositionData, SpeedData, unsigned long);
33
35
36 bool process(urcHandlerInterface &device, const char *params)
37 {
38 ClockData clck;
39 PositionData gps;
40 SpeedData spd;
41 unsigned long uncertainty = 0;
42 int scanNum;
43 int latH = 0, lonH = 0, alt = 0;
44 unsigned int speedU = 0, cogU = 0;
45 char latL[10], lonL[10];
46 int dateStore[5] = {0, 0, 0, 0, 0};
47 unsigned int year = 0, ms = 0;
48
49 memset(&clck, 0, sizeof(clck));
50 memset(&gps, 0, sizeof(gps));
51 memset(&spd, 0, sizeof(spd));
52
53 // This assumes the ULOC response type is "0" or "1" - as selected by gpsRequest detailed
54 scanNum = sscanf(params,
55 "%d/%d/%u,%d:%d:%d.%u,%d.%9[^,],%d.%9[^,],%d,%lu,%u,%u,%*s",
56 &dateStore[0], &dateStore[1], &year,
57 &dateStore[2], &dateStore[3], &dateStore[4], &ms,
58 &latH, latL, &lonH, lonL, &alt, &uncertainty,
59 &speedU, &cogU);
60 clck.date.day = dateStore[0];
61 clck.date.month = dateStore[1];
62 clck.date.year = year;
63 clck.time.hour = dateStore[2];
64 clck.time.minute = dateStore[3];
65 clck.time.second = dateStore[4];
66 clck.time.ms = ms;
67
68 if (scanNum < 13)
69 return false;
70
71 // Found a Location string!
72 device.urcDebug().debugPrintln("processURCEvent: location");
73
74 if (latH >= 0)
75 gps.lat = (float)latH + ((float)atol(latL) / pow(10, strlen(latL)));
76 else
77 gps.lat = (float)latH - ((float)atol(latL) / pow(10, strlen(latL)));
78 if (lonH >= 0)
79 gps.lon = (float)lonH + ((float)atol(lonL) / pow(10, strlen(lonL)));
80 else
81 gps.lon = (float)lonH - ((float)atol(lonL) / pow(10, strlen(lonL)));
82 gps.alt = (float)alt;
83 if (scanNum >= 15) // If detailed response, get speed data
84 {
85 spd.speed = (float)speedU;
86 spd.cog = (float)cogU;
87 }
88
89 if (_callbackPtr[0] != nullptr)
90 ((callback_t)_callbackPtr[0])(clck, gps, spd, uncertainty);
91
92 return true;
93 }
94 };
95
97
98} // namespace SparkFun_Iridium_9604
const char IRIDIUM_9604_GNSS_REQUEST_LOCATION_URC[]
[Not documented for the 9604]
Definition: Iridium_9604_AT_commands.h:150
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 +UULOC: - Localization information (CellLocate and hybrid positioning)....
Definition: urcUULOC.h:30
urcUULOC(void)
Definition: urcUULOC.h:34
void(* callback_t)(ClockData, PositionData, SpeedData, unsigned long)
The callback signature. See the file description.
Definition: urcUULOC.h:32
bool process(urcHandlerInterface &device, const char *params)
Parse the URC parameters and act on them.
Definition: urcUULOC.h:36
Definition: nmeaMessage.h:30
The date and time.
Definition: Iridium_9604_typedefs.h:186
struct TimeData time
The time.
Definition: Iridium_9604_typedefs.h:188
struct DateData date
The date.
Definition: Iridium_9604_typedefs.h:187
uint8_t month
Month.
Definition: Iridium_9604_typedefs.h:169
uint8_t day
Day.
Definition: Iridium_9604_typedefs.h:168
unsigned int year
Year.
Definition: Iridium_9604_typedefs.h:170
A position.
Definition: Iridium_9604_typedefs.h:193
float alt
Altitude.
Definition: Iridium_9604_typedefs.h:197
float lat
Degrees: +/- 90.
Definition: Iridium_9604_typedefs.h:195
float lon
Degrees: +/- 180.
Definition: Iridium_9604_typedefs.h:196
A speed and course.
Definition: Iridium_9604_typedefs.h:204
float speed
m/s
Definition: Iridium_9604_typedefs.h:205
float cog
Degrees.
Definition: Iridium_9604_typedefs.h:206
uint8_t second
Second.
Definition: Iridium_9604_typedefs.h:178
unsigned int ms
Milliseconds.
Definition: Iridium_9604_typedefs.h:179
uint8_t hour
Hour.
Definition: Iridium_9604_typedefs.h:176
uint8_t minute
Minute.
Definition: Iridium_9604_typedefs.h:177
#define urcRegisterHandler(kHandler)
Declare a file-scope static builder that self-registers a URC handler class.
Definition: urcHandler.h:238