Skip to content

Commit 1a68dcf

Browse files
committed
Add documentation
1 parent 372ab54 commit 1a68dcf

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

src/ArduinoCellular.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,17 @@ class ArduinoCellular {
236236
#endif
237237

238238
/**
239-
* @brief Gets the HTTP client for the specified server and port.
239+
* @brief Gets a HTTP client for the specified server and port.
240+
* The maximum number of HTTP clients is limited by the number of sockets available.
240241
* @param server The server address.
241242
* @param port The server port.
242243
* @return The HTTP client.
243244
*/
244245
HttpClient getHTTPClient(const char * server, const int port);
245246

246247
/**
247-
* @brief Gets the HTTPS client for the specified server and port.
248+
* @brief Gets a HTTPS client for the specified server and port.
249+
* The maximum number of HTTP clients is limited by the number of sockets available.
248250
* @param server The server address.
249251
* @param port The server port.
250252
* @return The HTTPS client.

src/ManagedTinyGsmClient.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
#include "ModemInterface.h"
55

6+
/**
7+
* @class ManagedTinyGsmClient
8+
* @brief A managed client for TinyGSM that automatically handles socket allocation and release.
9+
* This class allows you to create multiple clients without worrying about socket management.
10+
* It uses a static bit field to track used sockets and provides methods to lock and unlock the sockets.
11+
*/
612
class ManagedTinyGsmClient : public TinyGsmClient {
713
private:
814
int socketId;
@@ -15,14 +21,62 @@ class ManagedTinyGsmClient : public TinyGsmClient {
1521
static void unlockSockets();
1622

1723
public:
24+
/**
25+
* @brief Constructs a ManagedTinyGsmClient with the specified modem.
26+
* @param modem The TinyGsm modem to use.
27+
*/
1828
ManagedTinyGsmClient(TinyGsm& modem);
29+
30+
/**
31+
* Copy constructor for ManagedTinyGsmClient.
32+
* This constructor allocates a new socket for the copied client.
33+
* @param other The other ManagedTinyGsmClient to copy from.
34+
* Note: If the other client is invalid, this will also create an invalid client.
35+
* The socketId will be -1.
36+
*/
1937
ManagedTinyGsmClient(const ManagedTinyGsmClient& other);
38+
39+
/**
40+
* Assignment operator for ManagedTinyGsmClient.
41+
* @param other The other ManagedTinyGsmClient to copy from.
42+
* @return A reference to this ManagedTinyGsmClient.
43+
*/
2044
ManagedTinyGsmClient& operator=(const ManagedTinyGsmClient& other);
45+
46+
/**
47+
* Move constructor for ManagedTinyGsmClient.
48+
* @param other The other ManagedTinyGsmClient to move from.
49+
*/
2150
ManagedTinyGsmClient(ManagedTinyGsmClient&& other);
51+
52+
/**
53+
* Move assignment operator for ManagedTinyGsmClient.
54+
* This operator transfers ownership of the socket from the other client to this one.
55+
* @param other The other ManagedTinyGsmClient to move from.
56+
* @return A reference to this ManagedTinyGsmClient.
57+
*/
2258
ManagedTinyGsmClient& operator=(ManagedTinyGsmClient&& other);
59+
60+
/**
61+
* Destructor for ManagedTinyGsmClient.
62+
* Releases the socket if it is valid.
63+
*/
2364
~ManagedTinyGsmClient();
2465

66+
/**
67+
* Get the socket ID for this client.
68+
* The maximum number of sockets is defined by TINY_GSM_MUX_COUNT.
69+
* If the client is invalid, the socketId will be -1.
70+
* @return The socket ID (0 - (TINY_GSM_MUX_COUNT - 1) or -1 if invalid).
71+
*/
2572
int getSocketId() const { return socketId; }
73+
74+
/**
75+
* Check if the client is valid.
76+
* A client is valid if it has a socket ID >= 0.
77+
* This is useful to check if the client can be used for network operations.
78+
* @return True if the client is valid, false otherwise.
79+
*/
2680
bool isValid() const { return socketId >= 0; }
2781
};
2882

0 commit comments

Comments
 (0)