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
urcUUSOLI.h
Go to the documentation of this file.
1
21#pragma once
22
23#include "../urcHandler.h"
24
26{
27
29 class urcUUSOLI : public urcHandler
30 {
31 public:
32 typedef void (*callback_t)(int, sfe_ip_address_t, unsigned int, int, sfe_ip_address_t, unsigned int);
33
35
36 bool process(urcHandlerInterface &device, const char *params)
37 {
38 int socket = 0;
39 int listenSocket = 0;
40 unsigned int port = 0;
41 unsigned int listenPort = 0;
42 sfe_ip_address_t remoteIP = {0, 0, 0, 0};
43 sfe_ip_address_t localIP = {0, 0, 0, 0};
44 int remoteIPstore[4] = {0, 0, 0, 0};
45 int localIPstore[4] = {0, 0, 0, 0};
46
47 int ret = sscanf(params,
48 "%d,\"%d.%d.%d.%d\",%u,%d,\"%d.%d.%d.%d\",%u",
49 &socket,
50 &remoteIPstore[0], &remoteIPstore[1], &remoteIPstore[2], &remoteIPstore[3],
51 &port, &listenSocket,
52 &localIPstore[0], &localIPstore[1], &localIPstore[2], &localIPstore[3],
53 &listenPort);
54 for (int i = 0; i <= 3; i++)
55 {
56 if (ret >= 5)
57 remoteIP[i] = (uint8_t)remoteIPstore[i];
58 if (ret >= 11)
59 localIP[i] = (uint8_t)localIPstore[i];
60 }
61 if (ret < 5)
62 return false;
63
64 device.urcDebug().debugPrintln("processURCEvent: socket listen");
65 device.urcSocketListenIndication(localIP, remoteIP); // Record the addresses for lastRemoteIP()
66
67 if (_callbackPtr[0] != nullptr)
68 ((callback_t)_callbackPtr[0])(listenSocket, localIP, listenPort, socket, remoteIP, port);
69
70 return true;
71 }
72 };
73
75
76} // namespace SparkFun_Iridium_9604
const char IRIDIUM_9604_LISTEN_SOCKET_URC[]
The +UUSOLI: URC.
Definition: Iridium_9604_AT_commands.h:148
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.
virtual void urcSocketListenIndication(sfe_ip_address_t localIP, sfe_ip_address_t remoteIP)=0
Record the IP addresses (lastRemoteIP())
The URC handler for +UUSOLI: - Set Listening Socket: incoming connection. See the file description fo...
Definition: urcUUSOLI.h:30
void(* callback_t)(int, sfe_ip_address_t, unsigned int, int, sfe_ip_address_t, unsigned int)
The callback signature. See the file description.
Definition: urcUUSOLI.h:32
bool process(urcHandlerInterface &device, const char *params)
Parse the URC parameters and act on them.
Definition: urcUUSOLI.h:36
urcUUSOLI(void)
Definition: urcUUSOLI.h:34
Definition: nmeaMessage.h:30
#define urcRegisterHandler(kHandler)
Declare a file-scope static builder that self-registers a URC handler class.
Definition: urcHandler.h:238