From ecab85d6e02749d9d4e12f6d6fb8eedf6bfa5976 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Tue, 26 Nov 2024 02:47:41 +0100 Subject: [PATCH 01/43] API documentation --- .gitignore | 1 + libraries/WiFiS3/src/Modem.h | 48 +++++++++++++++++++- libraries/WiFiS3/src/StringHelpers.h | 11 +++++ libraries/WiFiS3/src/WiFiClient.h | 65 +++++++++++++++++++++++++++ libraries/WiFiS3/src/WiFiFileSystem.h | 19 ++++++++ 5 files changed, 143 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bef9554fc..38b51e79b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ cores/arduino/mydebug.cpp.donotuse .DS_Store? /.vs /.gitignore +.vscode/settings.json diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index 78539e7e3..239f4f13c 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -18,28 +18,66 @@ class ModemClass { public: + /** + * Initializes an instance of the `ModemClass` class with + * specific transmit (tx) and receive (rx) pins for communication. + */ ModemClass(int tx, int rx); ModemClass(UART * _serial); ~ModemClass(); + /** + * Initializes the modem communication with a specified baud rate. By default, + * the baud rate is set to 115200. Call function after creating an instance of the + * `ModemClass` to set up the communication parameters before sending or receiving data. + */ void begin(int badurate = 115200); + + /** + * Shutts down the modem communication and releases any resources that were allocated during the + * communication process. + */ void end(); + + /** + * Sends a command to the modem and waits for a response. + * It takes a command string `cmd`, a string `str` where the response will be stored + * and a format string `fmt` along with additional arguments. + */ bool write(const std::string &cmd, std::string &str, const char * fmt, ...); + + /** + * Used to send a command to the modem without waiting for a response. + * It takes a command string `cmd`, a string `str` where the response will be stored, + * and a format string `fmt` along with additional arguments. + */ void write_nowait(const std::string &cmd, std::string &str, const char * fmt, ...); + /** + * Sends binary data directly to the modem without any processing or interpretation. + * It takes a pointer to the binary `data` and the `size` of the data as arguments. + * Used for sending raw binary commands or data to the modem for operations that + * require direct communication without any additional formatting or parsing. + */ bool passthrough(const uint8_t *data, size_t size); + void avoid_trim_results() { /* one shot - it works only 1 time the it is necessary to call again this funtion */ trim_results = false; } + + /** + * When this function is called, it enables a specific mode of reading + * where the size of the data to be read is considered for processing. + */ void read_using_size() { read_by_size = true; } bool beginned; - /* calling this function with no argument will enable debug message to be printed + /* Calling this function with no argument will enable debug message to be printed on Serial use first parameter UART *u to redirect debug output to a different serial @@ -54,15 +92,23 @@ class ModemClass { _debug_level = level; } + /** + * Used to disable debugging output for the modem communication. + */ void noDebug() { _serial_debug = nullptr; } + /*NOT SURE*/ #ifdef SELECTABLE_MODEM_DEBUG bool enable_dbg = false; void debug(bool e) {enable_dbg = e;} #endif + /** + * Sets the timeout value for communication operations. + * Can be called with a specified timeout value in milliseconds. + */ void timeout(size_t timeout_ms) {_timeout = timeout_ms;} private: diff --git a/libraries/WiFiS3/src/StringHelpers.h b/libraries/WiFiS3/src/StringHelpers.h index 807b2690f..320ebca81 100644 --- a/libraries/WiFiS3/src/StringHelpers.h +++ b/libraries/WiFiS3/src/StringHelpers.h @@ -5,6 +5,9 @@ #include #include +/** + * Trims whitespace characters from the beginning (left side) of the input string `s`. + */ void ltrim(std::string &s); // trim from end (in place) @@ -13,8 +16,16 @@ void rtrim(std::string &s); // trim from both ends (in place) void trim(std::string &s); +/** + * Takes a string `str` and splits it into substrings based on a specified `delimiter`. + * The resulting substrings are stored in the `res` vector of strings. + */ void split(std::vector &res, std::string &str, const std::string &delimiter, bool _trim = true); +/** + * Checks if the input string `str` starts with the specified string `what`. If `str` starts + * with `what`, the function removes `what` from the beginning of `str` and returns `true`. + */ bool removeAtBegin(std::string &str, const std::string &what); #endif \ No newline at end of file diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index 81f5afae6..c36666d12 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -38,17 +38,69 @@ class WiFiClient : public Client { WiFiClient(int s); WiFiClient(const WiFiClient& c); ~WiFiClient(); + + /** + * Establish a connection to a remote server using the specified IP address and port number. + */ virtual int connect(IPAddress ip, uint16_t port); + + /** + * Establish a connection to a remote server + * using the specified host (domain name or IP address) and port number. + */ virtual int connect(const char *host, uint16_t port); + + /** + * Writes a single byte of data to the connected client. + */ virtual size_t write(uint8_t); + + /** + * Writes a buffer of data to the connected client. + * Takes a pointer to a buffer `buf` containing the data to be written + * and the size of the buffer `size` as parameters. + * The function writes the data in the buffer to the connected client + * and returns the number of bytes written. + */ virtual size_t write(const uint8_t *buf, size_t size); + + /** + * Checks how many bytes are available for reading from the connected client. + */ virtual int available(); + + /** + * Reads a single byte of data from the connected client. + */ virtual int read(); + + /** + * Reads a specified number of bytes from the connected client into a buffer. + */ virtual int read(uint8_t *buf, size_t size); + + /** + * Peeks at the next byte of incoming data without removing it from the internal buffer. + */ virtual int peek(); + + /** + * Clears any buffered outgoing data that has not been sent to the connected client. + */ virtual void flush(); + + /** + * Closes the connection to the remote server. + * Terminates the connection and release any resources associated with it. + */ virtual void stop(); + + /** + * Checks whether the client is currently connected to a remote server. + * Returns a `uint8_t` value indicating the connection status of the client. + */ virtual uint8_t connected(); + virtual operator bool() { return _sock != -1; } @@ -57,9 +109,22 @@ class WiFiClient : public Client { { return !this->operator==(whs); }; + + /** + * Returns the IP address of the remote server to which the client is connected. + */ virtual IPAddress remoteIP(); + + /** + * Returns the port number of the remote server for the connetec client. + */ virtual uint16_t remotePort(); + /** + * Sets the connection timeout value for the client. + * It takes an integer `timeout` as a parameter which determines how long the client will wait + * for a connection to be established before timing out. + */ void setConnectionTimeout(int timeout) { _connectionTimeout = timeout; } diff --git a/libraries/WiFiS3/src/WiFiFileSystem.h b/libraries/WiFiS3/src/WiFiFileSystem.h index 3f92425c2..929f91833 100644 --- a/libraries/WiFiS3/src/WiFiFileSystem.h +++ b/libraries/WiFiS3/src/WiFiFileSystem.h @@ -27,9 +27,28 @@ class WiFiFileSystem { public: + /** + * Initializes objects of the `WiFiFileSystem` class. + */ WiFiFileSystem(); + + /** + * Mounts the file system. + * If `format_on_fault` is set to `true`, + * the file system will be formatted if a fault occurs during mounting. + */ void mount(bool format_on_fault = false); + + /** + * Writes data to a file in the file system. + */ size_t writefile(const char* name, const char* data, size_t size, int operation = WIFI_FILE_WRITE); + + /** + * Reads data from a file in the file system. + * It takes a `const char* name` parameter, + * which specifies the name of the file to be read. + */ void readfile(const char* name); }; From 12a02c9120c4734f2a590ef8f8ea9b6776c478d7 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Tue, 26 Nov 2024 10:21:47 +0100 Subject: [PATCH 02/43] Api docs --- libraries/WiFiS3/src/WiFiSSLClient.h | 65 ++++++++++++++++++++++++++++ libraries/WiFiS3/src/WiFiServer.h | 28 ++++++++++++ 2 files changed, 93 insertions(+) diff --git a/libraries/WiFiS3/src/WiFiSSLClient.h b/libraries/WiFiS3/src/WiFiSSLClient.h index 6bdbf9687..48866f226 100644 --- a/libraries/WiFiS3/src/WiFiSSLClient.h +++ b/libraries/WiFiS3/src/WiFiSSLClient.h @@ -29,20 +29,85 @@ class WiFiSSLClient : public WiFiClient { public: + /** + * Initializes objects of the `WiFiSSLClient` class. + */ WiFiSSLClient(); ~WiFiSSLClient(); + + /** + * Establishes a secure SSL connection to a specified IP address and port. + * It takes an `IPAddress` object representing the IP address of the server + * and a `uint16_t` port number as parameters. + */ virtual int connect(IPAddress ip, uint16_t port); + + /** + * Establishes a secure SSL connection to a specified host (domain name) and port. + */ virtual int connect(const char* host, uint16_t port); + + /** + * Sets the Certificate Authority (CA) certificate for establishing secure SSL connections. + */ void setCACert(const char* root_ca); + + /** + * Sets the ECC (Elliptic Curve Cryptography) key slot and + * certificate for establishing secure SSL connections. + * `int ecc508KeySlot` specifies the ECC key slot to be used for the SSL connection. + * `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. + * `int certLength` specifies the length of the certificate data array. + */ void setEccSlot(int ecc508KeySlot, const byte cert[], int certLength); + + /** + * Allows writing a single byte of data to the SSL connection. + * The `uint8_t` parameter represents the byte of data to be written. + */ virtual size_t write(uint8_t); + + /** + * Allows writing a buffer of data to the SSL connection. + */ virtual size_t write(const uint8_t *buf, size_t size); + + /** + * Checks the number of bytes available for reading from the SSL connection. + * It returns the number of bytes available to read from the SSL connection without blocking. + */ virtual int available(); + + /** + * Reads a single byte of data from the SSL connection. + */ virtual int read(); + + /** + * Reads a buffer of data from the SSL connection. + */ virtual int read(uint8_t *buf, size_t size); + + /** + * Peeks at the next byte of incoming data without removing it + * from the internal buffer of the SSL connection. + */ virtual int peek(); + + /** + * Flushes any pending data in the SSL connection. + * When called, this function ensures that any buffered outgoing data is + * sent over the SSL connection immediately. + */ virtual void flush(); + + /** + * Closes the SSL connection. + * When called, this function will terminate the SSL connection and + * release any associated resources. + */ virtual void stop(); + virtual uint8_t connected(); virtual operator bool() { return _sock != -1; diff --git a/libraries/WiFiS3/src/WiFiServer.h b/libraries/WiFiS3/src/WiFiServer.h index eb749330b..d08663583 100644 --- a/libraries/WiFiS3/src/WiFiServer.h +++ b/libraries/WiFiS3/src/WiFiServer.h @@ -34,14 +34,42 @@ class WiFiServer : public Server { WiFiClient client; public: + /** + * Initializes a `WiFiServer` object. + */ WiFiServer(); WiFiServer(int p); + + /** + * Checks if there are any incoming client connections waiting to be accepted. + * It returns a `WiFiClient` object representing the next client connection that is available + * for processing. + */ WiFiClient available(); + + /** + * Accepts and returns a new client connection that is waiting to be processed. + * When called, it will accept the next incoming client connection and + * return a `WiFiClient` object representing that connection. + */ WiFiClient accept(); + + /** + * Initializes the WiFi server on a specific port. + * When this function is called with a port number as an argument, + * it sets up the server to listen for incoming client connections on that specified port. + */ void begin(int port); + void begin(); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); + + /** + * Closes the server and release any resources associated with it. + * When you call `end()`, it stops the server from listening for incoming client connections + * and cleans up any allocated memory or resources. + */ void end(); explicit operator bool(); virtual bool operator==(const WiFiServer&); From 45de9862c374b532216ab12736dc7d68036617f1 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Wed, 27 Nov 2024 01:21:26 +0100 Subject: [PATCH 03/43] Added API tags --- libraries/WiFiS3/src/Modem.h | 37 +++++---- libraries/WiFiS3/src/StringHelpers.h | 57 +++++++++++-- libraries/WiFiS3/src/WiFiClient.h | 46 ++++++----- libraries/WiFiS3/src/WiFiFileSystem.h | 28 +++++-- libraries/WiFiS3/src/WiFiSSLClient.h | 113 ++++++++++++++++++++------ libraries/WiFiS3/src/WiFiServer.h | 58 ++++++++++--- 6 files changed, 252 insertions(+), 87 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index 239f4f13c..a22a68bc9 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -19,7 +19,7 @@ class ModemClass { public: /** - * Initializes an instance of the `ModemClass` class with + * @param Initializes an instance of the `ModemClass` class with * specific transmit (tx) and receive (rx) pins for communication. */ ModemClass(int tx, int rx); @@ -27,35 +27,39 @@ class ModemClass { ~ModemClass(); /** - * Initializes the modem communication with a specified baud rate. By default, - * the baud rate is set to 115200. Call function after creating an instance of the + * @brief Initializes the modem communication with a specified baud rate. + * + * @param The baud rate is set to 115200. Call function after creating an instance of the * `ModemClass` to set up the communication parameters before sending or receiving data. */ void begin(int badurate = 115200); /** - * Shutts down the modem communication and releases any resources that were allocated during the - * communication process. + * @brief Shutts down the modem communication and releases any + * resources that were allocated during the communication process. */ void end(); /** - * Sends a command to the modem and waits for a response. - * It takes a command string `cmd`, a string `str` where the response will be stored + * @brief Sends a command to the modem and waits for a response. + * + * @param It takes a command string `cmd`, a string `str` where the response will be stored * and a format string `fmt` along with additional arguments. */ bool write(const std::string &cmd, std::string &str, const char * fmt, ...); /** - * Used to send a command to the modem without waiting for a response. - * It takes a command string `cmd`, a string `str` where the response will be stored, + * @brief Used to send a command to the modem without waiting for a response. + * + * @param It takes a command string `cmd`, a string `str` where the response will be stored, * and a format string `fmt` along with additional arguments. */ void write_nowait(const std::string &cmd, std::string &str, const char * fmt, ...); /** - * Sends binary data directly to the modem without any processing or interpretation. - * It takes a pointer to the binary `data` and the `size` of the data as arguments. + * @brief Sends binary data directly to the modem without any processing or interpretation. + * + * @param It takes a pointer to the binary `data` and the `size` of the data as arguments. * Used for sending raw binary commands or data to the modem for operations that * require direct communication without any additional formatting or parsing. */ @@ -69,8 +73,8 @@ class ModemClass { /** - * When this function is called, it enables a specific mode of reading - * where the size of the data to be read is considered for processing. + * @brief Enables a specific mode of reading where the size of the data + * to be read is considered for processing. */ void read_using_size() { read_by_size = true; @@ -93,7 +97,7 @@ class ModemClass { } /** - * Used to disable debugging output for the modem communication. + * @brief Used to disable debugging output for the modem communication. */ void noDebug() { _serial_debug = nullptr; @@ -106,8 +110,9 @@ class ModemClass { #endif /** - * Sets the timeout value for communication operations. - * Can be called with a specified timeout value in milliseconds. + * @brief Sets the timeout value for communication operations. + * + * @param Can be called with a specified timeout value in milliseconds. */ void timeout(size_t timeout_ms) {_timeout = timeout_ms;} diff --git a/libraries/WiFiS3/src/StringHelpers.h b/libraries/WiFiS3/src/StringHelpers.h index 320ebca81..184aa7d25 100644 --- a/libraries/WiFiS3/src/StringHelpers.h +++ b/libraries/WiFiS3/src/StringHelpers.h @@ -6,25 +6,68 @@ #include /** - * Trims whitespace characters from the beginning (left side) of the input string `s`. + * @brief Trims whitespace characters from the beginning of a string. + * + * @param `s` is the string from which leading whitespace characters will be removed. + * The function modifies this string directly. */ void ltrim(std::string &s); -// trim from end (in place) +/** + * @brief Trims trailing whitespace characters from a string. + * + * @param `s` the string from which trailing whitespace characters will be removed. + * The function modifies this string directly. + */ void rtrim(std::string &s); -// trim from both ends (in place) + +/** + * @brief Trims whitespace characters from both ends of a string. + * + * This function removes any leading and trailing whitespace characters (spaces, + * tabs, etc.) from the given string. It modifies the string in place, erasing + * whitespace from both the beginning and the end of the string. + * + * @param `s` is the string from which both leading and trailing whitespace characters + * will be removed. The function modifies this string directly. + */ void trim(std::string &s); /** - * Takes a string `str` and splits it into substrings based on a specified `delimiter`. - * The resulting substrings are stored in the `res` vector of strings. + * @brief Takes a string and splits it into substrings. + * + * This function splits a string into multiple substrings, storing each substring + * as an element in the `res` vector. The string is split at each occurrence of + * the specified delimiter. Optionally, the function can trim whitespace from + * each token before storing it in the result vector. + * + * @param `res` is a reference to a vector of strings where the resulting tokens + * will be stored. + * `str` is the string to be split. This string will be modified as it is + * split. + * `delimiter` is the delimiter string that separates the tokens in `str`. + * `_trim` is a boolean flag indicating whether to trim whitespace from each + * token. If true, leading and trailing whitespace will be removed from each token. Defaults to true. */ void split(std::vector &res, std::string &str, const std::string &delimiter, bool _trim = true); /** - * Checks if the input string `str` starts with the specified string `what`. If `str` starts - * with `what`, the function removes `what` from the beginning of `str` and returns `true`. + * @brief Removes a specified substring from the beginning of a string. + * + * This function attempts to remove the first occurrence of the specified substring + * (`what`) from the beginning of the string (`str`). Before performing the removal, + * it trims leading whitespace from the string. If the substring is found at the + * beginning of the string, it is removed, and the function returns `true`. If the + * substring is not found at the beginning, the string remains unchanged, and the + * function returns `false`. + * + * @param `str` is a reference to the string from which the substring will be removed. + * The string is modified if the substring is removed. + * `what` is the substring to be removed from the beginning of `str`. + * + * @return `true` if the substring was found and removed from the beginning of + * the string, `false` otherwise. */ bool removeAtBegin(std::string &str, const std::string &what); diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index c36666d12..b6f61d4a0 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -40,64 +40,68 @@ class WiFiClient : public Client { ~WiFiClient(); /** - * Establish a connection to a remote server using the specified IP address and port number. + * @brief Establish a connection to a remote server using the specified IP address and port number. */ virtual int connect(IPAddress ip, uint16_t port); /** - * Establish a connection to a remote server - * using the specified host (domain name or IP address) and port number. + * @brief Establish a connection to a remote server. + * + * @param Uses the specified domain name or IP address `host` and `port` for port number. */ virtual int connect(const char *host, uint16_t port); /** - * Writes a single byte of data to the connected client. + * @brief Writes a single byte of data to the connected client. */ virtual size_t write(uint8_t); /** - * Writes a buffer of data to the connected client. - * Takes a pointer to a buffer `buf` containing the data to be written + * @brief Writes a buffer of data to the connected client. + * + * @param Takes a pointer to a buffer `buf` containing the data to be written * and the size of the buffer `size` as parameters. - * The function writes the data in the buffer to the connected client + * + * @return The function writes the data in the buffer to the connected client * and returns the number of bytes written. */ virtual size_t write(const uint8_t *buf, size_t size); /** - * Checks how many bytes are available for reading from the connected client. + * @brief Checks how many bytes are available for reading from the connected client. */ virtual int available(); /** - * Reads a single byte of data from the connected client. + * @brief Reads a single byte of data from the connected client. */ virtual int read(); /** - * Reads a specified number of bytes from the connected client into a buffer. + * @brief Reads a specified number of bytes from the connected client into a buffer. */ virtual int read(uint8_t *buf, size_t size); /** - * Peeks at the next byte of incoming data without removing it from the internal buffer. + * @brief Peeks at the next byte of incoming data without removing it from the internal buffer. */ virtual int peek(); /** - * Clears any buffered outgoing data that has not been sent to the connected client. + * @brief Clears any buffered outgoing data that has not been sent to the connected client. */ virtual void flush(); /** - * Closes the connection to the remote server. - * Terminates the connection and release any resources associated with it. + * @brief Closes the connection to the remote server + * and releases any resources associated with it. */ virtual void stop(); /** - * Checks whether the client is currently connected to a remote server. - * Returns a `uint8_t` value indicating the connection status of the client. + * @brief Checks whether the client is currently connected to a remote server. + * + * @return Returns a `uint8_t` value indicating the connection status of the client. */ virtual uint8_t connected(); @@ -111,19 +115,19 @@ class WiFiClient : public Client { }; /** - * Returns the IP address of the remote server to which the client is connected. + * @return Returns the IP address of the remote server to which the client is connected. */ virtual IPAddress remoteIP(); /** - * Returns the port number of the remote server for the connetec client. + * @return Returns the port number of the remote server for the connetec client. */ virtual uint16_t remotePort(); /** - * Sets the connection timeout value for the client. - * It takes an integer `timeout` as a parameter which determines how long the client will wait - * for a connection to be established before timing out. + * @brief Sets the connection timeout value for the client. + * @param It takes an integer `timeout` as a parameter which determines how long the + * client will wait for a connection to be established before timing out. */ void setConnectionTimeout(int timeout) { _connectionTimeout = timeout; diff --git a/libraries/WiFiS3/src/WiFiFileSystem.h b/libraries/WiFiS3/src/WiFiFileSystem.h index 929f91833..fa4c6591d 100644 --- a/libraries/WiFiS3/src/WiFiFileSystem.h +++ b/libraries/WiFiS3/src/WiFiFileSystem.h @@ -28,26 +28,38 @@ class WiFiFileSystem { public: /** - * Initializes objects of the `WiFiFileSystem` class. + * @brief Initializes objects of the `WiFiFileSystem` class. */ WiFiFileSystem(); /** - * Mounts the file system. - * If `format_on_fault` is set to `true`, + * @brief Mounts the file system and optionally formats it on failure. + * + * @param If `format_on_fault` is set to `true`, * the file system will be formatted if a fault occurs during mounting. */ void mount(bool format_on_fault = false); /** - * Writes data to a file in the file system. + * @brief Writes data to a file in the file system. + * + * @param `name` is the name of the file to which the data will be written. + * A pointer `data` to the data that will be written to the file. + * `size` is the number of bytes to write from the provided data buffer. + * `operation` determines the type of file operation to perform (e.g., create, overwrite). + * + * @return Returns the number of bytes successfully written. Returns 0 if the operation fails. */ size_t writefile(const char* name, const char* data, size_t size, int operation = WIFI_FILE_WRITE); - + /** - * Reads data from a file in the file system. - * It takes a `const char* name` parameter, - * which specifies the name of the file to be read. + * @brief Reads a file from the file system and prints its content. + * + * It sends the read request to the modem, which fetches the data. The content + * is printed to the serial output in chunks, with each chunk being processed + * until the entire file is read. + * + * @param `name` is the name of the file to be read from the file system. */ void readfile(const char* name); diff --git a/libraries/WiFiS3/src/WiFiSSLClient.h b/libraries/WiFiS3/src/WiFiSSLClient.h index 48866f226..831bc2f3f 100644 --- a/libraries/WiFiS3/src/WiFiSSLClient.h +++ b/libraries/WiFiS3/src/WiFiSSLClient.h @@ -30,84 +30,131 @@ class WiFiSSLClient : public WiFiClient { public: /** - * Initializes objects of the `WiFiSSLClient` class. + * @brief Initializes objects of the `WiFiSSLClient` class. */ WiFiSSLClient(); ~WiFiSSLClient(); /** - * Establishes a secure SSL connection to a specified IP address and port. - * It takes an `IPAddress` object representing the IP address of the server + * @brief Establishes a secure SSL connection to a specified IP address and port. + * + * @param It takes an `IPAddress` object representing the IP address of the server * and a `uint16_t` port number as parameters. + * + * @return Returns a status code indicating the success or failure of the + * connection. */ virtual int connect(IPAddress ip, uint16_t port); /** - * Establishes a secure SSL connection to a specified host (domain name) and port. + * @brief Establishes a secure SSL connection to a specified host and port. + * + * @param `host` is the hostname or IP address of the server to connect to. + * `port` is the port number to connect to. + * + * @return Returns 1 if the connection is successfully established, 0 otherwise. */ virtual int connect(const char* host, uint16_t port); /** - * Sets the Certificate Authority (CA) certificate for establishing secure SSL connections. + * @brief Sets the Certificate Authority (CA) for SSL/TLS verification. + * + * @param `root_ca` is a pointer to a null-terminated string containing the root + * CA certificate in PEM format. If set to `nullptr`, the default root + * CA bundle will be used. */ void setCACert(const char* root_ca); /** - * Sets the ECC (Elliptic Curve Cryptography) key slot and + * @brief Sets the ECC (Elliptic Curve Cryptography) key slot and * certificate for establishing secure SSL connections. - * `int ecc508KeySlot` specifies the ECC key slot to be used for the SSL connection. + * + * @param `int ecc508KeySlot` specifies the ECC key slot to be used for the SSL connection. * `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. * `int certLength` specifies the length of the certificate data array. */ void setEccSlot(int ecc508KeySlot, const byte cert[], int certLength); /** - * Allows writing a single byte of data to the SSL connection. - * The `uint8_t` parameter represents the byte of data to be written. + * @brief Writes a single byte of data to the SSL connection. + * + * @param `b` is the byte to be sent. + * + * @return size_t The number of bytes successfully written. Returns 1 if the byte + * was sent successfully, or 0 if an error occurred. */ virtual size_t write(uint8_t); /** - * Allows writing a buffer of data to the SSL connection. + * @brief Writes a buffer of data to the SSL connection. + * + * @param `buf` is a pointer to the buffer containing the data to be sent. + * `size` is the number of bytes to send from the buffer. + * + * @return Returns `size` if the data is successfully sent, + * or 0 if the transmission fails or the socket is invalid. */ virtual size_t write(const uint8_t *buf, size_t size); /** - * Checks the number of bytes available for reading from the SSL connection. - * It returns the number of bytes available to read from the SSL connection without blocking. + * @brief Checks the number of bytes available for reading from the SSL connection. + * + * @return Returns the number of bytes available to read from the SSL connection without blocking. */ virtual int available(); /** - * Reads a single byte of data from the SSL connection. + * @brief Reads data from the SSL connection into the receive buffer. + * + * @return Returns the number of bytes successfully read into the buffer. Returns + * 0 if no data is received, or -1 if the socket is invalid or an error occurs. */ virtual int read(); /** - * Reads a buffer of data from the SSL connection. + * @brief Reads a specified number of bytes from the SSL connection into a buffer. + * + * @param `buf` is a pointer to the buffer where the read data will be stored. + * `size` is the maximum number of bytes to read into the buffer. + * + * @return The number of bytes successfully read. Returns 0 if no data is + * available or an error occurs. */ virtual int read(uint8_t *buf, size_t size); /** - * Peeks at the next byte of incoming data without removing it - * from the internal buffer of the SSL connection. + * @brief Peeks at the next byte available from the SSL connection without removing it. + * + * This function queries the modem to retrieve the next byte available in the + * SSL/TLS connection, allowing the byte to remain in the buffer for future reads. + * + * @return The next byte available as an integer value (0–255), or -1 if + * the socket is invalid or no data is available. */ virtual int peek(); /** - * Flushes any pending data in the SSL connection. - * When called, this function ensures that any buffered outgoing data is - * sent over the SSL connection immediately. + * @brief Flushes the write buffer of the SSL connection. + * + * This function clears the write buffer, ensuring that any pending data is sent + * over the SSL/TLS connection. It uses the modem to handle the flush operation. */ virtual void flush(); /** - * Closes the SSL connection. - * When called, this function will terminate the SSL connection and - * release any associated resources. + * @brief Terminates the SSL/TLS connection and clears the receive buffer. */ virtual void stop(); - + + /** + * @brief Checks if the SSL/TLS connection is active. + * + * This function determines if the SSL/TLS client is still connected by querying + * the modem for the connection status. It checks the validity of the socket + * before proceeding with the query. + * + * @return uint8_t Returns 1 if the client is connected, 0 otherwise. + */ virtual uint8_t connected(); virtual operator bool() { return _sock != -1; @@ -117,7 +164,27 @@ class WiFiSSLClient : public WiFiClient { { return !this->operator==(whs); }; + + /** + * @brief Retrieves the remote IP address of the WiFi SSL client. + * + * This function queries the modem for the remote IP address associated with + * the current connection. + * + * @return The remote IP address of the client. Returns 0.0.0.0 if the + * socket is not valid or the query fails. + */ virtual IPAddress remoteIP(); + + /** + * @brief Retrieves the remote port number of the WiFi SSL client. + * + * This function queries the modem to obtain the remote port number associated + * with the current connection. + * + * @return Returns the remote port number of the client. Returns 0 if the socket + * is not valid or the query fails. + */ virtual uint16_t remotePort(); friend class WiFiServer; diff --git a/libraries/WiFiS3/src/WiFiServer.h b/libraries/WiFiS3/src/WiFiServer.h index d08663583..3a0ba0419 100644 --- a/libraries/WiFiS3/src/WiFiServer.h +++ b/libraries/WiFiS3/src/WiFiServer.h @@ -35,40 +35,74 @@ class WiFiServer : public Server { public: /** - * Initializes a `WiFiServer` object. + * @brief Initializes objects of the `WiFiServer` class. */ WiFiServer(); WiFiServer(int p); /** - * Checks if there are any incoming client connections waiting to be accepted. - * It returns a `WiFiClient` object representing the next client connection that is available + * @brief Checks if there are any incoming client connections waiting to be accepted. + * + * This function queries the server to check if there is a client waiting to be + * accepted. If a client is available, it returns a `WiFiClient` object representing + * the client. It uses the modem to query the server for an available client + * socket and accepts the connection if a valid client is found. + * + * @return Returns a `WiFiClient` object representing the next client connection that is available * for processing. */ WiFiClient available(); /** - * Accepts and returns a new client connection that is waiting to be processed. - * When called, it will accept the next incoming client connection and - * return a `WiFiClient` object representing that connection. + * @brief Accepts an incoming client connection on the server. + * + * @return Returns a `WiFiClient` object representing the accepted client. */ WiFiClient accept(); /** - * Initializes the WiFi server on a specific port. - * When this function is called with a port number as an argument, - * it sets up the server to listen for incoming client connections on that specified port. + * @brief Starts the Wi-Fi server and binds it to the specified port. + * + * @param `port` is the port number which the server will listen to for incoming connections. */ void begin(int port); + /** + * @brief Starts the Wi-Fi server and binds it to the default port. + * + * This function initializes the server and binds it to a default port. + */ void begin(); + + /** + * @brief Writes a single byte to all connected clients. + * + * @param `b` is the byte to be sent to the clients. + */ virtual size_t write(uint8_t); + + /** + * @brief Writes data to all connected clients. + * + * This function sends a buffer of data to all clients connected to the server. + * It writes the specified number of bytes to the server + * socket and returns the count of successfully written bytes. + * + * @param `buf` is a pointer to the buffer containing the data to be sent. + * `size` is the number of bytes to write from the buffer. + * + * @return The number of bytes successfully written. Returns 0 if the + * data could not be sent. + */ virtual size_t write(const uint8_t *buf, size_t size); /** - * Closes the server and release any resources associated with it. - * When you call `end()`, it stops the server from listening for incoming client connections - * and cleans up any allocated memory or resources. + * @brief Ends the Wi-Fi server and closes the server socket. + * + * This function terminates the server by sending a command to the modem to + * close the server socket. It sets the server socket variable to an invalid + * state (`-1`) to indicate that the server is no longer active. + * */ void end(); explicit operator bool(); From c116b89fba6afba38df32dc92968502e07414b8f Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Wed, 27 Nov 2024 08:40:11 +0100 Subject: [PATCH 04/43] GPT fix --- libraries/WiFiS3/src/StringHelpers.h | 3 +- libraries/WiFiS3/src/WiFiClient.h | 92 ++++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 13 deletions(-) diff --git a/libraries/WiFiS3/src/StringHelpers.h b/libraries/WiFiS3/src/StringHelpers.h index 184aa7d25..bc933d95a 100644 --- a/libraries/WiFiS3/src/StringHelpers.h +++ b/libraries/WiFiS3/src/StringHelpers.h @@ -58,8 +58,7 @@ void split(std::vector &res, std::string &str, const std::string &d * This function attempts to remove the first occurrence of the specified substring * (`what`) from the beginning of the string (`str`). Before performing the removal, * it trims leading whitespace from the string. If the substring is found at the - * beginning of the string, it is removed, and the function returns `true`. If the - * substring is not found at the beginning, the string remains unchanged, and the + * beginning of the string, it is removed, and the function returns `true`. Otherwise the * function returns `false`. * * @param `str` is a reference to the string from which the substring will be removed. diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index b6f61d4a0..6f6218e10 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -33,52 +33,122 @@ class WiFiClient : public Client { public: + /** + * @brief Default constructor for the WiFiClient class. + */ WiFiClient(); + /* this constructor is not intended to be called outside of the Server class */ + /** + * @brief Constructor to initialize a WiFiClient object with a specific socket. + * + * @param `s` is the socket descriptor to associate with this client. + */ WiFiClient(int s); + + /** + * @brief Copy constructor for the WiFiClient class. + * + * @param `c` is the `WiFiClient` object to copy. + */ WiFiClient(const WiFiClient& c); ~WiFiClient(); + /** - * @brief Establish a connection to a remote server using the specified IP address and port number. + * @brief Establishes a connection to a server using an IP address and port. + * + * This function initiates a connection to a server using the specified IP address + * and port. Internally, it converts the IP address to a string and delegates + * the connection task to the `connect(const char*, uint16_t)` method. + * + * @param ip The IP address of the server to connect to. + * @param port The port number on the server to connect to. + * + * @return `1` on a successful connection, `0` on failure. + */ + + /** + * @brief Establishes a connection to a server using an IP address and port. + * + * @param Using `ip` as the IP address of the server to connect to. + * And `port` as the port number on the server to connect to. + * + * @return `1` on a successful connection, `0` on failure. */ virtual int connect(IPAddress ip, uint16_t port); /** - * @brief Establish a connection to a remote server. + * @brief Establishes a connection to a server using a hostname and port. * - * @param Uses the specified domain name or IP address `host` and `port` for port number. + * @param `host` is a pointer to a null-terminated string containing the hostname of the server. + * And `port` is the port number on the server to connect to. + * + * @return `1` if the connection was successful, `0` otherwise. */ virtual int connect(const char *host, uint16_t port); - + /** - * @brief Writes a single byte of data to the connected client. + * @brief Sends a single byte of data to the connected server. + * + * @param `b` being the byte of data to send. + * + * @return The number of bytes successfully written, which is `1` on success or `0` on failure. */ virtual size_t write(uint8_t); /** - * @brief Writes a buffer of data to the connected client. + * @brief Writes a buffer of data to the connected server. * * @param Takes a pointer to a buffer `buf` containing the data to be written * and the size of the buffer `size` as parameters. * - * @return The function writes the data in the buffer to the connected client - * and returns the number of bytes written. + * @return The number of bytes successfully written, or `0` if the write operation fails. */ virtual size_t write(const uint8_t *buf, size_t size); /** - * @brief Checks how many bytes are available for reading from the connected client. + * @brief Checks the number of bytes available for reading from the server. + * + * @return The number of bytes available to read. Returns `0` if no data is + * available, or if the socket is invalid. */ virtual int available(); /** - * @brief Reads a single byte of data from the connected client. + * @brief Reads a single byte of data from the server. + * + * @return The byte read as an `int` (0–255). Returns `-1` if no data is available + * or if an error occurs. */ virtual int read(); /** - * @brief Reads a specified number of bytes from the connected client into a buffer. + * @brief Reads multiple bytes of data from the server into a buffer. + * + * This function retrieves data from the server's receive buffer and stores it + * into the provided array. It attempts to read up to the specified number of + * bytes (`size`). The function stops reading if no more data is available or + * if an error occurs. + * + * @param[out] buf Pointer to the buffer where the data will be stored. + * @param[in] size Maximum number of bytes to read. + * @return The number of bytes successfully read into the buffer. + * Returns `0` if no data is available or if the socket is invalid. + */ + + /** + * @brief Reads multiple bytes of data from the server into a buffer. + * + * This function retrieves data from the server's receive buffer and stores it + * into the provided array. It attempts to read up to the specified number of + * bytes (`size`). + * + * @param[out] `buf` is a pointer to the buffer where the data will be stored. + * @param[in] `size` is the maximum number of bytes to read. + * + * @return The number of bytes successfully read into the buffer. + * Returns `0` if no data is available or if the socket is invalid. */ virtual int read(uint8_t *buf, size_t size); From 38503fe0da9be9f1d62ff6cfd46913b02a37c400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Wed, 27 Nov 2024 08:53:23 +0100 Subject: [PATCH 05/43] Update --- libraries/WiFiS3/src/WiFiClient.h | 46 ++++++++++++++----------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index 6f6218e10..eb2033667 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -123,20 +123,6 @@ class WiFiClient : public Client { */ virtual int read(); - /** - * @brief Reads multiple bytes of data from the server into a buffer. - * - * This function retrieves data from the server's receive buffer and stores it - * into the provided array. It attempts to read up to the specified number of - * bytes (`size`). The function stops reading if no more data is available or - * if an error occurs. - * - * @param[out] buf Pointer to the buffer where the data will be stored. - * @param[in] size Maximum number of bytes to read. - * @return The number of bytes successfully read into the buffer. - * Returns `0` if no data is available or if the socket is invalid. - */ - /** * @brief Reads multiple bytes of data from the server into a buffer. * @@ -151,27 +137,33 @@ class WiFiClient : public Client { * Returns `0` if no data is available or if the socket is invalid. */ virtual int read(uint8_t *buf, size_t size); - + /** * @brief Peeks at the next byte of incoming data without removing it from the internal buffer. + * + * @return The next byte as an `int` (0–255). Returns `-1` if no data is available + * or if the socket is invalid. */ virtual int peek(); /** - * @brief Clears any buffered outgoing data that has not been sent to the connected client. + * @brief Flushes the write buffer of the client. + * + * This function ensures that any data buffered for transmission is sent to the + * connected server. If there is any pending data in the send buffer, it is + * transmitted over the network. */ virtual void flush(); /** - * @brief Closes the connection to the remote server - * and releases any resources associated with it. + * @brief Closes the connection to the server and clears the receive buffer. */ virtual void stop(); /** - * @brief Checks whether the client is currently connected to a remote server. + * @brief Checks if the client is connected to a server. * - * @return Returns a `uint8_t` value indicating the connection status of the client. + * @return Returns 1 if the client is connected, 0 otherwise. */ virtual uint8_t connected(); @@ -185,19 +177,23 @@ class WiFiClient : public Client { }; /** - * @return Returns the IP address of the remote server to which the client is connected. + * @brief Retrieves the remote IP address of the server the client is connected to. + * + * @return The IP address of the remote server. If not connected, returns IPAddress(0, 0, 0, 0). */ virtual IPAddress remoteIP(); /** - * @return Returns the port number of the remote server for the connetec client. + * @brief Retrieves the remote port number of the server the client is connected to. + * + * @return Returns the port number of the remote server. If not connected, returns 0. */ virtual uint16_t remotePort(); /** - * @brief Sets the connection timeout value for the client. - * @param It takes an integer `timeout` as a parameter which determines how long the - * client will wait for a connection to be established before timing out. + * @brief Sets the connection timeout for the client. + * + * @param `timeout` is the timeout value in milliseconds. */ void setConnectionTimeout(int timeout) { _connectionTimeout = timeout; From 38d67517cf41e434ad7ae6d766888bfd9f6e1417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Wed, 27 Nov 2024 08:53:55 +0100 Subject: [PATCH 06/43] Update --- libraries/WiFiS3/src/Modem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index a22a68bc9..b96bbedb4 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -103,7 +103,6 @@ class ModemClass { _serial_debug = nullptr; } - /*NOT SURE*/ #ifdef SELECTABLE_MODEM_DEBUG bool enable_dbg = false; void debug(bool e) {enable_dbg = e;} From 96df3e6f2e7a2b1c5068e95e4c77100cdf6752ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Wed, 27 Nov 2024 08:57:03 +0100 Subject: [PATCH 07/43] Updated API docs --- libraries/WiFiS3/src/Modem.h | 10 +++++++++- libraries/WiFiS3/src/WiFiClient.h | 14 -------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index b96bbedb4..1426b786d 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -19,10 +19,18 @@ class ModemClass { public: /** + * @brief Constructor for the ModemClass, which initializes the modem with the specified transmit (TX) and receive (RX) pins. + * * @param Initializes an instance of the `ModemClass` class with - * specific transmit (tx) and receive (rx) pins for communication. + * specific transmit `tx` and receive `rx` pins for communication. */ ModemClass(int tx, int rx); + + /** + * @brief Constructor for the ModemClass, which initializes the modem with the specified UART interface. + * + * @param `_serial` is a pointer to the UART object that will be used for communication with the modem. + */ ModemClass(UART * _serial); ~ModemClass(); diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index eb2033667..791cc17c7 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -54,20 +54,6 @@ class WiFiClient : public Client { WiFiClient(const WiFiClient& c); ~WiFiClient(); - - /** - * @brief Establishes a connection to a server using an IP address and port. - * - * This function initiates a connection to a server using the specified IP address - * and port. Internally, it converts the IP address to a string and delegates - * the connection task to the `connect(const char*, uint16_t)` method. - * - * @param ip The IP address of the server to connect to. - * @param port The port number on the server to connect to. - * - * @return `1` on a successful connection, `0` on failure. - */ - /** * @brief Establishes a connection to a server using an IP address and port. * From 003c19d22e051adb42e9ee995915bf17a00e1267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Wed, 27 Nov 2024 09:44:40 +0100 Subject: [PATCH 08/43] Updated API --- libraries/WiFiS3/src/WiFiClient.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index 791cc17c7..06fe1b4c6 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -57,8 +57,8 @@ class WiFiClient : public Client { /** * @brief Establishes a connection to a server using an IP address and port. * - * @param Using `ip` as the IP address of the server to connect to. - * And `port` as the port number on the server to connect to. + * @param `ip` as the IP address of the server to connect to. + * @param `port` as the port number on the server to connect to. * * @return `1` on a successful connection, `0` on failure. */ @@ -68,7 +68,7 @@ class WiFiClient : public Client { * @brief Establishes a connection to a server using a hostname and port. * * @param `host` is a pointer to a null-terminated string containing the hostname of the server. - * And `port` is the port number on the server to connect to. + * @param `port` is the port number on the server to connect to. * * @return `1` if the connection was successful, `0` otherwise. */ From c74ed4d92636e606dfff7754204cb9c564a31fa2 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 27 Nov 2024 09:39:35 +0100 Subject: [PATCH 09/43] Add API docs workflow --- .github/workflows/render-documentation.yml | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/render-documentation.yml diff --git a/.github/workflows/render-documentation.yml b/.github/workflows/render-documentation.yml new file mode 100644 index 000000000..a4bfb6ee6 --- /dev/null +++ b/.github/workflows/render-documentation.yml @@ -0,0 +1,29 @@ +name: Render Documentation + +on: + push: + branches: + - main + paths: + - ".github/workflows/render-documentation.ya?ml" + - "./libraries/WiFiS3/examples/**" + - "./libraries/WiFiS3/src/**" + pull_request: + branches: + - main + paths: + - ".github/workflows/render-documentation.ya?ml" + - "./libraries/WiFiS3/examples/**" + - "./libraries/WiFiS3/src/**" + workflow_dispatch: + +jobs: + render-docs: + permissions: + contents: write + uses: arduino/render-docs-github-action/.github/workflows/render-docs.yml@main + with: + source-path: './libraries/WiFiS3/src' + target-path: './libraries/WiFiS3/docs/api.md' + exclude-pattern: 'StringHelpers.h WiFi.h Modem.h' + commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PR \ No newline at end of file From c8716e0eb8cf8033f3621862b2100a501e00b781 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Wed, 27 Nov 2024 15:54:22 +0100 Subject: [PATCH 10/43] api docs update --- libraries/WiFiS3/src/Modem.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index 1426b786d..9a7f82485 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -37,17 +37,29 @@ class ModemClass { /** * @brief Initializes the modem communication with a specified baud rate. * - * @param The baud rate is set to 115200. Call function after creating an instance of the - * `ModemClass` to set up the communication parameters before sending or receiving data. + * @param[in] `badurate` sets the baud rate for the serial connection. */ void begin(int badurate = 115200); /** - * @brief Shutts down the modem communication and releases any - * resources that were allocated during the communication process. + * @brief Ends the modem communication. */ void end(); + + /** + * @brief Sends a formatted command string to a device and stores the response. + * + * This function formats a command string using the provided format and arguments, + * sends it to a device, and waits for a response, which is stored in the `str` string. + * + * @param cmd A string representing the command to be sent to the device. + * @param str A reference to a string that will hold the device's response. + * @param fmt A format string for constructing the command. + * + * @return `true` if the command was successfully sent and a response was received, + * `false` otherwise. + */ /** * @brief Sends a command to the modem and waits for a response. * From ff3171e39b3e07e92d4c6b9d5c3024a14c7dfbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Mon, 2 Dec 2024 17:19:10 +0100 Subject: [PATCH 11/43] Added more documentation --- libraries/WiFiS3/src/WiFi.h | 78 ++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 8a50f4178..cc6711536 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -51,35 +51,85 @@ class CWifi { public: + /** + * @brief Default constructor for the CWifi class. + */ CWifi(); - /* - * Get firmware version + /** + * @brief Get firmware version */ static const char* firmwareVersion(); - - /* - * Start WiFi connection for OPEN networks - * param ssid: Pointer to the SSID string. + /** + * @brief Start WiFi connection for OPEN networks. + * + * @param `ssid` a pointer to the SSID string. */ int begin(const char* ssid); - - - /* Start WiFi connection with passphrase - * the most secure supported mode will be automatically selected + /** + * @brief start WiFi connection with passphrase the most secure + * supported mode will be automatically selected. * - * param ssid: Pointer to the SSID string. - * param passphrase: Passphrase. Valid characters in a passphrase - * must be between ASCII 32-126 (decimal). + * @param `ssid` Pointer to the SSID string. + * @param `passphrase` Passphrase. Valid characters in a passphrase + * must be between ASCII 32-126 (decimal). */ int begin(const char* ssid, const char *passphrase); - /* connect as Access Point with a standard passphrase */ + /** + * @brief Starts a Wi-Fi Access Point with the specified SSID. + * + * This function initializes a Wi-Fi Access Point (AP) with the given SSID. + * It defaults to an open network (no password) and uses channel 1 for the AP. + * + * @param `ssid` The SSID (network name) of the Access Point. + * + * @return 1 if the Access Point is successfully started. 0 if the Access Point initialization failed. + */ uint8_t beginAP(const char *ssid); + uint8_t beginAP(const char *ssid); + + /** + * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. + * + * This function initializes a Wi-Fi Access Point (AP) with the provided SSID + * and channel. It defaults to using no password (open network). + * + * @param `ssid` The SSID (name) of the Wi-Fi Access Point. + * @param `channel` The channel on which the Access Point will operate. + * + * @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start. + */ uint8_t beginAP(const char *ssid, uint8_t channel); + + /** + * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. + * + * This function initializes a Wi-Fi Access Point (AP) using the provided SSID + * and passphrase, defaulting to channel 1. + * + * @param `ssid` The SSID (name) of the Wi-Fi Access Point. + * @param `passphrase` The passphrase for securing the Access Point. If empty, the + * network will be open (no password). + * + * @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start. + */ uint8_t beginAP(const char *ssid, const char* passphrase); + + /** + * @brief Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. + * + * This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. + * It sets the mode to AP and attempts to start the network. + * + * @param `ssid` The SSID (name) of the Wi-Fi Access Point. + * @param `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. + * @param `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). + * + * @return WL_AP_LISTENING if the Access Point is successfully started. WL_AP_FAILED if the Access Point failed to start. + */ uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel); From ae58089b4d32c0f7c8d54bca2f3f183ab8af5e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Tue, 3 Dec 2024 03:34:16 +0100 Subject: [PATCH 12/43] More api documentation --- libraries/WiFiS3/src/Modem.h | 49 ++++++++++----- libraries/WiFiS3/src/StringHelpers.h | 10 +-- libraries/WiFiS3/src/WiFi.h | 90 +++++++++++++++------------ libraries/WiFiS3/src/WiFiClient.h | 57 +++++++++++++++++ libraries/WiFiS3/src/WiFiFileSystem.h | 6 ++ libraries/WiFiS3/src/WiFiSSLClient.h | 47 +++++++++++++- libraries/WiFiS3/src/WiFiServer.h | 55 +++++++++++++++- 7 files changed, 251 insertions(+), 63 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index 9a7f82485..d937ab9b7 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -15,6 +15,13 @@ #define DO_NOT_CHECK_CMD "NO_CMD_CHECK" +/** + * @brief A class that provides methods to interact with a modem. + * + * This class is responsible for providing an interface to communicate with + * a modem through serial communication. It includes methods for initialization, + * sending and receiving data, and handling modem configurations. + */ class ModemClass { public: @@ -32,6 +39,10 @@ class ModemClass { * @param `_serial` is a pointer to the UART object that will be used for communication with the modem. */ ModemClass(UART * _serial); + + /** + * @brief Destructor for ModemClass. + */ ~ModemClass(); /** @@ -48,23 +59,17 @@ class ModemClass { /** - * @brief Sends a formatted command string to a device and stores the response. - * - * This function formats a command string using the provided format and arguments, - * sends it to a device, and waits for a response, which is stored in the `str` string. - * - * @param cmd A string representing the command to be sent to the device. - * @param str A reference to a string that will hold the device's response. - * @param fmt A format string for constructing the command. - * - * @return `true` if the command was successfully sent and a response was received, - * `false` otherwise. - */ - /** - * @brief Sends a command to the modem and waits for a response. + * @brief Sends a formatted command string to a device and stores the response. + * + * This function formats a command string using the provided format and arguments, + * sends it to a device, and waits for a response, which is stored in the `str` string. + * + * @param `cmd` A string representing the command to be sent to the device. + * @param `str` A reference to a string that will hold the device's response. + * @param `fmt` A format string for constructing the command. * - * @param It takes a command string `cmd`, a string `str` where the response will be stored - * and a format string `fmt` along with additional arguments. + * @return `true` if the command was successfully sent and a response was received, + * `false` otherwise. */ bool write(const std::string &cmd, std::string &str, const char * fmt, ...); @@ -85,13 +90,19 @@ class ModemClass { */ bool passthrough(const uint8_t *data, size_t size); + /** + * @brief Disables automatic trimming of results for one operation. + * + * This function disables the automatic trimming of results for one operation. + * After it is called, the results will not be trimmed automatically until + * the function is called again. + */ void avoid_trim_results() { /* one shot - it works only 1 time the it is necessary to call again this funtion */ trim_results = false; } - /** * @brief Enables a specific mode of reading where the size of the data * to be read is considered for processing. @@ -99,6 +110,10 @@ class ModemClass { void read_using_size() { read_by_size = true; } + + /** + * @brief Flag indicating whether the system has been initialized. + */ bool beginned; /* Calling this function with no argument will enable debug message to be printed diff --git a/libraries/WiFiS3/src/StringHelpers.h b/libraries/WiFiS3/src/StringHelpers.h index bc933d95a..f348caca0 100644 --- a/libraries/WiFiS3/src/StringHelpers.h +++ b/libraries/WiFiS3/src/StringHelpers.h @@ -44,10 +44,10 @@ void trim(std::string &s); * * @param `res` is a reference to a vector of strings where the resulting tokens * will be stored. - * `str` is the string to be split. This string will be modified as it is + * @param `str` is the string to be split. This string will be modified as it is * split. - * `delimiter` is the delimiter string that separates the tokens in `str`. - * `_trim` is a boolean flag indicating whether to trim whitespace from each + * @param `delimiter` is the delimiter string that separates the tokens in `str`. + * @param `_trim` is a boolean flag indicating whether to trim whitespace from each * token. If true, leading and trailing whitespace will be removed from each token. Defaults to true. */ void split(std::vector &res, std::string &str, const std::string &delimiter, bool _trim = true); @@ -63,10 +63,10 @@ void split(std::vector &res, std::string &str, const std::string &d * * @param `str` is a reference to the string from which the substring will be removed. * The string is modified if the substring is removed. - * `what` is the substring to be removed from the beginning of `str`. + * @param `what` is the substring to be removed from the beginning of `str`. * * @return `true` if the substring was found and removed from the beginning of - * the string, `false` otherwise. + * the string, `false` otherwise. */ bool removeAtBegin(std::string &str, const std::string &what); diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index cc6711536..58a67c164 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -86,7 +86,7 @@ class CWifi { * * @param `ssid` The SSID (network name) of the Access Point. * - * @return 1 if the Access Point is successfully started. 0 if the Access Point initialization failed. + * @return `1` if the Access Point is successfully started. `0` if the Access Point initialization failed. */ uint8_t beginAP(const char *ssid); uint8_t beginAP(const char *ssid); @@ -100,7 +100,7 @@ class CWifi { * @param `ssid` The SSID (name) of the Wi-Fi Access Point. * @param `channel` The channel on which the Access Point will operate. * - * @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start. + * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ uint8_t beginAP(const char *ssid, uint8_t channel); @@ -114,7 +114,7 @@ class CWifi { * @param `passphrase` The passphrase for securing the Access Point. If empty, the * network will be open (no password). * - * @return 1 if the Access Point is successfully started. 0 if the Access Point failed to start. + * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ uint8_t beginAP(const char *ssid, const char* passphrase); @@ -128,70 +128,82 @@ class CWifi { * @param `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. * @param `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). * - * @return WL_AP_LISTENING if the Access Point is successfully started. WL_AP_FAILED if the Access Point failed to start. + * @return `WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start. */ uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel); - /* Change IP configuration settings disabling the DHCP client - * - * param local_ip: Static IP configuration - */ + /** + * @brief Change IP configuration settings disabling the DHCP client + * + * @param `local_ip` The static IP address to assign to the device. + */ void config(IPAddress local_ip); - /* Change IP configuration settings disabling the DHCP client - * - * param local_ip: Static IP configuration - * param dns_server: IP configuration for DNS server 1 - */ + /** + * @brief Configures the network settings for the Wi-Fi connection with a specified DNS server. + * + * Sets the device's IP configuration using the specified local IP address and DNS server. + * The gateway and subnet mask are set to default values based on the provided local IP. + * + * @param `local_ip` The static IP address to assign to the device. + * @param `dns_server` The primary DNS server to use for domain name resolution. + */ void config(IPAddress local_ip, IPAddress dns_server); - /* Change IP configuration settings disabling the DHCP client - * - * param local_ip: Static IP configuration - * param dns_server: IP configuration for DNS server 1 - * param gateway : Static gateway configuration - */ + /** + * @brief Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server. + * + * + * @param `local_ip` The static IP address to assign to the device. + * @param `dns_server` The primary DNS server to use for domain name resolution. + * @param `gateway` The Static gateway used for configuration. + */ void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway); - /* Change IP configuration settings disabling the DHCP client - * - * param local_ip: Static IP configuration - * param dns_server: IP configuration for DNS server 1 - * param gateway: Static gateway configuration - * param subnet: Static Subnet mask - */ + /** + * @brief Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server. + * + * + * @param `local_ip` The static IP address to assign to the device. + * @param `dns_server` The primary DNS server to use for domain name resolution. + * @param `gateway` The static gateway used for configuration. + * @param `subnet` The static subnet mask to use for the network. + */ void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); - /* Change DNS IP configuration + /** + * @brief Sets the primary DNS server for the Wi-Fi connection. * - * param dns_server1: IP configuration for DNS server 1 + * @param `dns_server1` The primary DNS server to use for domain name resolution. */ void setDNS(IPAddress dns_server1); - /* Change DNS IP configuration - * - * param dns_server1: IP configuration for DNS server 1 - * param dns_server2: IP configuration for DNS server 2 + /** + * @brief Sets the primary and secondary DNS servers for the Wi-Fi connection. * + * @param `dns_server1` sets the IP configuration for DNS server 1 + * @param `dns_server2` sets the IP configuration for DNS server 2 */ void setDNS(IPAddress dns_server1, IPAddress dns_server2); - - /* Set the hostname used for DHCP requests - * - * param name: hostname to set + /** + * @brief Sets the hostname for for DHCP requests. * + * @param `name` sets the hostname. */ void setHostname(const char* name); - /* - * Disconnect from the network + /** + * @brief Disconnects from the current Wi-Fi network. * - * return: one value of wl_status_t enum + * @return `1` if the disconnection was successful, `0` otherwise. */ int disconnect(void); + /** + * @brief Resets and disables the Wi-Fi module. + */ void end(void); /* diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index 06fe1b4c6..50caa27e0 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -30,6 +30,17 @@ #include "FifoBuffer.h" #include + +/** + * @brief Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. + * + * The `WiFiClient` class allows for network communication over Wi-Fi, providing methods + * for establishing connections, sending and receiving data, and managing the client’s + * socket state. This class is used to manage client connections in a Wi-Fi network, + * either for communication or for network data transfer. + * + * It inherits from the `Client` class, providing basic socket communication functionality. + */ class WiFiClient : public Client { public: @@ -52,6 +63,10 @@ class WiFiClient : public Client { * @param `c` is the `WiFiClient` object to copy. */ WiFiClient(const WiFiClient& c); + + /** + * @brief Destructor for the WiFiClient class. + */ ~WiFiClient(); /** @@ -153,10 +168,40 @@ class WiFiClient : public Client { */ virtual uint8_t connected(); + /** + * @brief Implicit conversion operator to `bool`. + * + * Converts the `WiFiClient` object to a `bool` value indicating whether the client + * is connected or not. + * + * @return `true` if the client socket is open and valid, `false` otherwise. + */ virtual operator bool() { return _sock != -1; } + + /** + * @brief Equality operator for comparing two `WiFiClient` objects. + * + * Compares the current `WiFiClient` object with another `WiFiClient` object + * to determine if they represent the same socket connection. + * + * @param The `WiFiClient` object to compare with. + * @return `true` if both `WiFiClient` objects represent the same socket, + * `false` otherwise. + */ virtual bool operator==(const WiFiClient&); + + /** + * @brief Inequality operator for comparing two `WiFiClient` objects. + * + * Compares the current `WiFiClient` object with another `WiFiClient` object + * to determine if they represent different socket connections. + * + * @param `whs` is the `WiFiClient` object to compare with. + * @return `true` if both WiFiClient objects represent different sockets, + * `false` if they represent the same socket. + */ virtual bool operator!=(const WiFiClient& whs) { return !this->operator==(whs); @@ -185,8 +230,20 @@ class WiFiClient : public Client { _connectionTimeout = timeout; } + /** + * @brief Declares `WiFiServer` as a friend class. + * + * This allows the `WiFiServer` class to access private and protected members + * of the `WiFiClient` class. + */ friend class WiFiServer; + /** + * @brief Inherits the `write` method from the `Print` class. + * + * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * `Print` class. + */ using Print::write; protected: diff --git a/libraries/WiFiS3/src/WiFiFileSystem.h b/libraries/WiFiS3/src/WiFiFileSystem.h index fa4c6591d..407317060 100644 --- a/libraries/WiFiS3/src/WiFiFileSystem.h +++ b/libraries/WiFiS3/src/WiFiFileSystem.h @@ -24,6 +24,12 @@ #include "WiFiCommands.h" #include "Modem.h" +/** + * @brief Class that handles the WiFi file system operations. + * + * This class provides functionality for managing files on a WiFi-connected + * device, including mounting, reading, writing, and configuring the file system. + */ class WiFiFileSystem { public: diff --git a/libraries/WiFiS3/src/WiFiSSLClient.h b/libraries/WiFiS3/src/WiFiSSLClient.h index 831bc2f3f..9b6941f5d 100644 --- a/libraries/WiFiS3/src/WiFiSSLClient.h +++ b/libraries/WiFiS3/src/WiFiSSLClient.h @@ -25,7 +25,13 @@ #include "Modem.h" #include "WiFiFileSystem.h" - +/** + * @brief A specialized client class for secure SSL/TLS connections. + * + * The `WiFiSSLClient` class extends the functionality of the `WiFiClient` class to provide secure + * communication over SSL/TLS protocols. It ensures encrypted and authenticated communication + * between the client and a remote server. + */ class WiFiSSLClient : public WiFiClient { public: @@ -156,10 +162,36 @@ class WiFiSSLClient : public WiFiClient { * @return uint8_t Returns 1 if the client is connected, 0 otherwise. */ virtual uint8_t connected(); + + /** + * @brief Implicit conversion operator to check if the SSL client is connected. + * + * @return `true` if the socket is valid (i.e., connected), `false` otherwise. + */ virtual operator bool() { return _sock != -1; } + + /** + * @brief Comparison operator to check equality between two `WiFiSSLClient` objects. + * + * @param `WiFiSSLClient` object to compare. + * + * @return `true` if both `WiFiSSLClient` objects are equivalent (i.e., they have the same socket), + * `false` otherwise. + */ virtual bool operator==(const WiFiSSLClient&); + + /** + * @brief Inequality operator to compare two `WiFiSSLClient` objects. + * + * This operator compares the current `WiFiSSLClient` object with another `WiFiSSLClient` object + * to determine if they are not equal, based on their underlying socket or connection. + * + * @param `whs` The WiFiSSLClient object to compare with. + * @return `true` if the two `WiFiSSLClient` objects do not represent the same connection (i.e., have different sockets), + * `false` otherwise. + */ virtual bool operator!=(const WiFiSSLClient& whs) { return !this->operator==(whs); @@ -187,8 +219,21 @@ class WiFiSSLClient : public WiFiClient { */ virtual uint16_t remotePort(); + + /** + * @brief Declares `WiFiServer` as a friend class. + * + * This allows the `WiFiServer` class to access private and protected members + * of the `WiFiSSLClient` class. + */ friend class WiFiServer; + /** + * @brief Inherits the `write` method from the `Print` class. + * + * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * `Print` class. + */ using Print::write; private: diff --git a/libraries/WiFiS3/src/WiFiServer.h b/libraries/WiFiS3/src/WiFiServer.h index 3a0ba0419..cdf27d03f 100644 --- a/libraries/WiFiS3/src/WiFiServer.h +++ b/libraries/WiFiS3/src/WiFiServer.h @@ -26,7 +26,14 @@ #include "WiFiClient.h" - +/** + * @brief A class that provides server functionality for WiFi-based communication. + * + * The `WiFiServer` class inherits from the `Server` class and extends its functionality + * to create and manage a server over a WiFi connection. This class allows for accepting + * incoming client connections, handling data communication, and closing connections + * in a networked environment. + */ class WiFiServer : public Server { private: int _sock; @@ -38,6 +45,12 @@ class WiFiServer : public Server { * @brief Initializes objects of the `WiFiServer` class. */ WiFiServer(); + + /** + * @brief Constructs a `WiFiServer` object with the specified port. + * + * @param `p` The port number on which the server will listen for incoming connections. + */ WiFiServer(int p); /** @@ -105,15 +118,55 @@ class WiFiServer : public Server { * */ void end(); + + /** + * @brief Converts the `WiFiSSLClient` object to a boolean value. + * + * This operator allows a `WiFiSSLClient` object to be implicitly or explicitly + * converted to a boolean. It checks whether the client socket is valid (i.e., + * `_sock != -1`). + * + * @return `true` if the server socket is valid (server is running), `false` otherwise. + */ explicit operator bool(); + + /** + * @brief Compares two `WiFiServer` objects for equality. + * + * This virtual operator compares the underlying socket (`_sock`) of two `WiFiServer` + * objects to determine if they refer to the same server connection. + * + * @param `WiFiServer` object to compare against. + * @return `true` if both `WiFiServer` objects have the same socket; `false` otherwise. + */ virtual bool operator==(const WiFiServer&); + + /** + * @brief Compares two `WiFiServer` objects for inequality. + * + * This virtual operator compares the underlying socket (`_sock`) of two `WiFiServer` + * objects. It returns `true` if the objects do not refer to the same server connection + * (i.e., they have different socket values), and `false` otherwise. + * + * @param `whs` The WiFiServer object to compare against. + * @return `true` if the WiFiServer objects have different sockets; `false` otherwise. + */ virtual bool operator!=(const WiFiServer& whs) { return !this->operator==(whs); }; + /** + * @brief Inherits the `write` method from the `Print` class. + * + * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * `Print` class. + */ using Print::write; + /** + * @brief Grants `WiFiClient` class access to private and protected members of `WiFiServer`. + */ friend class WiFiClient; }; From fb14228cc195c79efcdff95291e4c1f9635ffab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Tue, 3 Dec 2024 04:25:17 +0100 Subject: [PATCH 13/43] Fixed wifi.h api docs --- libraries/WiFiS3/src/WiFi.h | 250 ++++++++++++++++++++++----------- libraries/WiFiS3/src/WiFiUdp.h | 7 + 2 files changed, 174 insertions(+), 83 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 58a67c164..ae45c2812 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -33,7 +33,14 @@ class CAccessPoint { - +/** + * @brief Class to manage Wi-Fi connectivity and operations. + * + * The `CWifi` class provides an interface to manage Wi-Fi operations such as connecting + * to networks, setting up an access point, retrieving network information, and more. + * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages + * connection settings such as IP address, DNS, and other network configurations. + */ class CWifi { private: void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); @@ -206,148 +213,225 @@ class CWifi { */ void end(void); - /* - * Get the interface MAC address. - * - * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH + + /** + * @brief Retrieves the MAC address of the device. + * + * This function retrieves the MAC address of the device based on its current operating mode. + * The value returned by this function is meaningfull only if called afert a + * begin (both begin or beginAP) or a ScanNetwork function otherwise + * an empty mac address is returned. * - * the value returned by this function is meaningfull only if called - * afert a begin (both begin or beginAP) or a ScanNetwork function - * otherwise an empty mac address is returned + * @param `_mac` A pointer to a uint8_t array where the MAC address will be stored. + * + * @return uint8_t* The pointer to the array containing the MAC address. */ uint8_t* macAddress(uint8_t* mac); - /* - * Get the interface IP address. - * - * return: IP address value + /** + * @brief Retrieves the local IP address of the device. + * + * This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) + * and retrieves the appropriate IP address based on the mode. + * + * @return `IPAddress` The local IP address of the device. */ IPAddress localIP(); - /* - * Get the interface subnet mask address. - * - * return: subnet mask address value + /** + * @brief Retrieves the subnet mask of the device. + * + * This function retrieves the subnet mask of the device by querying the modem for the subnet information. + * It sends a command to the modem to fetch the subnet mask and returns it as an `IPAddress` object. + * + * @return `IPAddress` The subnet mask address value of the device. */ IPAddress subnetMask(); - /* - * Get the gateway IP address. - * - * return: gateway IP address value - */ + /** + * @brief Retrieves the gateway IP address of the device. + * + * This function retrieves the gateway IP address of the device by querying the modem for the gateway + * information. It sends a command to the modem to fetch the gateway IP address and returns it as an + * `IPAddress` object. + * + * @return `IPAddress` The gateway IP address value of the device. + */ IPAddress gatewayIP(); + /** + * @brief Retrieves the DNS IP address. + * + * @param `n` The index of the DNS server to retrieve, `0` for the primary DNS server + * and `1` for the secondary DNS server. + * + * @return `IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. + */ IPAddress dnsIP(int n = 0); - /* - * Get the interface the AP IP address. - * - * return: IP address value + + /** + * @brief Retrieves the IP address of the soft access point (AP). + * + * @return `IPAddress` The IP address of the soft AP as an `IPAddress` object, or `0.0.0.0` if not found. */ IPAddress softAPIP(); - /* - * Return the current SSID associated with the network - * - * return: ssid string + /** + * @brief Retrieves the SSID of the current Wi-Fi connection or SoftAP. + * + * @return The SSID of the current Wi-Fi connection or SoftAP as a string. + * If unable to retrieve the SSID, returns an empty string. */ const char* SSID(); - /* - * Return the current BSSID associated with the network. - * - * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH - */ + /** + * @brief Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. + * + * @param `bssid` A pointer to an array where the BSSID will be stored. The array must be large enough to hold the MAC address. + * + * @return A pointer to the `bssid` array containing the retrieved BSSID. If the BSSID cannot be retrieved, returns `nullptr`. + */ uint8_t* BSSID(uint8_t* bssid); - /* - * Return the current RSSI/Received Signal Strength in dBm) - * associated with the network - * - * return: signed value - */ + /** + * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. + * + * @return The RSSI value representing the signal strength. A higher (less negative) value indicates a stronger signal. + * If the RSSI cannot be retrieved, returns 0. + */ int32_t RSSI(); - /* - * Return the current SSID associated with to the soft AP - * - * return: ssid string + /** + * @brief Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. + * + * @return The SSID of the SoftAP. If the SSID cannot be retrieved, an empty string is returned. */ const char* softAPSSID(); - - /* - * Start scan WiFi networks available - * - * return: Number of discovered networks + /** + * @brief Scans for available Wi-Fi networks and stores the information in the `access_points` list. + * + * This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, + * RSSI (signal strength), channel, and encryption mode for each detected access point. + * + * @return The number of networks found during the scan. Returns a negative value in case of an error. */ int8_t scanNetworks(); - /* - * Return the SSID discovered during the network scan. - * - * param networkItem: specify from which network item want to get the information - * - * return: SSID string of the specified item on the networks scanned list + /** + * @brief Retrieves the SSID of a specific Wi-Fi network from the scan results. + * + * @param `networkItem` The index of the network in the list of scanned access points. + * + * @return The SSID of the specified network, or `nullptr` if the index is out of bounds. */ const char* SSID(uint8_t networkItem); - /* - * Return the encryption type of the networks discovered during the scanNetworks - * - * param networkItem: specify from which network item want to get the information - * - * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list - - - + /** + * @brief Returns the encryption type for a specified network. + * + * This function retrieves the encryption type of a specific Wi-Fi access point + * based on its index in the list of scanned networks. + * + * @param `networkItem` The index of the network in the list of available access points. + * + * @return The encryption type in numeric form (e.g., 0 for no encryption, + * 1 for WEP, 2 for WPA, etc.). Returns 0 if the network item index is invalid. */ uint8_t encryptionType(uint8_t networkItem); + + /** + * @brief Returns the encryption type of the currently connected Wi-Fi network. + * + * @return The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). + * Returns `ENC_TYPE_UNKNOWN` if the encryption type cannot be determined. + */ uint8_t encryptionType(); + /** + * @brief Retrieves the BSSID of a specific Wi-Fi network. + * + * This function retrieves the BSSID (MAC address) of the Wi-Fi network at the specified + * index from the list of available networks. The BSSID is stored in the provided + * array of 6 bytes. + * + * @param `networkItem` The index of the Wi-Fi network in the list of available networks. + * @param `bssid` A pointer to a byte array (of size 6) where the BSSID will be stored. + * + * @return A pointer to the `bssid` array if the BSSID is successfully retrieved, + * or `nullptr` if the network index is out of range. + */ uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid); + + /** + * @brief Retrieves the channel number of a specific Wi-Fi network. + * + * @param `networkItem` The index of the Wi-Fi network in the list of available networks. + * + * @return The channel number of the specified network, or `0` if the network index + * is out of range. + */ uint8_t channel(uint8_t networkItem); - /* - * Return the RSSI of the networks discovered during the scanNetworks - * - * param networkItem: specify from which network item want to get the information - * - * return: signed value of RSSI of the specified item on the networks scanned list + /** + * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. + * + * @param `networkItem` The index of the Wi-Fi network in the list of available networks. + * + * @return The RSSI value of the specified network in dBm, or `-1000` if the network index + * is out of range. */ int32_t RSSI(uint8_t networkItem); - /* - * Return Connection status. - * - * return: one of the value defined in wl_status_t + /** + * @brief Retrieves the current connection status of the Wi-Fi connection. + * + * @return One of the values defined in wl_status_t */ uint8_t status(); - /* - * Return The deauthentication reason code. + /** + * @brief Retrieves The deauthentication reason code. * - * return: the deauthentication reason code + * @return The deauthentication reason code. */ uint8_t reasonCode(); - /* - * Resolve the given hostname to an IP address. - * param aHostname: Name to be resolved - * param aResult: IPAddress structure to store the returned IP address - * result: 1 if aIPAddrString was successfully converted to an IP address, - * else error code + /** + * @brief Resolves a hostname to an IP address. + * + * @param `aHostname` The hostname to resolve (e.g., "www.example.com"). + * @param `aResult` IPAddress structure to store the returned IP address result: + * 1 if aIPAddrString was successfully converted to an IP address, else error code + * + * @return Returns `1` if the hostname was successfully resolved, `0` otherwise. */ int hostByName(const char* aHostname, IPAddress& aResult); + /** + * @brief Retrieves the current time from the modem. + * + * @return The current time value in seconds, or `0` if the time could not be retrieved. + */ unsigned long getTime(); + /** + * @brief Sets the timeout value for the WiFi connection. + * + * @param `timeout` The timeout value in milliseconds. + */ void setTimeout(unsigned long timeout); }; +/** + * @brief Global instance of the CWifi class. + * + * This external declaration provides access to a global instance of the `CWifi` class, which + * facilitates interaction with the WiFi module. + */ extern CWifi WiFi; diff --git a/libraries/WiFiS3/src/WiFiUdp.h b/libraries/WiFiS3/src/WiFiUdp.h index a6d7c6026..6fbf20a3e 100644 --- a/libraries/WiFiS3/src/WiFiUdp.h +++ b/libraries/WiFiS3/src/WiFiUdp.h @@ -30,6 +30,13 @@ #include "Modem.h" #include "FifoBuffer.h" +/** + * @brief A class for handling UDP communication over a Wi-Fi network. + * + * The `WiFiUDP` class is an extension of the `UDP` class that enables sending and receiving UDP packets + * over a Wi-Fi network. It provides functions for initialization, packet transmission, and reception + * tailored for Wi-Fi connectivity. + */ class WiFiUDP : public UDP { private: int _sock; From 6a4093e98dd4dd1ee0fd6042d55e0d80a119a9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Tue, 3 Dec 2024 15:35:10 +0100 Subject: [PATCH 14/43] Finished API docs --- libraries/WiFiS3/src/WiFiUdp.h | 205 +++++++++++++++++++++++++++++---- 1 file changed, 180 insertions(+), 25 deletions(-) diff --git a/libraries/WiFiS3/src/WiFiUdp.h b/libraries/WiFiS3/src/WiFiUdp.h index 6fbf20a3e..adbff4e5b 100644 --- a/libraries/WiFiS3/src/WiFiUdp.h +++ b/libraries/WiFiS3/src/WiFiUdp.h @@ -48,57 +48,212 @@ class WiFiUDP : public UDP { virtual void read_if_needed(size_t s); public: - WiFiUDP(); // Constructor - virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + /** + * @brief Default constructor for the WiFiUDP class. + */ + WiFiUDP(); + + /** + * @brief Starts a UDP socket on the specified local port. + * + * @param `uint16_t` The local port number to bind the UDP socket to. + * + * @return Returns `1` if the socket is successfully opened, or + * `0` if the socket is already in use or could not be opened. + */ + virtual uint8_t begin(uint16_t); + + /** + * @brief Starts a UDP socket bound to a specific IP address and port. + * + * @param `a` The local IP address to bind the UDP socket to. + * @param `p` The local port number to bind the UDP socket to. + * + * @return Returns `1` if the socket is successfully opened, or + * `0` if the socket is already in use or could not be opened. + */ virtual uint8_t begin(IPAddress a, uint16_t p); - virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use - virtual void stop(); // Finish with the UDP socket + + /** + * @brief Starts a UDP multicast socket bound to a specific IP address and port. + * + * @param `IPAddress` The multicast IP address to bind the UDP socket to. + * @param `uint16_t` The port number to bind the UDP socket to. + * + * @return Returns `1` if the socket is successfully opened, or + * `0` if the socket is already in use or could not be opened. + */ + virtual uint8_t beginMulticast(IPAddress, uint16_t); + + /** + * @brief Stops the UDP socket and releases its resources. + */ + virtual void stop(); - // Sending UDP packets + /** + * @brief Begins constructing a multicast UDP packet for sending. + * + * @return Returns `1` if the packet preparation is successful. + * Or `0` if there is an error or the socket is not initialized. + */ virtual int beginMulticastPacket(); - // Start building up a packet to send to the remote host specific in ip and port - // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + + /** + * @brief Begins constructing a UDP packet for sending to a specific IP address and port. + * + * @param `ip` The destination IP address as an `IPAddress` object. + * @param `port` The destination port number. + * + * @return Returns `1` if the packet preparation is successful. + * Or `0` if there is an error or the socket is not initialized. + */ virtual int beginPacket(IPAddress ip, uint16_t port); - // Start building up a packet to send to the remote host specific in host and port - // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + + /** + * @brief Begins constructing a UDP packet for sending to a specific hostname and port. + * + * @param `host` The destination hostname as a null-terminated string. + * @param `port` The destination port number. + * + * @return Returns `1` if the packet preparation is successful. + * Or `0` if there is an error or the socket is not initialized. + */ virtual int beginPacket(const char *host, uint16_t port); - // Finish off this packet and send it - // Returns 1 if the packet was sent successfully, 0 if there was an error + + /** + * @brief Completes the construction of a UDP packet and sends it to the specified destination. + * + * @return Returns `1` if the packet is successfully transmitted. + * Or `0` if there is an error or the socket is not initialized. + */ virtual int endPacket(); - // Write a single byte into the packet + + /** + * @brief Sends a single byte of data to the currently opened UDP packet. + * + * @param `b` The byte of data to send. + * + * @return Returns `1` if the byte was successfully written. + * Or `0` if there was an error or the packet was not properly initialized. + */ virtual size_t write(uint8_t); - // Write size bytes from buffer into the packet + + /** + * @brief Sends a buffer of data to the currently opened UDP packet. + * + * @param `buffer` A pointer to the buffer containing the data to send. + * @param `size` The number of bytes from the buffer to write. + * + * @return Returns the number of bytes successfully written if the operation is successful. + * Or `0` if the data was not successfully written, or if the packet was not properly initialized. + */ virtual size_t write(const uint8_t *buffer, size_t size); + /** + * @brief Inherits the `write` method from the `Print` class. + * + * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * `Print` class. + */ using Print::write; - // Start processing the next available incoming packet - // Returns the size of the packet in bytes, or 0 if no packets are available + /** + * @brief Start processing the next available incoming packet + * + * @return Returns the size of the incoming packet, or `0` if no packet is available. + */ virtual int parsePacket(); - // Number of bytes remaining in the current packet + + /** + * @brief Checks if there are any available UDP packets to read. + * + * @return Returns the number of available bytes if packets are available, or `0` if no packets are available. + */ virtual int available(); - // Read a single byte from the current packet + + /** + * @brief Read a single byte from the current packet + * + * @return Returns the number of bytes read into the buffer, or `-1` if an error occurs. + */ virtual int read(); - // Read up to len bytes from the current packet and place them into buffer - // Returns the number of bytes read, or 0 if none are available + + /** + * @brief Reads data from the UDP receive buffer into a provided buffer. + * + * @param `buffer` A pointer to the buffer where the received data will be stored. + * @param `size` The number of bytes to read from the UDP buffer. + * + * @return The number of bytes successfully read into the buffer. + * If less than `size` bytes are read, it indicates that the buffer was exhausted early. + */ virtual int read(unsigned char* buffer, size_t len); - // Read up to len characters from the current packet and place them into buffer - // Returns the number of characters read, or 0 if none are available + + + /** + * @brief Reads data from the UDP receive buffer into a character buffer. + * + * @param `buffer` A pointer to the character buffer where the received data will be stored. + * @param `len` The number of bytes to read from the UDP buffer. + * + * @return The number of bytes successfully read into the buffer. + * If less than `len` bytes are read, it indicates that the buffer was exhausted early. + */ virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; - // Return the next byte from the current packet without moving on to the next byte + + /** + * @brief Peeks at the next byte available in the UDP buffer without moving on to the next byte. + * + * @return The value of the next byte in the UDP buffer, or `-1` if no data is available. + */ virtual int peek(); + + /** + * @brief Finish reading the current packet + */ virtual void flush(); // Finish reading the current packet + + /** + * @brief Compares two WiFiUDP objects for equality. + * + * This function compares two `WiFiUDP` objects by checking if their associated + * socket values (`_sock`) are the same. + * + * @param `WiFiUDP&` The WiFiUDP object to compare with the current object. + * + * @return `true` if the socket values are equal, `false` otherwise. + */ virtual bool operator==(const WiFiUDP&); + + /** + * @brief Compares two WiFiUDP objects for inequality. + * + * This function compares two `WiFiUDP` objects by checking if their associated + * socket values (`_sock`) are different. + * + * @param `whs` The WiFiUDP object to compare with the current object. + * @return `true` if the socket values are different, `false` otherwise. + */ virtual bool operator!=(const WiFiUDP& whs) { return !this->operator==(whs); }; - // Return the IP address of the host who sent the current incoming packet + /** + * @brief Retrieves the remote IP address of the host who sent the current incoming packet. + * + * @return An `IPAddress` object representing the remote IP address. If the socket + * is not valid or the address cannot be retrieved, it returns `IPAddress(0, 0, 0, 0)`. + */ virtual IPAddress remoteIP(); - // Return the port of the host who sent the current incoming packet + + /** + * @brief Return the port of the host who sent the current incoming packet. + * + * @return The remote port number as a `uint16_t`. If the socket is not valid or + * the port cannot be retrieved, it returns `0`. + */ virtual uint16_t remotePort(); - }; From 70bf17967058d7319f28b0bbf319dfc4fb2586c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Wed, 4 Dec 2024 12:11:12 +0100 Subject: [PATCH 15/43] First api.h draft --- libraries/WiFiS3/docs/api.md | 2106 ++++++++++++++++++++++++++++++++++ 1 file changed, 2106 insertions(+) create mode 100644 libraries/WiFiS3/docs/api.md diff --git a/libraries/WiFiS3/docs/api.md b/libraries/WiFiS3/docs/api.md new file mode 100644 index 000000000..c7f0b06f6 --- /dev/null +++ b/libraries/WiFiS3/docs/api.md @@ -0,0 +1,2106 @@ +# Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +`class ` [`CAccessPoint`](#class_c_access_point) | +`class ` [`CWifi`](#class_c_wifi) | Class to manage Wi-Fi connectivity and operations. +`class ` [`ModemClass`](#class_modem_class) | A class that provides methods to interact with a modem. +`class ` [`WiFiClient`](#class_wi_fi_client) | Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. +`class ` [`WiFiFileSystem`](#class_wi_fi_file_system) | Class that handles the WiFi file system operations. +`class ` [`WiFiServer`](#class_wi_fi_server) | A class that provides server functionality for WiFi-based communication. +`class ` [`WiFiSSLClient`](#class_wi_fi_s_s_l_client) | A specialized client class for secure SSL/TLS connections. +`class ` [`WiFiUDP`](#class_wi_fi_u_d_p) | A class for handling UDP communication over a Wi-Fi network. + +# class `CAccessPoint` + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`ssid`](#class_c_access_point_1ac0161f0bae3c82f5caed8b05898fc49e) | | +| [`bssid`](#class_c_access_point_1ad1bc1d6e1bee842a46ffdc408fa59947) | | +| [`uint_bssid`](#class_c_access_point_1a5cf478e57a7138a1490b231b2aeb9c3e) | | +| [`rssi`](#class_c_access_point_1a7b5640ed8c2ed9f62e38051ffe8fe6a0) | | +| [`channel`](#class_c_access_point_1aa95219f17673f68cf3b1c6e17345b0e4) | | +| [`encryption_mode`](#class_c_access_point_1ac293ee77db560b0cda65d91374249412) | | + +## Members + +### `ssid` + +```cpp +std::string ssid +``` + +
+ +### `bssid` + +```cpp +std::string bssid +``` + +
+ +### `uint_bssid` + +```cpp +uint8_t uint_bssid +``` + +
+ +### `rssi` + +```cpp +std::string rssi +``` + +
+ +### `channel` + +```cpp +std::string channel +``` + +
+ +### `encryption_mode` + +```cpp +std::string encryption_mode +``` + +
+ +# class `CWifi` + +Class to manage Wi-Fi connectivity and operations. + +The `[CWifi](#class_c_wifi)` class provides an interface to manage Wi-Fi operations such as connecting to networks, setting up an access point, retrieving network information, and more. It interfaces with a modem to execute commands related to Wi-Fi functionality and manages connection settings such as IP address, DNS, and other network configurations. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`CWifi`](#class_c_wifi_1a64b74dbe44a73d1b7fd4618b5b606c02) | Default constructor for the [CWifi](#class_c_wifi) class. | +| [`begin`](#class_c_wifi_1a9c4fc0f23a197e9dc5ddf02bc1793c35) | Start WiFi connection for OPEN networks. | +| [`begin`](#class_c_wifi_1a4a2bf8820b00494648188c7c06871a26) | start WiFi connection with passphrase the most secure supported mode will be automatically selected. | +| [`beginAP`](#class_c_wifi_1adeaffb4fe03faf22e7f69697d5e83492) | | +| [`beginAP`](#class_c_wifi_1ae9059d5f875a96b5cdf19d2cf87e9848) | Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. | +| [`beginAP`](#class_c_wifi_1aee76c2fbb9f83a3f085b034e80c1025c) | Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. | +| [`beginAP`](#class_c_wifi_1a9e1257e9b28cd3489209d7c7d5ea8845) | Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. | +| [`config`](#class_c_wifi_1a75742aab24859611b36e74e08602dc47) | Change IP configuration settings disabling the DHCP client. | +| [`config`](#class_c_wifi_1ac799224e1f9c65e4808e2c8deb802ead) | Configures the network settings for the Wi-Fi connection with a specified DNS server. | +| [`config`](#class_c_wifi_1acd5a6e9bb901fb4dbaec311378f99eb6) | Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server. | +| [`config`](#class_c_wifi_1afc80a6fd238b6d0e59aebb2d27ec8e9e) | Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server. | +| [`setDNS`](#class_c_wifi_1a4043b10b6a83cb3add95e127c79056a0) | Sets the primary DNS server for the Wi-Fi connection. | +| [`setDNS`](#class_c_wifi_1adaa95a2dd3a8bab54080669e612f9d37) | Sets the primary and secondary DNS servers for the Wi-Fi connection. | +| [`setHostname`](#class_c_wifi_1aece8d82cb1f1a55c0c22a606d66f8ea7) | Sets the hostname for for DHCP requests. | +| [`disconnect`](#class_c_wifi_1a59591cd8450c695f3588df818fb58d34) | Disconnects from the current Wi-Fi network. | +| [`end`](#class_c_wifi_1a50a8e7ca94f40d31ea5c9b2def045575) | Resets and disables the Wi-Fi module. | +| [`macAddress`](#class_c_wifi_1a58ebcdba481cc413f32f06226dba8481) | Retrieves the MAC address of the device. | +| [`localIP`](#class_c_wifi_1ae6885ef712d13bfcfe54a23f28b2aecb) | Retrieves the local IP address of the device. | +| [`subnetMask`](#class_c_wifi_1afcdd6b286e90258b5296c8f30f4e7c81) | Retrieves the subnet mask of the device. | +| [`gatewayIP`](#class_c_wifi_1a775e014fc255686df09b1f40f6cb9453) | Retrieves the gateway IP address of the device. | +| [`dnsIP`](#class_c_wifi_1a3ee65c20906927f5772b96386d6b5700) | Retrieves the DNS IP address. | +| [`softAPIP`](#class_c_wifi_1a6e64918a2784cb53588f1553c97dc333) | Retrieves the IP address of the soft access point (AP). | +| [`SSID`](#class_c_wifi_1a46c576561933d9f067121b81ab8b3806) | Retrieves the SSID of the current Wi-Fi connection or SoftAP. | +| [`BSSID`](#class_c_wifi_1a9b153ec8de3bd6e95255e94140314ad2) | Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. | +| [`RSSI`](#class_c_wifi_1a39a8f1b67aee1a1f52d8c0f2085ebb52) | Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. | +| [`softAPSSID`](#class_c_wifi_1accf0212b364b4686a4d47f7e6f58485b) | Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. | +| [`scanNetworks`](#class_c_wifi_1af31d8a0baaa568178e2091b7a9e830a1) | Scans for available Wi-Fi networks and stores the information in the `access_points` list. | +| [`SSID`](#class_c_wifi_1a452fefff75ab36097d6f4b6ad401ffcb) | Retrieves the SSID of a specific Wi-Fi network from the scan results. | +| [`encryptionType`](#class_c_wifi_1ab434b47d2935bf6d0b58ec50d78c3799) | Returns the encryption type for a specified network. | +| [`encryptionType`](#class_c_wifi_1a8da9fb03f5349f7887d3cdda3268ed8c) | Returns the encryption type of the currently connected Wi-Fi network. | +| [`BSSID`](#class_c_wifi_1a10793238a64c312f2652b710c693022e) | Retrieves the BSSID of a specific Wi-Fi network. | +| [`channel`](#class_c_wifi_1a871866aab35d3c10b98e27e51b37d8b6) | Retrieves the channel number of a specific Wi-Fi network. | +| [`RSSI`](#class_c_wifi_1a86ecf1c49591c18296a6d1b1400954e5) | Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. | +| [`status`](#class_c_wifi_1aeeddb0fe0a897d043415a97d363f68e0) | Retrieves the current connection status of the Wi-Fi connection. | +| [`reasonCode`](#class_c_wifi_1a453afce0d716bb1b92c3d73ba4f621e4) | Retrieves The deauthentication reason code. | +| [`hostByName`](#class_c_wifi_1a97ef95bf4e58c3c11a88ab03a4702425) | Resolves a hostname to an IP address. | +| [`getTime`](#class_c_wifi_1a9c3f3a794a063c20b9ef81851226a625) | Retrieves the current time from the modem. | +| [`setTimeout`](#class_c_wifi_1a53250475083a7537de61d2fc14217345) | Sets the timeout value for the WiFi connection. | +| [`firmwareVersion`](#class_c_wifi_1a4b2746f36f799c1e075d8f083b8bd6ee) | Get firmware version. | + +## Members + +### `CWifi` + +```cpp +CWifi() +``` + +Default constructor for the [CWifi](#class_c_wifi) class. + +
+ +### `begin` + +```cpp +int begin(const char * ssid) +``` + +Start WiFi connection for OPEN networks. + +#### Parameters +* `ssid` a pointer to the SSID string. +
+ +### `begin` + +```cpp +int begin(const char * ssid, const char * passphrase) +``` + +start WiFi connection with passphrase the most secure supported mode will be automatically selected. + +#### Parameters +* `ssid` Pointer to the SSID string. + +* `passphrase` Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal). +
+ +### `beginAP` + +```cpp +uint8_t beginAP(const char * ssid) +``` + +
+ +### `beginAP` + +```cpp +uint8_t beginAP(const char * ssid, uint8_t channel) +``` + +Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. + +This function initializes a Wi-Fi Access Point (AP) with the provided SSID and channel. It defaults to using no password (open network). + +#### Parameters +* `ssid` The SSID (name) of the Wi-Fi Access Point. + +* `channel` The channel on which the Access Point will operate. + +#### Returns +`1` if the Access Point is successfully started. `0` if the Access Point failed to start. +
+ +### `beginAP` + +```cpp +uint8_t beginAP(const char * ssid, const char * passphrase) +``` + +Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. + +This function initializes a Wi-Fi Access Point (AP) using the provided SSID and passphrase, defaulting to channel 1. + +#### Parameters +* `ssid` The SSID (name) of the Wi-Fi Access Point. + +* `passphrase` The passphrase for securing the Access Point. If empty, the network will be open (no password). + +#### Returns +`1` if the Access Point is successfully started. `0` if the Access Point failed to start. +
+ +### `beginAP` + +```cpp +uint8_t beginAP(const char * ssid, const char * passphrase, uint8_t channel) +``` + +Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. + +This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. It sets the mode to AP and attempts to start the network. + +#### Parameters +* `ssid` The SSID (name) of the Wi-Fi Access Point. + +* `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. + +* `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). + +#### Returns +`WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start. +
+ +### `config` + +```cpp +void config(IPAddress local_ip) +``` + +Change IP configuration settings disabling the DHCP client. + +#### Parameters +* `local_ip` The static IP address to assign to the device. +
+ +### `config` + +```cpp +void config(IPAddress local_ip, IPAddress dns_server) +``` + +Configures the network settings for the Wi-Fi connection with a specified DNS server. + +Sets the device's IP configuration using the specified local IP address and DNS server. The gateway and subnet mask are set to default values based on the provided local IP. + +#### Parameters +* `local_ip` The static IP address to assign to the device. + +* `dns_server` The primary DNS server to use for domain name resolution. +
+ +### `config` + +```cpp +void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) +``` + +Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server. + +#### Parameters +* `local_ip` The static IP address to assign to the device. + +* `dns_server` The primary DNS server to use for domain name resolution. + +* `gateway` The Static gateway used for configuration. +
+ +### `config` + +```cpp +void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) +``` + +Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server. + +#### Parameters +* `local_ip` The static IP address to assign to the device. + +* `dns_server` The primary DNS server to use for domain name resolution. + +* `gateway` The static gateway used for configuration. + +* `subnet` The static subnet mask to use for the network. +
+ +### `setDNS` + +```cpp +void setDNS(IPAddress dns_server1) +``` + +Sets the primary DNS server for the Wi-Fi connection. + +#### Parameters +* `dns_server1` The primary DNS server to use for domain name resolution. +
+ +### `setDNS` + +```cpp +void setDNS(IPAddress dns_server1, IPAddress dns_server2) +``` + +Sets the primary and secondary DNS servers for the Wi-Fi connection. + +#### Parameters +* `dns_server1` sets the IP configuration for DNS server 1 + +* `dns_server2` sets the IP configuration for DNS server 2 +
+ +### `setHostname` + +```cpp +void setHostname(const char * name) +``` + +Sets the hostname for for DHCP requests. + +#### Parameters +* `name` sets the hostname. +
+ +### `disconnect` + +```cpp +int disconnect(void) +``` + +Disconnects from the current Wi-Fi network. + +#### Returns +`1` if the disconnection was successful, `0` otherwise. +
+ +### `end` + +```cpp +void end(void) +``` + +Resets and disables the Wi-Fi module. + +
+ +### `macAddress` + +```cpp +uint8_t * macAddress(uint8_t * mac) +``` + +Retrieves the MAC address of the device. + +This function retrieves the MAC address of the device based on its current operating mode. The value returned by this function is meaningfull only if called afert a begin (both begin or beginAP) or a ScanNetwork function otherwise an empty mac address is returned. + +#### Parameters +* `_mac` A pointer to a uint8_t array where the MAC address will be stored. + +#### Returns +uint8_t* The pointer to the array containing the MAC address. +
+ +### `localIP` + +```cpp +IPAddress localIP() +``` + +Retrieves the local IP address of the device. + +This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) and retrieves the appropriate IP address based on the mode. + +#### Returns +`IPAddress` The local IP address of the device. +
+ +### `subnetMask` + +```cpp +IPAddress subnetMask() +``` + +Retrieves the subnet mask of the device. + +This function retrieves the subnet mask of the device by querying the modem for the subnet information. It sends a command to the modem to fetch the subnet mask and returns it as an `IPAddress` object. + +#### Returns +`IPAddress` The subnet mask address value of the device. +
+ +### `gatewayIP` + +```cpp +IPAddress gatewayIP() +``` + +Retrieves the gateway IP address of the device. + +This function retrieves the gateway IP address of the device by querying the modem for the gateway information. It sends a command to the modem to fetch the gateway IP address and returns it as an `IPAddress` object. + +#### Returns +`IPAddress` The gateway IP address value of the device. +
+ +### `dnsIP` + +```cpp +IPAddress dnsIP(int n) +``` + +Retrieves the DNS IP address. + +#### Parameters +* `n` The index of the DNS server to retrieve, `0` for the primary DNS server and `1` for the secondary DNS server. + +#### Returns +`IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. +
+ +### `softAPIP` + +```cpp +IPAddress softAPIP() +``` + +Retrieves the IP address of the soft access point (AP). + +#### Returns +`IPAddress` The IP address of the soft AP as an `IPAddress` object, or `0.0.0.0` if not found. +
+ +### `SSID` + +```cpp +const char * SSID() +``` + +Retrieves the SSID of the current Wi-Fi connection or SoftAP. + +#### Returns +The SSID of the current Wi-Fi connection or SoftAP as a string. If unable to retrieve the SSID, returns an empty string. +
+ +### `BSSID` + +```cpp +uint8_t * BSSID(uint8_t * bssid) +``` + +Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. + +#### Parameters +* `bssid` A pointer to an array where the BSSID will be stored. The array must be large enough to hold the MAC address. + +#### Returns +A pointer to the `bssid` array containing the retrieved BSSID. If the BSSID cannot be retrieved, returns `nullptr`. +
+ +### `RSSI` + +```cpp +int32_t RSSI() +``` + +Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. + +#### Returns +The RSSI value representing the signal strength. A higher (less negative) value indicates a stronger signal. If the RSSI cannot be retrieved, returns 0. +
+ +### `softAPSSID` + +```cpp +const char * softAPSSID() +``` + +Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. + +#### Returns +The SSID of the SoftAP. If the SSID cannot be retrieved, an empty string is returned. +
+ +### `scanNetworks` + +```cpp +int8_t scanNetworks() +``` + +Scans for available Wi-Fi networks and stores the information in the `access_points` list. + +This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, RSSI (signal strength), channel, and encryption mode for each detected access point. + +#### Returns +The number of networks found during the scan. Returns a negative value in case of an error. +
+ +### `SSID` + +```cpp +const char * SSID(uint8_t networkItem) +``` + +Retrieves the SSID of a specific Wi-Fi network from the scan results. + +#### Parameters +* `networkItem` The index of the network in the list of scanned access points. + +#### Returns +The SSID of the specified network, or `nullptr` if the index is out of bounds. +
+ +### `encryptionType` + +```cpp +uint8_t encryptionType(uint8_t networkItem) +``` + +Returns the encryption type for a specified network. + +This function retrieves the encryption type of a specific Wi-Fi access point based on its index in the list of scanned networks. + +#### Parameters +* `networkItem` The index of the network in the list of available access points. + +#### Returns +The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). Returns 0 if the network item index is invalid. +
+ +### `encryptionType` + +```cpp +uint8_t encryptionType() +``` + +Returns the encryption type of the currently connected Wi-Fi network. + +#### Returns +The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). Returns `ENC_TYPE_UNKNOWN` if the encryption type cannot be determined. +
+ +### `BSSID` + +```cpp +uint8_t * BSSID(uint8_t networkItem, uint8_t * bssid) +``` + +Retrieves the BSSID of a specific Wi-Fi network. + +This function retrieves the BSSID (MAC address) of the Wi-Fi network at the specified index from the list of available networks. The BSSID is stored in the provided array of 6 bytes. + +#### Parameters +* `networkItem` The index of the Wi-Fi network in the list of available networks. + +* `bssid` A pointer to a byte array (of size 6) where the BSSID will be stored. + +#### Returns +A pointer to the `bssid` array if the BSSID is successfully retrieved, or `nullptr` if the network index is out of range. +
+ +### `channel` + +```cpp +uint8_t channel(uint8_t networkItem) +``` + +Retrieves the channel number of a specific Wi-Fi network. + +#### Parameters +* `networkItem` The index of the Wi-Fi network in the list of available networks. + +#### Returns +The channel number of the specified network, or `0` if the network index is out of range. +
+ +### `RSSI` + +```cpp +int32_t RSSI(uint8_t networkItem) +``` + +Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. + +#### Parameters +* `networkItem` The index of the Wi-Fi network in the list of available networks. + +#### Returns +The RSSI value of the specified network in dBm, or `-1000` if the network index is out of range. +
+ +### `status` + +```cpp +uint8_t status() +``` + +Retrieves the current connection status of the Wi-Fi connection. + +#### Returns +One of the values defined in wl_status_t +
+ +### `reasonCode` + +```cpp +uint8_t reasonCode() +``` + +Retrieves The deauthentication reason code. + +#### Returns +The deauthentication reason code. +
+ +### `hostByName` + +```cpp +int hostByName(const char * aHostname, IPAddress & aResult) +``` + +Resolves a hostname to an IP address. + +#### Parameters +* `aHostname` The hostname to resolve (e.g., "www.example.com"). + +* `aResult` IPAddress structure to store the returned IP address result: 1 if aIPAddrString was successfully converted to an IP address, else error code + +#### Returns +Returns `1` if the hostname was successfully resolved, `0` otherwise. +
+ +### `getTime` + +```cpp +unsigned long getTime() +``` + +Retrieves the current time from the modem. + +#### Returns +The current time value in seconds, or `0` if the time could not be retrieved. +
+ +### `setTimeout` + +```cpp +void setTimeout(unsigned long timeout) +``` + +Sets the timeout value for the WiFi connection. + +#### Parameters +* `timeout` The timeout value in milliseconds. +
+ +### `firmwareVersion` + +```cpp +static const char * firmwareVersion() +``` + +Get firmware version. + +
+ +# class `ModemClass` + +A class that provides methods to interact with a modem. + +This class is responsible for providing an interface to communicate with a modem through serial communication. It includes methods for initialization, sending and receiving data, and handling modem configurations. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`beginned`](#class_modem_class_1ad21db7f5eb0b759c9b6c02af03b8f964) | Flag indicating whether the system has been initialized. | +| [`enable_dbg`](#class_modem_class_1a77cc6948341d08f0285233c67ef1e928) | | +| [`ModemClass`](#class_modem_class_1acce8d910277f180f32607ed8e84f090b) | Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified transmit (TX) and receive (RX) pins. | +| [`ModemClass`](#class_modem_class_1af222286fa398b86d02bd6230e0c42039) | Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified UART interface. | +| [`~ModemClass`](#class_modem_class_1a458f1f4e43e27fdc522caaf4c40d9579) | Destructor for [ModemClass](#class_modem_class). | +| [`begin`](#class_modem_class_1a36c32d41d4111e5fc63d8bf1a017368f) | Initializes the modem communication with a specified baud rate. | +| [`end`](#class_modem_class_1a434e5c4b8c67d90c10eff5e20da56556) | Ends the modem communication. | +| [`write`](#class_modem_class_1acd102543a8544be0686128fea53c9a11) | Sends a formatted command string to a device and stores the response. | +| [`write_nowait`](#class_modem_class_1aa9923ac664a16c2aaf5024de9de1ef03) | Used to send a command to the modem without waiting for a response. | +| [`passthrough`](#class_modem_class_1aa8750f17b14472819ffb8016118f869b) | Sends binary data directly to the modem without any processing or interpretation. | +| [`avoid_trim_results`](#class_modem_class_1ac7aff51f7bb09bbfd7190af1715274f8) | Disables automatic trimming of results for one operation. | +| [`read_using_size`](#class_modem_class_1a83d1105d39191e2c902331b3f0c4c8f5) | Enables a specific mode of reading where the size of the data to be read is considered for processing. | +| [`debug`](#class_modem_class_1a6e6c472f405698e25db0d90a1de359f4) | | +| [`noDebug`](#class_modem_class_1a0b73ad5e52ad405a3be764d948cd8522) | Used to disable debugging output for the modem communication. | +| [`debug`](#class_modem_class_1a0d2808ffeccd83db3e26cc3568e33eeb) | | +| [`timeout`](#class_modem_class_1a240fc0451c5152615f192b675beabadc) | Sets the timeout value for communication operations. | + +## Members + +### `beginned` + +```cpp +bool beginned +``` + +Flag indicating whether the system has been initialized. + +
+ +### `enable_dbg` + +```cpp +bool enable_dbg +``` + +
+ +### `ModemClass` + +```cpp +ModemClass(int tx, int rx) +``` + +Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified transmit (TX) and receive (RX) pins. + +#### Parameters +* `Initializes` an instance of the `[ModemClass](#class_modem_class)` class with specific transmit `tx` and receive `rx` pins for communication. +
+ +### `ModemClass` + +```cpp +ModemClass(UART * _serial) +``` + +Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified UART interface. + +#### Parameters +* `_serial` is a pointer to the UART object that will be used for communication with the modem. +
+ +### `~ModemClass` + +```cpp +~ModemClass() +``` + +Destructor for [ModemClass](#class_modem_class). + +
+ +### `begin` + +```cpp +void begin(int badurate) +``` + +Initializes the modem communication with a specified baud rate. + +#### Parameters +* `badurate` sets the baud rate for the serial connection. +
+ +### `end` + +```cpp +void end() +``` + +Ends the modem communication. + +
+ +### `write` + +```cpp +bool write(const std::string & cmd, std::string & str, const char * fmt, ...) +``` + +Sends a formatted command string to a device and stores the response. + +This function formats a command string using the provided format and arguments, sends it to a device, and waits for a response, which is stored in the `str` string. + +#### Parameters +* `cmd` A string representing the command to be sent to the device. + +* `str` A reference to a string that will hold the device's response. + +* `fmt` A format string for constructing the command. + +#### Returns +`true` if the command was successfully sent and a response was received, `false` otherwise. +
+ +### `write_nowait` + +```cpp +void write_nowait(const std::string & cmd, std::string & str, const char * fmt, ...) +``` + +Used to send a command to the modem without waiting for a response. + +#### Parameters +* `It` takes a command string `cmd`, a string `str` where the response will be stored, and a format string `fmt` along with additional arguments. +
+ +### `passthrough` + +```cpp +bool passthrough(const uint8_t * data, size_t size) +``` + +Sends binary data directly to the modem without any processing or interpretation. + +#### Parameters +* `It` takes a pointer to the binary `data` and the `size` of the data as arguments. Used for sending raw binary commands or data to the modem for operations that require direct communication without any additional formatting or parsing. +
+ +### `avoid_trim_results` + +```cpp +inline void avoid_trim_results() +``` + +Disables automatic trimming of results for one operation. + +This function disables the automatic trimming of results for one operation. After it is called, the results will not be trimmed automatically until the function is called again. +
+ +### `read_using_size` + +```cpp +inline void read_using_size() +``` + +Enables a specific mode of reading where the size of the data to be read is considered for processing. + +
+ +### `debug` + +```cpp +inline void debug(Stream & u, uint8_t level) +``` + +
+ +### `noDebug` + +```cpp +inline void noDebug() +``` + +Used to disable debugging output for the modem communication. + +
+ +### `debug` + +```cpp +inline void debug(bool e) +``` + +
+ +### `timeout` + +```cpp +inline void timeout(size_t timeout_ms) +``` + +Sets the timeout value for communication operations. + +#### Parameters +* `Can` be called with a specified timeout value in milliseconds. +
+ +# class `WiFiClient` + +```cpp +class WiFiClient + : public Client +``` + +Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. + +The [WiFiClient](#class_wi_fi_client) class allows for network communication over Wi-Fi, providing methods for establishing connections, sending and receiving data, and managing the client’s socket state. This class is used to manage client connections in a Wi-Fi network, either for communication or for network data transfer. + +It inherits from the `Client` class, providing basic socket communication functionality. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`WiFiClient`](#class_wi_fi_client_1aa22ef0fd15a3e2b8ac45eceb0df3bc74) | Default constructor for the [WiFiClient](#class_wi_fi_client) class. | +| [`WiFiClient`](#class_wi_fi_client_1a53ed2903b15a61a52c3b90406978be89) | Constructor to initialize a [WiFiClient](#class_wi_fi_client) object with a specific socket. | +| [`WiFiClient`](#class_wi_fi_client_1a1b176d034c1239bdcffa6db13ef5e485) | Copy constructor for the [WiFiClient](#class_wi_fi_client) class. | +| [`~WiFiClient`](#class_wi_fi_client_1a6410fb12d526d541c436136b18faa0db) | Destructor for the [WiFiClient](#class_wi_fi_client) class. | +| [`connect`](#class_wi_fi_client_1a0c10a429fa90cf0589daa9742e10e0ee) | Establishes a connection to a server using an IP address and port. | +| [`connect`](#class_wi_fi_client_1a00fe1cf5622b3d941c99c944cc2df0e8) | Establishes a connection to a server using a hostname and port. | +| [`write`](#class_wi_fi_client_1a1bbd17136c9320c9eecb5a98a5fc1720) | Sends a single byte of data to the connected server. | +| [`write`](#class_wi_fi_client_1a03638bc1d73e73e9cc5cddf6a4a9c320) | Writes a buffer of data to the connected server. | +| [`available`](#class_wi_fi_client_1ae3f72b88b376090eb24f1fe1c16212d7) | Checks the number of bytes available for reading from the server. | +| [`read`](#class_wi_fi_client_1a8207089f4496ef5b429277fa8cc2d259) | Reads a single byte of data from the server. | +| [`read`](#class_wi_fi_client_1abd26fb1cce208783b3392507e448d0d2) | Reads multiple bytes of data from the server into a buffer. | +| [`peek`](#class_wi_fi_client_1a892443057ba2c24ae094c5a87e50cff5) | Peeks at the next byte of incoming data without removing it from the internal buffer. | +| [`flush`](#class_wi_fi_client_1a54739070fd04288ced179019ee212530) | Flushes the write buffer of the client. | +| [`stop`](#class_wi_fi_client_1acb61f8e0ecd50e40ce6cbcb7106ce1b1) | Closes the connection to the server and clears the receive buffer. | +| [`connected`](#class_wi_fi_client_1af083fe27b94aebec37f140c0b973f974) | Checks if the client is connected to a server. | +| [`operator bool`](#class_wi_fi_client_1adaf93736006b5bb2426e9816de4207eb) | Implicit conversion operator to `bool`. | +| [`operator==`](#class_wi_fi_client_1ac1e068fb2468d84536e93f6e1b51b099) | Equality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. | +| [`operator!=`](#class_wi_fi_client_1a31b6e43ab5ab9d6fe511778a5a1f173c) | Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. | +| [`remoteIP`](#class_wi_fi_client_1a46d45c8d326b62256f85d55eaa337df0) | Retrieves the remote IP address of the server the client is connected to. | +| [`remotePort`](#class_wi_fi_client_1a38ca1399ebf6570d2c852c9062ec92d8) | Retrieves the remote port number of the server the client is connected to. | +| [`setConnectionTimeout`](#class_wi_fi_client_1af32938f36f09c9121e85e38338d432d7) | Sets the connection timeout for the client. | + +## Members + +### `WiFiClient` + +```cpp +WiFiClient() +``` + +Default constructor for the [WiFiClient](#class_wi_fi_client) class. + +
+ +### `WiFiClient` + +```cpp +WiFiClient(int s) +``` + +Constructor to initialize a [WiFiClient](#class_wi_fi_client) object with a specific socket. + +#### Parameters +* `s` is the socket descriptor to associate with this client. +
+ +### `WiFiClient` + +```cpp +WiFiClient(const WiFiClient & c) +``` + +Copy constructor for the [WiFiClient](#class_wi_fi_client) class. + +#### Parameters +* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy. +
+ +### `~WiFiClient` + +```cpp +~WiFiClient() +``` + +Destructor for the [WiFiClient](#class_wi_fi_client) class. + +
+ +### `connect` + +```cpp +virtual int connect(IPAddress ip, uint16_t port) +``` + +Establishes a connection to a server using an IP address and port. + +#### Parameters +* `ip` as the IP address of the server to connect to. + +* `port` as the port number on the server to connect to. + +#### Returns +`1` on a successful connection, `0` on failure. +
+ +### `connect` + +```cpp +virtual int connect(const char * host, uint16_t port) +``` + +Establishes a connection to a server using a hostname and port. + +#### Parameters +* `host` is a pointer to a null-terminated string containing the hostname of the server. + +* `port` is the port number on the server to connect to. + +#### Returns +`1` if the connection was successful, `0` otherwise. +
+ +### `write` + +```cpp +virtual size_t write(uint8_t) +``` + +Sends a single byte of data to the connected server. + +#### Parameters +* `b` being the byte of data to send. + +#### Returns +The number of bytes successfully written, which is `1` on success or `0` on failure. +
+ +### `write` + +```cpp +virtual size_t write(const uint8_t * buf, size_t size) +``` + +Writes a buffer of data to the connected server. + +#### Parameters +* `Takes` a pointer to a buffer `buf` containing the data to be written and the size of the buffer `size` as parameters. + +#### Returns +The number of bytes successfully written, or `0` if the write operation fails. +
+ +### `available` + +```cpp +virtual int available() +``` + +Checks the number of bytes available for reading from the server. + +#### Returns +The number of bytes available to read. Returns `0` if no data is available, or if the socket is invalid. +
+ +### `read` + +```cpp +virtual int read() +``` + +Reads a single byte of data from the server. + +#### Returns +The byte read as an `int` (0–255). Returns `-1` if no data is available or if an error occurs. +
+ +### `read` + +```cpp +virtual int read(uint8_t * buf, size_t size) +``` + +Reads multiple bytes of data from the server into a buffer. + +This function retrieves data from the server's receive buffer and stores it into the provided array. It attempts to read up to the specified number of bytes (`size`). + +#### Parameters +* `buf` is a pointer to the buffer where the data will be stored. + +* `size` is the maximum number of bytes to read. + +#### Returns +The number of bytes successfully read into the buffer. Returns `0` if no data is available or if the socket is invalid. +
+ +### `peek` + +```cpp +virtual int peek() +``` + +Peeks at the next byte of incoming data without removing it from the internal buffer. + +#### Returns +The next byte as an `int` (0–255). Returns `-1` if no data is available or if the socket is invalid. +
+ +### `flush` + +```cpp +virtual void flush() +``` + +Flushes the write buffer of the client. + +This function ensures that any data buffered for transmission is sent to the connected server. If there is any pending data in the send buffer, it is transmitted over the network. +
+ +### `stop` + +```cpp +virtual void stop() +``` + +Closes the connection to the server and clears the receive buffer. + +
+ +### `connected` + +```cpp +virtual uint8_t connected() +``` + +Checks if the client is connected to a server. + +#### Returns +Returns 1 if the client is connected, 0 otherwise. +
+ +### `operator bool` + +```cpp +inline virtual operator bool() +``` + +Implicit conversion operator to `bool`. + +Converts the `[WiFiClient](#class_wi_fi_client)` object to a `bool` value indicating whether the client is connected or not. + +#### Returns +`true` if the client socket is open and valid, `false` otherwise. +
+ +### `operator==` + +```cpp +virtual bool operator==(const WiFiClient &) +``` + +Equality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. + +Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent the same socket connection. + +#### Parameters +* `The` `[WiFiClient](#class_wi_fi_client)` object to compare with. + +#### Returns +`true` if both `[WiFiClient](#class_wi_fi_client)` objects represent the same socket, `false` otherwise. +
+ +### `operator!=` + +```cpp +inline virtual bool operator!=(const WiFiClient & whs) +``` + +Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. + +Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent different socket connections. + +#### Parameters +* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. + +#### Returns +`true` if both [WiFiClient](#class_wi_fi_client) objects represent different sockets, `false` if they represent the same socket. +
+ +### `remoteIP` + +```cpp +virtual IPAddress remoteIP() +``` + +Retrieves the remote IP address of the server the client is connected to. + +#### Returns +The IP address of the remote server. If not connected, returns IPAddress(0, 0, 0, 0). +
+ +### `remotePort` + +```cpp +virtual uint16_t remotePort() +``` + +Retrieves the remote port number of the server the client is connected to. + +#### Returns +Returns the port number of the remote server. If not connected, returns 0. +
+ +### `setConnectionTimeout` + +```cpp +inline void setConnectionTimeout(int timeout) +``` + +Sets the connection timeout for the client. + +#### Parameters +* `timeout` is the timeout value in milliseconds. +
+ +# class `WiFiFileSystem` + +Class that handles the WiFi file system operations. + +This class provides functionality for managing files on a WiFi-connected device, including mounting, reading, writing, and configuring the file system. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`WiFiFileSystem`](#class_wi_fi_file_system_1af4d9123dd9631c69853070498afb41a2) | Initializes objects of the `[WiFiFileSystem](#class_wi_fi_file_system)` class. | +| [`mount`](#class_wi_fi_file_system_1aa5baed674db176f774488b50fa35c3d1) | Mounts the file system and optionally formats it on failure. | +| [`writefile`](#class_wi_fi_file_system_1a0121ce8d9a1b9d4a53e7b7ea7ecc4c1c) | Writes data to a file in the file system. | +| [`readfile`](#class_wi_fi_file_system_1acd3d52b7a20f5f65b7ca28dbb7b04343) | Reads a file from the file system and prints its content. | + +## Members + +### `WiFiFileSystem` + +```cpp +WiFiFileSystem() +``` + +Initializes objects of the `[WiFiFileSystem](#class_wi_fi_file_system)` class. + +
+ +### `mount` + +```cpp +void mount(bool format_on_fault) +``` + +Mounts the file system and optionally formats it on failure. + +#### Parameters +* `If` `format_on_fault` is set to `true`, the file system will be formatted if a fault occurs during mounting. +
+ +### `writefile` + +```cpp +size_t writefile(const char * name, const char * data, size_t size, int operation) +``` + +Writes data to a file in the file system. + +#### Parameters +* `name` is the name of the file to which the data will be written. A pointer `data` to the data that will be written to the file. `size` is the number of bytes to write from the provided data buffer. `operation` determines the type of file operation to perform (e.g., create, overwrite). + +#### Returns +Returns the number of bytes successfully written. Returns 0 if the operation fails. +
+ +### `readfile` + +```cpp +void readfile(const char * name) +``` + +Reads a file from the file system and prints its content. + +It sends the read request to the modem, which fetches the data. The content is printed to the serial output in chunks, with each chunk being processed until the entire file is read. + +#### Parameters +* `name` is the name of the file to be read from the file system. +
+ +# class `WiFiServer` + +```cpp +class WiFiServer + : public Server +``` + +A class that provides server functionality for WiFi-based communication. + +The `[WiFiServer](#class_wi_fi_server)` class inherits from the `Server` class and extends its functionality to create and manage a server over a WiFi connection. This class allows for accepting incoming client connections, handling data communication, and closing connections in a networked environment. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`WiFiServer`](#class_wi_fi_server_1acfa8226decf3a818dfbd45ec7940280a) | Initializes objects of the `[WiFiServer](#class_wi_fi_server)` class. | +| [`WiFiServer`](#class_wi_fi_server_1a63b71b18a7011b40fb86d893bc4c72fd) | Constructs a `[WiFiServer](#class_wi_fi_server)` object with the specified port. | +| [`available`](#class_wi_fi_server_1abfd839b75fa3c40bd5e22c4a122ed800) | Checks if there are any incoming client connections waiting to be accepted. | +| [`accept`](#class_wi_fi_server_1ad29b9a043c87bad43140cc3066210088) | Accepts an incoming client connection on the server. | +| [`begin`](#class_wi_fi_server_1a52e68fa8b767579e5055de9ff072f08c) | Starts the Wi-Fi server and binds it to the specified port. | +| [`begin`](#class_wi_fi_server_1a953b3d2a3ea0b0582be9535b6aa908d9) | Starts the Wi-Fi server and binds it to the default port. | +| [`write`](#class_wi_fi_server_1ad3d206415f9733dee2170f136b909e54) | Writes a single byte to all connected clients. | +| [`write`](#class_wi_fi_server_1a6bef9499519bcedd59379024c4e7b360) | Writes data to all connected clients. | +| [`end`](#class_wi_fi_server_1a26d44e7107a4121589f96b505c73593d) | Ends the Wi-Fi server and closes the server socket. | +| [`operator bool`](#class_wi_fi_server_1a1cca17be23aad6b7dce5fc2315226e5d) | Converts the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to a boolean value. | +| [`operator==`](#class_wi_fi_server_1a6e3fc602a5e129d19e6fa5076419511f) | Compares two `[WiFiServer](#class_wi_fi_server)` objects for equality. | +| [`operator!=`](#class_wi_fi_server_1a3b34f02716dd23e22b85585b4d648169) | Compares two `[WiFiServer](#class_wi_fi_server)` objects for inequality. | + +## Members + +### `WiFiServer` + +```cpp +WiFiServer() +``` + +Initializes objects of the `[WiFiServer](#class_wi_fi_server)` class. + +
+ +### `WiFiServer` + +```cpp +WiFiServer(int p) +``` + +Constructs a `[WiFiServer](#class_wi_fi_server)` object with the specified port. + +#### Parameters +* `p` The port number on which the server will listen for incoming connections. +
+ +### `available` + +```cpp +WiFiClient available() +``` + +Checks if there are any incoming client connections waiting to be accepted. + +This function queries the server to check if there is a client waiting to be accepted. If a client is available, it returns a `[WiFiClient](#class_wi_fi_client)` object representing the client. It uses the modem to query the server for an available client socket and accepts the connection if a valid client is found. + +#### Returns +Returns a `[WiFiClient](#class_wi_fi_client)` object representing the next client connection that is available for processing. +
+ +### `accept` + +```cpp +WiFiClient accept() +``` + +Accepts an incoming client connection on the server. + +#### Returns +Returns a `[WiFiClient](#class_wi_fi_client)` object representing the accepted client. +
+ +### `begin` + +```cpp +void begin(int port) +``` + +Starts the Wi-Fi server and binds it to the specified port. + +#### Parameters +* `port` is the port number which the server will listen to for incoming connections. +
+ +### `begin` + +```cpp +void begin() +``` + +Starts the Wi-Fi server and binds it to the default port. + +This function initializes the server and binds it to a default port. +
+ +### `write` + +```cpp +virtual size_t write(uint8_t) +``` + +Writes a single byte to all connected clients. + +#### Parameters +* `b` is the byte to be sent to the clients. +
+ +### `write` + +```cpp +virtual size_t write(const uint8_t * buf, size_t size) +``` + +Writes data to all connected clients. + +This function sends a buffer of data to all clients connected to the server. It writes the specified number of bytes to the server socket and returns the count of successfully written bytes. + +#### Parameters +* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to write from the buffer. + +#### Returns +The number of bytes successfully written. Returns 0 if the data could not be sent. +
+ +### `end` + +```cpp +void end() +``` + +Ends the Wi-Fi server and closes the server socket. + +This function terminates the server by sending a command to the modem to close the server socket. It sets the server socket variable to an invalid state (`-1`) to indicate that the server is no longer active. +
+ +### `operator bool` + +```cpp +explicit operator bool() +``` + +Converts the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to a boolean value. + +This operator allows a `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to be implicitly or explicitly converted to a boolean. It checks whether the client socket is valid (i.e., `_sock != -1`). + +#### Returns +`true` if the server socket is valid (server is running), `false` otherwise. +
+ +### `operator==` + +```cpp +virtual bool operator==(const WiFiServer &) +``` + +Compares two `[WiFiServer](#class_wi_fi_server)` objects for equality. + +This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServer](#class_wi_fi_server)` objects to determine if they refer to the same server connection. + +#### Parameters +* `WiFiServer` object to compare against. + +#### Returns +`true` if both `[WiFiServer](#class_wi_fi_server)` objects have the same socket; `false` otherwise. +
+ +### `operator!=` + +```cpp +inline virtual bool operator!=(const WiFiServer & whs) +``` + +Compares two `[WiFiServer](#class_wi_fi_server)` objects for inequality. + +This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServer](#class_wi_fi_server)` objects. It returns `true` if the objects do not refer to the same server connection (i.e., they have different socket values), and `false` otherwise. + +#### Parameters +* `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. + +#### Returns +`true` if the [WiFiServer](#class_wi_fi_server) objects have different sockets; `false` otherwise. +
+ +# class `WiFiSSLClient` + +```cpp +class WiFiSSLClient + : public WiFiClient +``` + +A specialized client class for secure SSL/TLS connections. + +The `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class extends the functionality of the `[WiFiClient](#class_wi_fi_client)` class to provide secure communication over SSL/TLS protocols. It ensures encrypted and authenticated communication between the client and a remote server. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`WiFiSSLClient`](#class_wi_fi_s_s_l_client_1aeecf408e130c75ca84c9e41f7cf708aa) | Initializes objects of the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class. | +| [`~WiFiSSLClient`](#class_wi_fi_s_s_l_client_1afe721b778749143fe61fdfff259218af) | | +| [`connect`](#class_wi_fi_s_s_l_client_1a82ed27a660bb90559c0467920182c947) | Establishes a secure SSL connection to a specified IP address and port. | +| [`connect`](#class_wi_fi_s_s_l_client_1a46375064a7f581ba072e67bdc68be494) | Establishes a secure SSL connection to a specified host and port. | +| [`setCACert`](#class_wi_fi_s_s_l_client_1ad97df1f2253445c9fec5f4471afcdbf1) | Sets the Certificate Authority (CA) for SSL/TLS verification. | +| [`setEccSlot`](#class_wi_fi_s_s_l_client_1a9720117b29a35bc2a43c133f76fd8f8e) | Sets the ECC (Elliptic Curve Cryptography) key slot and certificate for establishing secure SSL connections. | +| [`write`](#class_wi_fi_s_s_l_client_1aa998458d525200ce36277d637008f87c) | Writes a single byte of data to the SSL connection. | +| [`write`](#class_wi_fi_s_s_l_client_1afa24293a9551bbcca1b565da2607eb2b) | Writes a buffer of data to the SSL connection. | +| [`available`](#class_wi_fi_s_s_l_client_1ae52872cae6f3aa8b53c50ebe2373eb81) | Checks the number of bytes available for reading from the SSL connection. | +| [`read`](#class_wi_fi_s_s_l_client_1adac00db4d021b38a513c5ae97e6305ec) | Reads data from the SSL connection into the receive buffer. | +| [`read`](#class_wi_fi_s_s_l_client_1a163b81ae7656797ed010cdcb0b576e58) | Reads a specified number of bytes from the SSL connection into a buffer. | +| [`peek`](#class_wi_fi_s_s_l_client_1aafdaf6405d3cbc7807b0ac04fc511061) | Peeks at the next byte available from the SSL connection without removing it. | +| [`flush`](#class_wi_fi_s_s_l_client_1ae894698f8e8b90ebd298fa66fedadd32) | Flushes the write buffer of the SSL connection. | +| [`stop`](#class_wi_fi_s_s_l_client_1a66113af6fbc85f0dbb73f8d276b8a77a) | Terminates the SSL/TLS connection and clears the receive buffer. | +| [`connected`](#class_wi_fi_s_s_l_client_1a5e993c746855bb67c744d27baa6cf1bb) | Checks if the SSL/TLS connection is active. | +| [`operator bool`](#class_wi_fi_s_s_l_client_1a46888795cc1562c33fad408b57d2ad40) | Implicit conversion operator to check if the SSL client is connected. | +| [`operator==`](#class_wi_fi_s_s_l_client_1aa0bdf11dd3e6ef48133967dc0a036004) | Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. | +| [`operator!=`](#class_wi_fi_s_s_l_client_1a2cdd8020168fae9e08d3c6d00b30b065) | Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. | +| [`remoteIP`](#class_wi_fi_s_s_l_client_1acff0aa8078124dff0c0ff3bfee7cfd83) | Retrieves the remote IP address of the WiFi SSL client. | +| [`remotePort`](#class_wi_fi_s_s_l_client_1aea76ab94b3cdfec17ab6e73c7b169da7) | Retrieves the remote port number of the WiFi SSL client. | + +## Members + +### `WiFiSSLClient` + +```cpp +WiFiSSLClient() +``` + +Initializes objects of the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class. + +
+ +### `~WiFiSSLClient` + +```cpp +~WiFiSSLClient() +``` + +
+ +### `connect` + +```cpp +virtual int connect(IPAddress ip, uint16_t port) +``` + +Establishes a secure SSL connection to a specified IP address and port. + +#### Parameters +* `It` takes an `IPAddress` object representing the IP address of the server and a `uint16_t` port number as parameters. + +#### Returns +Returns a status code indicating the success or failure of the connection. +
+ +### `connect` + +```cpp +virtual int connect(const char * host, uint16_t port) +``` + +Establishes a secure SSL connection to a specified host and port. + +#### Parameters +* `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. + +#### Returns +Returns 1 if the connection is successfully established, 0 otherwise. +
+ +### `setCACert` + +```cpp +void setCACert(const char * root_ca) +``` + +Sets the Certificate Authority (CA) for SSL/TLS verification. + +#### Parameters +* `root_ca` is a pointer to a null-terminated string containing the root CA certificate in PEM format. If set to `nullptr`, the default root CA bundle will be used. +
+ +### `setEccSlot` + +```cpp +void setEccSlot(int ecc508KeySlot, const byte cert, int certLength) +``` + +Sets the ECC (Elliptic Curve Cryptography) key slot and certificate for establishing secure SSL connections. + +#### Parameters +* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. `int certLength` specifies the length of the certificate data array. +
+ +### `write` + +```cpp +virtual size_t write(uint8_t) +``` + +Writes a single byte of data to the SSL connection. + +#### Parameters +* `b` is the byte to be sent. + +#### Returns +size_t The number of bytes successfully written. Returns 1 if the byte was sent successfully, or 0 if an error occurred. +
+ +### `write` + +```cpp +virtual size_t write(const uint8_t * buf, size_t size) +``` + +Writes a buffer of data to the SSL connection. + +#### Parameters +* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to send from the buffer. + +#### Returns +Returns `size` if the data is successfully sent, or 0 if the transmission fails or the socket is invalid. +
+ +### `available` + +```cpp +virtual int available() +``` + +Checks the number of bytes available for reading from the SSL connection. + +#### Returns +Returns the number of bytes available to read from the SSL connection without blocking. +
+ +### `read` + +```cpp +virtual int read() +``` + +Reads data from the SSL connection into the receive buffer. + +#### Returns +Returns the number of bytes successfully read into the buffer. Returns 0 if no data is received, or -1 if the socket is invalid or an error occurs. +
+ +### `read` + +```cpp +virtual int read(uint8_t * buf, size_t size) +``` + +Reads a specified number of bytes from the SSL connection into a buffer. + +#### Parameters +* `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. + +#### Returns +The number of bytes successfully read. Returns 0 if no data is available or an error occurs. +
+ +### `peek` + +```cpp +virtual int peek() +``` + +Peeks at the next byte available from the SSL connection without removing it. + +This function queries the modem to retrieve the next byte available in the SSL/TLS connection, allowing the byte to remain in the buffer for future reads. + +#### Returns +The next byte available as an integer value (0–255), or -1 if the socket is invalid or no data is available. +
+ +### `flush` + +```cpp +virtual void flush() +``` + +Flushes the write buffer of the SSL connection. + +This function clears the write buffer, ensuring that any pending data is sent over the SSL/TLS connection. It uses the modem to handle the flush operation. +
+ +### `stop` + +```cpp +virtual void stop() +``` + +Terminates the SSL/TLS connection and clears the receive buffer. + +
+ +### `connected` + +```cpp +virtual uint8_t connected() +``` + +Checks if the SSL/TLS connection is active. + +This function determines if the SSL/TLS client is still connected by querying the modem for the connection status. It checks the validity of the socket before proceeding with the query. + +#### Returns +uint8_t Returns 1 if the client is connected, 0 otherwise. +
+ +### `operator bool` + +```cpp +inline virtual operator bool() +``` + +Implicit conversion operator to check if the SSL client is connected. + +#### Returns +`true` if the socket is valid (i.e., connected), `false` otherwise. +
+ +### `operator==` + +```cpp +virtual bool operator==(const WiFiSSLClient &) +``` + +Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. + +#### Parameters +* `WiFiSSLClient` object to compare. + +#### Returns +`true` if both `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects are equivalent (i.e., they have the same socket), `false` otherwise. +
+ +### `operator!=` + +```cpp +inline virtual bool operator!=(const WiFiSSLClient & whs) +``` + +Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. + +This operator compares the current `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object with another `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to determine if they are not equal, based on their underlying socket or connection. + +#### Parameters +* `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. + +#### Returns +`true` if the two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects do not represent the same connection (i.e., have different sockets), `false` otherwise. +
+ +### `remoteIP` + +```cpp +virtual IPAddress remoteIP() +``` + +Retrieves the remote IP address of the WiFi SSL client. + +This function queries the modem for the remote IP address associated with the current connection. + +#### Returns +The remote IP address of the client. Returns 0.0.0.0 if the socket is not valid or the query fails. +
+ +### `remotePort` + +```cpp +virtual uint16_t remotePort() +``` + +Retrieves the remote port number of the WiFi SSL client. + +This function queries the modem to obtain the remote port number associated with the current connection. + +#### Returns +Returns the remote port number of the client. Returns 0 if the socket is not valid or the query fails. +
+ +# class `WiFiUDP` + +```cpp +class WiFiUDP + : public UDP +``` + +A class for handling UDP communication over a Wi-Fi network. + +The `[WiFiUDP](#class_wi_fi_u_d_p)` class is an extension of the `UDP` class that enables sending and receiving UDP packets over a Wi-Fi network. It provides functions for initialization, packet transmission, and reception tailored for Wi-Fi connectivity. + +## Summary + + Members | Descriptions +--------------------------------|--------------------------------------------- +| [`WiFiUDP`](#class_wi_fi_u_d_p_1a84c016f902e4999f74b2356d2af483ea) | Default constructor for the [WiFiUDP](#class_wi_fi_u_d_p) class. | +| [`begin`](#class_wi_fi_u_d_p_1af48f0679da52268c8d3d74110fa56035) | Starts a UDP socket on the specified local port. | +| [`begin`](#class_wi_fi_u_d_p_1a830cf425860621f6c71f785012b07ff6) | Starts a UDP socket bound to a specific IP address and port. | +| [`beginMulticast`](#class_wi_fi_u_d_p_1a470bcdb3a2fffdfecf2d5945a2345789) | Starts a UDP multicast socket bound to a specific IP address and port. | +| [`stop`](#class_wi_fi_u_d_p_1a87ee974d0e6ec204364d5e73396be9fa) | Stops the UDP socket and releases its resources. | +| [`beginMulticastPacket`](#class_wi_fi_u_d_p_1a96258bfc994f75c2144ede2afcbc0636) | Begins constructing a multicast UDP packet for sending. | +| [`beginPacket`](#class_wi_fi_u_d_p_1a2e51a25f349ed007b2fa7f78dca43a89) | Begins constructing a UDP packet for sending to a specific IP address and port. | +| [`beginPacket`](#class_wi_fi_u_d_p_1a448452411940224e708b9d907d56fa74) | Begins constructing a UDP packet for sending to a specific hostname and port. | +| [`endPacket`](#class_wi_fi_u_d_p_1ab157246011e8f79564881f68a9bd1b11) | Completes the construction of a UDP packet and sends it to the specified destination. | +| [`write`](#class_wi_fi_u_d_p_1ab36596bdae87541922d3b2653517500b) | Sends a single byte of data to the currently opened UDP packet. | +| [`write`](#class_wi_fi_u_d_p_1ae6a547561e192e3446f3190a429bbbd5) | Sends a buffer of data to the currently opened UDP packet. | +| [`parsePacket`](#class_wi_fi_u_d_p_1a52641a292b2c9ea8494bc91c22bba2ac) | Start processing the next available incoming packet. | +| [`available`](#class_wi_fi_u_d_p_1a72f5e44ece70dd7a2a96647a897951d2) | Checks if there are any available UDP packets to read. | +| [`read`](#class_wi_fi_u_d_p_1a4474f72712418b90f2415581a4e5b9e5) | Read a single byte from the current packet. | +| [`read`](#class_wi_fi_u_d_p_1aacde0f39adec12a6151b42a89badea02) | Reads data from the UDP receive buffer into a provided buffer. | +| [`read`](#class_wi_fi_u_d_p_1a04e1b1de54485392307a90ae3c703529) | Reads data from the UDP receive buffer into a character buffer. | +| [`peek`](#class_wi_fi_u_d_p_1adf9cda99b5319dd9c58a2dd50075639b) | Peeks at the next byte available in the UDP buffer without moving on to the next byte. | +| [`flush`](#class_wi_fi_u_d_p_1acd8e5a16383d8b47c13536007ee04a71) | Finish reading the current packet. | +| [`operator==`](#class_wi_fi_u_d_p_1a31b0064b29cee88cf5aa7eb056f2b3a8) | Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for equality. | +| [`operator!=`](#class_wi_fi_u_d_p_1a9fc23a50af71ef9b34c73c7dee897c01) | Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for inequality. | +| [`remoteIP`](#class_wi_fi_u_d_p_1a840ae72c440bed1c3e429f177cb41740) | Retrieves the remote IP address of the host who sent the current incoming packet. | +| [`remotePort`](#class_wi_fi_u_d_p_1a2ebb4b0e8fc1c4c147bd5936ff7ab250) | Return the port of the host who sent the current incoming packet. | + +## Members + +### `WiFiUDP` + +```cpp +WiFiUDP() +``` + +Default constructor for the [WiFiUDP](#class_wi_fi_u_d_p) class. + +
+ +### `begin` + +```cpp +virtual uint8_t begin(uint16_t) +``` + +Starts a UDP socket on the specified local port. + +#### Parameters +* `uint16_t` The local port number to bind the UDP socket to. + +#### Returns +Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. +
+ +### `begin` + +```cpp +virtual uint8_t begin(IPAddress a, uint16_t p) +``` + +Starts a UDP socket bound to a specific IP address and port. + +#### Parameters +* `a` The local IP address to bind the UDP socket to. + +* `p` The local port number to bind the UDP socket to. + +#### Returns +Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. +
+ +### `beginMulticast` + +```cpp +virtual uint8_t beginMulticast(IPAddress, uint16_t) +``` + +Starts a UDP multicast socket bound to a specific IP address and port. + +#### Parameters +* `IPAddress` The multicast IP address to bind the UDP socket to. + +* `uint16_t` The port number to bind the UDP socket to. + +#### Returns +Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. +
+ +### `stop` + +```cpp +virtual void stop() +``` + +Stops the UDP socket and releases its resources. + +
+ +### `beginMulticastPacket` + +```cpp +virtual int beginMulticastPacket() +``` + +Begins constructing a multicast UDP packet for sending. + +#### Returns +Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. +
+ +### `beginPacket` + +```cpp +virtual int beginPacket(IPAddress ip, uint16_t port) +``` + +Begins constructing a UDP packet for sending to a specific IP address and port. + +#### Parameters +* `ip` The destination IP address as an `IPAddress` object. + +* `port` The destination port number. + +#### Returns +Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. +
+ +### `beginPacket` + +```cpp +virtual int beginPacket(const char * host, uint16_t port) +``` + +Begins constructing a UDP packet for sending to a specific hostname and port. + +#### Parameters +* `host` The destination hostname as a null-terminated string. + +* `port` The destination port number. + +#### Returns +Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. +
+ +### `endPacket` + +```cpp +virtual int endPacket() +``` + +Completes the construction of a UDP packet and sends it to the specified destination. + +#### Returns +Returns `1` if the packet is successfully transmitted. Or `0` if there is an error or the socket is not initialized. +
+ +### `write` + +```cpp +virtual size_t write(uint8_t) +``` + +Sends a single byte of data to the currently opened UDP packet. + +#### Parameters +* `b` The byte of data to send. + +#### Returns +Returns `1` if the byte was successfully written. Or `0` if there was an error or the packet was not properly initialized. +
+ +### `write` + +```cpp +virtual size_t write(const uint8_t * buffer, size_t size) +``` + +Sends a buffer of data to the currently opened UDP packet. + +#### Parameters +* `buffer` A pointer to the buffer containing the data to send. + +* `size` The number of bytes from the buffer to write. + +#### Returns +Returns the number of bytes successfully written if the operation is successful. Or `0` if the data was not successfully written, or if the packet was not properly initialized. +
+ +### `parsePacket` + +```cpp +virtual int parsePacket() +``` + +Start processing the next available incoming packet. + +#### Returns +Returns the size of the incoming packet, or `0` if no packet is available. +
+ +### `available` + +```cpp +virtual int available() +``` + +Checks if there are any available UDP packets to read. + +#### Returns +Returns the number of available bytes if packets are available, or `0` if no packets are available. +
+ +### `read` + +```cpp +virtual int read() +``` + +Read a single byte from the current packet. + +#### Returns +Returns the number of bytes read into the buffer, or `-1` if an error occurs. +
+ +### `read` + +```cpp +virtual int read(unsigned char * buffer, size_t len) +``` + +Reads data from the UDP receive buffer into a provided buffer. + +#### Parameters +* `buffer` A pointer to the buffer where the received data will be stored. + +* `size` The number of bytes to read from the UDP buffer. + +#### Returns +The number of bytes successfully read into the buffer. If less than `size` bytes are read, it indicates that the buffer was exhausted early. +
+ +### `read` + +```cpp +inline virtual int read(char * buffer, size_t len) +``` + +Reads data from the UDP receive buffer into a character buffer. + +#### Parameters +* `buffer` A pointer to the character buffer where the received data will be stored. + +* `len` The number of bytes to read from the UDP buffer. + +#### Returns +The number of bytes successfully read into the buffer. If less than `len` bytes are read, it indicates that the buffer was exhausted early. +
+ +### `peek` + +```cpp +virtual int peek() +``` + +Peeks at the next byte available in the UDP buffer without moving on to the next byte. + +#### Returns +The value of the next byte in the UDP buffer, or `-1` if no data is available. +
+ +### `flush` + +```cpp +virtual void flush() +``` + +Finish reading the current packet. + +
+ +### `operator==` + +```cpp +virtual bool operator==(const WiFiUDP &) +``` + +Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for equality. + +This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are the same. + +#### Parameters +* `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. + +#### Returns +`true` if the socket values are equal, `false` otherwise. +
+ +### `operator!=` + +```cpp +inline virtual bool operator!=(const WiFiUDP & whs) +``` + +Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for inequality. + +This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are different. + +#### Parameters +* `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. + +#### Returns +`true` if the socket values are different, `false` otherwise. +
+ +### `remoteIP` + +```cpp +virtual IPAddress remoteIP() +``` + +Retrieves the remote IP address of the host who sent the current incoming packet. + +#### Returns +An `IPAddress` object representing the remote IP address. If the socket is not valid or the address cannot be retrieved, it returns `IPAddress(0, 0, 0, 0)`. +
+ +### `remotePort` + +```cpp +virtual uint16_t remotePort() +``` + +Return the port of the host who sent the current incoming packet. + +#### Returns +The remote port number as a `uint16_t`. If the socket is not valid or the port cannot be retrieved, it returns `0`. +
+ From 6b8ebbb7661d134b8ad0bf4b3ec23d8d835e3814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Mon, 9 Dec 2024 01:32:59 +0100 Subject: [PATCH 16/43] Fixed for formating --- libraries/WiFiS3/src/Modem.h | 2 +- libraries/WiFiS3/src/WiFi.h | 2 +- libraries/WiFiS3/src/WiFiClient.h | 12 +++---- libraries/WiFiS3/src/WiFiFileSystem.h | 2 +- libraries/WiFiS3/src/WiFiSSLClient.h | 46 +++++++++++++-------------- libraries/WiFiS3/src/WiFiServer.h | 29 +++++++++-------- libraries/WiFiS3/src/WiFiUdp.h | 6 ++-- 7 files changed, 50 insertions(+), 49 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index d937ab9b7..bf1751aa0 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -28,7 +28,7 @@ class ModemClass { /** * @brief Constructor for the ModemClass, which initializes the modem with the specified transmit (TX) and receive (RX) pins. * - * @param Initializes an instance of the `ModemClass` class with + * @param Initializes an instance of the ModemClass class with * specific transmit `tx` and receive `rx` pins for communication. */ ModemClass(int tx, int rx); diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index ae45c2812..350e4e54f 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -36,7 +36,7 @@ class CAccessPoint { /** * @brief Class to manage Wi-Fi connectivity and operations. * - * The `CWifi` class provides an interface to manage Wi-Fi operations such as connecting + * The CWifi class provides an interface to manage Wi-Fi operations such as connecting * to networks, setting up an access point, retrieving network information, and more. * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages * connection settings such as IP address, DNS, and other network configurations. diff --git a/libraries/WiFiS3/src/WiFiClient.h b/libraries/WiFiS3/src/WiFiClient.h index 50caa27e0..7f12ad8ee 100644 --- a/libraries/WiFiS3/src/WiFiClient.h +++ b/libraries/WiFiS3/src/WiFiClient.h @@ -34,12 +34,12 @@ /** * @brief Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. * - * The `WiFiClient` class allows for network communication over Wi-Fi, providing methods + * The WiFiClient class allows for network communication over Wi-Fi, providing methods * for establishing connections, sending and receiving data, and managing the client’s * socket state. This class is used to manage client connections in a Wi-Fi network, * either for communication or for network data transfer. * - * It inherits from the `Client` class, providing basic socket communication functionality. + * It inherits from the Client class, providing basic socket communication functionality. */ class WiFiClient : public Client { @@ -231,17 +231,17 @@ class WiFiClient : public Client { } /** - * @brief Declares `WiFiServer` as a friend class. + * @brief Declares WiFiServer as a friend class. * - * This allows the `WiFiServer` class to access private and protected members - * of the `WiFiClient` class. + * This allows the WiFiServer class to access private and protected members + * of the WiFiClient class. */ friend class WiFiServer; /** * @brief Inherits the `write` method from the `Print` class. * - * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * This allows the WiFiSSLClient class to use the `write` method defined in the * `Print` class. */ using Print::write; diff --git a/libraries/WiFiS3/src/WiFiFileSystem.h b/libraries/WiFiS3/src/WiFiFileSystem.h index 407317060..e03157654 100644 --- a/libraries/WiFiS3/src/WiFiFileSystem.h +++ b/libraries/WiFiS3/src/WiFiFileSystem.h @@ -34,7 +34,7 @@ class WiFiFileSystem { public: /** - * @brief Initializes objects of the `WiFiFileSystem` class. + * @brief Initializes objects of the WiFiFileSystem class. */ WiFiFileSystem(); diff --git a/libraries/WiFiS3/src/WiFiSSLClient.h b/libraries/WiFiS3/src/WiFiSSLClient.h index 9b6941f5d..2642c3d42 100644 --- a/libraries/WiFiS3/src/WiFiSSLClient.h +++ b/libraries/WiFiS3/src/WiFiSSLClient.h @@ -28,7 +28,7 @@ /** * @brief A specialized client class for secure SSL/TLS connections. * - * The `WiFiSSLClient` class extends the functionality of the `WiFiClient` class to provide secure + * The WiFiSSLClient class extends the functionality of the WiFiClient class to provide secure * communication over SSL/TLS protocols. It ensures encrypted and authenticated communication * between the client and a remote server. */ @@ -36,7 +36,7 @@ class WiFiSSLClient : public WiFiClient { public: /** - * @brief Initializes objects of the `WiFiSSLClient` class. + * @brief Initializes objects of the WiFiSSLClient class. */ WiFiSSLClient(); ~WiFiSSLClient(); @@ -58,7 +58,7 @@ class WiFiSSLClient : public WiFiClient { * @param `host` is the hostname or IP address of the server to connect to. * `port` is the port number to connect to. * - * @return Returns 1 if the connection is successfully established, 0 otherwise. + * @return Returns `1` if the connection is successfully established, `0` otherwise. */ virtual int connect(const char* host, uint16_t port); @@ -76,8 +76,8 @@ class WiFiSSLClient : public WiFiClient { * certificate for establishing secure SSL connections. * * @param `int ecc508KeySlot` specifies the ECC key slot to be used for the SSL connection. - * `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. - * `int certLength` specifies the length of the certificate data array. + * @param `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. + * @param `int certLength` specifies the length of the certificate data array. */ void setEccSlot(int ecc508KeySlot, const byte cert[], int certLength); @@ -86,8 +86,8 @@ class WiFiSSLClient : public WiFiClient { * * @param `b` is the byte to be sent. * - * @return size_t The number of bytes successfully written. Returns 1 if the byte - * was sent successfully, or 0 if an error occurred. + * @return The number of bytes successfully written. Returns `1` if the byte + * was sent successfully, or `0` if an error occurred. */ virtual size_t write(uint8_t); @@ -95,10 +95,10 @@ class WiFiSSLClient : public WiFiClient { * @brief Writes a buffer of data to the SSL connection. * * @param `buf` is a pointer to the buffer containing the data to be sent. - * `size` is the number of bytes to send from the buffer. + * @param `size` is the number of bytes to send from the buffer. * * @return Returns `size` if the data is successfully sent, - * or 0 if the transmission fails or the socket is invalid. + * or `0` if the transmission fails or the socket is invalid. */ virtual size_t write(const uint8_t *buf, size_t size); @@ -113,7 +113,7 @@ class WiFiSSLClient : public WiFiClient { * @brief Reads data from the SSL connection into the receive buffer. * * @return Returns the number of bytes successfully read into the buffer. Returns - * 0 if no data is received, or -1 if the socket is invalid or an error occurs. + * `0` if no data is received, or `-1` if the socket is invalid or an error occurs. */ virtual int read(); @@ -123,7 +123,7 @@ class WiFiSSLClient : public WiFiClient { * @param `buf` is a pointer to the buffer where the read data will be stored. * `size` is the maximum number of bytes to read into the buffer. * - * @return The number of bytes successfully read. Returns 0 if no data is + * @return The number of bytes successfully read. Returns `0` if no data is * available or an error occurs. */ virtual int read(uint8_t *buf, size_t size); @@ -134,7 +134,7 @@ class WiFiSSLClient : public WiFiClient { * This function queries the modem to retrieve the next byte available in the * SSL/TLS connection, allowing the byte to remain in the buffer for future reads. * - * @return The next byte available as an integer value (0–255), or -1 if + * @return The next byte available as an integer value (0–255), or `-1` if * the socket is invalid or no data is available. */ virtual int peek(); @@ -159,7 +159,7 @@ class WiFiSSLClient : public WiFiClient { * the modem for the connection status. It checks the validity of the socket * before proceeding with the query. * - * @return uint8_t Returns 1 if the client is connected, 0 otherwise. + * @return Returns `1` if the client is connected, `0` otherwise. */ virtual uint8_t connected(); @@ -177,7 +177,7 @@ class WiFiSSLClient : public WiFiClient { * * @param `WiFiSSLClient` object to compare. * - * @return `true` if both `WiFiSSLClient` objects are equivalent (i.e., they have the same socket), + * @return `true` if both WiFiSSLClient objects are equivalent (i.e., they have the same socket), * `false` otherwise. */ virtual bool operator==(const WiFiSSLClient&); @@ -189,7 +189,7 @@ class WiFiSSLClient : public WiFiClient { * to determine if they are not equal, based on their underlying socket or connection. * * @param `whs` The WiFiSSLClient object to compare with. - * @return `true` if the two `WiFiSSLClient` objects do not represent the same connection (i.e., have different sockets), + * @return `true` if the two WiFiSSLClient objects do not represent the same connection (i.e., have different sockets), * `false` otherwise. */ virtual bool operator!=(const WiFiSSLClient& whs) @@ -203,7 +203,7 @@ class WiFiSSLClient : public WiFiClient { * This function queries the modem for the remote IP address associated with * the current connection. * - * @return The remote IP address of the client. Returns 0.0.0.0 if the + * @return The remote IP address of the client. Returns `0.0.0.0` if the * socket is not valid or the query fails. */ virtual IPAddress remoteIP(); @@ -214,25 +214,25 @@ class WiFiSSLClient : public WiFiClient { * This function queries the modem to obtain the remote port number associated * with the current connection. * - * @return Returns the remote port number of the client. Returns 0 if the socket + * @return Returns the remote port number of the client. Returns `0` if the socket * is not valid or the query fails. */ virtual uint16_t remotePort(); /** - * @brief Declares `WiFiServer` as a friend class. + * @brief Declares WiFiServer as a friend class. * - * This allows the `WiFiServer` class to access private and protected members - * of the `WiFiSSLClient` class. + * This allows the WiFiServer class to access private and protected members + * of the WiFiSSLClient class. */ friend class WiFiServer; /** - * @brief Inherits the `write` method from the `Print` class. + * @brief Inherits the `write` method from the Print class. * - * This allows the `WiFiSSLClient` class to use the `write` method defined in the - * `Print` class. + * This allows the WiFiSSLClient class to use the `write` method defined in the + * Print class. */ using Print::write; diff --git a/libraries/WiFiS3/src/WiFiServer.h b/libraries/WiFiS3/src/WiFiServer.h index cdf27d03f..fe212a246 100644 --- a/libraries/WiFiS3/src/WiFiServer.h +++ b/libraries/WiFiS3/src/WiFiServer.h @@ -29,7 +29,7 @@ /** * @brief A class that provides server functionality for WiFi-based communication. * - * The `WiFiServer` class inherits from the `Server` class and extends its functionality + * The WiFiServer class inherits from the Server class and extends its functionality * to create and manage a server over a WiFi connection. This class allows for accepting * incoming client connections, handling data communication, and closing connections * in a networked environment. @@ -42,12 +42,12 @@ class WiFiServer : public Server { public: /** - * @brief Initializes objects of the `WiFiServer` class. + * @brief Initializes objects of the WiFiServer class. */ WiFiServer(); /** - * @brief Constructs a `WiFiServer` object with the specified port. + * @brief Constructs a WiFiServer object with the specified port. * * @param `p` The port number on which the server will listen for incoming connections. */ @@ -61,7 +61,7 @@ class WiFiServer : public Server { * the client. It uses the modem to query the server for an available client * socket and accepts the connection if a valid client is found. * - * @return Returns a `WiFiClient` object representing the next client connection that is available + * @return Returns a WiFiClient object representing the next client connection that is available * for processing. */ WiFiClient available(); @@ -69,7 +69,7 @@ class WiFiServer : public Server { /** * @brief Accepts an incoming client connection on the server. * - * @return Returns a `WiFiClient` object representing the accepted client. + * @return Returns a WiFiClient object representing the accepted client. */ WiFiClient accept(); @@ -120,9 +120,9 @@ class WiFiServer : public Server { void end(); /** - * @brief Converts the `WiFiSSLClient` object to a boolean value. + * @brief Converts the WiFiSSLClient object to a boolean value. * - * This operator allows a `WiFiSSLClient` object to be implicitly or explicitly + * This operator allows a WiFiSSLClient object to be implicitly or explicitly * converted to a boolean. It checks whether the client socket is valid (i.e., * `_sock != -1`). * @@ -131,20 +131,21 @@ class WiFiServer : public Server { explicit operator bool(); /** - * @brief Compares two `WiFiServer` objects for equality. + * @brief Compares two WiFiServer objects for equality. * * This virtual operator compares the underlying socket (`_sock`) of two `WiFiServer` * objects to determine if they refer to the same server connection. * - * @param `WiFiServer` object to compare against. - * @return `true` if both `WiFiServer` objects have the same socket; `false` otherwise. + * @param WiFiServer object to compare against. + * + * @return `true` if both WiFiServer objects have the same socket; `false` otherwise. */ virtual bool operator==(const WiFiServer&); /** - * @brief Compares two `WiFiServer` objects for inequality. + * @brief Compares two WiFiServer objects for inequality. * - * This virtual operator compares the underlying socket (`_sock`) of two `WiFiServer` + * This virtual operator compares the underlying socket (`_sock`) of two WiFiServer * objects. It returns `true` if the objects do not refer to the same server connection * (i.e., they have different socket values), and `false` otherwise. * @@ -159,13 +160,13 @@ class WiFiServer : public Server { /** * @brief Inherits the `write` method from the `Print` class. * - * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * This allows the WiFiSSLClient class to use the `write` method defined in the * `Print` class. */ using Print::write; /** - * @brief Grants `WiFiClient` class access to private and protected members of `WiFiServer`. + * @brief Grants WiFiClient class access to private and protected members of WiFiServer. */ friend class WiFiClient; }; diff --git a/libraries/WiFiS3/src/WiFiUdp.h b/libraries/WiFiS3/src/WiFiUdp.h index adbff4e5b..d042efea1 100644 --- a/libraries/WiFiS3/src/WiFiUdp.h +++ b/libraries/WiFiS3/src/WiFiUdp.h @@ -33,7 +33,7 @@ /** * @brief A class for handling UDP communication over a Wi-Fi network. * - * The `WiFiUDP` class is an extension of the `UDP` class that enables sending and receiving UDP packets + * The WiFiUDP class is an extension of the UDP class that enables sending and receiving UDP packets * over a Wi-Fi network. It provides functions for initialization, packet transmission, and reception * tailored for Wi-Fi connectivity. */ @@ -150,9 +150,9 @@ class WiFiUDP : public UDP { virtual size_t write(const uint8_t *buffer, size_t size); /** - * @brief Inherits the `write` method from the `Print` class. + * @brief Inherits the `write` method from the Print class. * - * This allows the `WiFiSSLClient` class to use the `write` method defined in the + * This allows the WiFiSSLClient class to use the `write` method defined in the * `Print` class. */ using Print::write; From be2e2fbe0715f2ec36b7b22ec3e0906c4c680e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Mon, 9 Dec 2024 01:38:41 +0100 Subject: [PATCH 17/43] Fixed api docs file --- libraries/WiFiS3/docs/api.md | 84 +++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/libraries/WiFiS3/docs/api.md b/libraries/WiFiS3/docs/api.md index c7f0b06f6..003459ecf 100644 --- a/libraries/WiFiS3/docs/api.md +++ b/libraries/WiFiS3/docs/api.md @@ -78,7 +78,7 @@ std::string encryption_mode Class to manage Wi-Fi connectivity and operations. -The `[CWifi](#class_c_wifi)` class provides an interface to manage Wi-Fi operations such as connecting to networks, setting up an access point, retrieving network information, and more. It interfaces with a modem to execute commands related to Wi-Fi functionality and manages connection settings such as IP address, DNS, and other network configurations. +The [CWifi](#class_c_wifi) class provides an interface to manage Wi-Fi operations such as connecting to networks, setting up an access point, retrieving network information, and more. It interfaces with a modem to execute commands related to Wi-Fi functionality and manages connection settings such as IP address, DNS, and other network configurations. ## Summary @@ -726,7 +726,7 @@ ModemClass(int tx, int rx) Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified transmit (TX) and receive (RX) pins. #### Parameters -* `Initializes` an instance of the `[ModemClass](#class_modem_class)` class with specific transmit `tx` and receive `rx` pins for communication. +* `Initializes` an instance of the [ModemClass](#class_modem_class) class with specific transmit `tx` and receive `rx` pins for communication.
### `ModemClass` @@ -888,7 +888,7 @@ Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. The [WiFiClient](#class_wi_fi_client) class allows for network communication over Wi-Fi, providing methods for establishing connections, sending and receiving data, and managing the client’s socket state. This class is used to manage client connections in a Wi-Fi network, either for communication or for network data transfer. -It inherits from the `Client` class, providing basic socket communication functionality. +It inherits from the Client class, providing basic socket communication functionality. ## Summary @@ -1208,7 +1208,7 @@ This class provides functionality for managing files on a WiFi-connected device, Members | Descriptions --------------------------------|--------------------------------------------- -| [`WiFiFileSystem`](#class_wi_fi_file_system_1af4d9123dd9631c69853070498afb41a2) | Initializes objects of the `[WiFiFileSystem](#class_wi_fi_file_system)` class. | +| [`WiFiFileSystem`](#class_wi_fi_file_system_1af4d9123dd9631c69853070498afb41a2) | Initializes objects of the [WiFiFileSystem](#class_wi_fi_file_system) class. | | [`mount`](#class_wi_fi_file_system_1aa5baed674db176f774488b50fa35c3d1) | Mounts the file system and optionally formats it on failure. | | [`writefile`](#class_wi_fi_file_system_1a0121ce8d9a1b9d4a53e7b7ea7ecc4c1c) | Writes data to a file in the file system. | | [`readfile`](#class_wi_fi_file_system_1acd3d52b7a20f5f65b7ca28dbb7b04343) | Reads a file from the file system and prints its content. | @@ -1221,7 +1221,7 @@ This class provides functionality for managing files on a WiFi-connected device, WiFiFileSystem() ``` -Initializes objects of the `[WiFiFileSystem](#class_wi_fi_file_system)` class. +Initializes objects of the [WiFiFileSystem](#class_wi_fi_file_system) class.
@@ -1275,14 +1275,14 @@ class WiFiServer A class that provides server functionality for WiFi-based communication. -The `[WiFiServer](#class_wi_fi_server)` class inherits from the `Server` class and extends its functionality to create and manage a server over a WiFi connection. This class allows for accepting incoming client connections, handling data communication, and closing connections in a networked environment. +The [WiFiServer](#class_wi_fi_server) class inherits from the Server class and extends its functionality to create and manage a server over a WiFi connection. This class allows for accepting incoming client connections, handling data communication, and closing connections in a networked environment. ## Summary Members | Descriptions --------------------------------|--------------------------------------------- -| [`WiFiServer`](#class_wi_fi_server_1acfa8226decf3a818dfbd45ec7940280a) | Initializes objects of the `[WiFiServer](#class_wi_fi_server)` class. | -| [`WiFiServer`](#class_wi_fi_server_1a63b71b18a7011b40fb86d893bc4c72fd) | Constructs a `[WiFiServer](#class_wi_fi_server)` object with the specified port. | +| [`WiFiServer`](#class_wi_fi_server_1acfa8226decf3a818dfbd45ec7940280a) | Initializes objects of the [WiFiServer](#class_wi_fi_server) class. | +| [`WiFiServer`](#class_wi_fi_server_1a63b71b18a7011b40fb86d893bc4c72fd) | Constructs a [WiFiServer](#class_wi_fi_server) object with the specified port. | | [`available`](#class_wi_fi_server_1abfd839b75fa3c40bd5e22c4a122ed800) | Checks if there are any incoming client connections waiting to be accepted. | | [`accept`](#class_wi_fi_server_1ad29b9a043c87bad43140cc3066210088) | Accepts an incoming client connection on the server. | | [`begin`](#class_wi_fi_server_1a52e68fa8b767579e5055de9ff072f08c) | Starts the Wi-Fi server and binds it to the specified port. | @@ -1290,9 +1290,9 @@ The `[WiFiServer](#class_wi_fi_server)` class inherits from the `Server` class a | [`write`](#class_wi_fi_server_1ad3d206415f9733dee2170f136b909e54) | Writes a single byte to all connected clients. | | [`write`](#class_wi_fi_server_1a6bef9499519bcedd59379024c4e7b360) | Writes data to all connected clients. | | [`end`](#class_wi_fi_server_1a26d44e7107a4121589f96b505c73593d) | Ends the Wi-Fi server and closes the server socket. | -| [`operator bool`](#class_wi_fi_server_1a1cca17be23aad6b7dce5fc2315226e5d) | Converts the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to a boolean value. | -| [`operator==`](#class_wi_fi_server_1a6e3fc602a5e129d19e6fa5076419511f) | Compares two `[WiFiServer](#class_wi_fi_server)` objects for equality. | -| [`operator!=`](#class_wi_fi_server_1a3b34f02716dd23e22b85585b4d648169) | Compares two `[WiFiServer](#class_wi_fi_server)` objects for inequality. | +| [`operator bool`](#class_wi_fi_server_1a1cca17be23aad6b7dce5fc2315226e5d) | Converts the [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to a boolean value. | +| [`operator==`](#class_wi_fi_server_1a6e3fc602a5e129d19e6fa5076419511f) | Compares two [WiFiServer](#class_wi_fi_server) objects for equality. | +| [`operator!=`](#class_wi_fi_server_1a3b34f02716dd23e22b85585b4d648169) | Compares two [WiFiServer](#class_wi_fi_server) objects for inequality. | ## Members @@ -1302,7 +1302,7 @@ The `[WiFiServer](#class_wi_fi_server)` class inherits from the `Server` class a WiFiServer() ``` -Initializes objects of the `[WiFiServer](#class_wi_fi_server)` class. +Initializes objects of the [WiFiServer](#class_wi_fi_server) class.
@@ -1312,7 +1312,7 @@ Initializes objects of the `[WiFiServer](#class_wi_fi_server)` class. WiFiServer(int p) ``` -Constructs a `[WiFiServer](#class_wi_fi_server)` object with the specified port. +Constructs a [WiFiServer](#class_wi_fi_server) object with the specified port. #### Parameters * `p` The port number on which the server will listen for incoming connections. @@ -1329,7 +1329,7 @@ Checks if there are any incoming client connections waiting to be accepted. This function queries the server to check if there is a client waiting to be accepted. If a client is available, it returns a `[WiFiClient](#class_wi_fi_client)` object representing the client. It uses the modem to query the server for an available client socket and accepts the connection if a valid client is found. #### Returns -Returns a `[WiFiClient](#class_wi_fi_client)` object representing the next client connection that is available for processing. +Returns a [WiFiClient](#class_wi_fi_client) object representing the next client connection that is available for processing.
### `accept` @@ -1341,7 +1341,7 @@ WiFiClient accept() Accepts an incoming client connection on the server. #### Returns -Returns a `[WiFiClient](#class_wi_fi_client)` object representing the accepted client. +Returns a [WiFiClient](#class_wi_fi_client) object representing the accepted client.
### `begin` @@ -1413,9 +1413,9 @@ This function terminates the server by sending a command to the modem to close t explicit operator bool() ``` -Converts the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to a boolean value. +Converts the [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to a boolean value. -This operator allows a `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to be implicitly or explicitly converted to a boolean. It checks whether the client socket is valid (i.e., `_sock != -1`). +This operator allows a [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to be implicitly or explicitly converted to a boolean. It checks whether the client socket is valid (i.e., `_sock != -1`). #### Returns `true` if the server socket is valid (server is running), `false` otherwise. @@ -1427,15 +1427,15 @@ This operator allows a `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to be virtual bool operator==(const WiFiServer &) ``` -Compares two `[WiFiServer](#class_wi_fi_server)` objects for equality. +Compares two [WiFiServer](#class_wi_fi_server) objects for equality. This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServer](#class_wi_fi_server)` objects to determine if they refer to the same server connection. #### Parameters -* `WiFiServer` object to compare against. +* `[WiFiServer](#class_wi_fi_server)` object to compare against. #### Returns -`true` if both `[WiFiServer](#class_wi_fi_server)` objects have the same socket; `false` otherwise. +`true` if both [WiFiServer](#class_wi_fi_server) objects have the same socket; `false` otherwise.
### `operator!=` @@ -1444,9 +1444,9 @@ This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServ inline virtual bool operator!=(const WiFiServer & whs) ``` -Compares two `[WiFiServer](#class_wi_fi_server)` objects for inequality. +Compares two [WiFiServer](#class_wi_fi_server) objects for inequality. -This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServer](#class_wi_fi_server)` objects. It returns `true` if the objects do not refer to the same server connection (i.e., they have different socket values), and `false` otherwise. +This virtual operator compares the underlying socket (`_sock`) of two [WiFiServer](#class_wi_fi_server) objects. It returns `true` if the objects do not refer to the same server connection (i.e., they have different socket values), and `false` otherwise. #### Parameters * `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. @@ -1464,13 +1464,13 @@ class WiFiSSLClient A specialized client class for secure SSL/TLS connections. -The `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class extends the functionality of the `[WiFiClient](#class_wi_fi_client)` class to provide secure communication over SSL/TLS protocols. It ensures encrypted and authenticated communication between the client and a remote server. +The [WiFiSSLClient](#class_wi_fi_s_s_l_client) class extends the functionality of the [WiFiClient](#class_wi_fi_client) class to provide secure communication over SSL/TLS protocols. It ensures encrypted and authenticated communication between the client and a remote server. ## Summary Members | Descriptions --------------------------------|--------------------------------------------- -| [`WiFiSSLClient`](#class_wi_fi_s_s_l_client_1aeecf408e130c75ca84c9e41f7cf708aa) | Initializes objects of the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class. | +| [`WiFiSSLClient`](#class_wi_fi_s_s_l_client_1aeecf408e130c75ca84c9e41f7cf708aa) | Initializes objects of the [WiFiSSLClient](#class_wi_fi_s_s_l_client) class. | | [`~WiFiSSLClient`](#class_wi_fi_s_s_l_client_1afe721b778749143fe61fdfff259218af) | | | [`connect`](#class_wi_fi_s_s_l_client_1a82ed27a660bb90559c0467920182c947) | Establishes a secure SSL connection to a specified IP address and port. | | [`connect`](#class_wi_fi_s_s_l_client_1a46375064a7f581ba072e67bdc68be494) | Establishes a secure SSL connection to a specified host and port. | @@ -1499,7 +1499,7 @@ The `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class extends the functionality WiFiSSLClient() ``` -Initializes objects of the `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` class. +Initializes objects of the [WiFiSSLClient](#class_wi_fi_s_s_l_client) class.
@@ -1538,7 +1538,7 @@ Establishes a secure SSL connection to a specified host and port. * `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. #### Returns -Returns 1 if the connection is successfully established, 0 otherwise. +Returns `1` if the connection is successfully established, `0` otherwise.
### `setCACert` @@ -1562,7 +1562,11 @@ void setEccSlot(int ecc508KeySlot, const byte cert, int certLength) Sets the ECC (Elliptic Curve Cryptography) key slot and certificate for establishing secure SSL connections. #### Parameters -* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. `const byte cert[]` is a pointer to the certificate data in the form of an array of bytes. `int certLength` specifies the length of the certificate data array. +* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. + +* `const` byte cert[] is a pointer to the certificate data in the form of an array of bytes. + +* `int` certLength specifies the length of the certificate data array.
### `write` @@ -1577,7 +1581,7 @@ Writes a single byte of data to the SSL connection. * `b` is the byte to be sent. #### Returns -size_t The number of bytes successfully written. Returns 1 if the byte was sent successfully, or 0 if an error occurred. +The number of bytes successfully written. Returns `1` if the byte was sent successfully, or `0` if an error occurred.
### `write` @@ -1589,10 +1593,12 @@ virtual size_t write(const uint8_t * buf, size_t size) Writes a buffer of data to the SSL connection. #### Parameters -* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to send from the buffer. +* `buf` is a pointer to the buffer containing the data to be sent. + +* `size` is the number of bytes to send from the buffer. #### Returns -Returns `size` if the data is successfully sent, or 0 if the transmission fails or the socket is invalid. +Returns `size` if the data is successfully sent, or `0` if the transmission fails or the socket is invalid.
### `available` @@ -1616,7 +1622,7 @@ virtual int read() Reads data from the SSL connection into the receive buffer. #### Returns -Returns the number of bytes successfully read into the buffer. Returns 0 if no data is received, or -1 if the socket is invalid or an error occurs. +Returns the number of bytes successfully read into the buffer. Returns `0` if no data is received, or `-1` if the socket is invalid or an error occurs.
### `read` @@ -1631,7 +1637,7 @@ Reads a specified number of bytes from the SSL connection into a buffer. * `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. #### Returns -The number of bytes successfully read. Returns 0 if no data is available or an error occurs. +The number of bytes successfully read. Returns `0` if no data is available or an error occurs.
### `peek` @@ -1645,7 +1651,7 @@ Peeks at the next byte available from the SSL connection without removing it. This function queries the modem to retrieve the next byte available in the SSL/TLS connection, allowing the byte to remain in the buffer for future reads. #### Returns -The next byte available as an integer value (0–255), or -1 if the socket is invalid or no data is available. +The next byte available as an integer value (0–255), or `-1` if the socket is invalid or no data is available.
### `flush` @@ -1680,7 +1686,7 @@ Checks if the SSL/TLS connection is active. This function determines if the SSL/TLS client is still connected by querying the modem for the connection status. It checks the validity of the socket before proceeding with the query. #### Returns -uint8_t Returns 1 if the client is connected, 0 otherwise. +Returns `1` if the client is connected, `0` otherwise.
### `operator bool` @@ -1707,7 +1713,7 @@ Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_ * `WiFiSSLClient` object to compare. #### Returns -`true` if both `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects are equivalent (i.e., they have the same socket), `false` otherwise. +`true` if both [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects are equivalent (i.e., they have the same socket), `false` otherwise.
### `operator!=` @@ -1724,7 +1730,7 @@ This operator compares the current `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` * `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. #### Returns -`true` if the two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects do not represent the same connection (i.e., have different sockets), `false` otherwise. +`true` if the two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects do not represent the same connection (i.e., have different sockets), `false` otherwise.
### `remoteIP` @@ -1738,7 +1744,7 @@ Retrieves the remote IP address of the WiFi SSL client. This function queries the modem for the remote IP address associated with the current connection. #### Returns -The remote IP address of the client. Returns 0.0.0.0 if the socket is not valid or the query fails. +The remote IP address of the client. Returns `0.0.0.0` if the socket is not valid or the query fails.
### `remotePort` @@ -1752,7 +1758,7 @@ Retrieves the remote port number of the WiFi SSL client. This function queries the modem to obtain the remote port number associated with the current connection. #### Returns -Returns the remote port number of the client. Returns 0 if the socket is not valid or the query fails. +Returns the remote port number of the client. Returns `0` if the socket is not valid or the query fails.
# class `WiFiUDP` @@ -1764,7 +1770,7 @@ class WiFiUDP A class for handling UDP communication over a Wi-Fi network. -The `[WiFiUDP](#class_wi_fi_u_d_p)` class is an extension of the `UDP` class that enables sending and receiving UDP packets over a Wi-Fi network. It provides functions for initialization, packet transmission, and reception tailored for Wi-Fi connectivity. +The [WiFiUDP](#class_wi_fi_u_d_p) class is an extension of the UDP class that enables sending and receiving UDP packets over a Wi-Fi network. It provides functions for initialization, packet transmission, and reception tailored for Wi-Fi connectivity. ## Summary From 20a201013fe7d3415c24ac8546bf830b0ce9fbc1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 10 Dec 2024 10:27:17 +0000 Subject: [PATCH 18/43] Update documentation --- libraries/WiFiS3/docs/api.md | 963 ++--------------------------------- 1 file changed, 47 insertions(+), 916 deletions(-) diff --git a/libraries/WiFiS3/docs/api.md b/libraries/WiFiS3/docs/api.md index 003459ecf..b38b63d7c 100644 --- a/libraries/WiFiS3/docs/api.md +++ b/libraries/WiFiS3/docs/api.md @@ -2,881 +2,12 @@ Members | Descriptions --------------------------------|--------------------------------------------- -`class ` [`CAccessPoint`](#class_c_access_point) | -`class ` [`CWifi`](#class_c_wifi) | Class to manage Wi-Fi connectivity and operations. -`class ` [`ModemClass`](#class_modem_class) | A class that provides methods to interact with a modem. `class ` [`WiFiClient`](#class_wi_fi_client) | Represents a Wi-Fi client that connects to a remote server over a Wi-Fi network. `class ` [`WiFiFileSystem`](#class_wi_fi_file_system) | Class that handles the WiFi file system operations. `class ` [`WiFiServer`](#class_wi_fi_server) | A class that provides server functionality for WiFi-based communication. `class ` [`WiFiSSLClient`](#class_wi_fi_s_s_l_client) | A specialized client class for secure SSL/TLS connections. `class ` [`WiFiUDP`](#class_wi_fi_u_d_p) | A class for handling UDP communication over a Wi-Fi network. -# class `CAccessPoint` - -## Summary - - Members | Descriptions ---------------------------------|--------------------------------------------- -| [`ssid`](#class_c_access_point_1ac0161f0bae3c82f5caed8b05898fc49e) | | -| [`bssid`](#class_c_access_point_1ad1bc1d6e1bee842a46ffdc408fa59947) | | -| [`uint_bssid`](#class_c_access_point_1a5cf478e57a7138a1490b231b2aeb9c3e) | | -| [`rssi`](#class_c_access_point_1a7b5640ed8c2ed9f62e38051ffe8fe6a0) | | -| [`channel`](#class_c_access_point_1aa95219f17673f68cf3b1c6e17345b0e4) | | -| [`encryption_mode`](#class_c_access_point_1ac293ee77db560b0cda65d91374249412) | | - -## Members - -### `ssid` - -```cpp -std::string ssid -``` - -
- -### `bssid` - -```cpp -std::string bssid -``` - -
- -### `uint_bssid` - -```cpp -uint8_t uint_bssid -``` - -
- -### `rssi` - -```cpp -std::string rssi -``` - -
- -### `channel` - -```cpp -std::string channel -``` - -
- -### `encryption_mode` - -```cpp -std::string encryption_mode -``` - -
- -# class `CWifi` - -Class to manage Wi-Fi connectivity and operations. - -The [CWifi](#class_c_wifi) class provides an interface to manage Wi-Fi operations such as connecting to networks, setting up an access point, retrieving network information, and more. It interfaces with a modem to execute commands related to Wi-Fi functionality and manages connection settings such as IP address, DNS, and other network configurations. - -## Summary - - Members | Descriptions ---------------------------------|--------------------------------------------- -| [`CWifi`](#class_c_wifi_1a64b74dbe44a73d1b7fd4618b5b606c02) | Default constructor for the [CWifi](#class_c_wifi) class. | -| [`begin`](#class_c_wifi_1a9c4fc0f23a197e9dc5ddf02bc1793c35) | Start WiFi connection for OPEN networks. | -| [`begin`](#class_c_wifi_1a4a2bf8820b00494648188c7c06871a26) | start WiFi connection with passphrase the most secure supported mode will be automatically selected. | -| [`beginAP`](#class_c_wifi_1adeaffb4fe03faf22e7f69697d5e83492) | | -| [`beginAP`](#class_c_wifi_1ae9059d5f875a96b5cdf19d2cf87e9848) | Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. | -| [`beginAP`](#class_c_wifi_1aee76c2fbb9f83a3f085b034e80c1025c) | Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. | -| [`beginAP`](#class_c_wifi_1a9e1257e9b28cd3489209d7c7d5ea8845) | Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. | -| [`config`](#class_c_wifi_1a75742aab24859611b36e74e08602dc47) | Change IP configuration settings disabling the DHCP client. | -| [`config`](#class_c_wifi_1ac799224e1f9c65e4808e2c8deb802ead) | Configures the network settings for the Wi-Fi connection with a specified DNS server. | -| [`config`](#class_c_wifi_1acd5a6e9bb901fb4dbaec311378f99eb6) | Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server. | -| [`config`](#class_c_wifi_1afc80a6fd238b6d0e59aebb2d27ec8e9e) | Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server. | -| [`setDNS`](#class_c_wifi_1a4043b10b6a83cb3add95e127c79056a0) | Sets the primary DNS server for the Wi-Fi connection. | -| [`setDNS`](#class_c_wifi_1adaa95a2dd3a8bab54080669e612f9d37) | Sets the primary and secondary DNS servers for the Wi-Fi connection. | -| [`setHostname`](#class_c_wifi_1aece8d82cb1f1a55c0c22a606d66f8ea7) | Sets the hostname for for DHCP requests. | -| [`disconnect`](#class_c_wifi_1a59591cd8450c695f3588df818fb58d34) | Disconnects from the current Wi-Fi network. | -| [`end`](#class_c_wifi_1a50a8e7ca94f40d31ea5c9b2def045575) | Resets and disables the Wi-Fi module. | -| [`macAddress`](#class_c_wifi_1a58ebcdba481cc413f32f06226dba8481) | Retrieves the MAC address of the device. | -| [`localIP`](#class_c_wifi_1ae6885ef712d13bfcfe54a23f28b2aecb) | Retrieves the local IP address of the device. | -| [`subnetMask`](#class_c_wifi_1afcdd6b286e90258b5296c8f30f4e7c81) | Retrieves the subnet mask of the device. | -| [`gatewayIP`](#class_c_wifi_1a775e014fc255686df09b1f40f6cb9453) | Retrieves the gateway IP address of the device. | -| [`dnsIP`](#class_c_wifi_1a3ee65c20906927f5772b96386d6b5700) | Retrieves the DNS IP address. | -| [`softAPIP`](#class_c_wifi_1a6e64918a2784cb53588f1553c97dc333) | Retrieves the IP address of the soft access point (AP). | -| [`SSID`](#class_c_wifi_1a46c576561933d9f067121b81ab8b3806) | Retrieves the SSID of the current Wi-Fi connection or SoftAP. | -| [`BSSID`](#class_c_wifi_1a9b153ec8de3bd6e95255e94140314ad2) | Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. | -| [`RSSI`](#class_c_wifi_1a39a8f1b67aee1a1f52d8c0f2085ebb52) | Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. | -| [`softAPSSID`](#class_c_wifi_1accf0212b364b4686a4d47f7e6f58485b) | Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. | -| [`scanNetworks`](#class_c_wifi_1af31d8a0baaa568178e2091b7a9e830a1) | Scans for available Wi-Fi networks and stores the information in the `access_points` list. | -| [`SSID`](#class_c_wifi_1a452fefff75ab36097d6f4b6ad401ffcb) | Retrieves the SSID of a specific Wi-Fi network from the scan results. | -| [`encryptionType`](#class_c_wifi_1ab434b47d2935bf6d0b58ec50d78c3799) | Returns the encryption type for a specified network. | -| [`encryptionType`](#class_c_wifi_1a8da9fb03f5349f7887d3cdda3268ed8c) | Returns the encryption type of the currently connected Wi-Fi network. | -| [`BSSID`](#class_c_wifi_1a10793238a64c312f2652b710c693022e) | Retrieves the BSSID of a specific Wi-Fi network. | -| [`channel`](#class_c_wifi_1a871866aab35d3c10b98e27e51b37d8b6) | Retrieves the channel number of a specific Wi-Fi network. | -| [`RSSI`](#class_c_wifi_1a86ecf1c49591c18296a6d1b1400954e5) | Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. | -| [`status`](#class_c_wifi_1aeeddb0fe0a897d043415a97d363f68e0) | Retrieves the current connection status of the Wi-Fi connection. | -| [`reasonCode`](#class_c_wifi_1a453afce0d716bb1b92c3d73ba4f621e4) | Retrieves The deauthentication reason code. | -| [`hostByName`](#class_c_wifi_1a97ef95bf4e58c3c11a88ab03a4702425) | Resolves a hostname to an IP address. | -| [`getTime`](#class_c_wifi_1a9c3f3a794a063c20b9ef81851226a625) | Retrieves the current time from the modem. | -| [`setTimeout`](#class_c_wifi_1a53250475083a7537de61d2fc14217345) | Sets the timeout value for the WiFi connection. | -| [`firmwareVersion`](#class_c_wifi_1a4b2746f36f799c1e075d8f083b8bd6ee) | Get firmware version. | - -## Members - -### `CWifi` - -```cpp -CWifi() -``` - -Default constructor for the [CWifi](#class_c_wifi) class. - -
- -### `begin` - -```cpp -int begin(const char * ssid) -``` - -Start WiFi connection for OPEN networks. - -#### Parameters -* `ssid` a pointer to the SSID string. -
- -### `begin` - -```cpp -int begin(const char * ssid, const char * passphrase) -``` - -start WiFi connection with passphrase the most secure supported mode will be automatically selected. - -#### Parameters -* `ssid` Pointer to the SSID string. - -* `passphrase` Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal). -
- -### `beginAP` - -```cpp -uint8_t beginAP(const char * ssid) -``` - -
- -### `beginAP` - -```cpp -uint8_t beginAP(const char * ssid, uint8_t channel) -``` - -Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. - -This function initializes a Wi-Fi Access Point (AP) with the provided SSID and channel. It defaults to using no password (open network). - -#### Parameters -* `ssid` The SSID (name) of the Wi-Fi Access Point. - -* `channel` The channel on which the Access Point will operate. - -#### Returns -`1` if the Access Point is successfully started. `0` if the Access Point failed to start. -
- -### `beginAP` - -```cpp -uint8_t beginAP(const char * ssid, const char * passphrase) -``` - -Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. - -This function initializes a Wi-Fi Access Point (AP) using the provided SSID and passphrase, defaulting to channel 1. - -#### Parameters -* `ssid` The SSID (name) of the Wi-Fi Access Point. - -* `passphrase` The passphrase for securing the Access Point. If empty, the network will be open (no password). - -#### Returns -`1` if the Access Point is successfully started. `0` if the Access Point failed to start. -
- -### `beginAP` - -```cpp -uint8_t beginAP(const char * ssid, const char * passphrase, uint8_t channel) -``` - -Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. - -This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. It sets the mode to AP and attempts to start the network. - -#### Parameters -* `ssid` The SSID (name) of the Wi-Fi Access Point. - -* `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. - -* `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). - -#### Returns -`WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start. -
- -### `config` - -```cpp -void config(IPAddress local_ip) -``` - -Change IP configuration settings disabling the DHCP client. - -#### Parameters -* `local_ip` The static IP address to assign to the device. -
- -### `config` - -```cpp -void config(IPAddress local_ip, IPAddress dns_server) -``` - -Configures the network settings for the Wi-Fi connection with a specified DNS server. - -Sets the device's IP configuration using the specified local IP address and DNS server. The gateway and subnet mask are set to default values based on the provided local IP. - -#### Parameters -* `local_ip` The static IP address to assign to the device. - -* `dns_server` The primary DNS server to use for domain name resolution. -
- -### `config` - -```cpp -void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway) -``` - -Configures the network settings for the Wi-Fi connection with a specified gateway and DNS server. - -#### Parameters -* `local_ip` The static IP address to assign to the device. - -* `dns_server` The primary DNS server to use for domain name resolution. - -* `gateway` The Static gateway used for configuration. -
- -### `config` - -```cpp -void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) -``` - -Configures the network settings for the Wi-Fi connection with a specified subnet mask, gateway, and DNS server. - -#### Parameters -* `local_ip` The static IP address to assign to the device. - -* `dns_server` The primary DNS server to use for domain name resolution. - -* `gateway` The static gateway used for configuration. - -* `subnet` The static subnet mask to use for the network. -
- -### `setDNS` - -```cpp -void setDNS(IPAddress dns_server1) -``` - -Sets the primary DNS server for the Wi-Fi connection. - -#### Parameters -* `dns_server1` The primary DNS server to use for domain name resolution. -
- -### `setDNS` - -```cpp -void setDNS(IPAddress dns_server1, IPAddress dns_server2) -``` - -Sets the primary and secondary DNS servers for the Wi-Fi connection. - -#### Parameters -* `dns_server1` sets the IP configuration for DNS server 1 - -* `dns_server2` sets the IP configuration for DNS server 2 -
- -### `setHostname` - -```cpp -void setHostname(const char * name) -``` - -Sets the hostname for for DHCP requests. - -#### Parameters -* `name` sets the hostname. -
- -### `disconnect` - -```cpp -int disconnect(void) -``` - -Disconnects from the current Wi-Fi network. - -#### Returns -`1` if the disconnection was successful, `0` otherwise. -
- -### `end` - -```cpp -void end(void) -``` - -Resets and disables the Wi-Fi module. - -
- -### `macAddress` - -```cpp -uint8_t * macAddress(uint8_t * mac) -``` - -Retrieves the MAC address of the device. - -This function retrieves the MAC address of the device based on its current operating mode. The value returned by this function is meaningfull only if called afert a begin (both begin or beginAP) or a ScanNetwork function otherwise an empty mac address is returned. - -#### Parameters -* `_mac` A pointer to a uint8_t array where the MAC address will be stored. - -#### Returns -uint8_t* The pointer to the array containing the MAC address. -
- -### `localIP` - -```cpp -IPAddress localIP() -``` - -Retrieves the local IP address of the device. - -This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) and retrieves the appropriate IP address based on the mode. - -#### Returns -`IPAddress` The local IP address of the device. -
- -### `subnetMask` - -```cpp -IPAddress subnetMask() -``` - -Retrieves the subnet mask of the device. - -This function retrieves the subnet mask of the device by querying the modem for the subnet information. It sends a command to the modem to fetch the subnet mask and returns it as an `IPAddress` object. - -#### Returns -`IPAddress` The subnet mask address value of the device. -
- -### `gatewayIP` - -```cpp -IPAddress gatewayIP() -``` - -Retrieves the gateway IP address of the device. - -This function retrieves the gateway IP address of the device by querying the modem for the gateway information. It sends a command to the modem to fetch the gateway IP address and returns it as an `IPAddress` object. - -#### Returns -`IPAddress` The gateway IP address value of the device. -
- -### `dnsIP` - -```cpp -IPAddress dnsIP(int n) -``` - -Retrieves the DNS IP address. - -#### Parameters -* `n` The index of the DNS server to retrieve, `0` for the primary DNS server and `1` for the secondary DNS server. - -#### Returns -`IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. -
- -### `softAPIP` - -```cpp -IPAddress softAPIP() -``` - -Retrieves the IP address of the soft access point (AP). - -#### Returns -`IPAddress` The IP address of the soft AP as an `IPAddress` object, or `0.0.0.0` if not found. -
- -### `SSID` - -```cpp -const char * SSID() -``` - -Retrieves the SSID of the current Wi-Fi connection or SoftAP. - -#### Returns -The SSID of the current Wi-Fi connection or SoftAP as a string. If unable to retrieve the SSID, returns an empty string. -
- -### `BSSID` - -```cpp -uint8_t * BSSID(uint8_t * bssid) -``` - -Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. - -#### Parameters -* `bssid` A pointer to an array where the BSSID will be stored. The array must be large enough to hold the MAC address. - -#### Returns -A pointer to the `bssid` array containing the retrieved BSSID. If the BSSID cannot be retrieved, returns `nullptr`. -
- -### `RSSI` - -```cpp -int32_t RSSI() -``` - -Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. - -#### Returns -The RSSI value representing the signal strength. A higher (less negative) value indicates a stronger signal. If the RSSI cannot be retrieved, returns 0. -
- -### `softAPSSID` - -```cpp -const char * softAPSSID() -``` - -Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. - -#### Returns -The SSID of the SoftAP. If the SSID cannot be retrieved, an empty string is returned. -
- -### `scanNetworks` - -```cpp -int8_t scanNetworks() -``` - -Scans for available Wi-Fi networks and stores the information in the `access_points` list. - -This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, RSSI (signal strength), channel, and encryption mode for each detected access point. - -#### Returns -The number of networks found during the scan. Returns a negative value in case of an error. -
- -### `SSID` - -```cpp -const char * SSID(uint8_t networkItem) -``` - -Retrieves the SSID of a specific Wi-Fi network from the scan results. - -#### Parameters -* `networkItem` The index of the network in the list of scanned access points. - -#### Returns -The SSID of the specified network, or `nullptr` if the index is out of bounds. -
- -### `encryptionType` - -```cpp -uint8_t encryptionType(uint8_t networkItem) -``` - -Returns the encryption type for a specified network. - -This function retrieves the encryption type of a specific Wi-Fi access point based on its index in the list of scanned networks. - -#### Parameters -* `networkItem` The index of the network in the list of available access points. - -#### Returns -The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). Returns 0 if the network item index is invalid. -
- -### `encryptionType` - -```cpp -uint8_t encryptionType() -``` - -Returns the encryption type of the currently connected Wi-Fi network. - -#### Returns -The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). Returns `ENC_TYPE_UNKNOWN` if the encryption type cannot be determined. -
- -### `BSSID` - -```cpp -uint8_t * BSSID(uint8_t networkItem, uint8_t * bssid) -``` - -Retrieves the BSSID of a specific Wi-Fi network. - -This function retrieves the BSSID (MAC address) of the Wi-Fi network at the specified index from the list of available networks. The BSSID is stored in the provided array of 6 bytes. - -#### Parameters -* `networkItem` The index of the Wi-Fi network in the list of available networks. - -* `bssid` A pointer to a byte array (of size 6) where the BSSID will be stored. - -#### Returns -A pointer to the `bssid` array if the BSSID is successfully retrieved, or `nullptr` if the network index is out of range. -
- -### `channel` - -```cpp -uint8_t channel(uint8_t networkItem) -``` - -Retrieves the channel number of a specific Wi-Fi network. - -#### Parameters -* `networkItem` The index of the Wi-Fi network in the list of available networks. - -#### Returns -The channel number of the specified network, or `0` if the network index is out of range. -
- -### `RSSI` - -```cpp -int32_t RSSI(uint8_t networkItem) -``` - -Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. - -#### Parameters -* `networkItem` The index of the Wi-Fi network in the list of available networks. - -#### Returns -The RSSI value of the specified network in dBm, or `-1000` if the network index is out of range. -
- -### `status` - -```cpp -uint8_t status() -``` - -Retrieves the current connection status of the Wi-Fi connection. - -#### Returns -One of the values defined in wl_status_t -
- -### `reasonCode` - -```cpp -uint8_t reasonCode() -``` - -Retrieves The deauthentication reason code. - -#### Returns -The deauthentication reason code. -
- -### `hostByName` - -```cpp -int hostByName(const char * aHostname, IPAddress & aResult) -``` - -Resolves a hostname to an IP address. - -#### Parameters -* `aHostname` The hostname to resolve (e.g., "www.example.com"). - -* `aResult` IPAddress structure to store the returned IP address result: 1 if aIPAddrString was successfully converted to an IP address, else error code - -#### Returns -Returns `1` if the hostname was successfully resolved, `0` otherwise. -
- -### `getTime` - -```cpp -unsigned long getTime() -``` - -Retrieves the current time from the modem. - -#### Returns -The current time value in seconds, or `0` if the time could not be retrieved. -
- -### `setTimeout` - -```cpp -void setTimeout(unsigned long timeout) -``` - -Sets the timeout value for the WiFi connection. - -#### Parameters -* `timeout` The timeout value in milliseconds. -
- -### `firmwareVersion` - -```cpp -static const char * firmwareVersion() -``` - -Get firmware version. - -
- -# class `ModemClass` - -A class that provides methods to interact with a modem. - -This class is responsible for providing an interface to communicate with a modem through serial communication. It includes methods for initialization, sending and receiving data, and handling modem configurations. - -## Summary - - Members | Descriptions ---------------------------------|--------------------------------------------- -| [`beginned`](#class_modem_class_1ad21db7f5eb0b759c9b6c02af03b8f964) | Flag indicating whether the system has been initialized. | -| [`enable_dbg`](#class_modem_class_1a77cc6948341d08f0285233c67ef1e928) | | -| [`ModemClass`](#class_modem_class_1acce8d910277f180f32607ed8e84f090b) | Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified transmit (TX) and receive (RX) pins. | -| [`ModemClass`](#class_modem_class_1af222286fa398b86d02bd6230e0c42039) | Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified UART interface. | -| [`~ModemClass`](#class_modem_class_1a458f1f4e43e27fdc522caaf4c40d9579) | Destructor for [ModemClass](#class_modem_class). | -| [`begin`](#class_modem_class_1a36c32d41d4111e5fc63d8bf1a017368f) | Initializes the modem communication with a specified baud rate. | -| [`end`](#class_modem_class_1a434e5c4b8c67d90c10eff5e20da56556) | Ends the modem communication. | -| [`write`](#class_modem_class_1acd102543a8544be0686128fea53c9a11) | Sends a formatted command string to a device and stores the response. | -| [`write_nowait`](#class_modem_class_1aa9923ac664a16c2aaf5024de9de1ef03) | Used to send a command to the modem without waiting for a response. | -| [`passthrough`](#class_modem_class_1aa8750f17b14472819ffb8016118f869b) | Sends binary data directly to the modem without any processing or interpretation. | -| [`avoid_trim_results`](#class_modem_class_1ac7aff51f7bb09bbfd7190af1715274f8) | Disables automatic trimming of results for one operation. | -| [`read_using_size`](#class_modem_class_1a83d1105d39191e2c902331b3f0c4c8f5) | Enables a specific mode of reading where the size of the data to be read is considered for processing. | -| [`debug`](#class_modem_class_1a6e6c472f405698e25db0d90a1de359f4) | | -| [`noDebug`](#class_modem_class_1a0b73ad5e52ad405a3be764d948cd8522) | Used to disable debugging output for the modem communication. | -| [`debug`](#class_modem_class_1a0d2808ffeccd83db3e26cc3568e33eeb) | | -| [`timeout`](#class_modem_class_1a240fc0451c5152615f192b675beabadc) | Sets the timeout value for communication operations. | - -## Members - -### `beginned` - -```cpp -bool beginned -``` - -Flag indicating whether the system has been initialized. - -
- -### `enable_dbg` - -```cpp -bool enable_dbg -``` - -
- -### `ModemClass` - -```cpp -ModemClass(int tx, int rx) -``` - -Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified transmit (TX) and receive (RX) pins. - -#### Parameters -* `Initializes` an instance of the [ModemClass](#class_modem_class) class with specific transmit `tx` and receive `rx` pins for communication. -
- -### `ModemClass` - -```cpp -ModemClass(UART * _serial) -``` - -Constructor for the [ModemClass](#class_modem_class), which initializes the modem with the specified UART interface. - -#### Parameters -* `_serial` is a pointer to the UART object that will be used for communication with the modem. -
- -### `~ModemClass` - -```cpp -~ModemClass() -``` - -Destructor for [ModemClass](#class_modem_class). - -
- -### `begin` - -```cpp -void begin(int badurate) -``` - -Initializes the modem communication with a specified baud rate. - -#### Parameters -* `badurate` sets the baud rate for the serial connection. -
- -### `end` - -```cpp -void end() -``` - -Ends the modem communication. - -
- -### `write` - -```cpp -bool write(const std::string & cmd, std::string & str, const char * fmt, ...) -``` - -Sends a formatted command string to a device and stores the response. - -This function formats a command string using the provided format and arguments, sends it to a device, and waits for a response, which is stored in the `str` string. - -#### Parameters -* `cmd` A string representing the command to be sent to the device. - -* `str` A reference to a string that will hold the device's response. - -* `fmt` A format string for constructing the command. - -#### Returns -`true` if the command was successfully sent and a response was received, `false` otherwise. -
- -### `write_nowait` - -```cpp -void write_nowait(const std::string & cmd, std::string & str, const char * fmt, ...) -``` - -Used to send a command to the modem without waiting for a response. - -#### Parameters -* `It` takes a command string `cmd`, a string `str` where the response will be stored, and a format string `fmt` along with additional arguments. -
- -### `passthrough` - -```cpp -bool passthrough(const uint8_t * data, size_t size) -``` - -Sends binary data directly to the modem without any processing or interpretation. - -#### Parameters -* `It` takes a pointer to the binary `data` and the `size` of the data as arguments. Used for sending raw binary commands or data to the modem for operations that require direct communication without any additional formatting or parsing. -
- -### `avoid_trim_results` - -```cpp -inline void avoid_trim_results() -``` - -Disables automatic trimming of results for one operation. - -This function disables the automatic trimming of results for one operation. After it is called, the results will not be trimmed automatically until the function is called again. -
- -### `read_using_size` - -```cpp -inline void read_using_size() -``` - -Enables a specific mode of reading where the size of the data to be read is considered for processing. - -
- -### `debug` - -```cpp -inline void debug(Stream & u, uint8_t level) -``` - -
- -### `noDebug` - -```cpp -inline void noDebug() -``` - -Used to disable debugging output for the modem communication. - -
- -### `debug` - -```cpp -inline void debug(bool e) -``` - -
- -### `timeout` - -```cpp -inline void timeout(size_t timeout_ms) -``` - -Sets the timeout value for communication operations. - -#### Parameters -* `Can` be called with a specified timeout value in milliseconds. -
- # class `WiFiClient` ```cpp @@ -937,7 +68,7 @@ WiFiClient(int s) Constructor to initialize a [WiFiClient](#class_wi_fi_client) object with a specific socket. #### Parameters -* `s` is the socket descriptor to associate with this client. +* `s` is the socket descriptor to associate with this client.
### `WiFiClient` @@ -949,7 +80,7 @@ WiFiClient(const WiFiClient & c) Copy constructor for the [WiFiClient](#class_wi_fi_client) class. #### Parameters -* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy. +* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy.
### `~WiFiClient` @@ -971,9 +102,9 @@ virtual int connect(IPAddress ip, uint16_t port) Establishes a connection to a server using an IP address and port. #### Parameters -* `ip` as the IP address of the server to connect to. +* `ip` as the IP address of the server to connect to. -* `port` as the port number on the server to connect to. +* `port` as the port number on the server to connect to. #### Returns `1` on a successful connection, `0` on failure. @@ -988,9 +119,9 @@ virtual int connect(const char * host, uint16_t port) Establishes a connection to a server using a hostname and port. #### Parameters -* `host` is a pointer to a null-terminated string containing the hostname of the server. +* `host` is a pointer to a null-terminated string containing the hostname of the server. -* `port` is the port number on the server to connect to. +* `port` is the port number on the server to connect to. #### Returns `1` if the connection was successful, `0` otherwise. @@ -1005,7 +136,7 @@ virtual size_t write(uint8_t) Sends a single byte of data to the connected server. #### Parameters -* `b` being the byte of data to send. +* `b` being the byte of data to send. #### Returns The number of bytes successfully written, which is `1` on success or `0` on failure. @@ -1061,9 +192,9 @@ Reads multiple bytes of data from the server into a buffer. This function retrieves data from the server's receive buffer and stores it into the provided array. It attempts to read up to the specified number of bytes (`size`). #### Parameters -* `buf` is a pointer to the buffer where the data will be stored. +* `buf` is a pointer to the buffer where the data will be stored. -* `size` is the maximum number of bytes to read. +* `size` is the maximum number of bytes to read. #### Returns The number of bytes successfully read into the buffer. Returns `0` if no data is available or if the socket is invalid. @@ -1156,7 +287,7 @@ Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` object Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent different socket connections. #### Parameters -* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. +* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. #### Returns `true` if both [WiFiClient](#class_wi_fi_client) objects represent different sockets, `false` if they represent the same socket. @@ -1195,7 +326,7 @@ inline void setConnectionTimeout(int timeout) Sets the connection timeout for the client. #### Parameters -* `timeout` is the timeout value in milliseconds. +* `timeout` is the timeout value in milliseconds.
# class `WiFiFileSystem` @@ -1246,7 +377,7 @@ size_t writefile(const char * name, const char * data, size_t size, int operatio Writes data to a file in the file system. #### Parameters -* `name` is the name of the file to which the data will be written. A pointer `data` to the data that will be written to the file. `size` is the number of bytes to write from the provided data buffer. `operation` determines the type of file operation to perform (e.g., create, overwrite). +* `name` is the name of the file to which the data will be written. A pointer `data` to the data that will be written to the file. `size` is the number of bytes to write from the provided data buffer. `operation` determines the type of file operation to perform (e.g., create, overwrite). #### Returns Returns the number of bytes successfully written. Returns 0 if the operation fails. @@ -1263,7 +394,7 @@ Reads a file from the file system and prints its content. It sends the read request to the modem, which fetches the data. The content is printed to the serial output in chunks, with each chunk being processed until the entire file is read. #### Parameters -* `name` is the name of the file to be read from the file system. +* `name` is the name of the file to be read from the file system.
# class `WiFiServer` @@ -1315,7 +446,7 @@ WiFiServer(int p) Constructs a [WiFiServer](#class_wi_fi_server) object with the specified port. #### Parameters -* `p` The port number on which the server will listen for incoming connections. +* `p` The port number on which the server will listen for incoming connections.
### `available` @@ -1353,7 +484,7 @@ void begin(int port) Starts the Wi-Fi server and binds it to the specified port. #### Parameters -* `port` is the port number which the server will listen to for incoming connections. +* `port` is the port number which the server will listen to for incoming connections.
### `begin` @@ -1376,7 +507,7 @@ virtual size_t write(uint8_t) Writes a single byte to all connected clients. #### Parameters -* `b` is the byte to be sent to the clients. +* `b` is the byte to be sent to the clients.
### `write` @@ -1390,7 +521,7 @@ Writes data to all connected clients. This function sends a buffer of data to all clients connected to the server. It writes the specified number of bytes to the server socket and returns the count of successfully written bytes. #### Parameters -* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to write from the buffer. +* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to write from the buffer. #### Returns The number of bytes successfully written. Returns 0 if the data could not be sent. @@ -1449,7 +580,7 @@ Compares two [WiFiServer](#class_wi_fi_server) objects for inequality. This virtual operator compares the underlying socket (`_sock`) of two [WiFiServer](#class_wi_fi_server) objects. It returns `true` if the objects do not refer to the same server connection (i.e., they have different socket values), and `false` otherwise. #### Parameters -* `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. +* `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. #### Returns `true` if the [WiFiServer](#class_wi_fi_server) objects have different sockets; `false` otherwise. @@ -1535,7 +666,7 @@ virtual int connect(const char * host, uint16_t port) Establishes a secure SSL connection to a specified host and port. #### Parameters -* `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. +* `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. #### Returns Returns `1` if the connection is successfully established, `0` otherwise. @@ -1550,7 +681,7 @@ void setCACert(const char * root_ca) Sets the Certificate Authority (CA) for SSL/TLS verification. #### Parameters -* `root_ca` is a pointer to a null-terminated string containing the root CA certificate in PEM format. If set to `nullptr`, the default root CA bundle will be used. +* `root_ca` is a pointer to a null-terminated string containing the root CA certificate in PEM format. If set to `nullptr`, the default root CA bundle will be used.
### `setEccSlot` @@ -1562,11 +693,11 @@ void setEccSlot(int ecc508KeySlot, const byte cert, int certLength) Sets the ECC (Elliptic Curve Cryptography) key slot and certificate for establishing secure SSL connections. #### Parameters -* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. +* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. -* `const` byte cert[] is a pointer to the certificate data in the form of an array of bytes. +* `const` byte cert[] is a pointer to the certificate data in the form of an array of bytes. -* `int` certLength specifies the length of the certificate data array. +* `int` certLength specifies the length of the certificate data array.
### `write` @@ -1578,7 +709,7 @@ virtual size_t write(uint8_t) Writes a single byte of data to the SSL connection. #### Parameters -* `b` is the byte to be sent. +* `b` is the byte to be sent. #### Returns The number of bytes successfully written. Returns `1` if the byte was sent successfully, or `0` if an error occurred. @@ -1593,9 +724,9 @@ virtual size_t write(const uint8_t * buf, size_t size) Writes a buffer of data to the SSL connection. #### Parameters -* `buf` is a pointer to the buffer containing the data to be sent. +* `buf` is a pointer to the buffer containing the data to be sent. -* `size` is the number of bytes to send from the buffer. +* `size` is the number of bytes to send from the buffer. #### Returns Returns `size` if the data is successfully sent, or `0` if the transmission fails or the socket is invalid. @@ -1634,7 +765,7 @@ virtual int read(uint8_t * buf, size_t size) Reads a specified number of bytes from the SSL connection into a buffer. #### Parameters -* `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. +* `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. #### Returns The number of bytes successfully read. Returns `0` if no data is available or an error occurs. @@ -1710,7 +841,7 @@ virtual bool operator==(const WiFiSSLClient &) Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. #### Parameters -* `WiFiSSLClient` object to compare. +* `WiFiSSLClient` object to compare. #### Returns `true` if both [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects are equivalent (i.e., they have the same socket), `false` otherwise. @@ -1727,7 +858,7 @@ Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` This operator compares the current `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object with another `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to determine if they are not equal, based on their underlying socket or connection. #### Parameters -* `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. +* `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. #### Returns `true` if the two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects do not represent the same connection (i.e., have different sockets), `false` otherwise. @@ -1820,7 +951,7 @@ virtual uint8_t begin(uint16_t) Starts a UDP socket on the specified local port. #### Parameters -* `uint16_t` The local port number to bind the UDP socket to. +* `uint16_t` The local port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -1835,9 +966,9 @@ virtual uint8_t begin(IPAddress a, uint16_t p) Starts a UDP socket bound to a specific IP address and port. #### Parameters -* `a` The local IP address to bind the UDP socket to. +* `a` The local IP address to bind the UDP socket to. -* `p` The local port number to bind the UDP socket to. +* `p` The local port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -1852,9 +983,9 @@ virtual uint8_t beginMulticast(IPAddress, uint16_t) Starts a UDP multicast socket bound to a specific IP address and port. #### Parameters -* `IPAddress` The multicast IP address to bind the UDP socket to. +* `IPAddress` The multicast IP address to bind the UDP socket to. -* `uint16_t` The port number to bind the UDP socket to. +* `uint16_t` The port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -1891,9 +1022,9 @@ virtual int beginPacket(IPAddress ip, uint16_t port) Begins constructing a UDP packet for sending to a specific IP address and port. #### Parameters -* `ip` The destination IP address as an `IPAddress` object. +* `ip` The destination IP address as an `IPAddress` object. -* `port` The destination port number. +* `port` The destination port number. #### Returns Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. @@ -1908,9 +1039,9 @@ virtual int beginPacket(const char * host, uint16_t port) Begins constructing a UDP packet for sending to a specific hostname and port. #### Parameters -* `host` The destination hostname as a null-terminated string. +* `host` The destination hostname as a null-terminated string. -* `port` The destination port number. +* `port` The destination port number. #### Returns Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. @@ -1937,7 +1068,7 @@ virtual size_t write(uint8_t) Sends a single byte of data to the currently opened UDP packet. #### Parameters -* `b` The byte of data to send. +* `b` The byte of data to send. #### Returns Returns `1` if the byte was successfully written. Or `0` if there was an error or the packet was not properly initialized. @@ -1952,9 +1083,9 @@ virtual size_t write(const uint8_t * buffer, size_t size) Sends a buffer of data to the currently opened UDP packet. #### Parameters -* `buffer` A pointer to the buffer containing the data to send. +* `buffer` A pointer to the buffer containing the data to send. -* `size` The number of bytes from the buffer to write. +* `size` The number of bytes from the buffer to write. #### Returns Returns the number of bytes successfully written if the operation is successful. Or `0` if the data was not successfully written, or if the packet was not properly initialized. @@ -2005,9 +1136,9 @@ virtual int read(unsigned char * buffer, size_t len) Reads data from the UDP receive buffer into a provided buffer. #### Parameters -* `buffer` A pointer to the buffer where the received data will be stored. +* `buffer` A pointer to the buffer where the received data will be stored. -* `size` The number of bytes to read from the UDP buffer. +* `size` The number of bytes to read from the UDP buffer. #### Returns The number of bytes successfully read into the buffer. If less than `size` bytes are read, it indicates that the buffer was exhausted early. @@ -2022,9 +1153,9 @@ inline virtual int read(char * buffer, size_t len) Reads data from the UDP receive buffer into a character buffer. #### Parameters -* `buffer` A pointer to the character buffer where the received data will be stored. +* `buffer` A pointer to the character buffer where the received data will be stored. -* `len` The number of bytes to read from the UDP buffer. +* `len` The number of bytes to read from the UDP buffer. #### Returns The number of bytes successfully read into the buffer. If less than `len` bytes are read, it indicates that the buffer was exhausted early. @@ -2063,7 +1194,7 @@ Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for equality. This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are the same. #### Parameters -* `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. +* `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. #### Returns `true` if the socket values are equal, `false` otherwise. @@ -2080,7 +1211,7 @@ Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for inequality. This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are different. #### Parameters -* `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. +* `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. #### Returns `true` if the socket values are different, `false` otherwise. From 1399224cb9f61bd94de61a12e7386d39b3435b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Fri, 13 Dec 2024 09:29:53 +0100 Subject: [PATCH 19/43] Removed unused tags --- libraries/WiFiS3/docs/api.md | 94 ++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libraries/WiFiS3/docs/api.md b/libraries/WiFiS3/docs/api.md index b38b63d7c..6a0f2bff6 100644 --- a/libraries/WiFiS3/docs/api.md +++ b/libraries/WiFiS3/docs/api.md @@ -68,7 +68,7 @@ WiFiClient(int s) Constructor to initialize a [WiFiClient](#class_wi_fi_client) object with a specific socket. #### Parameters -* `s` is the socket descriptor to associate with this client. +* `s` is the socket descriptor to associate with this client.
### `WiFiClient` @@ -80,7 +80,7 @@ WiFiClient(const WiFiClient & c) Copy constructor for the [WiFiClient](#class_wi_fi_client) class. #### Parameters -* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy. +* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy.
### `~WiFiClient` @@ -102,9 +102,9 @@ virtual int connect(IPAddress ip, uint16_t port) Establishes a connection to a server using an IP address and port. #### Parameters -* `ip` as the IP address of the server to connect to. +* `ip` as the IP address of the server to connect to. -* `port` as the port number on the server to connect to. +* `port` as the port number on the server to connect to. #### Returns `1` on a successful connection, `0` on failure. @@ -119,9 +119,9 @@ virtual int connect(const char * host, uint16_t port) Establishes a connection to a server using a hostname and port. #### Parameters -* `host` is a pointer to a null-terminated string containing the hostname of the server. +* `host` is a pointer to a null-terminated string containing the hostname of the server. -* `port` is the port number on the server to connect to. +* `port` is the port number on the server to connect to. #### Returns `1` if the connection was successful, `0` otherwise. @@ -136,7 +136,7 @@ virtual size_t write(uint8_t) Sends a single byte of data to the connected server. #### Parameters -* `b` being the byte of data to send. +* `b` being the byte of data to send. #### Returns The number of bytes successfully written, which is `1` on success or `0` on failure. @@ -192,9 +192,9 @@ Reads multiple bytes of data from the server into a buffer. This function retrieves data from the server's receive buffer and stores it into the provided array. It attempts to read up to the specified number of bytes (`size`). #### Parameters -* `buf` is a pointer to the buffer where the data will be stored. +* `buf` is a pointer to the buffer where the data will be stored. -* `size` is the maximum number of bytes to read. +* `size` is the maximum number of bytes to read. #### Returns The number of bytes successfully read into the buffer. Returns `0` if no data is available or if the socket is invalid. @@ -287,7 +287,7 @@ Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` object Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent different socket connections. #### Parameters -* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. +* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. #### Returns `true` if both [WiFiClient](#class_wi_fi_client) objects represent different sockets, `false` if they represent the same socket. @@ -326,7 +326,7 @@ inline void setConnectionTimeout(int timeout) Sets the connection timeout for the client. #### Parameters -* `timeout` is the timeout value in milliseconds. +* `timeout` is the timeout value in milliseconds.
# class `WiFiFileSystem` @@ -377,7 +377,7 @@ size_t writefile(const char * name, const char * data, size_t size, int operatio Writes data to a file in the file system. #### Parameters -* `name` is the name of the file to which the data will be written. A pointer `data` to the data that will be written to the file. `size` is the number of bytes to write from the provided data buffer. `operation` determines the type of file operation to perform (e.g., create, overwrite). +* `name` is the name of the file to which the data will be written. A pointer `data` to the data that will be written to the file. `size` is the number of bytes to write from the provided data buffer. `operation` determines the type of file operation to perform (e.g., create, overwrite). #### Returns Returns the number of bytes successfully written. Returns 0 if the operation fails. @@ -394,7 +394,7 @@ Reads a file from the file system and prints its content. It sends the read request to the modem, which fetches the data. The content is printed to the serial output in chunks, with each chunk being processed until the entire file is read. #### Parameters -* `name` is the name of the file to be read from the file system. +* `name` is the name of the file to be read from the file system.
# class `WiFiServer` @@ -446,7 +446,7 @@ WiFiServer(int p) Constructs a [WiFiServer](#class_wi_fi_server) object with the specified port. #### Parameters -* `p` The port number on which the server will listen for incoming connections. +* `p` The port number on which the server will listen for incoming connections.
### `available` @@ -484,7 +484,7 @@ void begin(int port) Starts the Wi-Fi server and binds it to the specified port. #### Parameters -* `port` is the port number which the server will listen to for incoming connections. +* `port` is the port number which the server will listen to for incoming connections.
### `begin` @@ -507,7 +507,7 @@ virtual size_t write(uint8_t) Writes a single byte to all connected clients. #### Parameters -* `b` is the byte to be sent to the clients. +* `b` is the byte to be sent to the clients.
### `write` @@ -521,7 +521,7 @@ Writes data to all connected clients. This function sends a buffer of data to all clients connected to the server. It writes the specified number of bytes to the server socket and returns the count of successfully written bytes. #### Parameters -* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to write from the buffer. +* `buf` is a pointer to the buffer containing the data to be sent. `size` is the number of bytes to write from the buffer. #### Returns The number of bytes successfully written. Returns 0 if the data could not be sent. @@ -580,7 +580,7 @@ Compares two [WiFiServer](#class_wi_fi_server) objects for inequality. This virtual operator compares the underlying socket (`_sock`) of two [WiFiServer](#class_wi_fi_server) objects. It returns `true` if the objects do not refer to the same server connection (i.e., they have different socket values), and `false` otherwise. #### Parameters -* `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. +* `whs` The [WiFiServer](#class_wi_fi_server) object to compare against. #### Returns `true` if the [WiFiServer](#class_wi_fi_server) objects have different sockets; `false` otherwise. @@ -666,7 +666,7 @@ virtual int connect(const char * host, uint16_t port) Establishes a secure SSL connection to a specified host and port. #### Parameters -* `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. +* `host` is the hostname or IP address of the server to connect to. `port` is the port number to connect to. #### Returns Returns `1` if the connection is successfully established, `0` otherwise. @@ -681,7 +681,7 @@ void setCACert(const char * root_ca) Sets the Certificate Authority (CA) for SSL/TLS verification. #### Parameters -* `root_ca` is a pointer to a null-terminated string containing the root CA certificate in PEM format. If set to `nullptr`, the default root CA bundle will be used. +* `root_ca` is a pointer to a null-terminated string containing the root CA certificate in PEM format. If set to `nullptr`, the default root CA bundle will be used.
### `setEccSlot` @@ -693,11 +693,11 @@ void setEccSlot(int ecc508KeySlot, const byte cert, int certLength) Sets the ECC (Elliptic Curve Cryptography) key slot and certificate for establishing secure SSL connections. #### Parameters -* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. +* `int` ecc508KeySlot specifies the ECC key slot to be used for the SSL connection. -* `const` byte cert[] is a pointer to the certificate data in the form of an array of bytes. +* `const` byte cert[] is a pointer to the certificate data in the form of an array of bytes. -* `int` certLength specifies the length of the certificate data array. +* `int` certLength specifies the length of the certificate data array.
### `write` @@ -709,7 +709,7 @@ virtual size_t write(uint8_t) Writes a single byte of data to the SSL connection. #### Parameters -* `b` is the byte to be sent. +* `b` is the byte to be sent. #### Returns The number of bytes successfully written. Returns `1` if the byte was sent successfully, or `0` if an error occurred. @@ -724,9 +724,9 @@ virtual size_t write(const uint8_t * buf, size_t size) Writes a buffer of data to the SSL connection. #### Parameters -* `buf` is a pointer to the buffer containing the data to be sent. +* `buf` is a pointer to the buffer containing the data to be sent. -* `size` is the number of bytes to send from the buffer. +* `size` is the number of bytes to send from the buffer. #### Returns Returns `size` if the data is successfully sent, or `0` if the transmission fails or the socket is invalid. @@ -765,7 +765,7 @@ virtual int read(uint8_t * buf, size_t size) Reads a specified number of bytes from the SSL connection into a buffer. #### Parameters -* `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. +* `buf` is a pointer to the buffer where the read data will be stored. `size` is the maximum number of bytes to read into the buffer. #### Returns The number of bytes successfully read. Returns `0` if no data is available or an error occurs. @@ -841,7 +841,7 @@ virtual bool operator==(const WiFiSSLClient &) Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. #### Parameters -* `WiFiSSLClient` object to compare. +* `WiFiSSLClient` object to compare. #### Returns `true` if both [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects are equivalent (i.e., they have the same socket), `false` otherwise. @@ -858,7 +858,7 @@ Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` This operator compares the current `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object with another `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to determine if they are not equal, based on their underlying socket or connection. #### Parameters -* `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. +* `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. #### Returns `true` if the two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects do not represent the same connection (i.e., have different sockets), `false` otherwise. @@ -951,7 +951,7 @@ virtual uint8_t begin(uint16_t) Starts a UDP socket on the specified local port. #### Parameters -* `uint16_t` The local port number to bind the UDP socket to. +* `uint16_t` The local port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -966,9 +966,9 @@ virtual uint8_t begin(IPAddress a, uint16_t p) Starts a UDP socket bound to a specific IP address and port. #### Parameters -* `a` The local IP address to bind the UDP socket to. +* `a` The local IP address to bind the UDP socket to. -* `p` The local port number to bind the UDP socket to. +* `p` The local port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -983,9 +983,9 @@ virtual uint8_t beginMulticast(IPAddress, uint16_t) Starts a UDP multicast socket bound to a specific IP address and port. #### Parameters -* `IPAddress` The multicast IP address to bind the UDP socket to. +* `IPAddress` The multicast IP address to bind the UDP socket to. -* `uint16_t` The port number to bind the UDP socket to. +* `uint16_t` The port number to bind the UDP socket to. #### Returns Returns `1` if the socket is successfully opened, or `0` if the socket is already in use or could not be opened. @@ -1022,9 +1022,9 @@ virtual int beginPacket(IPAddress ip, uint16_t port) Begins constructing a UDP packet for sending to a specific IP address and port. #### Parameters -* `ip` The destination IP address as an `IPAddress` object. +* `ip` The destination IP address as an `IPAddress` object. -* `port` The destination port number. +* `port` The destination port number. #### Returns Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. @@ -1039,9 +1039,9 @@ virtual int beginPacket(const char * host, uint16_t port) Begins constructing a UDP packet for sending to a specific hostname and port. #### Parameters -* `host` The destination hostname as a null-terminated string. +* `host` The destination hostname as a null-terminated string. -* `port` The destination port number. +* `port` The destination port number. #### Returns Returns `1` if the packet preparation is successful. Or `0` if there is an error or the socket is not initialized. @@ -1068,7 +1068,7 @@ virtual size_t write(uint8_t) Sends a single byte of data to the currently opened UDP packet. #### Parameters -* `b` The byte of data to send. +* `b` The byte of data to send. #### Returns Returns `1` if the byte was successfully written. Or `0` if there was an error or the packet was not properly initialized. @@ -1083,9 +1083,9 @@ virtual size_t write(const uint8_t * buffer, size_t size) Sends a buffer of data to the currently opened UDP packet. #### Parameters -* `buffer` A pointer to the buffer containing the data to send. +* `buffer` A pointer to the buffer containing the data to send. -* `size` The number of bytes from the buffer to write. +* `size` The number of bytes from the buffer to write. #### Returns Returns the number of bytes successfully written if the operation is successful. Or `0` if the data was not successfully written, or if the packet was not properly initialized. @@ -1136,9 +1136,9 @@ virtual int read(unsigned char * buffer, size_t len) Reads data from the UDP receive buffer into a provided buffer. #### Parameters -* `buffer` A pointer to the buffer where the received data will be stored. +* `buffer` A pointer to the buffer where the received data will be stored. -* `size` The number of bytes to read from the UDP buffer. +* `size` The number of bytes to read from the UDP buffer. #### Returns The number of bytes successfully read into the buffer. If less than `size` bytes are read, it indicates that the buffer was exhausted early. @@ -1153,9 +1153,9 @@ inline virtual int read(char * buffer, size_t len) Reads data from the UDP receive buffer into a character buffer. #### Parameters -* `buffer` A pointer to the character buffer where the received data will be stored. +* `buffer` A pointer to the character buffer where the received data will be stored. -* `len` The number of bytes to read from the UDP buffer. +* `len` The number of bytes to read from the UDP buffer. #### Returns The number of bytes successfully read into the buffer. If less than `len` bytes are read, it indicates that the buffer was exhausted early. @@ -1194,7 +1194,7 @@ Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for equality. This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are the same. #### Parameters -* `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. +* `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. #### Returns `true` if the socket values are equal, `false` otherwise. @@ -1211,7 +1211,7 @@ Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for inequality. This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are different. #### Parameters -* `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. +* `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. #### Returns `true` if the socket values are different, `false` otherwise. From a38272896580762d315103bcc0a3d5c5a0e29d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Fri, 13 Dec 2024 10:15:56 +0100 Subject: [PATCH 20/43] Fixed formatting --- libraries/WiFiS3/docs/api.md | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libraries/WiFiS3/docs/api.md b/libraries/WiFiS3/docs/api.md index 6a0f2bff6..c2b66bd6e 100644 --- a/libraries/WiFiS3/docs/api.md +++ b/libraries/WiFiS3/docs/api.md @@ -41,8 +41,8 @@ It inherits from the Client class, providing basic socket communication function | [`stop`](#class_wi_fi_client_1acb61f8e0ecd50e40ce6cbcb7106ce1b1) | Closes the connection to the server and clears the receive buffer. | | [`connected`](#class_wi_fi_client_1af083fe27b94aebec37f140c0b973f974) | Checks if the client is connected to a server. | | [`operator bool`](#class_wi_fi_client_1adaf93736006b5bb2426e9816de4207eb) | Implicit conversion operator to `bool`. | -| [`operator==`](#class_wi_fi_client_1ac1e068fb2468d84536e93f6e1b51b099) | Equality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. | -| [`operator!=`](#class_wi_fi_client_1a31b6e43ab5ab9d6fe511778a5a1f173c) | Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. | +| [`operator==`](#class_wi_fi_client_1ac1e068fb2468d84536e93f6e1b51b099) | Equality operator for comparing two [WiFiClient](#class_wi_fi_client) objects. | +| [`operator!=`](#class_wi_fi_client_1a31b6e43ab5ab9d6fe511778a5a1f173c) | Inequality operator for comparing two [WiFiClient](#class_wi_fi_client) objects. | | [`remoteIP`](#class_wi_fi_client_1a46d45c8d326b62256f85d55eaa337df0) | Retrieves the remote IP address of the server the client is connected to. | | [`remotePort`](#class_wi_fi_client_1a38ca1399ebf6570d2c852c9062ec92d8) | Retrieves the remote port number of the server the client is connected to. | | [`setConnectionTimeout`](#class_wi_fi_client_1af32938f36f09c9121e85e38338d432d7) | Sets the connection timeout for the client. | @@ -80,7 +80,7 @@ WiFiClient(const WiFiClient & c) Copy constructor for the [WiFiClient](#class_wi_fi_client) class. #### Parameters -* `c` is the `[WiFiClient](#class_wi_fi_client)` object to copy. +* `c` is the [WiFiClient](#class_wi_fi_client) object to copy.
### `~WiFiClient` @@ -253,7 +253,7 @@ inline virtual operator bool() Implicit conversion operator to `bool`. -Converts the `[WiFiClient](#class_wi_fi_client)` object to a `bool` value indicating whether the client is connected or not. +Converts the [WiFiClient](#class_wi_fi_client) object to a `bool` value indicating whether the client is connected or not. #### Returns `true` if the client socket is open and valid, `false` otherwise. @@ -265,15 +265,15 @@ Converts the `[WiFiClient](#class_wi_fi_client)` object to a `bool` value indica virtual bool operator==(const WiFiClient &) ``` -Equality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. +Equality operator for comparing two [WiFiClient](#class_wi_fi_client) objects. -Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent the same socket connection. +Compares the current [WiFiClient](#class_wi_fi_client) object with another [WiFiClient](#class_wi_fi_client) object to determine if they represent the same socket connection. #### Parameters -* `The` `[WiFiClient](#class_wi_fi_client)` object to compare with. +* `The` [WiFiClient](#class_wi_fi_client) object to compare with. #### Returns -`true` if both `[WiFiClient](#class_wi_fi_client)` objects represent the same socket, `false` otherwise. +`true` if both [WiFiClient](#class_wi_fi_client) objects represent the same socket, `false` otherwise.
### `operator!=` @@ -282,12 +282,12 @@ Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[W inline virtual bool operator!=(const WiFiClient & whs) ``` -Inequality operator for comparing two `[WiFiClient](#class_wi_fi_client)` objects. +Inequality operator for comparing two [WiFiClient](#class_wi_fi_client) objects. -Compares the current `[WiFiClient](#class_wi_fi_client)` object with another `[WiFiClient](#class_wi_fi_client)` object to determine if they represent different socket connections. +Compares the current [WiFiClient](#class_wi_fi_client) object with another [WiFiClient](#class_wi_fi_client) object to determine if they represent different socket connections. #### Parameters -* `whs` is the `[WiFiClient](#class_wi_fi_client)` object to compare with. +* `whs` is the [WiFiClient](#class_wi_fi_client) object to compare with. #### Returns `true` if both [WiFiClient](#class_wi_fi_client) objects represent different sockets, `false` if they represent the same socket. @@ -457,7 +457,7 @@ WiFiClient available() Checks if there are any incoming client connections waiting to be accepted. -This function queries the server to check if there is a client waiting to be accepted. If a client is available, it returns a `[WiFiClient](#class_wi_fi_client)` object representing the client. It uses the modem to query the server for an available client socket and accepts the connection if a valid client is found. +This function queries the server to check if there is a client waiting to be accepted. If a client is available, it returns a [WiFiClient](#class_wi_fi_client) object representing the client. It uses the modem to query the server for an available client socket and accepts the connection if a valid client is found. #### Returns Returns a [WiFiClient](#class_wi_fi_client) object representing the next client connection that is available for processing. @@ -560,10 +560,10 @@ virtual bool operator==(const WiFiServer &) Compares two [WiFiServer](#class_wi_fi_server) objects for equality. -This virtual operator compares the underlying socket (`_sock`) of two `[WiFiServer](#class_wi_fi_server)` objects to determine if they refer to the same server connection. +This virtual operator compares the underlying socket (`_sock`) of two [WiFiServer](#class_wi_fi_server) objects to determine if they refer to the same server connection. #### Parameters -* `[WiFiServer](#class_wi_fi_server)` object to compare against. +* [WiFiServer](#class_wi_fi_server) object to compare against. #### Returns `true` if both [WiFiServer](#class_wi_fi_server) objects have the same socket; `false` otherwise. @@ -617,8 +617,8 @@ The [WiFiSSLClient](#class_wi_fi_s_s_l_client) class extends the functionality o | [`stop`](#class_wi_fi_s_s_l_client_1a66113af6fbc85f0dbb73f8d276b8a77a) | Terminates the SSL/TLS connection and clears the receive buffer. | | [`connected`](#class_wi_fi_s_s_l_client_1a5e993c746855bb67c744d27baa6cf1bb) | Checks if the SSL/TLS connection is active. | | [`operator bool`](#class_wi_fi_s_s_l_client_1a46888795cc1562c33fad408b57d2ad40) | Implicit conversion operator to check if the SSL client is connected. | -| [`operator==`](#class_wi_fi_s_s_l_client_1aa0bdf11dd3e6ef48133967dc0a036004) | Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. | -| [`operator!=`](#class_wi_fi_s_s_l_client_1a2cdd8020168fae9e08d3c6d00b30b065) | Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. | +| [`operator==`](#class_wi_fi_s_s_l_client_1aa0bdf11dd3e6ef48133967dc0a036004) | Comparison operator to check equality between two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects. | +| [`operator!=`](#class_wi_fi_s_s_l_client_1a2cdd8020168fae9e08d3c6d00b30b065) | Inequality operator to compare two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects. | | [`remoteIP`](#class_wi_fi_s_s_l_client_1acff0aa8078124dff0c0ff3bfee7cfd83) | Retrieves the remote IP address of the WiFi SSL client. | | [`remotePort`](#class_wi_fi_s_s_l_client_1aea76ab94b3cdfec17ab6e73c7b169da7) | Retrieves the remote port number of the WiFi SSL client. | @@ -838,7 +838,7 @@ Implicit conversion operator to check if the SSL client is connected. virtual bool operator==(const WiFiSSLClient &) ``` -Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. +Comparison operator to check equality between two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects. #### Parameters * `WiFiSSLClient` object to compare. @@ -853,9 +853,9 @@ Comparison operator to check equality between two `[WiFiSSLClient](#class_wi_fi_ inline virtual bool operator!=(const WiFiSSLClient & whs) ``` -Inequality operator to compare two `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` objects. +Inequality operator to compare two [WiFiSSLClient](#class_wi_fi_s_s_l_client) objects. -This operator compares the current `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object with another `[WiFiSSLClient](#class_wi_fi_s_s_l_client)` object to determine if they are not equal, based on their underlying socket or connection. +This operator compares the current [WiFiSSLClient](#class_wi_fi_s_s_l_client) object with another [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to determine if they are not equal, based on their underlying socket or connection. #### Parameters * `whs` The [WiFiSSLClient](#class_wi_fi_s_s_l_client) object to compare with. @@ -1191,7 +1191,7 @@ virtual bool operator==(const WiFiUDP &) Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for equality. -This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are the same. +This function compares two [WiFiUDP](#class_wi_fi_u_d_p) objects by checking if their associated socket values (`_sock`) are the same. #### Parameters * `WiFiUDP&` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. @@ -1208,7 +1208,7 @@ inline virtual bool operator!=(const WiFiUDP & whs) Compares two [WiFiUDP](#class_wi_fi_u_d_p) objects for inequality. -This function compares two `[WiFiUDP](#class_wi_fi_u_d_p)` objects by checking if their associated socket values (`_sock`) are different. +This function compares two [WiFiUDP](#class_wi_fi_u_d_p) objects by checking if their associated socket values (`_sock`) are different. #### Parameters * `whs` The [WiFiUDP](#class_wi_fi_u_d_p) object to compare with the current object. @@ -1226,7 +1226,7 @@ virtual IPAddress remoteIP() Retrieves the remote IP address of the host who sent the current incoming packet. #### Returns -An `IPAddress` object representing the remote IP address. If the socket is not valid or the address cannot be retrieved, it returns `IPAddress(0, 0, 0, 0)`. +An `IPAddress` object representing the remote IP address. If the socket is not valid or the address cannot be retrieved, it returns `IPAddress(0, 0, 0, 0).
### `remotePort` From b594eff890deda768850f2041b45325e6b1e31ad Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 13 Feb 2025 08:58:12 +0100 Subject: [PATCH 21/43] RTC: add structs missing initializers --- libraries/RTC/src/RTC.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/RTC/src/RTC.cpp b/libraries/RTC/src/RTC.cpp index 843af650c..4f5d5d240 100644 --- a/libraries/RTC/src/RTC.cpp +++ b/libraries/RTC/src/RTC.cpp @@ -435,6 +435,11 @@ void __attribute__((weak)) rtc_callback(rtc_callback_args_t *p_args) { rtc_instance_ctrl_t rtc_ctrl = { .open = 0, + .p_cfg = nullptr, + .carry_isr_triggered = false, + .p_callback = nullptr, + .p_callback_memory = nullptr, + .p_context = nullptr, }; #ifndef RTC_CLOCK_SOURCE @@ -458,6 +463,7 @@ rtc_cfg_t rtc_cfg = { .carry_irq = FSP_INVALID_VECTOR, .p_callback = rtc_callback, .p_context = NULL, + .p_extend = NULL, }; #ifdef __cplusplus From 21a3dfd7430209c91710a543ce9a6265b4191aca Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 24 Feb 2025 11:59:40 +0100 Subject: [PATCH 22/43] adc: analogReadResolution fix adc1 resolution --- cores/arduino/analog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/analog.cpp b/cores/arduino/analog.cpp index 37d3d6cc7..a457bc2a3 100644 --- a/cores/arduino/analog.cpp +++ b/cores/arduino/analog.cpp @@ -645,7 +645,7 @@ void analogReadResolution(int bits) { default: _analogRequestedReadResolution = 12; adc.cfg.resolution = ADC_RESOLUTION_12_BIT; - adc1.cfg.resolution = ADC_RESOLUTION_10_BIT; + adc1.cfg.resolution = ADC_RESOLUTION_12_BIT; break; } From 34dd6a4bd624e29c6168fcb03bd09ef60c1614c5 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 26 Feb 2025 16:23:42 +0100 Subject: [PATCH 23/43] RTC: change on interrupt PIN to D7 --- libraries/RTC/examples/Test_RTC/Test_RTC.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/RTC/examples/Test_RTC/Test_RTC.ino b/libraries/RTC/examples/Test_RTC/Test_RTC.ino index 0fcbc5132..eca534eda 100644 --- a/libraries/RTC/examples/Test_RTC/Test_RTC.ino +++ b/libraries/RTC/examples/Test_RTC/Test_RTC.ino @@ -11,8 +11,8 @@ // Include the RTC library #include "RTC.h" -// Define the interrupt pin for LED control during interrupts -const int LED_ON_INTERRUPT = 22; +// Define the pin to toggle on interrupt +const int PIN_ON_INTERRUPT = D7; bool periodicFlag = false; bool alarmFlag = false; @@ -37,7 +37,7 @@ void setup() { // Set LED pins as outputs pinMode(LED_BUILTIN, OUTPUT); - pinMode(LED_ON_INTERRUPT, OUTPUT); + pinMode(PIN_ON_INTERRUPT, OUTPUT); // Initialize the RTC RTC.begin(); @@ -83,10 +83,10 @@ void loop() { // Toggle the LED based on callback state if (clb_st) { - digitalWrite(LED_ON_INTERRUPT, HIGH); + digitalWrite(PIN_ON_INTERRUPT, HIGH); } else { - digitalWrite(LED_ON_INTERRUPT, LOW); + digitalWrite(PIN_ON_INTERRUPT, LOW); } clb_st = !clb_st; // Toggle callback state From 68bdf786b8a9a2e3bf35305a7f4267684e7208a2 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 26 Feb 2025 16:43:52 +0100 Subject: [PATCH 24/43] WiFiS3: remove retries to get localIP --- libraries/WiFiS3/src/WiFi.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.cpp b/libraries/WiFiS3/src/WiFi.cpp index 7e73b94f1..249a9ef05 100644 --- a/libraries/WiFiS3/src/WiFi.cpp +++ b/libraries/WiFiS3/src/WiFi.cpp @@ -332,27 +332,18 @@ IPAddress CWifi::localIP() { int attempts = 0; IPAddress local_IP(0,0,0,0); - do { - delay(100); - if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) { - if(atoi(res.c_str()) == 1) { - if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), IP_ADDR)) { - - local_IP.fromString(res.c_str()); - - } + if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) { + if(atoi(res.c_str()) == 1) { + if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), IP_ADDR)) { + local_IP.fromString(res.c_str()); } - else if(atoi(res.c_str()) == 2) { - if(modem.write(string(PROMPT(_IPSOFTAP)),res, CMD(_IPSOFTAP))) { - - local_IP.fromString(res.c_str()); - } + } + else if(atoi(res.c_str()) == 2) { + if(modem.write(string(PROMPT(_IPSOFTAP)),res, CMD(_IPSOFTAP))) { + local_IP.fromString(res.c_str()); } } - attempts++; } - while(local_IP == IPAddress(0,0,0,0) && attempts < 50); - return local_IP; } From 375fef3cd30cdc845e5066472891205c4cc8370b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 27 Feb 2025 15:57:16 +0100 Subject: [PATCH 25/43] Removed workflow --- .github/workflows/render-documentation.yml | 29 ---------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/render-documentation.yml diff --git a/.github/workflows/render-documentation.yml b/.github/workflows/render-documentation.yml deleted file mode 100644 index a4bfb6ee6..000000000 --- a/.github/workflows/render-documentation.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Render Documentation - -on: - push: - branches: - - main - paths: - - ".github/workflows/render-documentation.ya?ml" - - "./libraries/WiFiS3/examples/**" - - "./libraries/WiFiS3/src/**" - pull_request: - branches: - - main - paths: - - ".github/workflows/render-documentation.ya?ml" - - "./libraries/WiFiS3/examples/**" - - "./libraries/WiFiS3/src/**" - workflow_dispatch: - -jobs: - render-docs: - permissions: - contents: write - uses: arduino/render-docs-github-action/.github/workflows/render-docs.yml@main - with: - source-path: './libraries/WiFiS3/src' - target-path: './libraries/WiFiS3/docs/api.md' - exclude-pattern: 'StringHelpers.h WiFi.h Modem.h' - commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PR \ No newline at end of file From f2d11bf7479eab8cea785fe5fe3cc975df17d2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 27 Feb 2025 16:53:29 +0100 Subject: [PATCH 26/43] Removed duplicate functions --- libraries/WiFiS3/src/WiFi.h | 225 +++++++++++++++++------------------- 1 file changed, 103 insertions(+), 122 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 8e003bb28..081b08d4d 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -1,7 +1,6 @@ #ifndef ARDUINO_WiFi_S3_H #define ARDUINO_WiFi_S3_H - #include #include "WiFiCommands.h" @@ -13,13 +12,14 @@ #include "WiFiUdp.h" #include "WiFiSSLClient.h" -#define DEFAULT_IP_AP_ADDRESS IPAddress(192,168,4,1) -#define DEFAULT_GW_AP_ADDRESS IPAddress(192,168,1,1) -#define DEFAULT_NM_AP_ADDRESS IPAddress(255,255,255,0) +#define DEFAULT_IP_AP_ADDRESS IPAddress(192, 168, 4, 1) +#define DEFAULT_GW_AP_ADDRESS IPAddress(192, 168, 1, 1) +#define DEFAULT_NM_AP_ADDRESS IPAddress(255, 255, 255, 0) #define WIFI_FIRMWARE_LATEST_VERSION "0.5.2" -class CAccessPoint { +class CAccessPoint +{ public: std::string ssid; std::string bssid; @@ -29,17 +29,16 @@ class CAccessPoint { std::string encryption_mode; }; - - /** * @brief Class to manage Wi-Fi connectivity and operations. - * - * The CWifi class provides an interface to manage Wi-Fi operations such as connecting - * to networks, setting up an access point, retrieving network information, and more. - * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages + * + * The CWifi class provides an interface to manage Wi-Fi operations such as connecting + * to networks, setting up an access point, retrieving network information, and more. + * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages * connection settings such as IP address, DNS, and other network configurations. */ -class CWifi { +class CWifi +{ private: void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); unsigned long _timeout; @@ -47,14 +46,10 @@ class CWifi { std::string ssid; std::string apssid; - IPAddress ip_ap = DEFAULT_IP_AP_ADDRESS; IPAddress gw_ap = DEFAULT_GW_AP_ADDRESS; IPAddress nm_ap = DEFAULT_NM_AP_ADDRESS; - - - public: /** * @brief Default constructor for the CWifi class. @@ -64,7 +59,7 @@ class CWifi { /** * @brief Get firmware version */ - static const char* firmwareVersion(); + static const char *firmwareVersion(); /* * Get firmware version U32 * @@ -74,25 +69,19 @@ class CWifi { */ uint32_t firmwareVersionU32(); - /** - * @brief Start WiFi connection for OPEN networks. - * - * @param `ssid` a pointer to the SSID string. - */ - int begin(const char* ssid); - /* * PING */ int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1); int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1); - int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1); + int ping(const char *host, uint8_t ttl = 128, uint8_t count = 1); - /* - * Start WiFi connection for OPEN networks - * param ssid: Pointer to the SSID string. + /** + * @brief Start WiFi connection for OPEN networks. + * + * @param `ssid` a pointer to the SSID string. */ - int begin(const char* ssid); + int begin(const char *ssid); /* Start WiFi connection with passphrase * the most secure supported mode will be automatically selected @@ -101,7 +90,7 @@ class CWifi { * @param `passphrase` Passphrase. Valid characters in a passphrase * must be between ASCII 32-126 (decimal). */ - int begin(const char* ssid, const char *passphrase); + int begin(const char *ssid, const char *passphrase); /** * @brief Starts a Wi-Fi Access Point with the specified SSID. @@ -110,21 +99,20 @@ class CWifi { * It defaults to an open network (no password) and uses channel 1 for the AP. * * @param `ssid` The SSID (network name) of the Access Point. - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point initialization failed. */ uint8_t beginAP(const char *ssid); - uint8_t beginAP(const char *ssid); /** * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. * - * This function initializes a Wi-Fi Access Point (AP) with the provided SSID + * This function initializes a Wi-Fi Access Point (AP) with the provided SSID * and channel. It defaults to using no password (open network). * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. * @param `channel` The channel on which the Access Point will operate. - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ uint8_t beginAP(const char *ssid, uint8_t channel); @@ -132,31 +120,30 @@ class CWifi { /** * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. * - * This function initializes a Wi-Fi Access Point (AP) using the provided SSID + * This function initializes a Wi-Fi Access Point (AP) using the provided SSID * and passphrase, defaulting to channel 1. * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. - * @param `passphrase` The passphrase for securing the Access Point. If empty, the + * @param `passphrase` The passphrase for securing the Access Point. If empty, the * network will be open (no password). - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ - uint8_t beginAP(const char *ssid, const char* passphrase); + uint8_t beginAP(const char *ssid, const char *passphrase); /** * @brief Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. * - * This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. + * This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. * It sets the mode to AP and attempts to start the network. * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. * @param `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. * @param `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). - * + * * @return `WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start. */ - uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel); - + uint8_t beginAP(const char *ssid, const char *passphrase, uint8_t channel); /** * @brief Change IP configuration settings disabling the DHCP client @@ -217,7 +204,7 @@ class CWifi { * * @param `name` sets the hostname. */ - void setHostname(const char* name); + void setHostname(const char *name); /** * @brief Disconnects from the current Wi-Fi network. @@ -233,86 +220,86 @@ class CWifi { /** * @brief Retrieves the MAC address of the device. - * + * * This function retrieves the MAC address of the device based on its current operating mode. - * The value returned by this function is meaningfull only if called afert a - * begin (both begin or beginAP) or a ScanNetwork function otherwise + * The value returned by this function is meaningfull only if called afert a + * begin (both begin or beginAP) or a ScanNetwork function otherwise * an empty mac address is returned. - * + * * @param `_mac` A pointer to a uint8_t array where the MAC address will be stored. - * + * * @return uint8_t* The pointer to the array with length WL_MAC_ADDR_LENGTH. */ - uint8_t* macAddress(uint8_t* mac); + uint8_t *macAddress(uint8_t *mac); /** * @brief Retrieves the local IP address of the device. - * - * This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) + * + * This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) * and retrieves the appropriate IP address based on the mode. - * + * * @return `IPAddress` The local IP address of the device. */ IPAddress localIP(); /** * @brief Retrieves the subnet mask of the device. - * - * This function retrieves the subnet mask of the device by querying the modem for the subnet information. + * + * This function retrieves the subnet mask of the device by querying the modem for the subnet information. * It sends a command to the modem to fetch the subnet mask and returns it as an `IPAddress` object. - * + * * @return `IPAddress` The subnet mask address value of the device. */ IPAddress subnetMask(); - /** - * @brief Retrieves the gateway IP address of the device. - * - * This function retrieves the gateway IP address of the device by querying the modem for the gateway - * information. It sends a command to the modem to fetch the gateway IP address and returns it as an - * `IPAddress` object. - * - * @return `IPAddress` The gateway IP address value of the device. - */ - IPAddress gatewayIP(); - - /** - * @brief Retrieves the DNS IP address. - * - * @param `n` The index of the DNS server to retrieve, `0` for the primary DNS server - * and `1` for the secondary DNS server. - * - * @return `IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. - */ - IPAddress dnsIP(int n = 0); + /** + * @brief Retrieves the gateway IP address of the device. + * + * This function retrieves the gateway IP address of the device by querying the modem for the gateway + * information. It sends a command to the modem to fetch the gateway IP address and returns it as an + * `IPAddress` object. + * + * @return `IPAddress` The gateway IP address value of the device. + */ + IPAddress gatewayIP(); + + /** + * @brief Retrieves the DNS IP address. + * + * @param `n` The index of the DNS server to retrieve, `0` for the primary DNS server + * and `1` for the secondary DNS server. + * + * @return `IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. + */ + IPAddress dnsIP(int n = 0); /** * @brief Retrieves the IP address of the soft access point (AP). - * + * * @return `IPAddress` The IP address of the soft AP as an `IPAddress` object, or `0.0.0.0` if not found. */ IPAddress softAPIP(); /** * @brief Retrieves the SSID of the current Wi-Fi connection or SoftAP. - * + * * @return The SSID of the current Wi-Fi connection or SoftAP as a string. * If unable to retrieve the SSID, returns an empty string. */ - const char* SSID(); + const char *SSID(); /** * @brief Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. - * + * * @param `bssid` A pointer to an array where the BSSID will be stored. The array must be large enough to hold the MAC address. - * + * * @return A pointer to the `bssid` array containing the retrieved BSSID. If the BSSID cannot be retrieved, returns `nullptr`. */ - uint8_t* BSSID(uint8_t* bssid); + uint8_t *BSSID(uint8_t *bssid); /** * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. - * + * * @return The RSSI value representing the signal strength. A higher (less negative) value indicates a stronger signal. * If the RSSI cannot be retrieved, returns 0. */ @@ -320,46 +307,46 @@ class CWifi { /** * @brief Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. - * + * * @return The SSID of the SoftAP. If the SSID cannot be retrieved, an empty string is returned. */ - const char* softAPSSID(); + const char *softAPSSID(); /** * @brief Scans for available Wi-Fi networks and stores the information in the `access_points` list. - * - * This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, + * + * This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, * RSSI (signal strength), channel, and encryption mode for each detected access point. - * + * * @return The number of networks found during the scan. Returns a negative value in case of an error. */ int8_t scanNetworks(); /** * @brief Retrieves the SSID of a specific Wi-Fi network from the scan results. - * + * * @param `networkItem` The index of the network in the list of scanned access points. - * + * * @return The SSID of the specified network, or `nullptr` if the index is out of bounds. */ - const char* SSID(uint8_t networkItem); + const char *SSID(uint8_t networkItem); /** * @brief Returns the encryption type for a specified network. - * + * * This function retrieves the encryption type of a specific Wi-Fi access point * based on its index in the list of scanned networks. - * + * * @param `networkItem` The index of the network in the list of available access points. - * - * @return The encryption type in numeric form (e.g., 0 for no encryption, + * + * @return The encryption type in numeric form (e.g., 0 for no encryption, * 1 for WEP, 2 for WPA, etc.). Returns 0 if the network item index is invalid. */ uint8_t encryptionType(uint8_t networkItem); /** * @brief Returns the encryption type of the currently connected Wi-Fi network. - * + * * @return The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). * Returns `ENC_TYPE_UNKNOWN` if the encryption type cannot be determined. */ @@ -367,42 +354,42 @@ class CWifi { /** * @brief Retrieves the BSSID of a specific Wi-Fi network. - * + * * This function retrieves the BSSID (MAC address) of the Wi-Fi network at the specified - * index from the list of available networks. The BSSID is stored in the provided + * index from the list of available networks. The BSSID is stored in the provided * array of 6 bytes. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. * @param `bssid` A pointer to a byte array (of size 6) where the BSSID will be stored. - * - * @return A pointer to the `bssid` array if the BSSID is successfully retrieved, + * + * @return A pointer to the `bssid` array if the BSSID is successfully retrieved, * or `nullptr` if the network index is out of range. */ - uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid); + uint8_t *BSSID(uint8_t networkItem, uint8_t *bssid); /** * @brief Retrieves the channel number of a specific Wi-Fi network. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. - * - * @return The channel number of the specified network, or `0` if the network index + * + * @return The channel number of the specified network, or `0` if the network index * is out of range. */ uint8_t channel(uint8_t networkItem); /** * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. - * - * @return The RSSI value of the specified network in dBm, or `-1000` if the network index + * + * @return The RSSI value of the specified network in dBm, or `-1000` if the network index * is out of range. */ int32_t RSSI(uint8_t networkItem); /** * @brief Retrieves the current connection status of the Wi-Fi connection. - * + * * @return One of the values defined in wl_status_t */ uint8_t status(); @@ -416,42 +403,36 @@ class CWifi { /** * @brief Resolves a hostname to an IP address. - * + * * @param `aHostname` The hostname to resolve (e.g., "www.example.com"). - * @param `aResult` IPAddress structure to store the returned IP address result: + * @param `aResult` IPAddress structure to store the returned IP address result: * 1 if aIPAddrString was successfully converted to an IP address, else error code - * + * * @return Returns `1` if the hostname was successfully resolved, `0` otherwise. */ - int hostByName(const char* aHostname, IPAddress& aResult); + int hostByName(const char *aHostname, IPAddress &aResult); /** * @brief Retrieves the current time from the modem. - * + * * @return The current time value in seconds, or `0` if the time could not be retrieved. */ unsigned long getTime(); /** * @brief Sets the timeout value for the WiFi connection. - * + * * @param `timeout` The timeout value in milliseconds. */ void setTimeout(unsigned long timeout); - - }; /** * @brief Global instance of the CWifi class. - * - * This external declaration provides access to a global instance of the `CWifi` class, which + * + * This external declaration provides access to a global instance of the `CWifi` class, which * facilitates interaction with the WiFi module. */ extern CWifi WiFi; - - - #endif - From 4a741b73b23a3e0d002c5852811750f40660a8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 27 Feb 2025 16:57:49 +0100 Subject: [PATCH 27/43] Revert "Removed duplicate functions" This reverts commit f2d11bf7479eab8cea785fe5fe3cc975df17d2e9. --- libraries/WiFiS3/src/WiFi.h | 225 +++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 103 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 081b08d4d..8e003bb28 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -1,6 +1,7 @@ #ifndef ARDUINO_WiFi_S3_H #define ARDUINO_WiFi_S3_H + #include #include "WiFiCommands.h" @@ -12,14 +13,13 @@ #include "WiFiUdp.h" #include "WiFiSSLClient.h" -#define DEFAULT_IP_AP_ADDRESS IPAddress(192, 168, 4, 1) -#define DEFAULT_GW_AP_ADDRESS IPAddress(192, 168, 1, 1) -#define DEFAULT_NM_AP_ADDRESS IPAddress(255, 255, 255, 0) +#define DEFAULT_IP_AP_ADDRESS IPAddress(192,168,4,1) +#define DEFAULT_GW_AP_ADDRESS IPAddress(192,168,1,1) +#define DEFAULT_NM_AP_ADDRESS IPAddress(255,255,255,0) #define WIFI_FIRMWARE_LATEST_VERSION "0.5.2" -class CAccessPoint -{ +class CAccessPoint { public: std::string ssid; std::string bssid; @@ -29,16 +29,17 @@ class CAccessPoint std::string encryption_mode; }; + + /** * @brief Class to manage Wi-Fi connectivity and operations. - * - * The CWifi class provides an interface to manage Wi-Fi operations such as connecting - * to networks, setting up an access point, retrieving network information, and more. - * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages + * + * The CWifi class provides an interface to manage Wi-Fi operations such as connecting + * to networks, setting up an access point, retrieving network information, and more. + * It interfaces with a modem to execute commands related to Wi-Fi functionality and manages * connection settings such as IP address, DNS, and other network configurations. */ -class CWifi -{ +class CWifi { private: void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); unsigned long _timeout; @@ -46,10 +47,14 @@ class CWifi std::string ssid; std::string apssid; + IPAddress ip_ap = DEFAULT_IP_AP_ADDRESS; IPAddress gw_ap = DEFAULT_GW_AP_ADDRESS; IPAddress nm_ap = DEFAULT_NM_AP_ADDRESS; + + + public: /** * @brief Default constructor for the CWifi class. @@ -59,7 +64,7 @@ class CWifi /** * @brief Get firmware version */ - static const char *firmwareVersion(); + static const char* firmwareVersion(); /* * Get firmware version U32 * @@ -69,19 +74,25 @@ class CWifi */ uint32_t firmwareVersionU32(); + /** + * @brief Start WiFi connection for OPEN networks. + * + * @param `ssid` a pointer to the SSID string. + */ + int begin(const char* ssid); + /* * PING */ int ping(IPAddress ip, uint8_t ttl = 128, uint8_t count = 1); int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1); - int ping(const char *host, uint8_t ttl = 128, uint8_t count = 1); + int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1); - /** - * @brief Start WiFi connection for OPEN networks. - * - * @param `ssid` a pointer to the SSID string. + /* + * Start WiFi connection for OPEN networks + * param ssid: Pointer to the SSID string. */ - int begin(const char *ssid); + int begin(const char* ssid); /* Start WiFi connection with passphrase * the most secure supported mode will be automatically selected @@ -90,7 +101,7 @@ class CWifi * @param `passphrase` Passphrase. Valid characters in a passphrase * must be between ASCII 32-126 (decimal). */ - int begin(const char *ssid, const char *passphrase); + int begin(const char* ssid, const char *passphrase); /** * @brief Starts a Wi-Fi Access Point with the specified SSID. @@ -99,20 +110,21 @@ class CWifi * It defaults to an open network (no password) and uses channel 1 for the AP. * * @param `ssid` The SSID (network name) of the Access Point. - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point initialization failed. */ uint8_t beginAP(const char *ssid); + uint8_t beginAP(const char *ssid); /** * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. * - * This function initializes a Wi-Fi Access Point (AP) with the provided SSID + * This function initializes a Wi-Fi Access Point (AP) with the provided SSID * and channel. It defaults to using no password (open network). * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. * @param `channel` The channel on which the Access Point will operate. - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ uint8_t beginAP(const char *ssid, uint8_t channel); @@ -120,30 +132,31 @@ class CWifi /** * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and passphrase. * - * This function initializes a Wi-Fi Access Point (AP) using the provided SSID + * This function initializes a Wi-Fi Access Point (AP) using the provided SSID * and passphrase, defaulting to channel 1. * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. - * @param `passphrase` The passphrase for securing the Access Point. If empty, the + * @param `passphrase` The passphrase for securing the Access Point. If empty, the * network will be open (no password). - * + * * @return `1` if the Access Point is successfully started. `0` if the Access Point failed to start. */ - uint8_t beginAP(const char *ssid, const char *passphrase); + uint8_t beginAP(const char *ssid, const char* passphrase); /** * @brief Initializes a Wi-Fi Access Point (AP) with the specified SSID, passphrase, and channel. * - * This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. + * This function configures the device as a Wi-Fi Access Point (AP) with the provided parameters. * It sets the mode to AP and attempts to start the network. * * @param `ssid` The SSID (name) of the Wi-Fi Access Point. * @param `passphrase` The passphrase for securing the Access Point. If empty, the network will be open. * @param `channel` The Wi-Fi channel on which the Access Point will operate (1-14, depending on region). - * + * * @return `WL_AP_LISTENING` if the Access Point is successfully started. `WL_AP_FAILED` if the Access Point failed to start. */ - uint8_t beginAP(const char *ssid, const char *passphrase, uint8_t channel); + uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel); + /** * @brief Change IP configuration settings disabling the DHCP client @@ -204,7 +217,7 @@ class CWifi * * @param `name` sets the hostname. */ - void setHostname(const char *name); + void setHostname(const char* name); /** * @brief Disconnects from the current Wi-Fi network. @@ -220,86 +233,86 @@ class CWifi /** * @brief Retrieves the MAC address of the device. - * + * * This function retrieves the MAC address of the device based on its current operating mode. - * The value returned by this function is meaningfull only if called afert a - * begin (both begin or beginAP) or a ScanNetwork function otherwise + * The value returned by this function is meaningfull only if called afert a + * begin (both begin or beginAP) or a ScanNetwork function otherwise * an empty mac address is returned. - * + * * @param `_mac` A pointer to a uint8_t array where the MAC address will be stored. - * + * * @return uint8_t* The pointer to the array with length WL_MAC_ADDR_LENGTH. */ - uint8_t *macAddress(uint8_t *mac); + uint8_t* macAddress(uint8_t* mac); /** * @brief Retrieves the local IP address of the device. - * - * This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) + * + * This function retrieves the local IP address of the device. It checks the current mode (station or soft AP) * and retrieves the appropriate IP address based on the mode. - * + * * @return `IPAddress` The local IP address of the device. */ IPAddress localIP(); /** * @brief Retrieves the subnet mask of the device. - * - * This function retrieves the subnet mask of the device by querying the modem for the subnet information. + * + * This function retrieves the subnet mask of the device by querying the modem for the subnet information. * It sends a command to the modem to fetch the subnet mask and returns it as an `IPAddress` object. - * + * * @return `IPAddress` The subnet mask address value of the device. */ IPAddress subnetMask(); - /** - * @brief Retrieves the gateway IP address of the device. - * - * This function retrieves the gateway IP address of the device by querying the modem for the gateway - * information. It sends a command to the modem to fetch the gateway IP address and returns it as an - * `IPAddress` object. - * - * @return `IPAddress` The gateway IP address value of the device. - */ - IPAddress gatewayIP(); - - /** - * @brief Retrieves the DNS IP address. - * - * @param `n` The index of the DNS server to retrieve, `0` for the primary DNS server - * and `1` for the secondary DNS server. - * - * @return `IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. - */ - IPAddress dnsIP(int n = 0); + /** + * @brief Retrieves the gateway IP address of the device. + * + * This function retrieves the gateway IP address of the device by querying the modem for the gateway + * information. It sends a command to the modem to fetch the gateway IP address and returns it as an + * `IPAddress` object. + * + * @return `IPAddress` The gateway IP address value of the device. + */ + IPAddress gatewayIP(); + + /** + * @brief Retrieves the DNS IP address. + * + * @param `n` The index of the DNS server to retrieve, `0` for the primary DNS server + * and `1` for the secondary DNS server. + * + * @return `IPAddress` The DNS IP address as an `IPAddress` object, or `0.0.0.0` if not found. + */ + IPAddress dnsIP(int n = 0); /** * @brief Retrieves the IP address of the soft access point (AP). - * + * * @return `IPAddress` The IP address of the soft AP as an `IPAddress` object, or `0.0.0.0` if not found. */ IPAddress softAPIP(); /** * @brief Retrieves the SSID of the current Wi-Fi connection or SoftAP. - * + * * @return The SSID of the current Wi-Fi connection or SoftAP as a string. * If unable to retrieve the SSID, returns an empty string. */ - const char *SSID(); + const char* SSID(); /** * @brief Retrieves the BSSID (MAC address) of the currently connected Wi-Fi network. - * + * * @param `bssid` A pointer to an array where the BSSID will be stored. The array must be large enough to hold the MAC address. - * + * * @return A pointer to the `bssid` array containing the retrieved BSSID. If the BSSID cannot be retrieved, returns `nullptr`. */ - uint8_t *BSSID(uint8_t *bssid); + uint8_t* BSSID(uint8_t* bssid); /** * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the currently connected Wi-Fi network. - * + * * @return The RSSI value representing the signal strength. A higher (less negative) value indicates a stronger signal. * If the RSSI cannot be retrieved, returns 0. */ @@ -307,46 +320,46 @@ class CWifi /** * @brief Retrieves the SSID (Service Set Identifier) of the SoftAP (Software Access Point) mode. - * + * * @return The SSID of the SoftAP. If the SSID cannot be retrieved, an empty string is returned. */ - const char *softAPSSID(); + const char* softAPSSID(); /** * @brief Scans for available Wi-Fi networks and stores the information in the `access_points` list. - * - * This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, + * + * This function initiates a scan for nearby Wi-Fi networks and retrieves details such as SSID, BSSID, * RSSI (signal strength), channel, and encryption mode for each detected access point. - * + * * @return The number of networks found during the scan. Returns a negative value in case of an error. */ int8_t scanNetworks(); /** * @brief Retrieves the SSID of a specific Wi-Fi network from the scan results. - * + * * @param `networkItem` The index of the network in the list of scanned access points. - * + * * @return The SSID of the specified network, or `nullptr` if the index is out of bounds. */ - const char *SSID(uint8_t networkItem); + const char* SSID(uint8_t networkItem); /** * @brief Returns the encryption type for a specified network. - * + * * This function retrieves the encryption type of a specific Wi-Fi access point * based on its index in the list of scanned networks. - * + * * @param `networkItem` The index of the network in the list of available access points. - * - * @return The encryption type in numeric form (e.g., 0 for no encryption, + * + * @return The encryption type in numeric form (e.g., 0 for no encryption, * 1 for WEP, 2 for WPA, etc.). Returns 0 if the network item index is invalid. */ uint8_t encryptionType(uint8_t networkItem); /** * @brief Returns the encryption type of the currently connected Wi-Fi network. - * + * * @return The encryption type in numeric form (e.g., 0 for no encryption, 1 for WEP, 2 for WPA, etc.). * Returns `ENC_TYPE_UNKNOWN` if the encryption type cannot be determined. */ @@ -354,42 +367,42 @@ class CWifi /** * @brief Retrieves the BSSID of a specific Wi-Fi network. - * + * * This function retrieves the BSSID (MAC address) of the Wi-Fi network at the specified - * index from the list of available networks. The BSSID is stored in the provided + * index from the list of available networks. The BSSID is stored in the provided * array of 6 bytes. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. * @param `bssid` A pointer to a byte array (of size 6) where the BSSID will be stored. - * - * @return A pointer to the `bssid` array if the BSSID is successfully retrieved, + * + * @return A pointer to the `bssid` array if the BSSID is successfully retrieved, * or `nullptr` if the network index is out of range. */ - uint8_t *BSSID(uint8_t networkItem, uint8_t *bssid); + uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid); /** * @brief Retrieves the channel number of a specific Wi-Fi network. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. - * - * @return The channel number of the specified network, or `0` if the network index + * + * @return The channel number of the specified network, or `0` if the network index * is out of range. */ uint8_t channel(uint8_t networkItem); /** * @brief Retrieves the RSSI (Received Signal Strength Indicator) of the networks discovered during the scanNetworks. - * + * * @param `networkItem` The index of the Wi-Fi network in the list of available networks. - * - * @return The RSSI value of the specified network in dBm, or `-1000` if the network index + * + * @return The RSSI value of the specified network in dBm, or `-1000` if the network index * is out of range. */ int32_t RSSI(uint8_t networkItem); /** * @brief Retrieves the current connection status of the Wi-Fi connection. - * + * * @return One of the values defined in wl_status_t */ uint8_t status(); @@ -403,36 +416,42 @@ class CWifi /** * @brief Resolves a hostname to an IP address. - * + * * @param `aHostname` The hostname to resolve (e.g., "www.example.com"). - * @param `aResult` IPAddress structure to store the returned IP address result: + * @param `aResult` IPAddress structure to store the returned IP address result: * 1 if aIPAddrString was successfully converted to an IP address, else error code - * + * * @return Returns `1` if the hostname was successfully resolved, `0` otherwise. */ - int hostByName(const char *aHostname, IPAddress &aResult); + int hostByName(const char* aHostname, IPAddress& aResult); /** * @brief Retrieves the current time from the modem. - * + * * @return The current time value in seconds, or `0` if the time could not be retrieved. */ unsigned long getTime(); /** * @brief Sets the timeout value for the WiFi connection. - * + * * @param `timeout` The timeout value in milliseconds. */ void setTimeout(unsigned long timeout); + + }; /** * @brief Global instance of the CWifi class. - * - * This external declaration provides access to a global instance of the `CWifi` class, which + * + * This external declaration provides access to a global instance of the `CWifi` class, which * facilitates interaction with the WiFi module. */ extern CWifi WiFi; + + + #endif + From af03bb1f7fc7a9b10a3b421208d22ea20f5f6b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 27 Feb 2025 17:01:21 +0100 Subject: [PATCH 28/43] Removed duplicate functions --- libraries/WiFiS3/src/WiFi.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 8e003bb28..c14a209d7 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -74,13 +74,6 @@ class CWifi { */ uint32_t firmwareVersionU32(); - /** - * @brief Start WiFi connection for OPEN networks. - * - * @param `ssid` a pointer to the SSID string. - */ - int begin(const char* ssid); - /* * PING */ @@ -88,9 +81,10 @@ class CWifi { int ping(const String &hostname, uint8_t ttl = 128, uint8_t count = 1); int ping(const char* host, uint8_t ttl = 128, uint8_t count = 1); - /* - * Start WiFi connection for OPEN networks - * param ssid: Pointer to the SSID string. + /** + * @brief Start WiFi connection for OPEN networks. + * + * @param `ssid` a pointer to the SSID string. */ int begin(const char* ssid); @@ -114,7 +108,6 @@ class CWifi { * @return `1` if the Access Point is successfully started. `0` if the Access Point initialization failed. */ uint8_t beginAP(const char *ssid); - uint8_t beginAP(const char *ssid); /** * @brief Starts a Wi-Fi Access Point (AP) with the specified SSID and channel. From 3c9ef2862374c4c500d47a1dc4a461c15446b116 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Mon, 24 Feb 2025 16:32:17 +0100 Subject: [PATCH 29/43] lwIpWrapper: rebuild lwip library to enable LWIP_RAW --- extras/net/lwipopts.h | 4 ++-- .../lwIpWrapper/src/cortex-m33/liblwIP.a | Bin 274428 -> 278314 bytes libraries/lwIpWrapper/src/lwipopts.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extras/net/lwipopts.h b/extras/net/lwipopts.h index 87d0d9a5c..3d8022920 100644 --- a/extras/net/lwipopts.h +++ b/extras/net/lwipopts.h @@ -277,7 +277,7 @@ * (requires the LWIP_RAW option) */ #ifndef MEMP_NUM_RAW_PCB -#define MEMP_NUM_RAW_PCB 0 +#define MEMP_NUM_RAW_PCB 1 #endif /** @@ -642,7 +642,7 @@ * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. */ #ifndef LWIP_RAW -#define LWIP_RAW 0 +#define LWIP_RAW 1 #endif /* diff --git a/libraries/lwIpWrapper/src/cortex-m33/liblwIP.a b/libraries/lwIpWrapper/src/cortex-m33/liblwIP.a index adaabfb1cd45db2e25e5800f1377a10dcf103d47..687e03a87e792d87c96efb5d6cfc284b98329b2b 100644 GIT binary patch delta 9761 zcmc&Z3s{s@+UNbg85l-JKNys&FgVB{C=C}8yp({Bng-r#DKkJoArXd)R{pdjyT2FI z3_Y92TrJ(Sr)_N?aI(qYOS)OvmK(IzYPVlg*IO!-e^Tq_|DNyr24-OBY5(?l{_mOh zd(V44?{{wRIcIMFxAgK4QggUtOu98Ib4>aetI32vd_3PK)9B2sOqp#e(h~w>2pP7a ze@Ln#q(7MaEg^lup)hCOOUV7p2r2l)H0S0ke>sNpJV*T zD}?;3@J2Kt9NrORaJUQqPZ;}OjpV0bfK<{A37ZN0Um^c{0x~$<1s`}pG=ZN3k8dLI zW3Xm60SABmR5*}9;HSVx$pqYR{$m0^0uJcNBfUW&Uz2Vay@3dBn6Q-yo{;|q5jgCd zO@y`=eZ$o&MCczJvQV6Qh4c%{9wnk18aEU1$Drj!BKC%l|4c+*aBTw-uMOs}4MZb6 zpg>eA(Ts~=8?7+Z8K5l}bW6&X*b8T8|H4`6e^qeQ7C%;4QDt9RPk3oTMOA5cp|Gl~ zzG9(FmQ+_&m6a$ur4@CaWNlf=GFhjttg5uWy0BtlVO?#B2dBFz7i!CvR4*%&i&bTh z5hJe^3xyT-!uludvViVzgwp)IL!3+WGYmR)InQ9RV+A8*xXxw>mEg<{e;@jYTAvq| zfOB)yJAFlp)rFY8R?ZW#$8^12IbTVvjPPb^Gty0_RF<6$NzT&A0eWvKWH_7hC9OBp zkDFv#X>w$u^ZeX!(OZfp;RRg-yqP*~lAfNDO0AIz#)mOO;iFBLQ34rBl4x~lEa>UR z(lPjcw{)q9JxR05EPmyv6GiAFW%FoDxW>7^Y>o&6SavhS43e$Ymq-$5WJQzzNTh?v zaQcUeyC9N&T5;E`aPn7GM<>f-$r&#?hTQa`hvLGeFcf_=8R$iaI;TH62-4ldt#D>; z4j}{4LT@Exh>8;s3nK{eLmZt(2zM2oM%OORr_U~yW=|wU!!_L7)3mLs zo{q28!3cU^^^}0e{go<4(CyVz=*T+GzlNm-xirCU20Jabo9Rh=7~N)<0=A$&4}JvQ zXOE$AHDUBCyJXnm=AtBs9o+>+8damC^(Y=+BN<-u5E~g>7mTzL#m7**zD5dYaf|8h zniv{V8%95?k-}ehbJ1rg0&gH*a}K?~*23D3h*J0w50!8amHBixsuXMzgLG~U`b=#M z)zpR2_iLr_Ha8b-hI-ghI=Rlmx;BYYz$v#19bFfror^uLW7%&(D7DuG2At^@uB?k; zFKrPd+EA^d2kWH7OKuUmHG8nVpj!3Pdi6g43m&6p>ZOzN70=Tk=nU9^df0Zy;(aI zTQP{iBGE|q)CYObOUPg;2F+cpc@9W4Y-t#NaLUrb&bybU3L!dYZh1+o#!6zL`Od8$ z?jYXcYgK_f2tMvOa9ZalTS$(*_ zF-Y@9<`6`_zLNvQAv+91MljC0IjRFbAA@l|m-RBJQ{{28JdCVB+Wqhf)~NCfEC-Va zoS1H@GV%7P@^V=oMfL;kthkO6Ks0%;m%$~~K#`ls?OyT-?0U{p0vbj}sdT(tK^)0O z+WqhVr>pXrSPmxfLd!aSPdSS4ZtbMA0_3wgX=JuXZpj&Y$%;20OKRE{SiAdb#e zmcZyq>QabIZYS7!WBNs7r~|oq+ta-8E#)$6_La+$9# zw6l7!74@R$C{4_xm7~UJO~~ibCUZQSkRrs>1$0n~1zrIki_s6LxIi)Be4IW+{~*dZ zo~H&dpAZzucD&K_53B3$g863Rq^l}+KNP&fqt?oo(1OPB$QT%2?++8xH_Jh>On*2u8tF|2D*H8JY1qX zS6hTk1N}1+6KUsa3(Tb9Yb+2*v+=!xR^U61Zp8N*x*y+GdUlP4b~Odkkftb@OH-OG zu!TO@WMPt7qk(c-Q*ESMnk4N@212a#l_oRXr0uA5ihkE*(FWo=6UIM^X0Das44t-? zyRX6bCHgGBr_!VN?x2_PZKpx&ECLxw$F7TqBeWO^X&_yT#D}zXokja0`jQtg+ObZ8 z85GuAv}-hkbkI@j&DzItyj1fg%B&5;RQiCjS~ailvs%$Z>vux{EqUtfAiaq%O4lz! zlF$ye06J&G)1Y^r+b|^Bdx=xF9@flEzV&dJ24JUnY&~MIgGXJyl|TGGf7^)i@(S(~ znu%$J?LW$6^JrHUi4RFnw}z`>^Gyt&7WPSEd!xKHa-DXLvjO zc3Anmjtw4dw>X*tkI1`TeTV;gIWwe4_JoSM?y`Z}_-ZRg65 zcLiG0%F~O^6@lr4izM+(+u{nE^Lg72+xhahFAApbFOoOpaPeho4R0M#E*24!eM)tQ zme{9+w{Gmplpy8Zy-;hPGO;xa<+(+<4Y?g4=GOP<5p!;lSex5mM!qAr-ah5XWo@v1 z%Bag7xhq=?wq{$5O=J7K%i2s5X10;Uyf%_FqisKiIIS(aA*e&}liC(H8Iy8O6Z14% zge}2#;xb7S7;hDo3`c%r}I1Rq;`HJ5 z5#>=uUly5cnTL2c>9}w7!A=#xDA#v6xUZ*29u9$RbZ2@JYxtWefj^C19z#v@B{s4O zOl-z=aUji`A51G34P=j2K`J#(li0y3uxfEekdYKJlH^hXYn%sJ?2~yg1QKXUd1Mfm z_dMamz+ei*&|RA)2j7J9jIawK7&Dy-vHRf}0C$ny52v#cxW1B>{m8v4jWZE>{sdP+ zSso$NI#Q<6+%_1uGxaLXmrTsz!Q@Gmaad*yAWyTb^Fj=~!Wt{Z7-s*AAhDK8QRB5& zIHTI+$u^XYMoF&DTmDME#%XMYS z@wV4tl(iK>m;)0P(c|888)6}mkR2SGmF=lMg^&eYj)~sRF&<-9aEzz6%^aircN~u< zWDm!<$yARAyB zS84flLk)Kac%18#>&qUmPv&hR_kcI4p7DE_?xTGV$K$-;!<0|`$+cybJuI*Dzk~P^ z`e62AslDZG%r6T1aJp{{dQ0%mqOgMMzLW+msH>B|8wVtXs$6zG6E?sub~FUc0fBhB z;Cr7a+BzpRfHyCHPT`&-lpXv6_ZLTA(7-^R)S;9XpEp7TFArXZN_>8}4T6!7WXZZ- zl3^(ElO@mfk|dzyFqhDl7c^}ALI@0q!)W*zh+-EW5o5G}M~ytL!J-O9$?&i{R@5-C z;%h=AvzCDdWcTb~fJQRZql%6@Kp4athd`uuJdO=3+c^Zxh6a@Kp~R&@?Alm}6exdZSp#_9h?v4Wc2!VUz;B{zL)zfPg)_BSmcINy5nmqB>9GwGu| z10wq6+k<-I>Z#mnO--jMkrwB!ufr|g3V7B$9S++;<9aLtUXJf0oREzfOy^pe4cP!X z_D&AmgQR~h+%5IibrsKnG%WyorT~TmxDFJ+551J+ZC_dnMuXcvm*!Cz9@xi=e6i-* z`xtoMto3|LYF0)j{}$J=Cm?Vrq`BHRL(l-k=XSz!kBhSG!~6!1J+TMogTL!pWiP=yzMu8fmjajCNKkKv{kQrMj<5amkz z3>*L{u9rWD_dKrQxT<_fm!8V17Kush=vjCZTx{i+a28guMdzRfO4;diurDIZCUy)G ze@hZ<&PKkofrMY%qT8}@m&dlAhpD4({QYFtach|k$QhDAZ$ zdt96yd^&%~CR~BLXl14;Ww1ICMN1R;EKRg;JqAU3Vej)BusT2W4_`mh8{E0?>NSV z<~5FS=W>{1%yZ`v3$cV;;uz=mR~*Omq`>tUhCWVBm5BLeBTt~IIfeTGUm0oNrz_RK992Y#;hThQQfQ{FQ> zD#7)UpK#n``SX$u*Y_jCS+&d{c+U17JCwaG`I5YA3J6u8L5>b17D3 ziru~lUv@ad@f!l7eZ{Hxd@#0upS$CH`Ftu~=)peMG>UJC~16*($) zU#8&idTE?+v~Tk^4iqbaE9hL`-R&#(&nF5y`qrj=t#-OE3uO&{AkSCJD=o2mR{t&0 zIoDT9DD_P)@T#wIq}csGi|d(rUUsTXvAg_;FFPfctOZ`NsCJ5MWtlIT;#?fPQJ(x7FpVC9>0a&(t3Dnk#CZ%GVx!qtDmM z8=;J>RI9uZI(bz1&f_0I)%fyfLaE2*MCAtE5^BKpNvE&s6j}2B^ds}pjktC!1J|ej z5Z?9}4jXsMlk(6%g-IR*Smi1fR1kewD6*?sU$PVa;>7;EJs;@H0=1P7*b4tRH3HhKnEc{nE3MqG#Kv7D{WrXc9eBQ%~EVx9`p3U;BE)xKZ|y z#a9&BBYf4QSokIPV}ajWnBwbuap-wY3N^Nk8NS->a+X*+swWYtx)qB=$>U#P&XtE| zR(e{7JT#BhiYMawm?`5r{8`a6+p8{drNYmz+UBd-P}aMll~D lrf0mm-Q$$NRQqncCWt;Cs&$P^)cmQt|J^#_BQ@v5{{`v)m7o9s delta 8838 zcmbta3v?7!60LeYlg}g}lYsdVk|BecNkB45Cc{Lcgx?s%BVhpn0f`(07Lg=?2ntR( zx{4A7dAiLCN6{5UVdXPw>xQ!dL5T8G@V6e0;QC{afQYQ070K4??wJhGnP#<5s;ghU z`>NijUcKs`yma1v?x=l5cFzBG;broB@{FgUZ$*h1;Fp6;BQs1*$W`(^{n4T z!QZRkH?==g1E5h5Fni-~r-61rGaBUu?39ABD)qWQt_O@o3ugfSKeX`%z%T{F4@P|V z5Wp~fZ~`zEeKr;FV)||upiZo?4kFZd7BHQH>O=KrV1l0S1#HIxV>+@8mZ1`@BkOfX%{CNzOiujVt*R-htecV+k$ovC{;r>f|LkaiM=Y zc6VS)4eW#;f9$+j?Rm z58l>~?#gX>2=zsIAhZtUo}qC|?a=7rYXno8W!`irm2Z0ptqq18@jl0nkfuZ>ZspO5|_O{|PLsN<)UQ&`^)|2$wIa%EHusv~HMA}NyN9Sb8SJzAS z#JY$$b#6ZYl)!B(l5gkbTSt=(H@|gQS6+Chy?7O=swEYoKh7vsM+rrL;2{#%B2qduBmFqZB!C7@ z2=D{)W5tCj9tLoX~5%2&v1otAX|@~|$Ughj6* zjtjLeuE!pt@6;(shj>^+T$IyQN`Uq9UK`5~?$E`;57WU0hlqzS;a8s$iDp`TGMv7k z+y#Es%j1ZrlP4wu1}Fc+TI1zHF4V9P}f4qQ<0fPY<7 zFJ@SXv$%fI#{aL*V1!(HzH|6-t>bPKk;W3{9>V4QK?_QvUt_=nciJ*(UI{E^p|>{Y>I#in_@M_Dgo_W^$b@p1IV? z<^yjSl#zZ9A;k&_mEu|e^7dz>41V`gJ8Mhk%}Wcd%_PoMsP4P(HO4 z?d*6m@AFWhRZNHmo%xWRolfS99x7zVK;HZ;sr);MeoE&12VfJerj1Vw-LoP=UUIH(t|%_@@t!uaTOol?6P*F*wjna z@Nlyo*YefPF6Nhb!{`kD2?^HoZwORJpjs7F{D_^sp2DjhDa6fk>oZa&zndg&DZKfS zLiVP_*AB_x?~sHZMNkZoMQYnXv!h;B77-M!3oH~AdC8+r>p1ehF>>n&bPj!&dVdq) z!z?dr(+ zj5-i1+0zpd`N+0)$U;B14Mvng{oi@RLZ$y47$#BGfJ3gHs1DB($ZF9B8ZLkQMuJ*{ z{J}#m#L%Wg_oiV*sP7jyrVv~F-R{)by_}3#3S+}v zwRj!IEA_QF5HVifG7<++@w<_DtvzN#W%v{beO$ue%z6!Z^3Kq*NTd*(2DLYzll0-be z6)PCV$zyilP%5t8fzNe~Sf^%}zI06Z0INF2UM!j&=Ps&_gHhq4`03iQ=6wUfaUJME_xC>@}wMp7K@lW zAbZYYj#Y@-l;LM_fW&q&Zub={ulDC}wt6V^!n!J~A5}x8Jm?ar+!KuYO`VbH-IsE90cD%%{W?yu)^*&Z{ED)4N+DNuduR|Y#-)Tac) zKC0)BA{Vl#bHWg)Y5cs%RHHUM{jM?{wPyN3&t;lETyAQ*rGlM~k3^^ngJ?%XEA#l| zTR*@e<%et7ukn%CXoMCYWc(e$+Yq7+_u%!>!!-nM>LHQaOZW(>|&iWzuL>+Ga+3 zb_}(dvrW}%Bbwf5IwB1inr8~sM$~@SWttvwkGaOhEGjuL9B;766hZ^=T$YzUxHP)! zK7;+C2e*%wnF51SNIZFoaBgJbD0zkP%NYa^#%9u(wUjwLfWU zj&w!sYD06Rr2&<$e~n&2L!jmplb<)8FAccqMN^>Wj_n&wO&@*PbfhI)O(DTo+31ca zXgJ1ix0z}gu-z20e5Wbo=x)=6sUIZVZtdRaIMJ_jNB;Hz&3EKPFapwv;HxatP6YNI z`#Hx9?X6UEQzdYMRdl4*MyizoaZ)2H2`ELK>oI^6Etdm~a$Q4Rbk592B{4~g`r2;@ z{3cl%(h)WcA)2loX{Nd~VD=TJz+WdP{^zq_d}GFoM#i&kI`DhmrPM;9&CzAL4u zaAr6qGynqjDv}O%1R_IVYH!JGsWkt1za)Cu{YK7AOGQTA<x=`B}ZTF)$z_V Date: Mon, 24 Feb 2025 16:33:12 +0100 Subject: [PATCH 30/43] lwIpWrapper: CNetIf add ping command --- libraries/Ethernet/src/Ethernet.cpp | 23 ++++++ libraries/Ethernet/src/EthernetC33.h | 6 ++ libraries/WiFi/src/WiFi.cpp | 25 ++++++- libraries/WiFi/src/WiFiC3.h | 7 +- libraries/lwIpWrapper/src/CNetIf.cpp | 105 +++++++++++++++++++++++++++ libraries/lwIpWrapper/src/CNetIf.h | 10 +++ 6 files changed, 173 insertions(+), 3 deletions(-) diff --git a/libraries/Ethernet/src/Ethernet.cpp b/libraries/Ethernet/src/Ethernet.cpp index 993ea2372..c2570d13f 100644 --- a/libraries/Ethernet/src/Ethernet.cpp +++ b/libraries/Ethernet/src/Ethernet.cpp @@ -223,4 +223,27 @@ IPAddress CEthernet::dnsServerIP() { return CLwipIf::getInstance().getDns(); } +/* -------------------------------------------------------------------------- */ +int CEthernet::ping(IPAddress ip, uint8_t ttl) { +/* -------------------------------------------------------------------------- */ + return CLwipIf::getInstance().ping(ip, ttl); +} + +/* -------------------------------------------------------------------------- */ +int CEthernet::ping(const String &hostname, uint8_t ttl) +/* -------------------------------------------------------------------------- */ +{ + return ping(hostname.c_str(), ttl); +} + +/* -------------------------------------------------------------------------- */ +int CEthernet::ping(const char* host, uint8_t ttl) { +/* -------------------------------------------------------------------------- */ + IPAddress ip; + if(CLwipIf::getInstance().getHostByName(host,ip)) { + return CLwipIf::getInstance().ping(ip, ttl); + } + return -1; +} + CEthernet Ethernet; diff --git a/libraries/Ethernet/src/EthernetC33.h b/libraries/Ethernet/src/EthernetC33.h index 5c684fe63..5147d0464 100644 --- a/libraries/Ethernet/src/EthernetC33.h +++ b/libraries/Ethernet/src/EthernetC33.h @@ -69,6 +69,12 @@ class CEthernet { IPAddress gatewayIP(); IPAddress dnsServerIP(); + /* + * PING + */ + int ping(IPAddress ip, uint8_t ttl = 128); + int ping(const String &hostname, uint8_t ttl = 128); + int ping(const char* host, uint8_t ttl = 128); friend class EthernetClient; friend class EthernetServer; diff --git a/libraries/WiFi/src/WiFi.cpp b/libraries/WiFi/src/WiFi.cpp index ba19f311c..db773d457 100644 --- a/libraries/WiFi/src/WiFi.cpp +++ b/libraries/WiFi/src/WiFi.cpp @@ -321,12 +321,33 @@ unsigned long CWifi::getTime() { return 0; } - - void CWifi::setTimeout(unsigned long timeout) { (void)(timeout); } +/* -------------------------------------------------------------------------- */ +int CWifi::ping(IPAddress ip, uint8_t ttl) { +/* -------------------------------------------------------------------------- */ + return CLwipIf::getInstance().ping(ip, ttl); +} + +/* -------------------------------------------------------------------------- */ +int CWifi::ping(const String &hostname, uint8_t ttl) +/* -------------------------------------------------------------------------- */ +{ + return ping(hostname.c_str(), ttl); +} + +/* -------------------------------------------------------------------------- */ +int CWifi::ping(const char* host, uint8_t ttl) { +/* -------------------------------------------------------------------------- */ + IPAddress ip; + if(hostByName(host,ip)) { + return CLwipIf::getInstance().ping(ip, ttl); + } + return -1; +} + CWifi WiFi; diff --git a/libraries/WiFi/src/WiFiC3.h b/libraries/WiFi/src/WiFiC3.h index 2995cdcf9..2ff804d42 100644 --- a/libraries/WiFi/src/WiFiC3.h +++ b/libraries/WiFi/src/WiFiC3.h @@ -254,7 +254,12 @@ class CWifi { void setTimeout(unsigned long timeout); - + /* + * PING + */ + int ping(IPAddress ip, uint8_t ttl = 128); + int ping(const String &hostname, uint8_t ttl = 128); + int ping(const char* host, uint8_t ttl = 128); }; diff --git a/libraries/lwIpWrapper/src/CNetIf.cpp b/libraries/lwIpWrapper/src/CNetIf.cpp index 810b14075..94aa7eb11 100644 --- a/libraries/lwIpWrapper/src/CNetIf.cpp +++ b/libraries/lwIpWrapper/src/CNetIf.cpp @@ -1,5 +1,9 @@ #include "CNetIf.h" #include +#include "lwip/include/lwip/raw.h" +#include "lwip/include/lwip/icmp.h" +#include "lwip/include/lwip/ip_addr.h" +#include "lwip/include/lwip/inet_chksum.h" IPAddress CNetIf::default_ip("192.168.0.10"); IPAddress CNetIf::default_nm("255.255.255.0"); @@ -14,6 +18,32 @@ bool CLwipIf::pending_eth_rx = false; FspTimer CLwipIf::timer; +u8_t icmp_receive_callback(void* arg, struct raw_pcb* pcb, struct pbuf* p, const ip_addr_t* addr) +{ + struct ping_data *d = (struct ping_data*)arg; + struct __attribute__((__packed__)) { + struct ip_hdr ipHeader; + struct icmp_echo_hdr header; + } response; + + if(d->s == pcb) { + if(p->len < sizeof(response)) { + pbuf_free(p); + return 1; + } + + pbuf_copy_partial(p, &response, sizeof(response), 0); + + if(response.header.id == d->echo_req.id && response.header.seqno == d->echo_req.seqno) { + d->endMillis = millis(); + } + pbuf_free(p); + return 1; + } + + return 0; +} + ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr) { IP_ADDR4(ipaddr, ipu8[0], ipu8[1], ipu8[2], ipu8[3]); @@ -120,6 +150,81 @@ void CLwipIf::lwip_task() } } +int CLwipIf::ping(IPAddress ip, uint8_t ttl) +{ + uint32_t result = -1; + uint32_t timeout = 5000; + uint32_t sendTime = 0; + uint32_t startWait = 0; + struct pbuf *p; + struct raw_pcb* s; + struct ping_data *d = new ping_data; + if (!d){ + goto exit; + } + + //Create a raw socket + s = raw_new(IP_PROTO_ICMP); + if(!s) { + goto exit; + } + + struct __attribute__((__packed__)) { + struct icmp_echo_hdr header; + uint8_t data[32]; + } request; + + ICMPH_TYPE_SET(&request.header, ICMP_ECHO); + ICMPH_CODE_SET(&request.header, 0); + request.header.chksum = 0; + request.header.id = 0xAFAF; + request.header.seqno = random(0xffff); + + d->echo_req = request.header; + + for (size_t i = 0; i < sizeof(request.data); i++) { + request.data[i] = i; + } + + request.header.chksum = inet_chksum(&request, sizeof(request)); + + ip_addr_t addr; + addr.addr = ip; + + d->endMillis = 0; + + raw_recv(s, icmp_receive_callback, d); + + // Build the packet + p = pbuf_alloc(PBUF_IP, sizeof(request), PBUF_RAM); + if (!p) { + goto exit; + } + + //Load payload into buffer + pbuf_take(p, &request, sizeof(request)); + + // Send the echo request + sendTime = millis(); + raw_sendto(s, p, &addr); + + // Wait for response + startWait = millis(); + do { + lwip_task(); + } while (d->endMillis == 0 && (millis() - startWait) < timeout); + + if (d->endMillis != 0) { + result = d->endMillis - sendTime; + } + +exit: + pbuf_free(p); + delete d; + raw_remove(s); + return result; +} + /* -------------------------------------------------------------------------- */ /* GET INSTANCE SINGLETONE FUNCTION */ /* -------------------------------------------------------------------------- */ diff --git a/libraries/lwIpWrapper/src/CNetIf.h b/libraries/lwIpWrapper/src/CNetIf.h index 407501b72..7606d6993 100644 --- a/libraries/lwIpWrapper/src/CNetIf.h +++ b/libraries/lwIpWrapper/src/CNetIf.h @@ -131,6 +131,12 @@ ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr); uint32_t ip_addr_to_u32(ip_addr_t* ipaddr); +struct ping_data{ + uint32_t endMillis; + icmp_echo_hdr echo_req; + struct raw_pcb* s; +}; + /* Base class implements DHCP, derived class will switch it on or off */ /* -------------------------------------------------------------------------- */ class CNetIf { @@ -436,6 +442,10 @@ class CLwipIf { int setWifiMode(WifiMode_t mode); void lwip_task(); + /* + * PING + */ + int ping(IPAddress ip, uint8_t ttl = 128); }; #endif From f5374059b08a3e0d76b98d58b5eb34b505e04a6c Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 19 Feb 2025 14:15:42 +0100 Subject: [PATCH 31/43] lwIpWrapper: CNetIf fix ping command --- libraries/lwIpWrapper/src/CNetIf.cpp | 139 ++++++++++++--------------- libraries/lwIpWrapper/src/CNetIf.h | 8 +- 2 files changed, 68 insertions(+), 79 deletions(-) diff --git a/libraries/lwIpWrapper/src/CNetIf.cpp b/libraries/lwIpWrapper/src/CNetIf.cpp index 94aa7eb11..e80065459 100644 --- a/libraries/lwIpWrapper/src/CNetIf.cpp +++ b/libraries/lwIpWrapper/src/CNetIf.cpp @@ -18,30 +18,30 @@ bool CLwipIf::pending_eth_rx = false; FspTimer CLwipIf::timer; -u8_t icmp_receive_callback(void* arg, struct raw_pcb* pcb, struct pbuf* p, const ip_addr_t* addr) +static u8_t icmp_receive_callback(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr) { - struct ping_data *d = (struct ping_data*)arg; - struct __attribute__((__packed__)) { - struct ip_hdr ipHeader; - struct icmp_echo_hdr header; - } response; + struct icmp_echo_hdr *iecho; + (void)(pcb); + (void)(addr); + LWIP_ASSERT("p != NULL", p != NULL); - if(d->s == pcb) { - if(p->len < sizeof(response)) { - pbuf_free(p); - return 1; - } + recv_callback_data* request = (recv_callback_data*)arg; - pbuf_copy_partial(p, &response, sizeof(response), 0); + if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) && + pbuf_remove_header(p, PBUF_IP_HLEN) == 0) { + iecho = (struct icmp_echo_hdr *)p->payload; - if(response.header.id == d->echo_req.id && response.header.seqno == d->echo_req.seqno) { - d->endMillis = millis(); + if ((iecho->id == 0xAFAF) && (iecho->seqno == lwip_htons(request->seqNum))) { + /* do some ping result processing */ + request->endMillis = millis(); + pbuf_free(p); + return 1; /* eat the packet */ } - pbuf_free(p); - return 1; + /* not eaten, restore original packet */ + pbuf_add_header(p, PBUF_IP_HLEN); } - return 0; + return 0; /* don't eat the packet */ } ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr) @@ -150,79 +150,68 @@ void CLwipIf::lwip_task() } } + int CLwipIf::ping(IPAddress ip, uint8_t ttl) { - uint32_t result = -1; - uint32_t timeout = 5000; - uint32_t sendTime = 0; - uint32_t startWait = 0; - struct pbuf *p; - struct raw_pcb* s; - struct ping_data *d = new ping_data; - if (!d){ - goto exit; - } + /* ttl is not supported. Default value used is 255 */ + (void)ttl; + ip_addr_t addr; + addr.addr = ip; + recv_callback_data requestCbkData = { 0, 0, (uint16_t)random(0xffff) }; //Create a raw socket - s = raw_new(IP_PROTO_ICMP); - if(!s) { - goto exit; - } - - struct __attribute__((__packed__)) { - struct icmp_echo_hdr header; - uint8_t data[32]; - } request; - - ICMPH_TYPE_SET(&request.header, ICMP_ECHO); - ICMPH_CODE_SET(&request.header, 0); - request.header.chksum = 0; - request.header.id = 0xAFAF; - request.header.seqno = random(0xffff); - - d->echo_req = request.header; - - for (size_t i = 0; i < sizeof(request.data); i++) { - request.data[i] = i; + struct raw_pcb* s = raw_new(IP_PROTO_ICMP); + if (!s) { + return -1; } - request.header.chksum = inet_chksum(&request, sizeof(request)); - - ip_addr_t addr; - addr.addr = ip; - - d->endMillis = 0; + raw_recv(s, icmp_receive_callback, (void*)&requestCbkData); + raw_bind(s, IP_ADDR_ANY); - raw_recv(s, icmp_receive_callback, d); + struct pbuf *p; + struct icmp_echo_hdr *iecho; + size_t ping_size = sizeof(struct icmp_echo_hdr) + 32; - // Build the packet - p = pbuf_alloc(PBUF_IP, sizeof(request), PBUF_RAM); + p = pbuf_alloc(PBUF_IP, (u16_t)ping_size, PBUF_RAM); if (!p) { - goto exit; + raw_remove(s); + return -1; } - //Load payload into buffer - pbuf_take(p, &request, sizeof(request)); + if ((p->len == p->tot_len) && (p->next == NULL)) { + iecho = (struct icmp_echo_hdr *)p->payload; - // Send the echo request - sendTime = millis(); - raw_sendto(s, p, &addr); + size_t i; + size_t data_len = ping_size - sizeof(struct icmp_echo_hdr); - // Wait for response - startWait = millis(); - do { - lwip_task(); - } while (d->endMillis == 0 && (millis() - startWait) < timeout); - - if (d->endMillis != 0) { - result = d->endMillis - sendTime; + ICMPH_TYPE_SET(iecho, ICMP_ECHO); + ICMPH_CODE_SET(iecho, 0); + iecho->chksum = 0; + iecho->id = 0xAFAF; + iecho->seqno = lwip_htons(requestCbkData.seqNum); + + /* fill the additional data buffer with some data */ + for(i = 0; i < data_len; i++) { + ((char*)iecho)[sizeof(struct icmp_echo_hdr) + i] = (char)i; + } + + iecho->chksum = inet_chksum(iecho, ping_size); + requestCbkData.startMillis = millis(); + raw_sendto(s, p, &addr); + + } + pbuf_free(p); + + bool timeout = false; + while (!requestCbkData.endMillis && !timeout) { + timeout = (millis() - requestCbkData.startMillis) > 5000; + } + + if (timeout) { + return -1; } -exit: - pbuf_free(p); - delete d; - raw_remove(s); - return result; + return requestCbkData.endMillis - requestCbkData.startMillis; } /* -------------------------------------------------------------------------- */ diff --git a/libraries/lwIpWrapper/src/CNetIf.h b/libraries/lwIpWrapper/src/CNetIf.h index 7606d6993..21a1ebaf9 100644 --- a/libraries/lwIpWrapper/src/CNetIf.h +++ b/libraries/lwIpWrapper/src/CNetIf.h @@ -131,10 +131,10 @@ ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr); uint32_t ip_addr_to_u32(ip_addr_t* ipaddr); -struct ping_data{ - uint32_t endMillis; - icmp_echo_hdr echo_req; - struct raw_pcb* s; +struct recv_callback_data{ + u32_t startMillis; + u32_t endMillis; + u16_t seqNum; }; /* Base class implements DHCP, derived class will switch it on or off */ From 489d637270f671878a780fb26a052d82dd87241a Mon Sep 17 00:00:00 2001 From: fabik111 Date: Thu, 27 Feb 2025 16:33:05 +0100 Subject: [PATCH 32/43] lwIpWrapper: CNetIf refactor ping functions --- libraries/Ethernet/src/Ethernet.cpp | 14 +++++------ libraries/WiFi/src/WiFi.cpp | 2 +- libraries/lwIpWrapper/src/CNetIf.cpp | 35 +++++++++++++++++----------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/libraries/Ethernet/src/Ethernet.cpp b/libraries/Ethernet/src/Ethernet.cpp index c2570d13f..35bbd4fd3 100644 --- a/libraries/Ethernet/src/Ethernet.cpp +++ b/libraries/Ethernet/src/Ethernet.cpp @@ -226,24 +226,24 @@ IPAddress CEthernet::dnsServerIP() { /* -------------------------------------------------------------------------- */ int CEthernet::ping(IPAddress ip, uint8_t ttl) { /* -------------------------------------------------------------------------- */ - return CLwipIf::getInstance().ping(ip, ttl); + return CLwipIf::getInstance().ping(ip, ttl); } /* -------------------------------------------------------------------------- */ int CEthernet::ping(const String &hostname, uint8_t ttl) /* -------------------------------------------------------------------------- */ { - return ping(hostname.c_str(), ttl); + return ping(hostname.c_str(), ttl); } /* -------------------------------------------------------------------------- */ int CEthernet::ping(const char* host, uint8_t ttl) { /* -------------------------------------------------------------------------- */ - IPAddress ip; - if(CLwipIf::getInstance().getHostByName(host,ip)) { - return CLwipIf::getInstance().ping(ip, ttl); - } - return -1; + IPAddress ip; + if(CLwipIf::getInstance().getHostByName(host,ip)) { + return CLwipIf::getInstance().ping(ip, ttl); + } + return -1; } CEthernet Ethernet; diff --git a/libraries/WiFi/src/WiFi.cpp b/libraries/WiFi/src/WiFi.cpp index db773d457..fe4a7e7b1 100644 --- a/libraries/WiFi/src/WiFi.cpp +++ b/libraries/WiFi/src/WiFi.cpp @@ -335,7 +335,7 @@ int CWifi::ping(IPAddress ip, uint8_t ttl) { int CWifi::ping(const String &hostname, uint8_t ttl) /* -------------------------------------------------------------------------- */ { - return ping(hostname.c_str(), ttl); + return ping(hostname.c_str(), ttl); } /* -------------------------------------------------------------------------- */ diff --git a/libraries/lwIpWrapper/src/CNetIf.cpp b/libraries/lwIpWrapper/src/CNetIf.cpp index e80065459..01a2c169d 100644 --- a/libraries/lwIpWrapper/src/CNetIf.cpp +++ b/libraries/lwIpWrapper/src/CNetIf.cpp @@ -26,22 +26,24 @@ static u8_t icmp_receive_callback(void *arg, struct raw_pcb *pcb, struct pbuf *p LWIP_ASSERT("p != NULL", p != NULL); recv_callback_data* request = (recv_callback_data*)arg; + if ((p->tot_len < (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) || + pbuf_remove_header(p, PBUF_IP_HLEN) != 0) { + return 0; /* don't consume the packet */ + } - if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) && - pbuf_remove_header(p, PBUF_IP_HLEN) == 0) { - iecho = (struct icmp_echo_hdr *)p->payload; + iecho = (struct icmp_echo_hdr *)p->payload; - if ((iecho->id == 0xAFAF) && (iecho->seqno == lwip_htons(request->seqNum))) { - /* do some ping result processing */ - request->endMillis = millis(); - pbuf_free(p); - return 1; /* eat the packet */ - } + if(iecho->id != 0xAFAF || iecho->seqno != lwip_htons(request->seqNum)) { /* not eaten, restore original packet */ pbuf_add_header(p, PBUF_IP_HLEN); + return 0; } - return 0; /* don't eat the packet */ + /* do some ping result processing */ + request->endMillis = millis(); + pbuf_free(p); + return 1; /* consume the packet */ + } ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr) @@ -202,12 +204,17 @@ int CLwipIf::ping(IPAddress ip, uint8_t ttl) } pbuf_free(p); - bool timeout = false; - while (!requestCbkData.endMillis && !timeout) { - timeout = (millis() - requestCbkData.startMillis) > 5000; + CLwipIf::getInstance().startSyncRequest(); + + while (!requestCbkData.endMillis && (millis() - requestCbkData.startMillis) <= 5000) { + CLwipIf::getInstance().lwip_task(); } - if (timeout) { + CLwipIf::getInstance().restartAsyncRequest(); + + raw_remove(s); + + if (!requestCbkData.endMillis) { return -1; } From 7f6ad1ea9b24b4e7cad0c67d62d7272c17a6fbe3 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Thu, 27 Feb 2025 16:33:35 +0100 Subject: [PATCH 33/43] add ping examples --- .../examples/EthernetPing/EthernetPing.ino | 83 ++++++++++++ libraries/WiFi/examples/WiFiPing/WiFiPing.ino | 120 ++++++++++++++++++ .../WiFi/examples/WiFiPing/arduino_secrets.h | 2 + 3 files changed, 205 insertions(+) create mode 100644 libraries/Ethernet/examples/EthernetPing/EthernetPing.ino create mode 100644 libraries/WiFi/examples/WiFiPing/WiFiPing.ino create mode 100644 libraries/WiFi/examples/WiFiPing/arduino_secrets.h diff --git a/libraries/Ethernet/examples/EthernetPing/EthernetPing.ino b/libraries/Ethernet/examples/EthernetPing/EthernetPing.ino new file mode 100644 index 000000000..2baadaadd --- /dev/null +++ b/libraries/Ethernet/examples/EthernetPing/EthernetPing.ino @@ -0,0 +1,83 @@ +/* + Web ICMP Ping + + This sketch pings a device based on the IP address or the hostname + using the Ethernet module. + + created 14 February 2024 + by paulvha + + updated 27 February 2025 + by Fabik111 + + */ + +#include "EthernetC33.h" + +int status = WL_IDLE_STATUS; + +// Set the static IP address to use if the DHCP fails to assign +IPAddress ip(10, 130, 22, 84); + +/* -------------------------------------------------------------------------- */ +void setup() { +/* -------------------------------------------------------------------------- */ + //Initialize serial and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // start the Ethernet connection: + if (Ethernet.begin() == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // try to configure using IP address instead of DHCP: + // IN THAT CASE YOU SHOULD CONFIGURE manually THE DNS or USE the IPAddress Server variable above + // that is what is automatically done here... + Ethernet.begin(ip); + } + // give the Ethernet shield a second to initialize: + delay(2000); +} + +/* -------------------------------------------------------------------------- */ +void loop() { +/* -------------------------------------------------------------------------- */ + + // Ping IP + const IPAddress remote_ip(140,82,121,4); + Serial.print("Trying to ping github.com on IP: "); + Serial.println(remote_ip); + + // using default ping count of 1 + int res = Ethernet.ping(remote_ip); + + if (res > 0) { + Serial.print("Ping response time: "); + Serial.print(res); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on IP!"); + } + + // Ping Host + const char* remote_host = "www.google.com"; + Serial.print("Trying to ping host: "); + Serial.println(remote_host); + + // setting ttl to 128 and ping count to 10 + int res1 = Ethernet.ping(remote_host); + + if (res1 > 0) { + Serial.print("Ping average response time: "); + Serial.print(res1); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on host!"); + } + + Serial.println(); + delay(1000); +} diff --git a/libraries/WiFi/examples/WiFiPing/WiFiPing.ino b/libraries/WiFi/examples/WiFiPing/WiFiPing.ino new file mode 100644 index 000000000..a8f9ee979 --- /dev/null +++ b/libraries/WiFi/examples/WiFiPing/WiFiPing.ino @@ -0,0 +1,120 @@ +/* + Web ICMP Ping + + This sketch pings a device based on the IP address or the hostname + using the WiFi module. By default the attempt is performed 5 times, but can + be changed to max. 255 + + It requires at least version 0.5.0 of USB Wifi bridge firmware and WiFiS3 library. + + This example is written for a network using WPA encryption. For + WEP or WPA, change the WiFi.begin() call accordingly. + + created 14 February 2024 + by paulvha + + updated 27 February 2025 + by Fabik111 + + */ + +#include "WiFiC3.h" +#include "arduino_secrets.h" + +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +int status = WL_IDLE_STATUS; + +/* -------------------------------------------------------------------------- */ +void setup() { +/* -------------------------------------------------------------------------- */ + //Initialize serial and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed."); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 10 seconds for connection: + delay(10000); + } + + printWifiStatus(); +} + +/* -------------------------------------------------------------------------- */ +void loop() { +/* -------------------------------------------------------------------------- */ + + // Ping IP + const IPAddress remote_ip(140,82,121,4); + Serial.print("Trying to ping github.com on IP: "); + Serial.println(remote_ip); + + // using default ping count of 1 + int res = WiFi.ping(remote_ip); + + if (res > 0) { + Serial.print("Ping response time: "); + Serial.print(res); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on IP!"); + } + + // Ping Host + const char* remote_host = "www.google.com"; + Serial.print("Trying to ping host: "); + Serial.println(remote_host); + + // setting ttl to 128 and ping count to 10 + int res1 = WiFi.ping(remote_host); + + if (res1 > 0) { + Serial.print("Ping average response time: "); + Serial.print(res1); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on host!"); + } + + Serial.println(); + delay(1000); +} + +/* -------------------------------------------------------------------------- */ +void printWifiStatus() { +/* -------------------------------------------------------------------------- */ + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/libraries/WiFi/examples/WiFiPing/arduino_secrets.h b/libraries/WiFi/examples/WiFiPing/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiPing/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" From 8094f719bf74c5327438902b9883e8abcef73c9e Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 3 Mar 2025 09:05:20 +0100 Subject: [PATCH 34/43] lwIpWrapper: CNetIf make recv_callback_data a static data structure This ensure access to existing data if icmp callback is fired after ping timeout --- libraries/lwIpWrapper/src/CNetIf.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/lwIpWrapper/src/CNetIf.cpp b/libraries/lwIpWrapper/src/CNetIf.cpp index 01a2c169d..ca1495f50 100644 --- a/libraries/lwIpWrapper/src/CNetIf.cpp +++ b/libraries/lwIpWrapper/src/CNetIf.cpp @@ -43,7 +43,6 @@ static u8_t icmp_receive_callback(void *arg, struct raw_pcb *pcb, struct pbuf *p request->endMillis = millis(); pbuf_free(p); return 1; /* consume the packet */ - } ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr) @@ -159,9 +158,15 @@ int CLwipIf::ping(IPAddress ip, uint8_t ttl) (void)ttl; ip_addr_t addr; addr.addr = ip; - recv_callback_data requestCbkData = { 0, 0, (uint16_t)random(0xffff) }; - //Create a raw socket + /* ICMP ping callback data structure */ + static recv_callback_data requestCbkData; + + /* initialize callback data for a new request */ + memset(&requestCbkData, 0, sizeof(recv_callback_data)); + requestCbkData.seqNum = (uint16_t)random(0xffff); + + /* Create a raw socket */ struct raw_pcb* s = raw_new(IP_PROTO_ICMP); if (!s) { return -1; From e18bdeaaaa799169e6c4a7fdba91d945a0f12bad Mon Sep 17 00:00:00 2001 From: fabik111 Date: Wed, 23 Oct 2024 13:57:24 +0200 Subject: [PATCH 35/43] WiFiS3: make scanNetworks return the first 10 AP with higer RSSI --- libraries/WiFiS3/src/WiFi.cpp | 142 ++++++++++++++++++++++------------ libraries/WiFiS3/src/WiFi.h | 35 +++++++-- 2 files changed, 119 insertions(+), 58 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.cpp b/libraries/WiFiS3/src/WiFi.cpp index 249a9ef05..8be758fd3 100644 --- a/libraries/WiFiS3/src/WiFi.cpp +++ b/libraries/WiFiS3/src/WiFi.cpp @@ -1,5 +1,7 @@ #include "WiFi.h" +#define SSID_MAX_COUNT 12 + using namespace std; /* -------------------------------------------------------------------------- */ @@ -256,6 +258,42 @@ uint8_t* CWifi::macAddress(uint8_t* _mac) { return _mac; } +/* -------------------------------------------------------------------------- */ +void CWifi::_sortAPlist(uint8_t num) { +/* -------------------------------------------------------------------------- */ + for(uint8_t i = 0; i < num; i++) { + for(uint8_t j = i+1; j < num; j++) { + if(access_points[j].rssi > access_points[i].rssi) { + CAccessPoint temp = access_points[i]; + access_points[i] = access_points[j]; + access_points[j] = temp; + } + } + } +} + +static uint8_t Encr2wl_enc(string e) { + if (e == string("open")) { + return ENC_TYPE_NONE; + } else if (e == string("WEP")) { + return ENC_TYPE_WEP; + } else if (e == string("WPA")) { + return ENC_TYPE_WPA; + } else if (e == string("WPA2")) { + return ENC_TYPE_WPA2; + } else if (e == string("WPA+WPA2")) { + return ENC_TYPE_WPA2; + } else if (e == string("WPA2-EAP")) { + return ENC_TYPE_WPA2_ENTERPRISE; + } else if (e == string("WPA2+WPA3")) { + return ENC_TYPE_WPA3; + } else if (e == string("WPA3")) { + return ENC_TYPE_WPA3; + } else { + return ENC_TYPE_UNKNOWN; + } +} + /* -------------------------------------------------------------------------- */ int8_t CWifi::scanNetworks() { /* -------------------------------------------------------------------------- */ @@ -264,30 +302,56 @@ int8_t CWifi::scanNetworks() { modem.avoid_trim_results(); modem.read_using_size(); - access_points.clear(); + memset(access_points,0x00,sizeof(access_points)); + _apsFound = 0; string res; - - vector aps; if(modem.write(string(PROMPT(_WIFISCAN)),res,CMD(_WIFISCAN))) { - - split(aps, res, string("\r\n")); - for(uint16_t i = 0; i < aps.size(); i++) { + char *startAp = (char*)res.c_str(); + char *endAP = strstr(startAp, "\r\n"); + for(; endAP != NULL; startAp = endAP, endAP = strstr(startAp, "\r\n")) { CAccessPoint ap; - vector tokens; - split(tokens, aps[i], string("|")); - if(tokens.size() >= 5) { - ap.ssid = tokens[0]; - ap.bssid = tokens[1]; - macStr2macArray(ap.uint_bssid, ap.bssid.c_str()); - ap.rssi = tokens[2]; - ap.channel = tokens[3]; - ap.encryption_mode = tokens[4]; - access_points.push_back(ap); + char *token[5]; + *endAP++ = '\0'; // Replace \r with \0 + endAP++; + char *startToken = startAp; + char *endToken = strstr(startAp, " | "); + uint8_t i = 0; + for(; i < 5 && endToken != NULL; i++){ + token[i] = startToken; + *endToken++ = '\0'; + endToken = endToken + 2; + startToken = endToken; + endToken = strstr(startToken, " | "); + if(endToken == NULL){ + token[++i] = startToken; + } + } + + if(i>=5) { + if(strlen(token[0]) > WL_SSID_MAX_LENGTH || strlen(token[1]) != WL_MAX_BSSID_LENGTH){ + continue; + } + strcpy(ap.ssid, token[0]); + macStr2macArray(ap.uint_bssid, token[1]); + ap.rssi = atoi(token[2]); + ap.channel = atoi(token[3]); + ap.encryption_mode = Encr2wl_enc(token[4]); + // insert in list + if( _apsFound < WL_MAX_AP_LIST ){ + access_points[_apsFound] = ap; + _apsFound++; + _sortAPlist(_apsFound); + }else{ + if (ap.rssi > access_points[WL_MAX_AP_LIST-1].rssi){ + access_points[WL_MAX_AP_LIST-1] = ap; + _sortAPlist(WL_MAX_AP_LIST); + } + } } } } - return (int8_t)access_points.size(); + return _apsFound; } /* -------------------------------------------------------------------------- */ @@ -376,8 +440,8 @@ IPAddress CWifi::gatewayIP() { /* -------------------------------------------------------------------------- */ const char* CWifi::SSID(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ - if(networkItem < access_points.size()) { - return access_points[networkItem].ssid.c_str(); + if(networkItem < _apsFound) { + return access_points[networkItem].ssid; } return nullptr; } @@ -385,42 +449,20 @@ const char* CWifi::SSID(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ int32_t CWifi::RSSI(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ - if(networkItem < access_points.size()) { - return atoi(access_points[networkItem].rssi.c_str()); + if(networkItem < _apsFound) { + return access_points[networkItem].rssi; } return -1000; } -static uint8_t Encr2wl_enc(string e) { - if (e == string("open")) { - return ENC_TYPE_NONE; - } else if (e == string("WEP")) { - return ENC_TYPE_WEP; - } else if (e == string("WPA")) { - return ENC_TYPE_WPA; - } else if (e == string("WPA2")) { - return ENC_TYPE_WPA2; - } else if (e == string("WPA+WPA2")) { - return ENC_TYPE_WPA2; - } else if (e == string("WPA2-EAP")) { - return ENC_TYPE_WPA2_ENTERPRISE; - } else if (e == string("WPA2+WPA3")) { - return ENC_TYPE_WPA3; - } else if (e == string("WPA3")) { - return ENC_TYPE_WPA3; - } else { - return ENC_TYPE_UNKNOWN; - } -} - /* -------------------------------------------------------------------------- */ uint8_t CWifi::encryptionType() { /* -------------------------------------------------------------------------- */ scanNetworks(); string myssid(SSID()); - for(unsigned int i = 0; i < access_points.size(); i++) { + for(unsigned int i = 0; i < _apsFound; i++) { if(myssid == access_points[i].ssid) { - return Encr2wl_enc(access_points[i].encryption_mode); + return access_points[i].encryption_mode; } } return ENC_TYPE_UNKNOWN; @@ -429,8 +471,8 @@ uint8_t CWifi::encryptionType() { /* -------------------------------------------------------------------------- */ uint8_t CWifi::encryptionType(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ - if(networkItem < access_points.size()) { - return Encr2wl_enc(access_points[networkItem].encryption_mode); + if(networkItem < _apsFound) { + return access_points[networkItem].encryption_mode; } return 0; } @@ -438,7 +480,7 @@ uint8_t CWifi::encryptionType(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ uint8_t* CWifi::BSSID(uint8_t networkItem, uint8_t* bssid) { /* -------------------------------------------------------------------------- */ - if(networkItem < access_points.size()) { + if(networkItem < _apsFound) { for(int i = 0; i < 6; i++) { *(bssid + i) = access_points[networkItem].uint_bssid[i]; } @@ -450,8 +492,8 @@ uint8_t* CWifi::BSSID(uint8_t networkItem, uint8_t* bssid) { /* -------------------------------------------------------------------------- */ uint8_t CWifi::channel(uint8_t networkItem) { /* -------------------------------------------------------------------------- */ - if(networkItem < access_points.size()) { - return atoi(access_points[networkItem].channel.c_str()); + if(networkItem < _apsFound) { + return access_points[networkItem].channel; } return 0; } diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 0e2999b7c..22888a735 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -19,24 +19,43 @@ #define WIFI_FIRMWARE_LATEST_VERSION "0.5.2" +#define WL_MAX_AP_LIST 10 +#define WL_MAX_BSSID_LENGTH 17 +#define WL_MAX_SSID_LENGHT_S WL_SSID_MAX_LENGTH + 1 // +1 for null terminator + class CAccessPoint { public: - std::string ssid; - std::string bssid; + CAccessPoint() {} + CAccessPoint(const CAccessPoint &obj) + { + strcpy(ssid, obj.ssid); + rssi = obj.rssi; + channel = obj.channel; + encryption_mode = obj.encryption_mode; + memcpy(uint_bssid, obj.uint_bssid, sizeof(uint_bssid)); + } + CAccessPoint &operator=(const CAccessPoint &obj) { + strcpy(ssid, obj.ssid); + rssi = obj.rssi; + channel = obj.channel; + encryption_mode = obj.encryption_mode; + memcpy(uint_bssid, obj.uint_bssid, sizeof(uint_bssid)); + } + char ssid[WL_MAX_SSID_LENGHT_S]; uint8_t uint_bssid[6]; - std::string rssi; - std::string channel; - std::string encryption_mode; + int rssi; + uint8_t channel; + uint8_t encryption_mode; }; - - class CWifi { private: void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); + void _sortAPlist(uint8_t num); unsigned long _timeout; - std::vector access_points; + CAccessPoint access_points[WL_MAX_AP_LIST]; + uint8_t _apsFound = 0; std::string ssid; std::string apssid; From 2850297ab0766c4fb59b1b02638b31f1e4df9366 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Wed, 5 Feb 2025 15:42:40 +0100 Subject: [PATCH 36/43] WiFiS3: remove unused define --- libraries/WiFiS3/src/WiFi.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.cpp b/libraries/WiFiS3/src/WiFi.cpp index 8be758fd3..0ee42a4c5 100644 --- a/libraries/WiFiS3/src/WiFi.cpp +++ b/libraries/WiFiS3/src/WiFi.cpp @@ -1,7 +1,5 @@ #include "WiFi.h" -#define SSID_MAX_COUNT 12 - using namespace std; /* -------------------------------------------------------------------------- */ From ec15716f021847999fb79baff31129941f1fb17e Mon Sep 17 00:00:00 2001 From: fabik111 Date: Thu, 27 Feb 2025 12:13:27 +0100 Subject: [PATCH 37/43] WiFiS3: scanNetwors refactor --- libraries/WiFiS3/src/WiFi.cpp | 72 +++++++++++++++++++---------------- libraries/WiFiS3/src/WiFi.h | 10 ++--- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/libraries/WiFiS3/src/WiFi.cpp b/libraries/WiFiS3/src/WiFi.cpp index 0ee42a4c5..9cb2b5c03 100644 --- a/libraries/WiFiS3/src/WiFi.cpp +++ b/libraries/WiFiS3/src/WiFi.cpp @@ -1,5 +1,7 @@ #include "WiFi.h" +#define WIFI_MAX_BSSID_STRING_LENGTH 17 + using namespace std; /* -------------------------------------------------------------------------- */ @@ -306,44 +308,48 @@ int8_t CWifi::scanNetworks() { if(modem.write(string(PROMPT(_WIFISCAN)),res,CMD(_WIFISCAN))) { char *startAp = (char*)res.c_str(); char *endAP = strstr(startAp, "\r\n"); - for(; endAP != NULL; startAp = endAP, endAP = strstr(startAp, "\r\n")) { - CAccessPoint ap; + for(; endAP != NULL; startAp = endAP + 2, endAP = strstr(startAp, "\r\n")) { + /* split the modem response in multiple lines and parse once at time. + * The output will be something like: + * SSID | BSSID | RSSI | CHANNEL | SECURITY + */ + *endAP = '\0'; // Replace \r with \0 + char *token[5]; - *endAP++ = '\0'; // Replace \r with \0 - endAP++; - char *startToken = startAp; - char *endToken = strstr(startAp, " | "); - uint8_t i = 0; - for(; i < 5 && endToken != NULL; i++){ - token[i] = startToken; - *endToken++ = '\0'; - endToken = endToken + 2; - startToken = endToken; - endToken = strstr(startToken, " | "); + uint8_t i = 1; + token[0] = startAp; + for(; i < 5; i++){ + char *endToken = strstr(token[i-1], " | "); if(endToken == NULL){ - token[++i] = startToken; + break; } + memset(endToken, '\0', 3); + token[i] = endToken + 3; } - if(i>=5) { - if(strlen(token[0]) > WL_SSID_MAX_LENGTH || strlen(token[1]) != WL_MAX_BSSID_LENGTH){ - continue; - } - strcpy(ap.ssid, token[0]); - macStr2macArray(ap.uint_bssid, token[1]); - ap.rssi = atoi(token[2]); - ap.channel = atoi(token[3]); - ap.encryption_mode = Encr2wl_enc(token[4]); - // insert in list - if( _apsFound < WL_MAX_AP_LIST ){ - access_points[_apsFound] = ap; - _apsFound++; - _sortAPlist(_apsFound); - }else{ - if (ap.rssi > access_points[WL_MAX_AP_LIST-1].rssi){ - access_points[WL_MAX_AP_LIST-1] = ap; - _sortAPlist(WL_MAX_AP_LIST); - } + if(i < 5 || strlen(token[0]) == 0 || strlen(token[0]) > WL_SSID_MAX_LENGTH || + strlen(token[1]) != WIFI_MAX_BSSID_STRING_LENGTH || + strlen(token[2]) == 0 || strlen(token[3]) == 0 || strlen(token[4]) == 0){ + /* Skip the row and process the next one */ + continue; + } + + CAccessPoint ap; + strcpy(ap.ssid, token[0]); + macStr2macArray(ap.uint_bssid, token[1]); + ap.rssi = atoi(token[2]); + ap.channel = atoi(token[3]); + ap.encryption_mode = Encr2wl_enc(token[4]); + + // insert in list + if( _apsFound < WIFI_MAX_SSID_COUNT ){ + access_points[_apsFound] = ap; + _apsFound++; + _sortAPlist(_apsFound); + }else{ + if (ap.rssi > access_points[WIFI_MAX_SSID_COUNT-1].rssi){ + access_points[WIFI_MAX_SSID_COUNT-1] = ap; + _sortAPlist(WIFI_MAX_SSID_COUNT); } } } diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index 22888a735..cfb8bf011 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -19,9 +19,9 @@ #define WIFI_FIRMWARE_LATEST_VERSION "0.5.2" -#define WL_MAX_AP_LIST 10 -#define WL_MAX_BSSID_LENGTH 17 -#define WL_MAX_SSID_LENGHT_S WL_SSID_MAX_LENGTH + 1 // +1 for null terminator +#ifndef WIFI_MAX_SSID_COUNT + #define WIFI_MAX_SSID_COUNT 10 +#endif class CAccessPoint { public: @@ -41,7 +41,7 @@ class CAccessPoint { encryption_mode = obj.encryption_mode; memcpy(uint_bssid, obj.uint_bssid, sizeof(uint_bssid)); } - char ssid[WL_MAX_SSID_LENGHT_S]; + char ssid[WL_SSID_MAX_LENGTH + 1]; // +1 for null terminator uint8_t uint_bssid[6]; int rssi; uint8_t channel; @@ -54,7 +54,7 @@ class CWifi { void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); void _sortAPlist(uint8_t num); unsigned long _timeout; - CAccessPoint access_points[WL_MAX_AP_LIST]; + CAccessPoint access_points[WIFI_MAX_SSID_COUNT]; uint8_t _apsFound = 0; std::string ssid; std::string apssid; From 64569086a679b075495fb5b5537dcb543796c5e9 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 3 Mar 2025 13:38:48 +0100 Subject: [PATCH 38/43] WiFiS3: add missing return value to CAccessPoint = operator overload --- libraries/WiFiS3/src/WiFi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/WiFiS3/src/WiFi.h b/libraries/WiFiS3/src/WiFi.h index cfb8bf011..62a9e4353 100644 --- a/libraries/WiFiS3/src/WiFi.h +++ b/libraries/WiFiS3/src/WiFi.h @@ -40,6 +40,7 @@ class CAccessPoint { channel = obj.channel; encryption_mode = obj.encryption_mode; memcpy(uint_bssid, obj.uint_bssid, sizeof(uint_bssid)); + return *this; } char ssid[WL_SSID_MAX_LENGTH + 1]; // +1 for null terminator uint8_t uint_bssid[6]; From 936d04864b723271db984c99d7cfabf17c14524d Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 4 Mar 2025 08:40:02 +0100 Subject: [PATCH 39/43] Publish 1.4.0 --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index 19740871b..8b46d2841 100644 --- a/platform.txt +++ b/platform.txt @@ -3,7 +3,7 @@ # https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification name=Arduino Renesas fsp Boards -version=1.3.2 +version=1.4.0 # Compile variables # ------------------------ From e5a09f856ec2beaf85229e56041eb8e57bfa5389 Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 6 Mar 2025 14:35:43 +0100 Subject: [PATCH 40/43] WiFiS3: remove unused variable --- libraries/WiFiS3/src/WiFi.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/WiFiS3/src/WiFi.cpp b/libraries/WiFiS3/src/WiFi.cpp index 9cb2b5c03..35fa33d68 100644 --- a/libraries/WiFiS3/src/WiFi.cpp +++ b/libraries/WiFiS3/src/WiFi.cpp @@ -397,7 +397,6 @@ IPAddress CWifi::localIP() { /* -------------------------------------------------------------------------- */ modem.begin(); string res = ""; - int attempts = 0; IPAddress local_IP(0,0,0,0); if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) { From 158e81c7913d908803d7742150afb0f068209a92 Mon Sep 17 00:00:00 2001 From: Mattia Pennasilico Date: Mon, 10 Mar 2025 12:38:40 +0100 Subject: [PATCH 41/43] Publish 1.4.1 --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index 8b46d2841..7acc348c8 100644 --- a/platform.txt +++ b/platform.txt @@ -3,7 +3,7 @@ # https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification name=Arduino Renesas fsp Boards -version=1.4.0 +version=1.4.1 # Compile variables # ------------------------ From 240388ed7b17b8f0b426248c6d66a1034f208c6c Mon Sep 17 00:00:00 2001 From: Mike Cookson <144849826+mgcookson@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:55:50 -0400 Subject: [PATCH 42/43] Do not attempt to read fixed sized result data when indicated length of that data is zero --- libraries/WiFiS3/src/Modem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/WiFiS3/src/Modem.cpp b/libraries/WiFiS3/src/Modem.cpp index d20b1bc7d..9665634c6 100644 --- a/libraries/WiFiS3/src/Modem.cpp +++ b/libraries/WiFiS3/src/Modem.cpp @@ -298,6 +298,9 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_ sized_read_size = atoi(data_res.c_str()); data_res.clear(); + if (sized_read_size == 0) { + state = at_parse_state_t::Res; + } } else if(c == '\r') { state = at_parse_state_t::ResWaitLF; } else if(c == '\n') { From f048f7f439ff4051152c1ab96819a557c34dd2ae Mon Sep 17 00:00:00 2001 From: Mike Cookson <144849826+mgcookson@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:09:10 -0400 Subject: [PATCH 43/43] Improve code readability --- libraries/WiFiS3/src/Modem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.cpp b/libraries/WiFiS3/src/Modem.cpp index 9665634c6..44303d9a3 100644 --- a/libraries/WiFiS3/src/Modem.cpp +++ b/libraries/WiFiS3/src/Modem.cpp @@ -289,16 +289,16 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_ * in case multiple parameters separated by ',' are sent, they will be present in data_res * - if we encounter we need to wait for * - if we encounter we need to parse the response status - * - if we encounter '|', the next token will contain binary sized data, the current value in + * - if we encounter '|', the next token will contain binary sized data, the current value * in data_res contains the length of the next token */ if(c == '|') { // sized read, the previous parameter is the length - state = at_parse_state_t::Sized; - sized_read_size = atoi(data_res.c_str()); data_res.clear(); - if (sized_read_size == 0) { + if (sized_read_size != 0) { + state = at_parse_state_t::Sized; + } else { state = at_parse_state_t::Res; } } else if(c == '\r') {