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
  • Hi,

    This is fixed in nRF Connect SDK v2.7.0. When entering an incorrect password in this version, you will get "Connection failed". Please try updating to v2.7.0 and see if that fixes the issue for you.

    Best regards,
    Marte

  • Thank you for your support.

    We are facing an issue related to the SSID. When we enable the hotspot on Android or iPhone devices and the SSID contains a special character, such as an apostrophe (e.g., Chirag's), the nRF7002-DK successfully connects to the Android device but fails to connect to the iOS device.

  • 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

Reply Children
Related