在Windows中收听并接受BLE Con​​nect请求

我一直在尝试使用低功耗蓝牙将iOS设备连接到Windows,我发现Windows BLE API非常不清楚。

Windows充当外围设备,iOS设备充当Central

我认为我的iOS设备上的Swift代码很好,它适用于BLE设备(就像我有的气候设备)我在iOS上做的是: – 启动BLE广告的扫描 – 收到广告后,如果ManufacturerData是我正在寻找的,我尝试连接到外围设备。

在Windows端,我: – 准备我的广告包 – 发布它

目前,我在iOS上收到了包,我启动了连接尝试……什么都没有! (甚至没有调用didFailToConnect)

我想我在Windows端缺少一些东西,我想有某种连接请求监听器? 我需要说“是的,我接受这种联系!” 或者“不,我没有!” 因为我的代码中不存在,连接请求永远不会被回答? 我在球场吗?

在谷歌搜索,stackoverflowing和WindowsAPIing我找不到如何做到这一点,如果这是我确实需要做的,或者如果我正在尝试甚至可以这样做!

不言而喻,任何帮助将不胜感激。 这是我在Windows端的C#代码,出于测试目的,它是一个简单的控制台应用程序,然后保持在一个丑陋的循环中,直到我想要它也不会终止:

namespace BluetoothClient { class Program { static void Main(string[] args) { BluetoothLEAdvertisementPublisher publisher = new BluetoothLEAdvertisementPublisher(); var manufacturerData = new BluetoothLEManufacturerData(); manufacturerData.CompanyId = 0xFFFA; var writer = new DataWriter(); writer.WriteString("Testme"); manufacturerData.Data = writer.DetachBuffer(); publisher.Advertisement.ManufacturerData.Add(manufacturerData); publisher.Start(); publisher.StatusChanged += Publisher_StatusChanged; Console.Write("Started\n"); while (true) { } } private static void Publisher_StatusChanged(BluetoothLEAdvertisementPublisher sender, BluetoothLEAdvertisementPublisherStatusChangedEventArgs args) { Console.Write("Status: "+args.Status+"\n"); } } } 

我期待着您的回复,并希望您能帮我爬出这个车辙,非常感谢和感谢!

Interesting Posts