Ema*_*eiz 5 c# bluetooth bluetooth-lowenergy uwp
我编写了一个 UWP 应用程序来宣传 GATT 服务。我想知道如何断开连接到 GATT 服务的客户端?我可以使用DeviceInformation类找到连接的设备,但是调用和对象的Dispose方法没有任何效果。SessionBluetoothLEDevice
string filter = BluetoothLEDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected);
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(filter);
foreach (DeviceInformation d in devices)
{
BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(d.Id);
var gattServices = await device.GetGattServicesAsync();
foreach (var service in gattServices.Services)
{
if (service.Session.SessionStatus == GattSessionStatus.Active)
service.Session.Dispose();
service.Dispose();
}
device.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以断开客户端设备的蓝牙连接?
| 归档时间: |
|
| 查看次数: |
1583 次 |
| 最近记录: |