我有诺基亚Lumia 925,我想要做的就是枚举所有蓝牙设备,并实时获得其信号强度。但有了这个.... Windows Phone SDK我根本找不到任何设备。
我确切地知道我正在使用哪个设备并在清单文件中建模:
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="proximity"/>
<DeviceCapability Name="bluetooth.genericAttributeProfile" />
<m2:DeviceCapability Name="humaninterfacedevice">
<m2:Device Id="vidpid:0421 0716">
<m2:Function Type="usage:ffaa 0001" />
<m2:Function Type="usage:ffee 0001" />
<m2:Function Type="usage:ffee 0002" />
<m2:Function Type="usage:ffee 0003" />
<m2:Function Type="usage:ffee 0004" />
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
但仍然没有。
async void StartLoadingDevices()
{
PeerFinder.AllowBluetooth = true;
PeerFinder.AllowInfrastructure = false;
// PeerFinder.Role = PeerRole.Host;
PeerFinder.AllowWiFiDirect = false;
//PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = "";
PeerFinder.Start();
int Runs = 0;
int Exceptions = 0;
while (true)
{
try
{
var devices = await PeerFinder.FindAllPeersAsync();
cList.Items.Clear();
cLabel.Text = "Updating Run " + Runs++;
foreach (var device in devices)
{
cList.Items.Add(String.Format("{0} {1}", device.DisplayName, device.ServiceName));
}
}
catch(UnauthorizedAccessException ex)
{
cExCount.Text = (++Exceptions).ToString();
}
}
}
我一直在 PeerFinder.Start 和 PeerFinder.FindAllPeersAsync 中获取异常,具体取决于我是否尝试获取所有配对设备。 我的目标是找到一个外面积雪覆盖的小型蓝牙设备。但到目前为止,我甚至无法获得设备列表。 WP8 API看起来很残缺,只支持非常具体的应用程序用例。通用用例似乎是为操作系统保留的。如果有一个WP8原生API我也可以。
我可以从雪中挖掘设备,但是我可以通过手机获得大致位置的更技术性解决方案。