From 1ac7e7fa1c6cc757a9a921296dcee230e7aec6bf Mon Sep 17 00:00:00 2001 From: Ravi Dondaputi Date: Thu, 6 Jun 2024 19:02:24 +0530 Subject: [PATCH] [nrf noup] zephyr: Start DHCP client only in station mode DHCP client is needed only when the device is running in station mode. Check if the SSID is configured in SME structure which indicates that the given interface is operating in STA mode. Signed-off-by: Ravi Dondaputi --- src/drivers/driver_zephyr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/drivers/driver_zephyr.c b/src/drivers/driver_zephyr.c index 165b0a891..119aa5758 100644 --- a/src/drivers/driver_zephyr.c +++ b/src/drivers/driver_zephyr.c @@ -1525,10 +1525,14 @@ static int wpa_drv_zep_set_supp_port(void *priv, authorized, if_ctx->bssid); -#ifdef CONFIG_NET_DHCPV4 - if (authorized) { - net_dhcpv4_restart(iface); - } +#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_SME) + struct wpa_supplicant *wpa_s = if_ctx->supp_if_ctx; + /* Need DHCP client in STA mode only */ + if (wpa_s && wpa_s->sme.ssid_len > 0) { + if (authorized) { + net_dhcpv4_restart(iface); + } + } #endif return ret;