mirror of
https://github.com/espressif/arduino-esp32.git
synced 2026-03-13 09:41:48 +08:00
fix(wifi): Fix conflicting param name and add String overloads (#12343)
* fix(wifi): Fix conflicting param name and add String overloads * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c4eab5fa26
commit
1a98625a64
@@ -448,7 +448,7 @@ begin
|
||||
|
||||
.. code-block:: arduino
|
||||
|
||||
wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
|
||||
wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool tryConnect = true);
|
||||
|
||||
Where:
|
||||
|
||||
@@ -456,11 +456,11 @@ Where:
|
||||
* ``passphrase`` sets the AP password. Set as ``NULL`` for open networks.
|
||||
* ``channel`` sets the Wi-Fi channel.
|
||||
* ``uint8_t* bssid`` sets the AP BSSID.
|
||||
* ``connect`` sets ``true`` to connect to the configured network automatically.
|
||||
* ``tryConnect`` sets ``true`` to connect to the configured network automatically.
|
||||
|
||||
.. code-block:: arduino
|
||||
|
||||
wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
|
||||
wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool tryConnect = true);
|
||||
|
||||
Where:
|
||||
|
||||
@@ -468,7 +468,11 @@ Where:
|
||||
* ``passphrase`` sets the AP password. Set as ``NULL`` for open networks.
|
||||
* ``channel`` sets the Wi-Fi channel.
|
||||
* ``bssid`` sets the AP BSSID.
|
||||
* ``connect`` sets ``true`` to connect to the configured network automatically.
|
||||
* ``tryConnect`` sets ``true`` to connect to the configured network automatically.
|
||||
|
||||
.. note::
|
||||
|
||||
The ``begin`` function also accepts ``String`` types for the ``ssid`` and ``passphrase`` parameters, providing convenient overloads for use with Arduino ``String`` objects.
|
||||
|
||||
Function to start the connection after being configured.
|
||||
|
||||
@@ -476,6 +480,27 @@ Function to start the connection after being configured.
|
||||
|
||||
wl_status_t begin();
|
||||
|
||||
connect
|
||||
*******
|
||||
|
||||
Function to connect to a Wi-Fi network. This is called internally by ``begin`` but can also be used directly for more control.
|
||||
|
||||
.. code-block:: arduino
|
||||
|
||||
bool connect(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool tryConnect = true);
|
||||
|
||||
Where:
|
||||
|
||||
* ``ssid`` sets the AP SSID.
|
||||
* ``passphrase`` sets the AP password. Set as ``NULL`` for open networks.
|
||||
* ``channel`` sets the Wi-Fi channel.
|
||||
* ``bssid`` sets the AP BSSID.
|
||||
* ``tryConnect`` sets ``true`` to connect to the configured network automatically.
|
||||
|
||||
.. note::
|
||||
|
||||
The ``connect`` function also accepts ``String`` types for the ``ssid`` and ``passphrase`` parameters, providing convenient overloads for use with Arduino ``String`` objects.
|
||||
|
||||
config
|
||||
******
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ bool STAClass::connect() {
|
||||
* @param passphrase const char * Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
|
||||
* @param bssid uint8_t[6] Optional. BSSID / MAC of AP
|
||||
* @param channel Optional. Channel of AP
|
||||
* @param connect Optional. call connect
|
||||
* @param tryConnect Optional. call connect
|
||||
* @return
|
||||
*/
|
||||
bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool tryConnect) {
|
||||
@@ -437,7 +437,7 @@ bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel
|
||||
* @param client_key const char* Pointer to a string with the contents of a .key file with client key
|
||||
* @param bssid uint8_t[6] Optional. BSSID / MAC of AP
|
||||
* @param channel Optional. Channel of AP
|
||||
* @param connect Optional. call connect
|
||||
* @param tryConnect Optional. call connect
|
||||
* @return
|
||||
*/
|
||||
bool STAClass::connect(
|
||||
|
||||
@@ -49,6 +49,14 @@ public:
|
||||
const char *ssid, const char *passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false,
|
||||
wifi_auth_mode_t auth_mode = WIFI_AP_DEFAULT_AUTH_MODE, wifi_cipher_type_t cipher = WIFI_AP_DEFAULT_CIPHER
|
||||
);
|
||||
|
||||
bool create(
|
||||
const String &ssid, const String &passphrase = emptyString, int channel = 1, int ssid_hidden = 0, int max_connection = 4, bool ftm_responder = false,
|
||||
wifi_auth_mode_t auth_mode = WIFI_AP_DEFAULT_AUTH_MODE, wifi_cipher_type_t cipher = WIFI_AP_DEFAULT_CIPHER
|
||||
) {
|
||||
return create(ssid.c_str(), passphrase.c_str(), channel, ssid_hidden, max_connection, ftm_responder, auth_mode, cipher);
|
||||
}
|
||||
|
||||
bool clear();
|
||||
|
||||
bool bandwidth(wifi_bandwidth_t bandwidth);
|
||||
|
||||
@@ -66,13 +66,15 @@ wl_status_t WiFiSTAClass::status() {
|
||||
#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT
|
||||
wl_status_t WiFiSTAClass::begin(
|
||||
const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity, const char *wpa2_username, const char *wpa2_password, const char *ca_pem,
|
||||
const char *client_crt, const char *client_key, int ttls_phase2_type, int32_t channel, const uint8_t *bssid, bool connect
|
||||
const char *client_crt, const char *client_key, int ttls_phase2_type, int32_t channel, const uint8_t *bssid, bool tryConnect
|
||||
) {
|
||||
if (!STA.begin()) {
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
if (!STA.connect(wpa2_ssid, method, wpa2_identity, wpa2_username, wpa2_password, ca_pem, client_crt, client_key, ttls_phase2_type, channel, bssid, connect)) {
|
||||
if (!STA.connect(
|
||||
wpa2_ssid, method, wpa2_identity, wpa2_username, wpa2_password, ca_pem, client_crt, client_key, ttls_phase2_type, channel, bssid, tryConnect
|
||||
)) {
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
@@ -80,12 +82,12 @@ wl_status_t WiFiSTAClass::begin(
|
||||
}
|
||||
#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */
|
||||
|
||||
wl_status_t WiFiSTAClass::begin(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool connect) {
|
||||
wl_status_t WiFiSTAClass::begin(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool tryConnect) {
|
||||
if (!STA.begin()) {
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
if (!STA.connect(ssid, passphrase, channel, bssid, connect)) {
|
||||
if (!STA.connect(ssid, passphrase, channel, bssid, tryConnect)) {
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,27 @@ public:
|
||||
bool bandwidth(wifi_bandwidth_t bandwidth);
|
||||
|
||||
bool connect();
|
||||
bool connect(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true);
|
||||
bool connect(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool tryConnect = true);
|
||||
bool connect(const String &ssid, const String &passphrase = emptyString, int32_t channel = 0, const uint8_t *bssid = NULL, bool tryConnect = true) {
|
||||
return connect(ssid.c_str(), passphrase.c_str(), channel, bssid, tryConnect);
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT
|
||||
bool connect(
|
||||
const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL,
|
||||
const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0,
|
||||
const uint8_t *bssid = 0, bool connect = true
|
||||
const uint8_t *bssid = 0, bool tryConnect = true
|
||||
);
|
||||
bool connect(
|
||||
const String &wpa2_ssid, wpa2_auth_method_t method, const String &wpa2_identity = emptyString, const String &wpa2_username = emptyString,
|
||||
const String &wpa2_password = emptyString, const String &ca_pem = emptyString, const String &client_crt = emptyString,
|
||||
const String &client_key = emptyString, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool tryConnect = true
|
||||
) {
|
||||
return connect(
|
||||
wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(),
|
||||
ttls_phase2_type, channel, bssid, tryConnect
|
||||
);
|
||||
}
|
||||
#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */
|
||||
bool disconnect(bool eraseap = false, unsigned long timeout = 0);
|
||||
bool reconnect();
|
||||
@@ -116,23 +130,24 @@ public:
|
||||
wl_status_t begin(
|
||||
const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL,
|
||||
const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0,
|
||||
const uint8_t *bssid = 0, bool connect = true
|
||||
const uint8_t *bssid = 0, bool tryConnect = true
|
||||
);
|
||||
wl_status_t begin(
|
||||
const String &wpa2_ssid, wpa2_auth_method_t method, const String &wpa2_identity = (const char *)NULL, const String &wpa2_username = (const char *)NULL,
|
||||
const String &wpa2_password = (const char *)NULL, const String &ca_pem = (const char *)NULL, const String &client_crt = (const char *)NULL,
|
||||
const String &client_key = (const char *)NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true
|
||||
const String &client_key = (const char *)NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool tryConnect = true
|
||||
) {
|
||||
return begin(
|
||||
wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(),
|
||||
ttls_phase2_type, channel, bssid, connect
|
||||
ttls_phase2_type, channel, bssid, tryConnect
|
||||
);
|
||||
}
|
||||
#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */
|
||||
|
||||
wl_status_t begin(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true);
|
||||
wl_status_t begin(const String &ssid, const String &passphrase = (const char *)NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true) {
|
||||
return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect);
|
||||
wl_status_t begin(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool tryConnect = true);
|
||||
wl_status_t
|
||||
begin(const String &ssid, const String &passphrase = (const char *)NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool tryConnect = true) {
|
||||
return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, tryConnect);
|
||||
}
|
||||
wl_status_t begin();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user