public async Task <bool> BLE_ScanAndConnect(string deviceName) { // Get BLE device if (null != deviceName) { // Try connect to ble device ScanFilter filter = new ScanFilter().SetAdvertisedDeviceName(deviceName); BlePeripheralConnectionRequest connection = await g_BLEAdapterObj.FindAndConnectToDevice(filter, TimeSpan.FromSeconds(15)); if (connection.IsSuccessful()) { if (true == await SetupBLEConnection(connection)) { return(true); } else { await connection.GattServer.Disconnect(); } } } return(false); }