mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Some RP2040 wifi changes for AP mode (#3953)
This commit is contained in:
parent
85faecb2fd
commit
a5d4ca0f6d
1 changed files with 6 additions and 16 deletions
|
@ -24,6 +24,11 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
|
||||||
cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_STA, true, CYW43_COUNTRY_WORLDWIDE);
|
cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_STA, true, CYW43_COUNTRY_WORLDWIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ap.has_value()) {
|
||||||
|
if (ap.value()) {
|
||||||
|
cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_AP, true, CYW43_COUNTRY_WORLDWIDE);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,22 +146,7 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||||
if (!this->wifi_mode_({}, true))
|
if (!this->wifi_mode_({}, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ap.get_channel().has_value()) {
|
WiFi.beginAP(ap.get_ssid().c_str(), ap.get_password().c_str(), ap.get_channel().value_or(1));
|
||||||
cyw43_wifi_ap_set_channel(&cyw43_state, ap.get_channel().value());
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ssid = ap.get_ssid().c_str();
|
|
||||||
|
|
||||||
cyw43_wifi_ap_set_ssid(&cyw43_state, strlen(ssid), (const uint8_t *) ssid);
|
|
||||||
|
|
||||||
if (!ap.get_password().empty()) {
|
|
||||||
const char *password = ap.get_password().c_str();
|
|
||||||
cyw43_wifi_ap_set_password(&cyw43_state, strlen(password), (const uint8_t *) password);
|
|
||||||
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_WPA2_MIXED_PSK);
|
|
||||||
} else {
|
|
||||||
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_OPEN);
|
|
||||||
}
|
|
||||||
cyw43_wifi_set_up(&cyw43_state, CYW43_ITF_AP, true, CYW43_COUNTRY_WORLDWIDE);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue