mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 08:55:22 +01:00
Configure ap ip for RP2040 (#7065)
This commit is contained in:
parent
aa8c963c50
commit
2f669c99f8
1 changed files with 18 additions and 2 deletions
|
@ -141,13 +141,29 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
// TODO:
|
esphome::network::IPAddress ip_address, gateway, subnet, dns;
|
||||||
return false;
|
if (manual_ip.has_value()) {
|
||||||
|
ip_address = manual_ip->static_ip;
|
||||||
|
gateway = manual_ip->gateway;
|
||||||
|
subnet = manual_ip->subnet;
|
||||||
|
dns = manual_ip->static_ip;
|
||||||
|
} else {
|
||||||
|
ip_address = network::IPAddress(192, 168, 4, 1);
|
||||||
|
gateway = network::IPAddress(192, 168, 4, 1);
|
||||||
|
subnet = network::IPAddress(255, 255, 255, 0);
|
||||||
|
dns = network::IPAddress(192, 168, 4, 1);
|
||||||
|
}
|
||||||
|
WiFi.config(ip_address, dns, gateway, subnet);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||||
if (!this->wifi_mode_({}, true))
|
if (!this->wifi_mode_({}, true))
|
||||||
return false;
|
return false;
|
||||||
|
if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
|
||||||
|
ESP_LOGV(TAG, "wifi_ap_ip_config_ failed!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
WiFi.beginAP(ap.get_ssid().c_str(), ap.get_password().c_str(), ap.get_channel().value_or(1));
|
WiFi.beginAP(ap.get_ssid().c_str(), ap.get_password().c_str(), ap.get_channel().value_or(1));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue