[wifi] Make wifi_channel_() public (#7818)

This commit is contained in:
NP v/d Spek 2024-11-24 21:16:51 +01:00 committed by GitHub
parent dea297c8d7
commit 2ecd5cff07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 10 additions and 8 deletions

View file

@ -444,7 +444,7 @@ void WiFiComponent::print_connect_params_() {
if (this->selected_ap_.get_bssid().has_value()) { if (this->selected_ap_.get_bssid().has_value()) {
ESP_LOGV(TAG, " Priority: %.1f", this->get_sta_priority(*this->selected_ap_.get_bssid())); ESP_LOGV(TAG, " Priority: %.1f", this->get_sta_priority(*this->selected_ap_.get_bssid()));
} }
ESP_LOGCONFIG(TAG, " Channel: %" PRId32, wifi_channel_()); ESP_LOGCONFIG(TAG, " Channel: %" PRId32, get_wifi_channel());
ESP_LOGCONFIG(TAG, " Subnet: %s", wifi_subnet_mask_().str().c_str()); ESP_LOGCONFIG(TAG, " Subnet: %s", wifi_subnet_mask_().str().c_str());
ESP_LOGCONFIG(TAG, " Gateway: %s", wifi_gateway_ip_().str().c_str()); ESP_LOGCONFIG(TAG, " Gateway: %s", wifi_gateway_ip_().str().c_str());
ESP_LOGCONFIG(TAG, " DNS1: %s", wifi_dns_ip_(0).str().c_str()); ESP_LOGCONFIG(TAG, " DNS1: %s", wifi_dns_ip_(0).str().c_str());
@ -763,7 +763,7 @@ void WiFiComponent::load_fast_connect_settings_() {
void WiFiComponent::save_fast_connect_settings_() { void WiFiComponent::save_fast_connect_settings_() {
bssid_t bssid = wifi_bssid(); bssid_t bssid = wifi_bssid();
uint8_t channel = wifi_channel_(); uint8_t channel = get_wifi_channel();
if (bssid != this->selected_ap_.get_bssid() || channel != this->selected_ap_.get_channel()) { if (bssid != this->selected_ap_.get_bssid() || channel != this->selected_ap_.get_channel()) {
SavedWifiFastConnectSettings fast_connect_save{}; SavedWifiFastConnectSettings fast_connect_save{};

View file

@ -317,6 +317,8 @@ class WiFiComponent : public Component {
Trigger<> *get_connect_trigger() const { return this->connect_trigger_; }; Trigger<> *get_connect_trigger() const { return this->connect_trigger_; };
Trigger<> *get_disconnect_trigger() const { return this->disconnect_trigger_; }; Trigger<> *get_disconnect_trigger() const { return this->disconnect_trigger_; };
int32_t get_wifi_channel();
protected: protected:
static std::string format_mac_addr(const uint8_t mac[6]); static std::string format_mac_addr(const uint8_t mac[6]);
@ -344,7 +346,7 @@ class WiFiComponent : public Component {
#endif // USE_WIFI_AP #endif // USE_WIFI_AP
bool wifi_disconnect_(); bool wifi_disconnect_();
int32_t wifi_channel_();
network::IPAddress wifi_subnet_mask_(); network::IPAddress wifi_subnet_mask_();
network::IPAddress wifi_gateway_ip_(); network::IPAddress wifi_gateway_ip_();
network::IPAddress wifi_dns_ip_(int num); network::IPAddress wifi_dns_ip_(int num);

View file

@ -799,7 +799,7 @@ bssid_t WiFiComponent::wifi_bssid() {
} }
std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); } std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); }
int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); } int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); }
int32_t WiFiComponent::wifi_channel_() { return WiFi.channel(); } int32_t WiFiComponent::get_wifi_channel() { return WiFi.channel(); }
network::IPAddress WiFiComponent::wifi_subnet_mask_() { return network::IPAddress(WiFi.subnetMask()); } network::IPAddress WiFiComponent::wifi_subnet_mask_() { return network::IPAddress(WiFi.subnetMask()); }
network::IPAddress WiFiComponent::wifi_gateway_ip_() { return network::IPAddress(WiFi.gatewayIP()); } network::IPAddress WiFiComponent::wifi_gateway_ip_() { return network::IPAddress(WiFi.gatewayIP()); }
network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return network::IPAddress(WiFi.dnsIP(num)); } network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return network::IPAddress(WiFi.dnsIP(num)); }

View file

@ -825,7 +825,7 @@ bssid_t WiFiComponent::wifi_bssid() {
} }
std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); } std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); }
int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); } int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); }
int32_t WiFiComponent::wifi_channel_() { return WiFi.channel(); } int32_t WiFiComponent::get_wifi_channel() { return WiFi.channel(); }
network::IPAddress WiFiComponent::wifi_subnet_mask_() { return {(const ip_addr_t *) WiFi.subnetMask()}; } network::IPAddress WiFiComponent::wifi_subnet_mask_() { return {(const ip_addr_t *) WiFi.subnetMask()}; }
network::IPAddress WiFiComponent::wifi_gateway_ip_() { return {(const ip_addr_t *) WiFi.gatewayIP()}; } network::IPAddress WiFiComponent::wifi_gateway_ip_() { return {(const ip_addr_t *) WiFi.gatewayIP()}; }
network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return {(const ip_addr_t *) WiFi.dnsIP(num)}; } network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return {(const ip_addr_t *) WiFi.dnsIP(num)}; }

View file

@ -973,7 +973,7 @@ int8_t WiFiComponent::wifi_rssi() {
} }
return info.rssi; return info.rssi;
} }
int32_t WiFiComponent::wifi_channel_() { int32_t WiFiComponent::get_wifi_channel() {
uint8_t primary; uint8_t primary;
wifi_second_chan_t second; wifi_second_chan_t second;
esp_err_t err = esp_wifi_get_channel(&primary, &second); esp_err_t err = esp_wifi_get_channel(&primary, &second);

View file

@ -473,7 +473,7 @@ bssid_t WiFiComponent::wifi_bssid() {
} }
std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); } std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); }
int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); } int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); }
int32_t WiFiComponent::wifi_channel_() { return WiFi.channel(); } int32_t WiFiComponent::get_wifi_channel() { return WiFi.channel(); }
network::IPAddress WiFiComponent::wifi_subnet_mask_() { return {WiFi.subnetMask()}; } network::IPAddress WiFiComponent::wifi_subnet_mask_() { return {WiFi.subnetMask()}; }
network::IPAddress WiFiComponent::wifi_gateway_ip_() { return {WiFi.gatewayIP()}; } network::IPAddress WiFiComponent::wifi_gateway_ip_() { return {WiFi.gatewayIP()}; }
network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return {WiFi.dnsIP(num)}; } network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return {WiFi.dnsIP(num)}; }

View file

@ -189,7 +189,7 @@ bssid_t WiFiComponent::wifi_bssid() {
} }
std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); } std::string WiFiComponent::wifi_ssid() { return WiFi.SSID().c_str(); }
int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); } int8_t WiFiComponent::wifi_rssi() { return WiFi.RSSI(); }
int32_t WiFiComponent::wifi_channel_() { return WiFi.channel(); } int32_t WiFiComponent::get_wifi_channel() { return WiFi.channel(); }
network::IPAddresses WiFiComponent::wifi_sta_ip_addresses() { network::IPAddresses WiFiComponent::wifi_sta_ip_addresses() {
network::IPAddresses addresses; network::IPAddresses addresses;