Skip to content

Conversation

@rado17
Copy link
Contributor

@rado17 rado17 commented Oct 8, 2025

Use ssids instead of filter_ssids to set the SSID in probe requests to DIRECT-. This is needed for identification by the P2P peers.

sachinthegreen
sachinthegreen previously approved these changes Oct 8, 2025
@github-actions
Copy link

github-actions bot commented Oct 10, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hostap zephyrproject-rtos/hostap@cf05f33 zephyrproject-rtos/hostap#107 zephyrproject-rtos/hostap#107/files

DNM label due to: 1 project with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hostap DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 10, 2025
@kapbh kapbh force-pushed the p2p_find branch 2 times, most recently from 9ace4b9 to 13e5c91 Compare October 10, 2025 12:16
@rado17 rado17 requested a review from krish2718 October 14, 2025 07:16
@github-actions github-actions bot removed manifest manifest-hostap DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 14, 2025
@github-actions github-actions bot added manifest manifest-hostap DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 14, 2025
params->resp[0] = '\0';
os_strlcpy(cmd_buf, "P2P_PEER FIRST", sizeof(cmd_buf));

while (1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a while 1? and break only in failure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed while 1

return -ENOEXEC;
}

if (resp_buf[0] != '\0') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the response not a proper struct? Wi-Fi management should work with any network manager not just wpa_supplicant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added fields in structures and removed buffer.

return 0;
}

static void parse_and_print_peer_info(const struct shell *sh, const char *mac_addr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to wpa_supplicant and only keep a proper data structure in Wi-Fi mgmt and this way you don't even need the _noprint API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved parsing of fields in api, need to use zephyr_wpa_cli_cmd_resp_noprint because zephyr_wpa_cli_cmd_resp will always prints the response with other info (not much readable format).

Comment on lines +1430 to +1447
WIFI_P2P_PEERS,
/** P2P show information about a known peer */
WIFI_P2P_PEER,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why two separate OPs, if known peer input is broadcast then it shows all peers, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIFI_P2P_PEERS will return all the peers info, WIFI_P2P_PEER we can specify mac address and get only one peer info.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but see my comment, can't you take broadcast MAC to dump all peers?

Copy link
Contributor

@krish2718 krish2718 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate API and Shell in to two commits

Use `ssids` instead of `filter_ssids` to set the SSID in probe requests. `filter_ssids` are to filter scan results to include only the specified SSIDs. Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
In P2P mode, inform supplicant that the driver is P2P capable. Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
kapbh and others added 4 commits October 27, 2025 12:49
Add supplicant api and mgmt ops support for P2P discovery. Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Add shell command support for P2P discovery. Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Update hostap revision to add wpa_cli command response with no print. Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no> Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Add P2P overlay. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Copy link
Contributor

@krish2718 krish2718 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this needs a doc update in Wi-Fi API with a separate section.

/** Device MAC address */
uint8_t mac[WIFI_MAC_ADDR_LEN];
/** Device name */
char device_name[32];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not storing null terminator for this and others?

Comment on lines +1430 to +1447
WIFI_P2P_PEERS,
/** P2P show information about a known peer */
WIFI_P2P_PEER,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but see my comment, can't you take broadcast MAC to dump all peers?

Comment on lines +64 to +70
#define P2P_CMD_BUF_SIZE 256
#define P2P_RESP_BUF_SIZE 256
#define P2P_ADDR_SIZE 32
#define P2P_CMD_SIZE 64
#define P2P_PEER_INFO_SIZE 512
#define P2P_RESP_MAX_SIZE 8192
#define P2P_RESP_SAFE_SIZE 7900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some references or sources to these magic values and whether they depend on something and can be reduce, their impact to stack sizes etc...

ret = 0;
break;

case WIFI_P2P_PEERS: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ can be removed

}

wpa_printf(MSG_DEBUG, "wpa_cli %s", cmd_buf);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need unnecessary new lines

Comment on lines +3652 to +3661
wait_time_ms = (params.timeout > 0) ? params.timeout * 1000 : P2P_DEFAULT_WAIT_TIME_MS;
k_sleep(K_MSEC(wait_time_ms));

PR("\n");

