-
-
Notifications
You must be signed in to change notification settings - Fork 104
WifiS3 - Non blocking Wifi connect #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
99df703
7350bbb
a260388
2d6b21e
61b798f
b233fe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… timeout value for buf_read in modem. Fix bug where timout is reset to the default of 10000ms when calling begin
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,89 +17,89 @@ | |||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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, | ||||||||||||||||||
| * a modem through serial communication. It includes methods for initialization, | ||||||||||||||||||
| * sending and receiving data, and handling modem configurations. | ||||||||||||||||||
| */ | ||||||||||||||||||
| 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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| 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); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @brief Destructor for ModemClass. | ||||||||||||||||||
| */ | ||||||||||||||||||
| ~ModemClass(); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @brief Initializes the modem communication with a specified baud rate. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param[in] `badurate` sets the baud rate for the serial connection. | ||||||||||||||||||
| */ | ||||||||||||||||||
| void begin(int badurate = 115200, int retry = 3); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| bool write(const std::string &cmd, std::string &str, const char * fmt, ...); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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, ...); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| 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 | ||||||||||||||||||
| /** | ||||||||||||||||||
| * @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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| 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); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @brief Destructor for ModemClass. | ||||||||||||||||||
| */ | ||||||||||||||||||
| ~ModemClass(); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @brief Initializes the modem communication with a specified baud rate. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param[in] `badurate` sets the baud rate for the serial connection. | ||||||||||||||||||
| */ | ||||||||||||||||||
| void begin(int badurate = 115200, int retry = 3); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| bool write(const std::string &cmd, std::string &str, const char * fmt, ...); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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, ...); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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. | ||||||||||||||||||
| */ | ||||||||||||||||||
| 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; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -109,9 +109,9 @@ class ModemClass { | |||||||||||||||||
| * to be read is considered for processing. | ||||||||||||||||||
| */ | ||||||||||||||||||
| void read_using_size() { | ||||||||||||||||||
| // read_by_size = true; // deprecated | ||||||||||||||||||
| // read_by_size = true; // deprecated | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| bool beginned; | ||||||||||||||||||
|
|
||||||||||||||||||
| /* Calling this function with no argument will enable debug message to be printed | ||||||||||||||||||
|
|
@@ -143,11 +143,32 @@ class ModemClass { | |||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @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;} | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * @brief Gets the timeout value for communication operations. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @return Can be called to get the specified timeout value in milliseconds. | ||||||||||||||||||
|
Comment on lines
+152
to
+154
|
||||||||||||||||||
| * @brief Gets the timeout value for communication operations. | |
| * | |
| * @return Can be called to get the specified timeout value in milliseconds. | |
| * @brief Gets the timeout value for modem communication operations. | |
| * | |
| * @return The current timeout value (in milliseconds) used for modem communication operations. |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation says "Can be called to get the specified read timeout value" but doesn't document what this timeout is used for or how it differs from the general timeout. Consider adding more context like "Gets the timeout value used specifically for read operations during modem communication."
| * @brief Gets the timeout value for reading communication operations. | |
| * | |
| * @return Can be called to get the specified read timeout value in milliseconds. | |
| * @brief Gets the timeout value used specifically for read operations during modem communication. | |
| * | |
| * This timeout determines how long the modem will wait for data to be read from the communication interface | |
| * before timing out. It is distinct from the general communication timeout, which applies to overall operations. | |
| * @return The specified read timeout value in milliseconds. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,6 +63,7 @@ class CWifi { | |||||||||||||||||||||
| void _config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2); | ||||||||||||||||||||||
| void _sortAPlist(uint8_t num); | ||||||||||||||||||||||
| unsigned long _timeout; | ||||||||||||||||||||||
| unsigned long _start_connection_time; | ||||||||||||||||||||||
k3ldar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
k3ldar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| CAccessPoint access_points[WIFI_MAX_SSID_COUNT]; | ||||||||||||||||||||||
| uint8_t _apsFound = 0; | ||||||||||||||||||||||
| std::string ssid; | ||||||||||||||||||||||
|
|
@@ -453,7 +454,12 @@ class CWifi { | |||||||||||||||||||||
| */ | ||||||||||||||||||||||
| void setTimeout(unsigned long timeout); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /* | ||||||||||||||||||||||
| * @brief Retrieves the connected state | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return Current connection state of WL_CONNECT_FAILED, WL_CONNECTED or WL_CONNECTING | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
k3ldar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
k3ldar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| int isConnected(); | ||||||||||||||||||||||
|
Comment on lines
+458
to
+462
|
||||||||||||||||||||||
| * @brief Retrieves the connected state | |
| * | |
| * @return Current connection state of WL_CONNECT_FAILED, WL_CONNECTED or WL_CONNECTING | |
| */ | |
| int isConnected(); | |
| * @brief Retrieves the current connection status. | |
| * | |
| * @return Current connection state: WL_CONNECT_FAILED, WL_CONNECTED, or WL_CONNECTING. | |
| */ | |
| int getConnectionStatus(); |
Uh oh!
There was an error while loading. Please reload this page.