@@ -108,6 +108,7 @@ static struct wifi_ap_sta_node sta_list[CONFIG_WIFI_SHELL_MAX_AP_STA];
108108enum iface_type {
109109 IFACE_TYPE_STA ,
110110 IFACE_TYPE_SAP ,
111+ IFACE_TYPE_P2P ,
111112};
112113
113114static struct net_if * get_iface (enum iface_type type , int argc , char * argv [])
@@ -148,10 +149,21 @@ static struct net_if *get_iface(enum iface_type type, int argc, char *argv[])
148149 } else if (type == IFACE_TYPE_SAP ) {
149150 iface = net_if_get_wifi_sap ();
150151 }
152+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
153+ else if (type == IFACE_TYPE_P2P ) {
154+ iface = net_if_get_wifi_p2p ();
155+ }
156+ #endif
151157
152158 if (iface == NULL ) {
153159 LOG_ERR ("No default interface found for type: %s" ,
154- type == IFACE_TYPE_STA ? "STA" : "SAP" );
160+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
161+ type == IFACE_TYPE_STA ? "STA" :
162+ type == IFACE_TYPE_SAP ? "SAP" : "P2P"
163+ #else
164+ type == IFACE_TYPE_STA ? "STA" : "SAP"
165+ #endif
166+ );
155167 return NULL ;
156168 }
157169 }
@@ -3937,7 +3949,7 @@ static void print_peer_info(const struct shell *sh, int index,
39373949
39383950static int cmd_wifi_p2p_peer (const struct shell * sh , size_t argc , char * argv [])
39393951{
3940- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
3952+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
39413953 struct wifi_p2p_params params = {0 };
39423954 uint8_t mac_addr [WIFI_MAC_ADDR_LEN ];
39433955 static struct wifi_p2p_device_info peers [WIFI_P2P_MAX_PEERS ];
@@ -3992,7 +4004,7 @@ static int cmd_wifi_p2p_peer(const struct shell *sh, size_t argc, char *argv[])
39924004
39934005static int cmd_wifi_p2p_find (const struct shell * sh , size_t argc , char * argv [])
39944006{
3995- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4007+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
39964008 struct wifi_p2p_params params = {0 };
39974009
39984010 context .sh = sh ;
@@ -4065,7 +4077,7 @@ static int cmd_wifi_p2p_find(const struct shell *sh, size_t argc, char *argv[])
40654077
40664078static int cmd_wifi_p2p_stop_find (const struct shell * sh , size_t argc , char * argv [])
40674079{
4068- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4080+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
40694081 struct wifi_p2p_params params = {0 };
40704082
40714083 context .sh = sh ;
@@ -4082,7 +4094,7 @@ static int cmd_wifi_p2p_stop_find(const struct shell *sh, size_t argc, char *arg
40824094
40834095static int cmd_wifi_p2p_connect (const struct shell * sh , size_t argc , char * argv [])
40844096{
4085- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4097+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
40864098 struct wifi_p2p_params params = {0 };
40874099 uint8_t mac_addr [WIFI_MAC_ADDR_LEN ];
40884100 const char * method_arg = NULL ;
@@ -4188,7 +4200,7 @@ static int cmd_wifi_p2p_connect(const struct shell *sh, size_t argc, char *argv[
41884200
41894201static int cmd_wifi_p2p_group_add (const struct shell * sh , size_t argc , char * argv [])
41904202{
4191- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4203+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
41924204 struct wifi_p2p_params params = {0 };
41934205 int opt ;
41944206 int opt_index = 0 ;
@@ -4280,7 +4292,7 @@ static int cmd_wifi_p2p_group_add(const struct shell *sh, size_t argc, char *arg
42804292
42814293static int cmd_wifi_p2p_group_remove (const struct shell * sh , size_t argc , char * argv [])
42824294{
4283- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4295+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
42844296 struct wifi_p2p_params params = {0 };
42854297
42864298 context .sh = sh ;
@@ -4305,7 +4317,7 @@ static int cmd_wifi_p2p_group_remove(const struct shell *sh, size_t argc, char *
43054317
43064318static int cmd_wifi_p2p_invite (const struct shell * sh , size_t argc , char * argv [])
43074319{
4308- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4320+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
43094321 struct wifi_p2p_params params = {0 };
43104322 uint8_t mac_addr [WIFI_MAC_ADDR_LEN ];
43114323 int opt ;
@@ -4438,7 +4450,7 @@ static int cmd_wifi_p2p_invite(const struct shell *sh, size_t argc, char *argv[]
44384450
44394451static int cmd_wifi_p2p_power_save (const struct shell * sh , size_t argc , char * argv [])
44404452{
4441- struct net_if * iface = get_iface (IFACE_TYPE_STA , argc , argv );
4453+ struct net_if * iface = get_iface (IFACE_TYPE_P2P , argc , argv );
44424454 struct wifi_p2p_params params = {0 };
44434455 bool power_save_enable = false;
44444456
0 commit comments