Skip to content

Commit

Permalink
hostap: Implement detailed connection result
Browse files Browse the repository at this point in the history
Use the newly added enumerations to translate from WPA supplicant status
codes to Zephyr Wi-Fi management status codes.

Signed-off-by: Chaitanya Tata <[email protected]>
Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
krish2718 authored and aescolar committed Mar 20, 2024
1 parent 74f8325 commit e5c90db
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion modules/hostap/src/supp_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include "includes.h"
#include "common.h"
#include "common/ieee802_11_defs.h"

#include <zephyr/net/wifi_mgmt.h>

/* Re-defines MAC2STR with address of the element */
#define MACADDR2STR(a) &(a)[0], &(a)[1], &(a)[2], &(a)[3], &(a)[4], &(a)[5]
Expand Down Expand Up @@ -40,6 +43,18 @@ static void copy_mac_addr(const unsigned int *src, uint8_t *dst)
}
}

static enum wifi_conn_status wpas_to_wifi_mgmt_conn_status(int status)
{
switch (status) {
case WLAN_STATUS_SUCCESS:
return WIFI_STATUS_CONN_SUCCESS;
case WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT:
return WIFI_STATUS_CONN_WRONG_PASSWORD;
default:
return WIFI_STATUS_CONN_FAIL;
}
}

static int supplicant_process_status(struct supplicant_int_event_data *event_data,
char *supplicant_status)
{
Expand Down Expand Up @@ -166,7 +181,9 @@ int supplicant_send_wifi_mgmt_event(const char *ifname, enum net_event_wifi_cmd

switch (event) {
case NET_EVENT_WIFI_CMD_CONNECT_RESULT:
wifi_mgmt_raise_connect_result_event(iface, *(int *)supplicant_status);
wifi_mgmt_raise_connect_result_event(
iface,
wpas_to_wifi_mgmt_conn_status(*(int *)supplicant_status));
break;
case NET_EVENT_WIFI_CMD_DISCONNECT_RESULT:
wifi_mgmt_raise_disconnect_result_event(iface, *(int *)supplicant_status);
Expand Down

0 comments on commit e5c90db

Please sign in to comment.