gpt4 book ai didi

c# - 检查 Microsoft Band 设备是否已连接

转载 作者:行者123 更新时间:2023-11-28 19:46:49 24 4
gpt4 key购买 nike

我正在使用适用于 iOS 和 Windows Phone 的 Microsoft Band SDK。我注意到在 iOS 上我可以检查可穿戴设备是否连接到智能手机:

MSBClient* bandClient = [[[MSBClientManager sharedManager]attachedClients]firstObject];

if(bandClient.isDeviceConnected){
//...
}

有没有办法在 Windows Phone 上实现相同的结果?我通过这种方式在 Windows Phone 上获取 bandClient:

IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
//stuff...
}

但是连接后,如何判断手环在某个时刻是否连接到手机(或断开连接)?在 Windows Phone sdk 上,没有 onClientDisconnected() 回调,也没有像 bandClient.isDeviceConnected() 这样的函数。

有没有办法检查手环是否连接到智能手机?这非常重要:例如,在连接后,我可以带着我的手环远离失去连接的智能手机。

最佳答案

在 Windows 上,不需要“已连接”方法,因为调用 IBandClientManager.ConnectAsync() 会尝试与 Band 建立蓝牙连接(仅当返回的 IBandClient 被处理时才会断开)。如果无法建立连接,该方法将抛出异常。

关于c# - 检查 Microsoft Band 设备是否已连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31702449/

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