简体   繁体   English

Xamarin.ios Core蓝牙中央管理器:检索带有标识符的已知外围设备

[英]Xamarin.ios Core Bluetooth Central Manager : retrieve known peripherals with identifiers

I am building a xamarin.ios app which will connect to peripheral using bluetooth. 我正在构建一个xamarin.ios应用程序,它将使用蓝牙连接到外围设备。 So far I have successfully discovered and connected to the peripheral i wanted to connect to. 到目前为止,我已经成功地发现并连接了我要连接的外围设备。

Now, the issue is that I don't want to scan and discover for device every time i need to connect to the device. 现在,问题是我不想每次需要连接到设备时都扫描并发现该设备。 I am trying to use CBCentralManager.RetrievePeripheralsWithIdentifiers (uuid) but i don't seem to have success using this method. 我正在尝试使用CBCentralManager.RetrievePeripheralsWithIdentifiers(uuid),但使用此方法似乎没有成功。 I can retrieve the known peripheral using this method. 我可以使用这种方法检索已知的外围设备。 When i see what it returns in the debug mode, it gives me the device name but the service list( which i want to use) is null. 当我看到它在调试模式下返回的内容时,它给了我设备名称,但服务列表(我想使用)为空。

Did anyone have any success using this method? 有人使用这种方法成功吗? Thanks in advance ! 提前致谢 !

Here's a small snippet of my code (calling this method): 这是我的代码的一小段(调用此方法):

NSUuid ns = new NSUuid ("known device id");


var  uuid = new NSUuid[]{ ns};

CBPeripheral []per= manager.RetrievePeripheralsWithIdentifiers (uuid);

Okay, I have figured out . 好的,我知道了。 The problem was not the list of services returning null.Because , the services list has to be null before connecting to the devices. 问题不在于返回null的服务列表,因为连接到设备之前,服务列表必须为null。 The problem was how should i used that method in appropriate delegate object. 问题是我应该如何在适当的委托对象中使用该方法。 It works perfect. 完美的作品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM