In the nRF7002, when the correct SSID is provided but an incorrect password is entered, the Wi-Fi callback function handle_wifi_connect_result sets context.connected to true

We are using SDK v2.6.1 for our application, along with the Fanstel module WT02C40C.

Internet connectivity is provided to the WT02C40C module via a hotspot, with CONFIG_STA_KEY_MGMT_WPA2 set for security.

However, when the correct SSID is provided but an incorrect password is entered, the Wi-Fi callback function handle_wifi_connect_result sets context.connected to true.

please provide the solution for this.

uint8_t Cus_ssid[] = "realme123";
uint8_t Cus_passwod[] = "Chirag@152";
static int cmd_wifi_status(void)
{
	struct net_if *iface = net_if_get_default();
	struct wifi_iface_status status = { 0 };

	if (net_mgmt(NET_REQUEST_WIFI_IFACE_STATUS, iface, &status,
				sizeof(struct wifi_iface_status))) {
		LOG_INF("Status request failed");

		return -ENOEXEC;
	}

	LOG_INF("==================");
	LOG_INF("State: %s", wifi_state_txt(status.state));

	if (status.state >= WIFI_STATE_ASSOCIATED) {
		uint8_t mac_string_buf[sizeof("xx:xx:xx:xx:xx:xx")];

		LOG_INF("Interface Mode: %s",
		       wifi_mode_txt(status.iface_mode));
		LOG_INF("Link Mode: %s",
		       wifi_link_mode_txt(status.link_mode));
		LOG_INF("SSID: %.32s", status.ssid);
		LOG_INF("BSSID: %s",
		       net_sprint_ll_addr_buf(
				status.bssid, WIFI_MAC_ADDR_LEN,
				mac_string_buf, sizeof(mac_string_buf)));
		LOG_INF("Band: %s", wifi_band_txt(status.band));
		LOG_INF("Channel: %d", status.channel);
		LOG_INF("Security: %s", wifi_security_txt(status.security));
		LOG_INF("MFP: %s", wifi_mfp_txt(status.mfp));
		LOG_INF("RSSI: %d", status.rssi);
	}
	return 0;
}

static void handle_wifi_connect_result(struct net_mgmt_event_callback *cb)
{
	const struct wifi_status *status =
		(const struct wifi_status *) cb->info;

	if (context.connected) {
		return;
	}

	if (status->status) {
		LOG_ERR("Connection failed (%d)", status->status);
	} else {
		LOG_INF("Connected");
		context.connected = true;
		Wifi_Connected = 1;
		gpio_pin_set_dt(&wifiled,0);
	}

	context.connect_result = true;
}

static int __wifi_args_to_params(struct wifi_connect_req_params *params)
{

	params->timeout =  70 * MSEC_PER_SEC;

	if (params->timeout == 0) {
		params->timeout = SYS_FOREVER_MS;
	}

	/* Defaults */
	params->band = WIFI_FREQ_BAND_UNKNOWN;
	params->channel = WIFI_CHANNEL_ANY;
	params->security = WIFI_SECURITY_TYPE_NONE;
	params->mfp = WIFI_MFP_OPTIONAL;

	/* SSID */
	params->ssid = Cus_ssid;//CONFIG_STA_SAMPLE_SSID;
	params->ssid_length = strlen(params->ssid);

#if defined(CONFIG_STA_KEY_MGMT_WPA2)
	params->security = 1;
#elif defined(CONFIG_STA_KEY_MGMT_WPA2_256)
	params->security = 2;
#elif defined(CONFIG_STA_KEY_MGMT_WPA3)
	params->security = 3;
#else
	params->security = 1;
#endif

#if !defined(CONFIG_STA_KEY_MGMT_NONE)
	params->psk = Cus_passwod;//CONFIG_STA_SAMPLE_PASSWORD;
	params->psk_length = strlen(params->psk);
#endif

	return 0;
}

Parents Reply Children
  • Hi,

    Can you share the application log?

    How are you setting the SSID in the project?

    Best regards,
    Marte

  • in below code i set the ssid.

    in logs we have got only Connection requested log in wifi_connect() function

    char Cus_ssid[] = "chirag's iPhone";
    char Cus_passwod[] = "Chirag@152";
    
    static int __wifi_args_to_params(struct wifi_connect_req_params *params)
    {
    
    
    	params->timeout =  70 * MSEC_PER_SEC;
    
    	if (params->timeout == 0) {
    		params->timeout = SYS_FOREVER_MS;
    	}
    
    	/* Defaults */
    	params->band = WIFI_FREQ_BAND_UNKNOWN;
    	params->channel = WIFI_CHANNEL_ANY;
    	//params->security = WIFI_SECURITY_TYPE_NONE;
    	params->security = WIFI_SECURITY_TYPE_PSK;
    	params->mfp = WIFI_MFP_OPTIONAL;
    
    	/* SSID */
    	params->ssid = Cus_ssid;//CONFIG_STA_SAMPLE_SSID;
    	params->ssid_length = strlen(params->ssid);
    
    // #if defined(CONFIG_STA_KEY_MGMT_WPA2)
    // 	params->security = 1;
    // #elif defined(CONFIG_STA_KEY_MGMT_WPA2_256)
    // 	params->security = 2;
    // #elif defined(CONFIG_STA_KEY_MGMT_WPA3)
    // 	params->security = 3;
    // #else
    // 	params->security = 1;
    // #endif
    
    #if !defined(CONFIG_STA_KEY_MGMT_NONE)
    	params->psk = Cus_passwod;//CONFIG_STA_SAMPLE_PASSWORD;
    	params->psk_length = strlen(params->psk);
    	// params->sae_password = Cus_passwod;//CONFIG_STA_SAMPLE_PASSWORD;
    	// params->sae_password_length = strlen(params->sae_password);
    
    #endif
    
    	return 0;
    }
    
    static int wifi_connect(void)
    {
    	//struct net_if *iface = net_if_get_default();
    	
    
    	//context.connected = false;
    	//context.connect_result = false;
    	
       	__wifi_args_to_params(&cnx_params);
    
    	if (net_mgmt(NET_REQUEST_WIFI_CONNECT, iface,
    		     &cnx_params, sizeof(struct wifi_connect_req_params))) {
    		LOG_ERR("Connection request failed");
    
    		return -ENOEXEC;
    	}
    
    	LOG_INF("Connection requested");
    
    	return 0;
    }

  • Hi,

    Can you enable debug log level in the WPA supplicant and share the application logs? You can enable it by setting CONFIG_WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_DBG=y.

    Do you only see the issue if you set the password using an array in the code, or do you also see it if you set it in Kconfig, for example, using CONFIG_WIFI_CREDENTIALS_STATIC_SSID?

    Best regards,
    Marte

  • I referred to the code from Wi-Fi Fundamentals Lesson-2, Exercise-2 and configured static Wi-Fi credentials. However, I am still unable to connect to the iPhone hotspot.

    Here are the static Wi-Fi credentials I used:

    CONFIG_WIFI_CREDENTIALS_STATIC_SSID="chirag's iPhone"
    CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="Chirag@152"

    i enable CONFIG_WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_DBG=y ,

    The logs I received are as follows:

    [00:00:00.315,856] <inf> wifi_nrf: Management buffer offload enabled
    [00:00:00.444,610] <inf> fs_nvs: 6 Sectors of 4096 bytes
    [00:00:00.444,641] <inf> fs_nvs: alloc wra: 0, fe8
    [00:00:00.444,641] <inf> fs_nvs: data wra: 0, 0
    *** Booting nRF Connect SDK v3.5.99-ncs1-2 ***
    [00:00:01.444,885] <inf> Lesson2_Exercise2: Connecting to Wi-Fi
  • Hi,

    Can you try with nRF Connect SDK v2.7.0 and see if you get the same issue there?

    Best regards,
    Marte

Related