Skip to content

Commit ecab85d

Browse files
API documentation
1 parent 1169821 commit ecab85d

File tree

5 files changed

+143
-1
lines changed

5 files changed

+143
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ cores/arduino/mydebug.cpp.donotuse
99
.DS_Store?
1010
/.vs
1111
/.gitignore
12+
.vscode/settings.json

libraries/WiFiS3/src/Modem.h

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,66 @@
1818
class ModemClass {
1919

2020
public:
21+
/**
22+
* Initializes an instance of the `ModemClass` class with
23+
* specific transmit (tx) and receive (rx) pins for communication.
24+
*/
2125
ModemClass(int tx, int rx);
2226
ModemClass(UART * _serial);
2327
~ModemClass();
2428

29+
/**
30+
* Initializes the modem communication with a specified baud rate. By default,
31+
* the baud rate is set to 115200. Call function after creating an instance of the
32+
* `ModemClass` to set up the communication parameters before sending or receiving data.
33+
*/
2534
void begin(int badurate = 115200);
35+
36+
/**
37+
* Shutts down the modem communication and releases any resources that were allocated during the
38+
* communication process.
39+
*/
2640
void end();
41+
42+
/**
43+
* Sends a command to the modem and waits for a response.
44+
* It takes a command string `cmd`, a string `str` where the response will be stored
45+
* and a format string `fmt` along with additional arguments.
46+
*/
2747
bool write(const std::string &cmd, std::string &str, const char * fmt, ...);
48+
49+
/**
50+
* Used to send a command to the modem without waiting for a response.
51+
* It takes a command string `cmd`, a string `str` where the response will be stored,
52+
* and a format string `fmt` along with additional arguments.
53+
*/
2854
void write_nowait(const std::string &cmd, std::string &str, const char * fmt, ...);
2955

56+
/**
57+
* Sends binary data directly to the modem without any processing or interpretation.
58+
* It takes a pointer to the binary `data` and the `size` of the data as arguments.
59+
* Used for sending raw binary commands or data to the modem for operations that
60+
* require direct communication without any additional formatting or parsing.
61+
*/
3062
bool passthrough(const uint8_t *data, size_t size);
63+
3164
void avoid_trim_results() {
3265
/* one shot - it works only 1 time the it is necessary to call again this
3366
funtion */
3467
trim_results = false;
3568
}
3669

70+
71+
/**
72+
* When this function is called, it enables a specific mode of reading
73+
* where the size of the data to be read is considered for processing.
74+
*/
3775
void read_using_size() {
3876
read_by_size = true;
3977
}
4078
bool beginned;
4179

42-
/* calling this function with no argument will enable debug message to be printed
80+
/* Calling this function with no argument will enable debug message to be printed
4381
on Serial
4482
use first parameter UART *u to redirect debug output to a different serial
4583
@@ -54,15 +92,23 @@ class ModemClass {
5492
_debug_level = level;
5593
}
5694

95+
/**
96+
* Used to disable debugging output for the modem communication.
97+
*/
5798
void noDebug() {
5899
_serial_debug = nullptr;
59100
}
60101

102+
/*NOT SURE*/
61103
#ifdef SELECTABLE_MODEM_DEBUG
62104
bool enable_dbg = false;
63105
void debug(bool e) {enable_dbg = e;}
64106
#endif
65107

108+
/**
109+
* Sets the timeout value for communication operations.
110+
* Can be called with a specified timeout value in milliseconds.
111+
*/
66112
void timeout(size_t timeout_ms) {_timeout = timeout_ms;}
67113

68114
private:

libraries/WiFiS3/src/StringHelpers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#include <vector>
66
#include <algorithm>
77

8+
/**
9+
* Trims whitespace characters from the beginning (left side) of the input string `s`.
10+
*/
811
void ltrim(std::string &s);
912

1013
// trim from end (in place)
@@ -13,8 +16,16 @@ void rtrim(std::string &s);
1316
// trim from both ends (in place)
1417
void trim(std::string &s);
1518

19+
/**
20+
* Takes a string `str` and splits it into substrings based on a specified `delimiter`.
21+
* The resulting substrings are stored in the `res` vector of strings.
22+
*/
1623
void split(std::vector<std::string> &res, std::string &str, const std::string &delimiter, bool _trim = true);
1724

25+
/**
26+
* Checks if the input string `str` starts with the specified string `what`. If `str` starts
27+
* with `what`, the function removes `what` from the beginning of `str` and returns `true`.
28+
*/
1829
bool removeAtBegin(std::string &str, const std::string &what);
1930

2031
#endif

libraries/WiFiS3/src/WiFiClient.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,69 @@ class WiFiClient : public Client {
3838
WiFiClient(int s);
3939
WiFiClient(const WiFiClient& c);
4040
~WiFiClient();
41+
42+
/**
43+
* Establish a connection to a remote server using the specified IP address and port number.
44+
*/
4145
virtual int connect(IPAddress ip, uint16_t port);
46+
47+
/**
48+
* Establish a connection to a remote server
49+
* using the specified host (domain name or IP address) and port number.
50+
*/
4251
virtual int connect(const char *host, uint16_t port);
52+
53+
/**
54+
* Writes a single byte of data to the connected client.
55+
*/
4356
virtual size_t write(uint8_t);
57+
58+
/**
59+
* Writes a buffer of data to the connected client.
60+
* Takes a pointer to a buffer `buf` containing the data to be written
61+
* and the size of the buffer `size` as parameters.
62+
* The function writes the data in the buffer to the connected client
63+
* and returns the number of bytes written.
64+
*/
4465
virtual size_t write(const uint8_t *buf, size_t size);
66+
67+
/**
68+
* Checks how many bytes are available for reading from the connected client.
69+
*/
4570
virtual int available();
71+
72+
/**
73+
* Reads a single byte of data from the connected client.
74+
*/
4675
virtual int read();
76+
77+
/**
78+
* Reads a specified number of bytes from the connected client into a buffer.
79+
*/
4780
virtual int read(uint8_t *buf, size_t size);
81+
82+
/**
83+
* Peeks at the next byte of incoming data without removing it from the internal buffer.
84+
*/
4885
virtual int peek();
86+
87+
/**
88+
* Clears any buffered outgoing data that has not been sent to the connected client.
89+
*/
4990
virtual void flush();
91+
92+
/**
93+
* Closes the connection to the remote server.
94+
* Terminates the connection and release any resources associated with it.
95+
*/
5096
virtual void stop();
97+
98+
/**
99+
* Checks whether the client is currently connected to a remote server.
100+
* Returns a `uint8_t` value indicating the connection status of the client.
101+
*/
51102
virtual uint8_t connected();
103+
52104
virtual operator bool() {
53105
return _sock != -1;
54106
}
@@ -57,9 +109,22 @@ class WiFiClient : public Client {
57109
{
58110
return !this->operator==(whs);
59111
};
112+
113+
/**
114+
* Returns the IP address of the remote server to which the client is connected.
115+
*/
60116
virtual IPAddress remoteIP();
117+
118+
/**
119+
* Returns the port number of the remote server for the connetec client.
120+
*/
61121
virtual uint16_t remotePort();
62122

123+
/**
124+
* Sets the connection timeout value for the client.
125+
* It takes an integer `timeout` as a parameter which determines how long the client will wait
126+
* for a connection to be established before timing out.
127+
*/
63128
void setConnectionTimeout(int timeout) {
64129
_connectionTimeout = timeout;
65130
}

libraries/WiFiS3/src/WiFiFileSystem.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,28 @@
2727
class WiFiFileSystem {
2828

2929
public:
30+
/**
31+
* Initializes objects of the `WiFiFileSystem` class.
32+
*/
3033
WiFiFileSystem();
34+
35+
/**
36+
* Mounts the file system.
37+
* If `format_on_fault` is set to `true`,
38+
* the file system will be formatted if a fault occurs during mounting.
39+
*/
3140
void mount(bool format_on_fault = false);
41+
42+
/**
43+
* Writes data to a file in the file system.
44+
*/
3245
size_t writefile(const char* name, const char* data, size_t size, int operation = WIFI_FILE_WRITE);
46+
47+
/**
48+
* Reads data from a file in the file system.
49+
* It takes a `const char* name` parameter,
50+
* which specifies the name of the file to be read.
51+
*/
3352
void readfile(const char* name);
3453

3554
};

0 commit comments

Comments
 (0)