Skip to content

Commit

Permalink
Preprocess away unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
HeMan committed Jun 19, 2023
1 parent 41a6187 commit 4db0ef6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions esphome/components/wifi/wifi_component_esp_idf.cpp
Expand Up @@ -58,7 +58,9 @@ struct IDFWiFiEvent {
wifi_event_ap_probe_req_rx_t ap_probe_req_rx;
wifi_event_bss_rssi_low_t bss_rssi_low;
ip_event_got_ip_t ip_got_ip;
#if LWIP_IPV6
ip_event_got_ip6_t ip_got_ip6;
#endif
ip_event_ap_staipassigned_t ip_ap_staipassigned;
} data;
};
Expand All @@ -82,8 +84,10 @@ void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, voi
memcpy(&event.data.sta_disconnected, event_data, sizeof(wifi_event_sta_disconnected_t));
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
memcpy(&event.data.ip_got_ip, event_data, sizeof(ip_event_got_ip_t));
#if LWIP_IPV6
} else if (event_base == IP_EVENT && event_id == IP_EVENT_GOT_IP6) {
memcpy(&event.data.ip_got_ip6, event_data, sizeof(ip_event_got_ip6_t));
#endif
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { // NOLINT(bugprone-branch-clone)
// no data
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_SCAN_DONE) {
Expand Down Expand Up @@ -504,7 +508,9 @@ const char *get_auth_mode_str(uint8_t mode) {
}

std::string format_ip4_addr(const esp_ip4_addr_t &ip) { return str_snprintf(IPSTR, 15, IP2STR(&ip)); }
#if LWIP_IPV6
std::string format_ip6_addr(const esp_ip6_addr_t &ip) { return str_snprintf(IPV6STR, 39, IPV62STR(ip)); }
#endif
const char *get_disconnect_reason_str(uint8_t reason) {
switch (reason) {
case WIFI_REASON_AUTH_EXPIRE:
Expand Down Expand Up @@ -644,9 +650,11 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
format_ip4_addr(it.ip_info.gw).c_str());
s_sta_got_ip = true;

#if LWIP_IPV6
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_GOT_IP6) {
const auto &it = data->data.ip_got_ip6;
ESP_LOGV(TAG, "Event: Got IPv6 address=%s", format_ip6_addr(it.ip6_info.ip).c_str());
#endif

} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_STA_LOST_IP) {
ESP_LOGV(TAG, "Event: Lost IP");
Expand Down

0 comments on commit 4db0ef6

Please sign in to comment.