NSD 和 WifiP2pManager 有什么不同?
What is different of NSD and WifiP2pManager?
在android中制作WiFi程序有多种选择,最常用的方法是使用NSD和WifiP2pManager。
这两个选择有什么不同?
首先,这不是要区分的两个实体。即使您将 Wi-Fi P2p 用于 NSD,您也应该使用 WifiP2pManager 进行连接初始化和协商。 NSD 将用于发现阶段
我假设你的问题是使用 Wi-Fi P2p 服务发现(NSD) 和不使用 之间的区别(使用正常扫描 WifiP2pManager.discoverPeers()
).
在三个子主题下 here 明确提供了答案。不过
区别实际上是在初始阶段:对等发现阶段
- 当您不使用 Wi-Fi P2p 服务发现时,您扫描所有
使用 WiFi direct 激活的设备。扫描结果列表可能包含您不感兴趣的节点。你没有办法,因为你没有过滤器。
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.
但是,在此阶段之后,在这两种方法中,都会从发现的列表中选择一个特定的设备并发起连接请求。从这里开始,接下来的阶段都是一样的——连接请求、协商、组队...
希望对您有所帮助。
在android中制作WiFi程序有多种选择,最常用的方法是使用NSD和WifiP2pManager。
这两个选择有什么不同?
首先,这不是要区分的两个实体。即使您将 Wi-Fi P2p 用于 NSD,您也应该使用 WifiP2pManager 进行连接初始化和协商。 NSD 将用于发现阶段
我假设你的问题是使用 Wi-Fi P2p 服务发现(NSD) 和不使用 之间的区别(使用正常扫描 WifiP2pManager.discoverPeers()
).
在三个子主题下 here 明确提供了答案。不过
区别实际上是在初始阶段:对等发现阶段
- 当您不使用 Wi-Fi P2p 服务发现时,您扫描所有 使用 WiFi direct 激活的设备。扫描结果列表可能包含您不感兴趣的节点。你没有办法,因为你没有过滤器。
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.
但是,在此阶段之后,在这两种方法中,都会从发现的列表中选择一个特定的设备并发起连接请求。从这里开始,接下来的阶段都是一样的——连接请求、协商、组队...
希望对您有所帮助。