Trigger FASTREASSOC to driver (WCN) only in connected state

sta_reassoc is also issued for the scenarios expecting the station to
reconnect to the AP with the maintained profile (cached PMKSA). Hence,
do not trigger FASTREASSOC to the driver in the disconnected state and
rather trigger REASSOCIATE command to wpa_supplicant. FASTREASSOC is
intended to trigger the roaming in the driver and thus is honored only
in the connected state.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
diff --git a/sta.c b/sta.c
index 2407ab1..1d3ff73 100644
--- a/sta.c
+++ b/sta.c
@@ -4700,9 +4700,11 @@
 	const char *val = get_param(cmd, "CHANNEL");
 	struct wpa_ctrl *ctrl;
 	char buf[100];
+	char result[32];
 	int res;
 	int chan = 0;
 	int status = 0;
+	int fastreassoc = 1;
 
 	if (bssid == NULL) {
 		send_resp(dut, conn, SIGMA_ERROR, "errorCode,Missing bssid "
@@ -4730,7 +4732,15 @@
 		return -1;
 	}
 
-	if (wifi_chip_type == DRIVER_WCN) {
+	if (get_wpa_status(get_station_ifname(), "wpa_state", result,
+			   sizeof(result)) < 0 ||
+	    strncmp(result, "COMPLETED", 9) != 0) {
+		sigma_dut_print(dut, DUT_MSG_DEBUG,
+				"sta_reassoc: Not connected");
+		fastreassoc = 0;
+	}
+
+	if (wifi_chip_type == DRIVER_WCN && fastreassoc) {
 #ifdef ANDROID
 		if (chan) {
 			unsigned int freq;