mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_wifi): NAN Service discovery and datapath bugfixes
1. Increase timeout value for NDP Accepted/Rejected events 2. Update publisher ID incase publisher restarts(service) 3. Ignore service discovery frames with invalid/inactive service ID 4. Update NAN documentation
This commit is contained in:
parent
e0b98b75e7
commit
5d05aa9942
@ -1063,6 +1063,7 @@ typedef struct {
|
||||
uint8_t subscribe_id; /**< Subscribe Service Identifier */
|
||||
uint8_t publish_id; /**< Publish Service Identifier */
|
||||
uint8_t pub_if_mac[6]; /**< NAN Interface MAC of the Publisher */
|
||||
bool update_pub_id; /**< Indicates whether publisher's service ID needs to be updated */
|
||||
} wifi_event_nan_svc_match_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_NAN_REPLIED event */
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c1a8747dab1ef3a138195b0a7e5de8dd9dfe539e
|
||||
Subproject commit fd77ffcf8e56ad5c9ea85d635f40ce63134101b0
|
@ -161,6 +161,8 @@ void esp_wifi_nan_get_ipv6_linklocal_from_mac(ip6_addr_t *ip6, uint8_t *mac_addr
|
||||
/**
|
||||
* brief Get own Service information from Service ID OR Name.
|
||||
*
|
||||
* @attention If service information is to be fetched from service name, set own_svc_id as zero.
|
||||
*
|
||||
* @param[inout] own_svc_id As input, it indicates Service ID to search for.
|
||||
* As output, it indicates Service ID of the service found using Service Name.
|
||||
* @param[inout] svc_name As input, it indicates Service Name to search for.
|
||||
|
@ -32,6 +32,8 @@
|
||||
#define MACADDR_EQUAL(a1, a2) (memcmp(a1, a2, MACADDR_LEN))
|
||||
#define MACADDR_COPY(dst, src) (memcpy(dst, src, MACADDR_LEN))
|
||||
#define NAN_DW_INTVL_MS 524 /* NAN DW interval (512 TU's ~= 524 mSec) */
|
||||
#define NAN_NDP_RESP_TIMEOUT_DW 4
|
||||
#define NAN_NDP_RESP_TIMEOUT NAN_NDP_RESP_TIMEOUT_DW*NAN_DW_INTVL_MS
|
||||
|
||||
/* Global Variables */
|
||||
static const char *TAG = "nan_app";
|
||||
@ -180,6 +182,16 @@ static struct peer_svc_info *nan_find_peer_svc(uint8_t own_svc_id, uint8_t peer_
|
||||
return p_peer_svc;
|
||||
}
|
||||
|
||||
static bool nan_update_peer_svc(uint8_t own_svc_id, uint8_t peer_svc_id, uint8_t peer_nmi[])
|
||||
{
|
||||
struct peer_svc_info *peer_info = nan_find_peer_svc(own_svc_id, 0, peer_nmi);
|
||||
if (peer_info) {
|
||||
peer_info->svc_id = peer_svc_id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nan_record_peer_svc(uint8_t own_svc_id, uint8_t peer_svc_id, uint8_t peer_nmi[])
|
||||
{
|
||||
struct own_svc_info *p_own_svc;
|
||||
@ -388,6 +400,11 @@ static void nan_fill_params_from_event(void *evt_data, uint8_t event)
|
||||
case WIFI_EVENT_NAN_SVC_MATCH: {
|
||||
wifi_event_nan_svc_match_t *evt = (wifi_event_nan_svc_match_t *)evt_data;
|
||||
|
||||
if (evt->update_pub_id) {
|
||||
if (nan_update_peer_svc(evt->subscribe_id, evt->publish_id, evt->pub_if_mac)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nan_find_peer_svc(evt->subscribe_id, evt->publish_id, evt->pub_if_mac)) {
|
||||
nan_record_peer_svc(evt->subscribe_id, evt->publish_id, evt->pub_if_mac);
|
||||
}
|
||||
@ -867,7 +884,7 @@ uint8_t esp_wifi_nan_datapath_req(wifi_nan_datapath_req_t *req)
|
||||
nan_record_new_ndl(ndp_id, req->pub_id, req->peer_mac, ESP_WIFI_NDP_ROLE_INITIATOR);
|
||||
ESP_LOGD(TAG, "Requested NDP with "MACSTR" [NDP ID - %d]", MAC2STR(req->peer_mac), ndp_id);
|
||||
|
||||
EventBits_t bits = os_event_group_wait_bits(nan_event_group, NDP_ACCEPTED | NDP_REJECTED, pdFALSE, pdFALSE, pdMS_TO_TICKS(2*NAN_DW_INTVL_MS));
|
||||
EventBits_t bits = os_event_group_wait_bits(nan_event_group, NDP_ACCEPTED | NDP_REJECTED, pdFALSE, pdFALSE, pdMS_TO_TICKS(NAN_NDP_RESP_TIMEOUT));
|
||||
if (bits & NDP_ACCEPTED) {
|
||||
os_event_group_clear_bits(nan_event_group, NDP_ACCEPTED);
|
||||
return ndp_id;
|
||||
|
@ -22,6 +22,10 @@ The following features are supported:
|
||||
- Multiple antennas
|
||||
- Channel state information
|
||||
|
||||
.. only:: SOC_WIFI_NAN_SUPPORT
|
||||
|
||||
- Wi-Fi Aware (NAN)
|
||||
|
||||
.. only:: esp32c6
|
||||
|
||||
- 4 virtual Wi-Fi interfaces, which are STA, AP, Sniffer and reserved.
|
||||
@ -1674,6 +1678,19 @@ For establishing a secure connection, AP and station negotiate and agree on the
|
||||
|
||||
Detailed information on creating certificates and how to run wpa2_enterprise example on {IDF_TARGET_NAME} can be found in :example:`wifi/wifi_enterprise`.
|
||||
|
||||
.. only:: SOC_WIFI_NAN_SUPPORT
|
||||
|
||||
Wi-Fi Aware\ :sup:`TM` (NAN)
|
||||
----------------------------
|
||||
|
||||
Wi-Fi Aware\ :sup:`TM` or NAN (Neighbor Awareness Networking) is a protocol that allows Wi-Fi devices to discover services in their proximity. NAN uses direct device-to-device communication and does not require any Internet or AP connection.
|
||||
|
||||
Multiple NAN devices in the vicinity will form a NAN cluster which allows them to communicate with each other. NAN devices in a cluster synchronise their clocks and listen to each other periodically on Channel 6. Devices can advertise (Publish) or seek for (Subscribe) services within their NAN Cluster using Service Discovery protocols. Matching of services is done by service name and optionally matching filters. Once a Subscriber gets a match with a Publisher, it can either send a message (Follow-up) or establish a datapath (NDP) with the Publisher. After NDP is setup both devices will obtain an IPv6 address and can use it for communication.
|
||||
|
||||
Please note that NAN Datapath security is not supported i.e. the data packets will go out unencrypted. NAN uses a separate interface for Discovery and Datapath, which is other than that used for STA and AP. NAN operates in standalone mode, which means co-existence with STA or AP interface is not supported.
|
||||
|
||||
Refer to ESP-IDF examples :idf_file:`examples/wifi/wifi_aware/nan_publisher/README.md` and :idf_file:`examples/wifi/wifi_aware/nan_subscriber/README.md` to setup a NAN Publisher and Subscriber.
|
||||
|
||||
Wireless Network Management
|
||||
----------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user