我已经创建了一个示例,用于从UWP应用连接BLE设备。
我做了以下步骤,
从设备列表中连接设备。连接代码如下,
//Id= "BluetoothLE#BluetoothLE58:00:e3:45:9c:4c-3c:15:c2:c4:46:71:be"
bluetoothDevice = await BluetoothLEDevice.FromIdAsync(Id);
if (bluetoothDevice != null)
{
bluetoothDevice.ConnectionStatusChanged += (s, e) =>
{
if (s.ConnectionStatus == BluetoothConnectionStatus.Connected)
{
state.Connected = true;
ConnectionStateChanged?.Invoke(this, state);
}
else if (s.ConnectionStatus == BluetoothConnectionStatus.Disconnected)
{
state.Connected = false;
ConnectionStateChanged?.Invoke(this, state);
}
};
//SetupMLDP();
}
我已经调用了此方法,但是从未调用ConnectionStateChanged方法。 我想念什么?如果您知道的话,请告诉我。