Skip to content

Commit e64c4a0

Browse files
committed
Expose parent class instead of subclass
1 parent 12a206a commit e64c4a0

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/ArduinoCellular.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22

33
#include "ArduinoCellular.h"
4+
#include "ManagedTinyGsmClient.h"
45

56
#if defined(ARDUINO_ARCH_MBED)
67
#include "Watchdog.h"
@@ -166,19 +167,12 @@ int ArduinoCellular::getSignalQuality(){
166167
return modem.getSignalQuality();
167168
}
168169

169-
ManagedTinyGsmClient ArduinoCellular::getNetworkClient(){
170+
TinyGsmClient ArduinoCellular::getNetworkClient(){
170171
return ManagedTinyGsmClient(modem);
171172
}
172173

173174
HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){
174-
ManagedTinyGsmClient client = getNetworkClient();
175-
if (!client.isValid()) {
176-
// Handle error: no available sockets
177-
// Option 1: Return an invalid HttpClient (if supported)
178-
// Option 2: Use a default/shared client (not recommended)
179-
// Option 3: Wait and retry (could add a delay/retry mechanism)
180-
// For now, we'll proceed but the connection will likely fail
181-
}
175+
TinyGsmClient client = getNetworkClient();
182176
return HttpClient(client, server, port);
183177
}
184178

@@ -189,7 +183,7 @@ HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
189183
}
190184

191185
BearSSLClient ArduinoCellular::getSecureNetworkClient(){
192-
ManagedTinyGsmClient client = getNetworkClient();
186+
TinyGsmClient client = getNetworkClient();
193187
return BearSSLClient(client);
194188
}
195189
#endif

src/ArduinoCellular.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <Arduino.h>
1818
#include <vector>
19-
#include "ManagedTinyGsmClient.h"
2019

2120
#if defined __has_include
2221
#if !__has_include (<ArduinoIoTCloud.h>)
@@ -219,10 +218,14 @@ class ArduinoCellular {
219218

220219

221220
/**
222-
* @brief Gets the Network client. (OSI Layer 3)
223-
* @return The GSM client.
221+
* @brief Gets a new Network client. (OSI Layer 3)
222+
* The library automatically manages the sockets, so you can create multiple clients
223+
* without worrying about socket management. You should ensure that you release the client when you are done with it.
224+
* It's possible that the client is invalid if no sockets are available.
225+
* This is indicated by the isValid() method and the socketId will be -1.
226+
* @return A GSM client object that can be used to connect to a server.
224227
*/
225-
ManagedTinyGsmClient getNetworkClient();
228+
TinyGsmClient getNetworkClient();
226229

227230
/**
228231
* @brief Gets the Transport Layer Security (TLS) client. (OSI Layer 4)

0 commit comments

Comments
 (0)