@@ -139,6 +139,8 @@ enum net_request_wifi_cmd {
139139 NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD ,
140140 /** Configure background scanning */
141141 NET_REQUEST_WIFI_CMD_BGSCAN ,
142+ /** Wi-Fi Direct (P2P) operations*/
143+ NET_REQUEST_WIFI_CMD_P2P_OPER ,
142144 /** @cond INTERNAL_HIDDEN */
143145 NET_REQUEST_WIFI_CMD_MAX
144146 /** @endcond */
@@ -339,6 +341,11 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD);
339341
340342NET_MGMT_DEFINE_REQUEST_HANDLER (NET_REQUEST_WIFI_BGSCAN );
341343
344+ #define NET_REQUEST_WIFI_P2P_OPER \
345+ (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_P2P_OPER)
346+
347+ NET_MGMT_DEFINE_REQUEST_HANDLER (NET_REQUEST_WIFI_P2P_OPER );
348+
342349/** @cond INTERNAL_HIDDEN */
343350
344351enum {
@@ -359,7 +366,7 @@ enum {
359366 NET_EVENT_WIFI_CMD_AP_STA_CONNECTED_VAL ,
360367 NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED_VAL ,
361368 NET_EVENT_WIFI_CMD_SUPPLICANT_VAL ,
362-
369+ NET_EVENT_WIFI_CMD_P2P_DEVICE_FOUND_VAL ,
363370 NET_EVENT_WIFI_CMD_MAX ,
364371};
365372
@@ -406,6 +413,8 @@ enum net_event_wifi_cmd {
406413 NET_MGMT_CMD (NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED ),
407414 /** Supplicant specific event */
408415 NET_MGMT_CMD (NET_EVENT_WIFI_CMD_SUPPLICANT ),
416+ /** P2P device found */
417+ NET_MGMT_CMD (NET_EVENT_WIFI_CMD_P2P_DEVICE_FOUND ),
409418};
410419
411420/** Event emitted for Wi-Fi scan result */
@@ -468,6 +477,38 @@ enum net_event_wifi_cmd {
468477#define NET_EVENT_WIFI_AP_STA_DISCONNECTED \
469478 (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED)
470479
480+ /** Event emitted for P2P device found event */
481+ #define NET_EVENT_WIFI_P2P_DEVICE_FOUND \
482+ (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_P2P_DEVICE_FOUND)
483+
484+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
485+ /** @brief Wi-Fi P2P device info */
486+ struct wifi_p2p_device_info {
487+ /** Device MAC address */
488+ uint8_t mac [WIFI_MAC_ADDR_LEN ];
489+ /** Device name (max 32 chars + null terminator) */
490+ char device_name [33 ];
491+ /** Primary device type */
492+ uint8_t pri_dev_type [8 ];
493+ /** Primary device type string */
494+ char pri_dev_type_str [32 ];
495+ /** Signal strength (RSSI) */
496+ int8_t rssi ;
497+ /** WPS configuration methods supported */
498+ uint16_t config_methods ;
499+ /** WPS configuration methods string */
500+ char config_methods_str [16 ];
501+ /** Device capability */
502+ uint8_t dev_capab ;
503+ /** Group capability */
504+ uint8_t group_capab ;
505+ /** Manufacturer (max 64 chars + null terminator) */
506+ char manufacturer [65 ];
507+ /** Model name (max 32 chars + null terminator) */
508+ char model_name [33 ];
509+ };
510+ #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P */
511+
471512/** @brief Wi-Fi version */
472513struct wifi_version {
473514 /** Driver version */
@@ -1104,6 +1145,9 @@ union wifi_mgmt_events {
11041145#endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
11051146 struct wifi_twt_params twt_params ;
11061147 struct wifi_ap_sta_info ap_sta_info ;
1148+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
1149+ struct wifi_p2p_device_info p2p_device_info ;
1150+ #endif
11071151};
11081152
11091153/** @endcond */
@@ -1387,6 +1431,51 @@ struct wifi_wps_config_params {
13871431 char pin [WIFI_WPS_PIN_MAX_LEN + 1 ];
13881432};
13891433
1434+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
1435+ /** Wi-Fi P2P operation */
1436+ enum wifi_p2p_op {
1437+ /** P2P find/discovery */
1438+ WIFI_P2P_FIND = 0 ,
1439+ /** P2P stop find/discovery */
1440+ WIFI_P2P_STOP_FIND ,
1441+ /** P2P query peer info use broadcast MAC (ff:ff:ff:ff:ff:ff) to list all peers,
1442+ * or specific MAC address to query a single peer
1443+ */
1444+ WIFI_P2P_PEER ,
1445+ };
1446+
1447+ /** Wi-Fi P2P discovery type */
1448+ enum wifi_p2p_discovery_type {
1449+ /** Start with full scan, then only social channels */
1450+ WIFI_P2P_FIND_START_WITH_FULL = 0 ,
1451+ /** Only social channels (1, 6, 11) */
1452+ WIFI_P2P_FIND_ONLY_SOCIAL ,
1453+ /** Progressive - scan through all channels one at a time */
1454+ WIFI_P2P_FIND_PROGRESSIVE ,
1455+ };
1456+
1457+ /** Maximum number of P2P peers that can be returned in a single query */
1458+ #define WIFI_P2P_MAX_PEERS 32
1459+
1460+ /** Wi-Fi P2P parameters */
1461+ struct wifi_p2p_params {
1462+ /** P2P operation */
1463+ enum wifi_p2p_op oper ;
1464+ /** Discovery type (for find operation) */
1465+ enum wifi_p2p_discovery_type discovery_type ;
1466+ /** Timeout in seconds (0 = no timeout, run until stopped) */
1467+ uint16_t timeout ;
1468+ /** Peer device address (for peer operation) */
1469+ uint8_t peer_addr [WIFI_MAC_ADDR_LEN ];
1470+ /** Flag to list only discovered peers (for peers operation) */
1471+ bool discovered_only ;
1472+ /** Pointer to array for peer info results */
1473+ struct wifi_p2p_device_info * peers ;
1474+ /** Actual number of peers returned */
1475+ uint16_t peer_count ;
1476+ };
1477+ #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P */
1478+
13901479/** Wi-Fi AP status
13911480 */
13921481enum wifi_sap_iface_state {
@@ -1775,6 +1864,17 @@ struct wifi_mgmt_ops {
17751864 */
17761865 int (* set_bgscan )(const struct device * dev , struct wifi_bgscan_params * params );
17771866#endif
1867+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
1868+ /** Wi-Fi Direct (P2P) operations for device discovery
1869+ *
1870+ * @param dev Pointer to the device structure for the driver instance.
1871+ * @param params P2P operation parameters including operation type, discovery settings,
1872+ * timeout values and peer information retrieval options
1873+ *
1874+ * @return 0 if ok, < 0 if error
1875+ */
1876+ int (* p2p_oper )(const struct device * dev , struct wifi_p2p_params * params );
1877+ #endif
17781878};
17791879
17801880/** Wi-Fi management offload API */
@@ -1906,6 +2006,17 @@ void wifi_mgmt_raise_ap_sta_connected_event(struct net_if *iface,
19062006void wifi_mgmt_raise_ap_sta_disconnected_event (struct net_if * iface ,
19072007 struct wifi_ap_sta_info * sta_info );
19082008
2009+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P
2010+ /**
2011+ * @brief Raise P2P device found event
2012+ *
2013+ * @param iface Network interface
2014+ * @param device_info P2P device information
2015+ */
2016+ void wifi_mgmt_raise_p2p_device_found_event (struct net_if * iface ,
2017+ struct wifi_p2p_device_info * peer_info );
2018+ #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P */
2019+
19092020/**
19102021 * @}
19112022 */
0 commit comments