gpt4 book ai didi

android - NSD 和 WifiP2pManager 有什么不同?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:38:03 27 4
gpt4 key购买 nike

在android中制作WiFi程序有多种选择,最常用的方法是使用NSDWifiP2pManager

这两个选择有什么不同?

最佳答案

首先,这不是要区分的两个实体。即使您将 Wi-Fi P2p 用于 NSD,您也应该使用 WifiP2pManager 进行连接初始化和协商。 NSD 将用于发现阶段

我认为您的问题是使用 Wi-Fi P2p 服务发现(NSD) 和不使用 之间的区别(使用正常扫描WifiP2pManager.discoverPeers( )).

明确提供了答案here在三个子主题下。然而

区别其实在于初始阶段:The peer discovery phase

  • 当您不使用 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 - NSD 和 WifiP2pManager 有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28558858/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com