mirror of
https://github.com/esphome/esphome.git
synced 2024-11-14 02:58:11 +01:00
Preprocess away unused code when IPv6 is disabled (#4973)
This commit is contained in:
parent
5a8b7c17da
commit
7ceb16cc5a
1 changed files with 8 additions and 0 deletions
|
@ -58,7 +58,9 @@ struct IDFWiFiEvent {
|
||||||
wifi_event_ap_probe_req_rx_t ap_probe_req_rx;
|
wifi_event_ap_probe_req_rx_t ap_probe_req_rx;
|
||||||
wifi_event_bss_rssi_low_t bss_rssi_low;
|
wifi_event_bss_rssi_low_t bss_rssi_low;
|
||||||
ip_event_got_ip_t ip_got_ip;
|
ip_event_got_ip_t ip_got_ip;
|
||||||
|
#if LWIP_IPV6
|
||||||
ip_event_got_ip6_t ip_got_ip6;
|
ip_event_got_ip6_t ip_got_ip6;
|
||||||
|
#endif
|
||||||
ip_event_ap_staipassigned_t ip_ap_staipassigned;
|
ip_event_ap_staipassigned_t ip_ap_staipassigned;
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
@ -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));
|
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) {
|
} 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));
|
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) {
|
} 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));
|
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)
|
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { // NOLINT(bugprone-branch-clone)
|
||||||
// no data
|
// no data
|
||||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_SCAN_DONE) {
|
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_SCAN_DONE) {
|
||||||
|
@ -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)); }
|
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)); }
|
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) {
|
const char *get_disconnect_reason_str(uint8_t reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case WIFI_REASON_AUTH_EXPIRE:
|
case WIFI_REASON_AUTH_EXPIRE:
|
||||||
|
@ -644,9 +650,11 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
|
||||||
format_ip4_addr(it.ip_info.gw).c_str());
|
format_ip4_addr(it.ip_info.gw).c_str());
|
||||||
s_sta_got_ip = true;
|
s_sta_got_ip = true;
|
||||||
|
|
||||||
|
#if LWIP_IPV6
|
||||||
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_GOT_IP6) {
|
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_GOT_IP6) {
|
||||||
const auto &it = data->data.ip_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());
|
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) {
|
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_STA_LOST_IP) {
|
||||||
ESP_LOGV(TAG, "Event: Lost IP");
|
ESP_LOGV(TAG, "Event: Lost IP");
|
||||||
|
|
Loading…
Reference in a new issue