What is different of NSD and WifiP2pManager?
Asked Answered
F

1

6

There are several choice for making a WiFi program in android, most common methods are using NSD and WifiP2pManager.

What is different between these 2 choice?

Fabricate answered 17/2, 2015 at 9:41 Comment(0)
R
20

Firstly, these are not two entities to be differentiated. Even if you use Wi-Fi P2p for NSD, you should use WifiP2pManager for connection initiation and negotiation. NSD is to be used for Discovery phase

I assume your question to be difference between Using Wi-Fi P2p Service Discovery(NSD) and Not using it (using normal scan WifiP2pManager.discoverPeers() ).

The answer is explicitly provided here under three sub-topics. However

The difference is actually in the initial phase: The peer discovery phase

  • When you don't use the Wi-Fi P2p Service discovery, you scan for all devices that are active with WiFi direct. The scan result list may contain peers that are not of your interest. You can't help it, as you do not have a filter.
  • In the case where you need to discover only peers that are of your interest, then Wi-Fi P2p Service discovery should be used. Here, the filter condition is set in the name of Service.

    For ex: your app "XYZ" needs to form groups ONLY with other devices that also use the same app "XYZ", then you can create a service and name it, say service_xyz, and this service info will be broadcast along with the Wi-Fi Direct device details. On the receiver end, you implement a service listener that listens for the service "service_xyz". By doing so, only devices with the desired service name are discovered and listed. Useful for gaming apps, social networking apps.

However, after this phase, in both the methods, from the discovered list a particular device is selected and connect request is initiated. From here on, the following phases are the same - connection request, negotiation, group formation...

hope this helped you.

Restrict answered 1/3, 2015 at 18:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.