Skip to content

Commit ae58089

Browse files
More api documentation
1 parent ff3171e commit ae58089

File tree

7 files changed

+251
-63
lines changed

7 files changed

+251
-63
lines changed

libraries/WiFiS3/src/Modem.h

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515

1616
#define DO_NOT_CHECK_CMD "NO_CMD_CHECK"
1717

18+
/**
19+
* @brief A class that provides methods to interact with a modem.
20+
*
21+
* This class is responsible for providing an interface to communicate with
22+
* a modem through serial communication. It includes methods for initialization,
23+
* sending and receiving data, and handling modem configurations.
24+
*/
1825
class ModemClass {
1926

2027
public:
@@ -32,6 +39,10 @@ class ModemClass {
3239
* @param `_serial` is a pointer to the UART object that will be used for communication with the modem.
3340
*/
3441
ModemClass(UART * _serial);
42+
43+
/**
44+
* @brief Destructor for ModemClass.
45+
*/
3546
~ModemClass();
3647

3748
/**
@@ -48,23 +59,17 @@ class ModemClass {
4859

4960

5061
/**
51-
* @brief Sends a formatted command string to a device and stores the response.
52-
*
53-
* This function formats a command string using the provided format and arguments,
54-
* sends it to a device, and waits for a response, which is stored in the `str` string.
55-
*
56-
* @param cmd A string representing the command to be sent to the device.
57-
* @param str A reference to a string that will hold the device's response.
58-
* @param fmt A format string for constructing the command.
59-
*
60-
* @return `true` if the command was successfully sent and a response was received,
61-
* `false` otherwise.
62-
*/
63-
/**
64-
* @brief Sends a command to the modem and waits for a response.
62+
* @brief Sends a formatted command string to a device and stores the response.
63+
*
64+
* This function formats a command string using the provided format and arguments,
65+
* sends it to a device, and waits for a response, which is stored in the `str` string.
66+
*
67+
* @param `cmd` A string representing the command to be sent to the device.
68+
* @param `str` A reference to a string that will hold the device's response.
69+
* @param `fmt` A format string for constructing the command.
6570
*
66-
* @param It takes a command string `cmd`, a string `str` where the response will be stored
67-
* and a format string `fmt` along with additional arguments.
71+
* @return `true` if the command was successfully sent and a response was received,
72+
* `false` otherwise.
6873
*/
6974
bool write(const std::string &cmd, std::string &str, const char * fmt, ...);
7075

@@ -85,20 +90,30 @@ class ModemClass {
8590
*/
8691
bool passthrough(const uint8_t *data, size_t size);
8792

93+
/**
94+
* @brief Disables automatic trimming of results for one operation.
95+
*
96+
* This function disables the automatic trimming of results for one operation.
97+
* After it is called, the results will not be trimmed automatically until
98+
* the function is called again.
99+
*/
88100
void avoid_trim_results() {
89101
/* one shot - it works only 1 time the it is necessary to call again this
90102
funtion */
91103
trim_results = false;
92104
}
93105

94-
95106
/**
96107
* @brief Enables a specific mode of reading where the size of the data
97108
* to be read is considered for processing.
98109
*/
99110
void read_using_size() {
100111
read_by_size = true;
101112
}
113+
114+
/**
115+
* @brief Flag indicating whether the system has been initialized.
116+
*/
102117
bool beginned;
103118

104119
/* Calling this function with no argument will enable debug message to be printed

libraries/WiFiS3/src/StringHelpers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ void trim(std::string &s);
4444
*
4545
* @param `res` is a reference to a vector of strings where the resulting tokens
4646
* will be stored.
47-
* `str` is the string to be split. This string will be modified as it is
47+
* @param `str` is the string to be split. This string will be modified as it is
4848
* split.
49-
* `delimiter` is the delimiter string that separates the tokens in `str`.
50-
* `_trim` is a boolean flag indicating whether to trim whitespace from each
49+
* @param `delimiter` is the delimiter string that separates the tokens in `str`.
50+
* @param `_trim` is a boolean flag indicating whether to trim whitespace from each
5151
* token. If true, leading and trailing whitespace will be removed from each token. Defaults to true.
5252
*/
5353
void split(std::vector<std::string> &res, std::string &str, const std::string &delimiter, bool _trim = true);
@@ -63,10 +63,10 @@ void split(std::vector<std::string> &res, std::string &str, const std::string &d
6363
*
6464
* @param `str` is a reference to the string from which the substring will be removed.
6565
* The string is modified if the substring is removed.
66-
* `what` is the substring to be removed from the beginning of `str`.
66+
* @param `what` is the substring to be removed from the beginning of `str`.
6767
*
6868
* @return `true` if the substring was found and removed from the beginning of
69-
* the string, `false` otherwise.
69+
* the string, `false` otherwise.
7070
*/
7171
bool removeAtBegin(std::string &str, const std::string &what);
7272

libraries/WiFiS3/src/WiFi.h

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class CWifi {
8686
*
8787
* @param `ssid` The SSID (network name) of the Access Point.
8888
*
89-
* @return 1 if the Access Point is successfully started. 0 if the Access Point initialization failed.
89+
* @return `1` if the Access Point is successfully started. `0` if the Access Point initialization failed.
9090
*/
9191
uint8_t beginAP(const char *ssid);
9292
uint8_t beginAP(const char *ssid);
@@ -100,7 +100,7 @@ class CWifi {
100100
* @param `ssid` The SSID (name) of the Wi-Fi Access Point.
101101
* @param `channel` The channel on which the Access Point will operate.
102102
*
103-
* @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start.
103+
* @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start.
104104
*/
105105
uint8_t beginAP(const char *ssid, uint8_t channel);
106106

@@ -114,7 +114,7 @@ class CWifi {
114114
* @param `passphrase` The passphrase for securing the Access Point. If empty, the
115115
* network will be open (no password).
116116
*
117-
* @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start.
117+
* @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start.
118118
*/
119119
uint8_t beginAP(const char *ssid, const char* passphrase);
120120

@@ -128,70 +128,82 @@ class CWifi {
128128
* @param `passphrase` The passphrase for securing the Access Point. If empty, the network will be open.
129129
* @param `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region).
130130
*
131-
* @return WL_AP_LISTENING if the Access Point is successfully started. WL_AP_FAILED if the Access Point failed to start.
131+
* @return `WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start.
132132
*/
133133
uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel);
134134

135135

136-
/* Change IP configuration settings disabling the DHCP client
137-
*
138-
* param local_ip: Static IP configuration
139-
*/
136+
/**
137+
* @brief Change IP configuration settings disabling the DHCP client
138+
*
139+
* @param `local_ip` The static IP address to assign to the device.
140+
*/
140141
void config(IPAddress local_ip);
141142

142-
/* Change IP configuration settings disabling the DHCP client
143-
*
144-
* param local_ip: Static IP configuration
145-
* param dns_server: IP configuration for DNS server 1
146-
*/
143+
/**
144+
* @brief Configures the network settings for the Wi-Fi connection with a specified DNS server.
145+
*
146+
* Sets the device's IP configuration using the specified local IP address and DNS server.
147+
* The gateway and subnet mask are set to default values based on the provided local IP.
148+
*
149+
* @param `local_ip` The static IP address to assign to the device.
150+
* @param `dns_server` The primary DNS server to use for domain name resolution.
151+
*/
147152
void config(IPAddress local_ip, IPAddress dns_server);
148153

149-
/* Change IP configuration settings disabling the DHCP client
150-
*
151-
* param local_ip: Static IP configuration
152-
* param dns_server: IP configuration for DNS server 1
153-
* param gateway : Static gateway configuration
154-
*/
154+
/**
155+
* @brief Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server.
156+
*
157+
*
158+
* @param `local_ip` The static IP address to assign to the device.
159+
* @param `dns_server` The primary DNS server to use for domain name resolution.
160+
* @param `gateway` The Static gateway used for configuration.
161+
*/
155162
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
156163

157-
/* Change IP configuration settings disabling the DHCP client
158-
*
159-
* param local_ip: Static IP configuration
160-
* param dns_server: IP configuration for DNS server 1
161-
* param gateway: Static gateway configuration
162-
* param subnet: Static Subnet mask
163-
*/
164+
/**
165+
* @brief Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server.
166+
*
167+
*
168+
* @param `local_ip` The static IP address to assign to the device.
169+
* @param `dns_server` The primary DNS server to use for domain name resolution.
170+
* @param `gateway` The static gateway used for configuration.
171+
* @param `subnet` The static subnet mask to use for the network.
172+
*/
164173
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
165174

166-
/* Change DNS IP configuration
175+
/**
176+
* @brief Sets the primary DNS server for the Wi-Fi connection.
167177
*
168-
* param dns_server1: IP configuration for DNS server 1
178+
* @param `dns_server1` The primary DNS server to use for domain name resolution.
169179
*/
170180
void setDNS(IPAddress dns_server1);
171181

172-
/* Change DNS IP configuration
173-
*
174-
* param dns_server1: IP configuration for DNS server 1
175-
* param dns_server2: IP configuration for DNS server 2
182+
/**
183+
* @brief Sets the primary and secondary DNS servers for the Wi-Fi connection.
176184
*
185+
* @param `dns_server1` sets the IP configuration for DNS server 1
186+
* @param `dns_server2` sets the IP configuration for DNS server 2
177187
*/
178188
void setDNS(IPAddress dns_server1, IPAddress dns_server2);
179189

180-
181-
/* Set the hostname used for DHCP requests
182-
*
183-
* param name: hostname to set
190+
/**
191+
* @brief Sets the hostname for for DHCP requests.
184192
*
193+
* @param `name` sets the hostname.
185194
*/
186195
void setHostname(const char* name);
187196

188-
/*
189-
* Disconnect from the network
197+
/**
198+
* @brief Disconnects from the current Wi-Fi network.
190199
*
191-
* return: one value of wl_status_t enum
200+
* @return `1` if the disconnection was successful, `0` otherwise.
192201
*/
193202
int disconnect(void);
194203

204+
/**
205+
* @brief Resets and disables the Wi-Fi module.
206+
*/
195207
void end(void);
196208

197209
/*

libraries/WiFiS3/src/WiFiClient.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
#include "FifoBuffer.h"
3131
#include <memory>
3232

33+
34+
/**
35+
* @brief Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network.
36+
*
37+
* The `WiFiClient` class allows for network communication over Wi-Fi, providing methods
38+
* for establishing connections, sending and receiving data, and managing the client’s
39+
* socket state. This class is used to manage client connections in a Wi-Fi network,
40+
* either for communication or for network data transfer.
41+
*
42+
* It inherits from the `Client` class, providing basic socket communication functionality.
43+
*/
3344
class WiFiClient : public Client {
3445

3546
public:
@@ -52,6 +63,10 @@ class WiFiClient : public Client {
5263
* @param `c` is the `WiFiClient` object to copy.
5364
*/
5465
WiFiClient(const WiFiClient& c);
66+
67+
/**
68+
* @brief Destructor for the WiFiClient class.
69+
*/
5570
~WiFiClient();
5671

5772
/**
@@ -153,10 +168,40 @@ class WiFiClient : public Client {
153168
*/
154169
virtual uint8_t connected();
155170

171+
/**
172+
* @brief Implicit conversion operator to `bool`.
173+
*
174+
* Converts the `WiFiClient` object to a `bool` value indicating whether the client
175+
* is connected or not.
176+
*
177+
* @return `true` if the client socket is open and valid, `false` otherwise.
178+
*/
156179
virtual operator bool() {
157180
return _sock != -1;
158181
}
182+
183+
/**
184+
* @brief Equality operator for comparing two `WiFiClient` objects.
185+
*
186+
* Compares the current `WiFiClient` object with another `WiFiClient` object
187+
* to determine if they represent the same socket connection.
188+
*
189+
* @param The `WiFiClient` object to compare with.
190+
* @return `true` if both `WiFiClient` objects represent the same socket,
191+
* `false` otherwise.
192+
*/
159193
virtual bool operator==(const WiFiClient&);
194+
195+
/**
196+
* @brief Inequality operator for comparing two `WiFiClient` objects.
197+
*
198+
* Compares the current `WiFiClient` object with another `WiFiClient` object
199+
* to determine if they represent different socket connections.
200+
*
201+
* @param `whs` is the `WiFiClient` object to compare with.
202+
* @return `true` if both WiFiClient objects represent different sockets,
203+
* `false` if they represent the same socket.
204+
*/
160205
virtual bool operator!=(const WiFiClient& whs)
161206
{
162207
return !this->operator==(whs);
@@ -185,8 +230,20 @@ class WiFiClient : public Client {
185230
_connectionTimeout = timeout;
186231
}
187232

233+
/**
234+
* @brief Declares `WiFiServer` as a friend class.
235+
*
236+
* This allows the `WiFiServer` class to access private and protected members
237+
* of the `WiFiClient` class.
238+
*/
188239
friend class WiFiServer;
189240

241+
/**
242+
* @brief Inherits the `write` method from the `Print` class.
243+
*
244+
* This allows the `WiFiSSLClient` class to use the `write` method defined in the
245+
* `Print` class.
246+
*/
190247
using Print::write;
191248

192249
protected:

libraries/WiFiS3/src/WiFiFileSystem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#include "WiFiCommands.h"
2525
#include "Modem.h"
2626

27+
/**
28+
* @brief Class that handles the WiFi file system operations.
29+
*
30+
* This class provides functionality for managing files on a WiFi-connected
31+
* device, including mounting, reading, writing, and configuring the file system.
32+
*/
2733
class WiFiFileSystem {
2834

2935
public:

0 commit comments

Comments
 (0)