peers = k_malloc(WIFI_P2P_MAX_PEERS * sizeof(struct wifi_p2p_device_info));
if (!peers) {
PR_ERROR("Failed to allocate memory for peer info\n");
return -ENOMEM;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not ideal, blocking the shell + malloc, can't we just model the wpa_cli here? i.e., trigger find and then based on event peer found prompt use to issue peers to get details of the peers?

As this is used as a reference, better to model a real world app.

@@ -0,0 +1,6 @@
CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P=y
CONFIG_WPA_CLI=y
CONFIG_NRF70_P2P_MODE=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't belong here and should be auto-enabled by CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P

Comment on lines +5 to +6
CONFIG_LTO=y
CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to p2p and is board specific

@@ -0,0 +1,6 @@
CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P=y
CONFIG_WPA_CLI=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? We should encourage wifi shell not wpa_cli

@@ -0,0 +1,6 @@
CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you follow below comments and end up with this single line then you don't really an overlay :)

@krish2718 krish2718 requested a review from Copilot October 27, 2025 15:44
@krish2718
Copy link
Contributor

Also, please update title and description to summarize the changes.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Wi-Fi Direct (P2P) support to the nRF WiFi driver by implementing P2P discovery functionality. The key change switches from using filter_ssids to ssids for setting the SSID in probe requests to "DIRECT-", which is required for P2P peer identification.

Key Changes:

  • Updated the nRF WiFi driver to use ssids instead of filter_ssids for P2P discovery probe requests
  • Added comprehensive P2P management infrastructure including shell commands, API definitions, and event handling
  • Integrated P2P capability support through hostap module updates

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
west.yml Updates hostap module to a development branch with P2P support
drivers/wifi/nrf_wifi/src/wpa_supp_if.c Switches scan parameters from filter_ssids to ssids and adds P2P capability flag
subsys/net/l2/wifi/wifi_shell.c Implements P2P find shell command with peer discovery and information display
subsys/net/l2/wifi/wifi_mgmt.c Adds P2P management request handler and device found event notification
include/zephyr/net/wifi_mgmt.h Defines P2P API structures, enums, and management operations
modules/hostap/src/supp_api.c Implements P2P command processing and peer information parsing
modules/hostap/src/supp_api.h Declares P2P API function signature
modules/hostap/src/supp_main.c Registers P2P operation handler in management ops
samples/net/wifi/shell/overlay-p2p.conf Adds P2P configuration overlay
samples/net/wifi/shell/CMakeLists.txt Forces P2P overlay configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cmake_minimum_required(VERSION 3.20.0)


set(EXTRA_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/overlay-p2p.conf" CACHE STRING "" FORCE)
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using FORCE to set EXTRA_CONF_FILE unconditionally will prevent users from using other overlay configurations. This change makes P2P configuration mandatory for all builds of this sample. Consider making this conditional or removing the FORCE flag to allow users to override the configuration.

Suggested change
set(EXTRA_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/overlay-p2p.conf" CACHE STRING "" FORCE)
set(EXTRA_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/overlay-p2p.conf" CACHE STRING "")
Copilot uses AI. Check for mistakes.
- name: hostap
path: modules/lib/hostap
revision: cf05f33f594de6b62840a3b0dd435f10467a2e4c
revision: pull/107/head
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revision points to a pull request head reference instead of a stable commit hash. This creates instability as the PR branch can be force-pushed or deleted. Use a specific commit SHA once the PR is merged or stable.

Suggested change
revision: pull/107/head
revision: 7e6b5e2e2e2b4e2e2e2b4e2e2e2b4e2e2e2b4e2e
Copilot uses AI. Check for mistakes.
Comment on lines +3577 to +3578
strncpy(mac_addr_str, state->optarg, 17);
mac_addr_str[17] = '\0';
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer size is 18 bytes but strncpy copies 17 bytes without null termination if the source is 17 bytes or longer. Use strncpy(mac_addr_str, state->optarg, sizeof(mac_addr_str) - 1) to ensure proper bounds checking.

Suggested change
strncpy(mac_addr_str, state->optarg, 17);
mac_addr_str[17] = '\0';
strncpy(mac_addr_str, state->optarg, sizeof(mac_addr_str) - 1);
mac_addr_str[sizeof(mac_addr_str) - 1] = '\0';
Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking area: Samples Samples area: Wi-Fi Wi-Fi DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hostap

6 participants