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
urcUUSORD.h
Go to the documentation of this file.
1
21#pragma once
22
23#include "../urcHandler.h"
24
26{
27
29 class urcUUSORD : public urcHandler
30 {
31 public:
33
34 bool process(urcHandlerInterface &device, const char *params)
35 {
36 int socket, length;
37 int ret = sscanf(params, "%d,%d", &socket, &length);
38 if (ret != 2)
39 return false;
40
41 if ((socket < 0) || (socket >= IRIDIUM_9604_NUM_SOCKETS))
42 return false;
43
44 device.urcDebug().debugPrintln("processURCEvent: read socket data");
45 // From the AT Commands Manual:
46 // "For the UDP socket type the URC +UUSORD: <socket>,<length> notifies that a UDP packet has been received,
47 // either when buffer is empty or after a UDP packet has been read and one or more packets are stored in the
48 // buffer."
49 // So we need to check if this is a TCP socket or a UDP socket:
50 // If UDP, we call urcSocketReadIndicationUDP.
51 // Otherwise, we call urcSocketReadIndication.
52 if (device.urcGetLastSocketProtocol(socket) == IRIDIUM_9604_UDP)
53 {
54 device.urcDebug().debugPrintln("processURCEvent: received +UUSORD but socket is UDP. Calling parseSocketReadIndicationUDP");
55 device.urcSocketReadIndicationUDP(socket, length);
56 }
57 else
58 device.urcSocketReadIndication(socket, length);
59 return true;
60 }
61 };
62
64
65} // namespace SparkFun_Iridium_9604
const char IRIDIUM_9604_READ_SOCKET_URC[]
The +UUSORD: URC.
Definition: Iridium_9604_AT_commands.h:146
@ IRIDIUM_9604_UDP
Definition: Iridium_9604_typedefs.h:234
#define IRIDIUM_9604_NUM_SOCKETS
The number of sockets: 0-6 (9604 AT manual, <socket> range).
Definition: Iridium_9604_typedefs.h:55
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
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 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 int urcGetLastSocketProtocol(int socket)=0
IRIDIUM_9604_TCP, IRIDIUM_9604_UDP or 0.
virtual IRIDIUM_9604_error_t urcSocketReadIndication(int socket, int length)=0
Read TCP data and pass it to the socket read callback(s)
The URC handler for +UUSORD: - Read Socket Data notification. See the file description for the callba...
Definition: urcUUSORD.h:30
urcUUSORD(void)
Definition: urcUUSORD.h:32
bool process(urcHandlerInterface &device, const char *params)
Parse the URC parameters and act on them.
Definition: urcUUSORD.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