-
Couldn't load subscription status.
- Fork 8.1k
drivers: wifi: nrf_wifi: Set SSID for P2P discovery #97183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
9ace4b9 to 13e5c91 Compare modules/hostap/src/supp_api.c Outdated
| params->resp[0] = '\0'; | ||
| os_strlcpy(cmd_buf, "P2P_PEER FIRST", sizeof(cmd_buf)); | ||
| | ||
| while (1) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed while 1
subsys/net/l2/wifi/wifi_shell.c Outdated
| return -ENOEXEC; | ||
| } | ||
| | ||
| if (resp_buf[0] != '\0') { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
subsys/net/l2/wifi/wifi_shell.c Outdated
| return 0; | ||
| } | ||
| | ||
| static void parse_and_print_peer_info(const struct shell *sh, const char *mac_addr, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
| WIFI_P2P_PEERS, | ||
| /** P2P show information about a known peer */ | ||
| WIFI_P2P_PEER, | ||
| }; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this 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>
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>
|
There was a problem hiding this 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]; |
There was a problem hiding this comment.
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?
| WIFI_P2P_PEERS, | ||
| /** P2P show information about a known peer */ | ||
| WIFI_P2P_PEER, | ||
| }; |
There was a problem hiding this comment.
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?
| #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 |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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); | ||
| |
There was a problem hiding this comment.
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
| 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; | ||
| } |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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
| CONFIG_LTO=y | ||
| CONFIG_ISR_TABLES_LOCAL_DECLARATION=y |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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 :)
| Also, please update title and description to summarize the changes. |
There was a problem hiding this 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
ssidsinstead offilter_ssidsfor 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) |
Copilot AI Oct 27, 2025
There was a problem hiding this comment.
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.
| 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 "") |
| - name: hostap | ||
| path: modules/lib/hostap | ||
| revision: cf05f33f594de6b62840a3b0dd435f10467a2e4c | ||
| revision: pull/107/head |
Copilot AI Oct 27, 2025
There was a problem hiding this comment.
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.
| revision: pull/107/head | |
| revision: 7e6b5e2e2e2b4e2e2e2b4e2e2e2b4e2e2e2b4e2e |
| strncpy(mac_addr_str, state->optarg, 17); | ||
| mac_addr_str[17] = '\0'; |
Copilot AI Oct 27, 2025
There was a problem hiding this comment.
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.
| 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'; |



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