通过智能设备框架添加无线接入点
我有几个问题:
一般来说,智能设备框架中的 OpenNETCF.Net
命名空间和 OpenNETCF.Net.NetworkInformation
命名空间之间的一般区别是什么?两者之间似乎有很多功能重叠。现在是否已弃用 OpenNETCF.Net
命名空间,取而代之的是 NetworkInformation 命名空间?
更具体地说,我有一个带有无线适配器的设备。我的目标是能够查询附近的接入点,然后通过我自己的用户界面连接到它们。
OpenNETCF.Net.Networking.GetAdapters()[1]
为我提供了代表无线适配器的适配器对象。即使这是一个无线适配器,IsWireless 和 IsWirelessZeroConfigCompatible 都会返回 false。但是,NearbyAccessPoints 确实会返回附近接入点的列表,正如您期望无线适配器所做的那样。
我需要一种方法将发现的接入点之一添加到 PreferredAccessPoints 集合中。我还没有找到在 OpenNETCF.Net 命名空间中完成此操作的方法。我发现添加 AccessPoint 的唯一方法是通过 OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface
类的 AddPreferredNetwork()
方法。我遇到的问题是我一直无法找到获取 WirelessZeroConfigNetworkInterface
对象的方法。 NetworkInterface.GetAllNetworkInterfaces() 方法返回的对象只是一个普通的旧 NetWorkInterface 对象,而不是我希望的 WirelessZeroConfigNetworkInterface 对象。我确信这可能与 IsWireless 在 NetworkAdapter 对象中返回 false 的问题有关。
有没有办法构造 WirelessZeroConfigNetworkInterface
对象,即使框架似乎认为它不是无线的?看起来该功能已经存在,如 NetworkAdapter 对象的无线相关方法所示。
I have a couple questions:
In general, what is the general difference between the OpenNETCF.Net
namespace and the OpenNETCF.Net.NetworkInformation
namespace in the Smart Device Framework? There seems to be a lot of functionality overlap between the two. Is the OpenNETCF.Net
namespace now deprecated in favor of the NetworkInformation namespace?
More specifically, I have a device with a wireless adapter. My goal is to be able to query nearby access points and then connect to them through my own user interface.
OpenNETCF.Net.Networking.GetAdapters()[1]
gives me my adapter object representing the wireless adapter. Even though this is a wireless adapter, IsWireless and IsWirelessZeroConfigCompatible both return false. However, NearbyAccessPoints DOES return a list of nearby access points as you would expect a wireless adapter to do.
I need a way to add one of the discovered access points to the PreferredAccessPoints collection. I have not found a method to accomplish this within the OpenNETCF.Net
namespace. The only way I've found to add an AccessPoint is through the AddPreferredNetwork()
method of the OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface
class. The problem I'm having is that I've been unable to find a way to obtain a WirelessZeroConfigNetworkInterface
object. The object returned by the NetworkInterface.GetAllNetworkInterfaces()
method is just a plain old NetWorkInterface object, not a WirelessZeroConfigNetworkInterface
object as I hoped. I'm sure this is probably related to the issue with IsWireless returning false in the NetworkAdapter
object.
Is there a way to construct the WirelessZeroConfigNetworkInterface
object even though the framework seems to think it is not wireless? It looks like the functionality is there as demostrated by the Wireless related methods of the NetworkAdapter
object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
历史有点令人困惑,是的。基本上,SDF 2.2(或更早的版本,我不记得了)在 OpenNETCF.Net 命名空间中拥有所有内容。当我在 2.3 中添加功能时,我在 OpenNETCF.Net.NetworkInformation 命名空间中添加了大量与完整框架并行的内容。其中一些与我们在无线方面所做的事情有功能重叠,因此我决定将所有内容移至 OpenNETCF.Net.NetworkInformation 命名空间。我保留了原始版本并将它们标记为已弃用,以尝试对现有部署友好。您应该使用的项目是 OpenNETCF.Net.NetworkInformation 命名空间中的项目。
现在来看看这些东西是如何运作的。首先,我们查询所有网络接口的 NDIS。这为我们提供了有线、RNDIS、无线等——基本上是网络堆栈所知道的一切。然而,NDIS 对“无线”的东西知之甚少——但它确实知道一些。
一旦我们有了已知适配器的列表,我们就会询问 NDIS 它是否是无线设备 - 它至少可以告诉我们,因为驱动程序在注册时告诉 NDIS。
一旦我们有了无线适配器列表,我们就会遍历它们并询问 WZC 子系统是否知道该适配器。 WZC 是一个了解无线设备一切的接口,使我们能够通过通用的、已发布的接口与其进行交互。如果 WZC 确实知道这一点(意味着驱动程序在初始化时向 WZC 报告了自身),那么我们为其创建一个 WirelessZeroConfigNetworkInterface。如果 WZC 不知道它,那么我们知道它是无线的(NDIS 告诉我们它是),但我们只有 NDIS 方法与其交互。
NDIS 没有为我们提供联系的方式。它确实为我们提供了一种询问附近 SSID 的方法。然后,您拥有的适配器接口公开了我们所知道的功能。
在某些情况下,驱动程序有一个专有的 API 来操纵 WiFi 设置(例如旧的 Cisco 卡)。
您运行的操作系统是什么版本?您使用什么 WiFi 芯片组/适配器?
The history is a bit confusing, yes. Basically SDF 2.2 (or earlier, I don't recall any more) had everything in the OpenNETCF.Net namespace. When I was adding features in 2.3, I added a boatload of stuff in the OpenNETCF.Net.NetworkInformation namespace that paralleled the full framework. Some of that had functional overlap with things we had done in the wireless stuff, so I made the decision to move everything over to the OpenNETCF.Net.NetworkInformation namespace. I left the originals and marked them as deprecated to try to be friendly to existing deployments. The items you should use are the ones in the OpenNETCF.Net.NetworkInformation namespace.
Now on to how the stuff functions. First we query NDIS for all network interfaces. This gives us wired, RNDIS, wireless, etc - basically everything that the network stack knows about. NDIS, however, doesn't know much about "wireless" stuff - it does know some though.
Once we have our list of known adapters, we then ask NDIS if it's a wireless device - it can at least tell us that becasue the driver tells NDIS at registration.
Once we have a list of wireless adapters, we then walk them and ask the WZC subsystem if it knows about the adapter. WZC is an interface that knows everything about the wireless devices, allowing us to intereact with it through a common, published interface. If WZC does know about it (meaning the driver reported itself at initialization to WZC) then we create a WirelessZeroConfigNetworkInterface for it. If it isn't known by WZC, then we know it's wireless (NDIS told us it was), but we only have the NDIS methods for interacting with it.
NDIS doesn't give us a way to associate. It does give us a way to ask for nearby SSIDs. The Adapter interface you have, then, exposes the capabilities we know of.
In some cases the driver has a proprietary API to manipulate the WiFi settings (e.g. old Cisco cards).
What version of the OS is this you're running on? What WiFi chipset/adapter are you using?