private async void RfcommScanner_Added(object sender, Bluetooth.IBluetoothDevice e) { if (e.Address == BluetoothUtils.AddressStringToInt64("DC:53:60:DD:AE:63")) { //var serviceResult = await e.GetRfcommServicesAsync(); await e.RfcommConnectAsync(); //var serviceResult = await e.GetRfcommServicesForIdAsync(Constants.ServiceId); var serviceResult = await e.GetRfcommServicesAsync(); IRfcommDeviceService service = null; if (serviceResult.Error == BluetoothError.Success && serviceResult.Services.Count > 0) { foreach (var ser in serviceResult.Services) { if (ser.ServiceId == Constants.ServiceId) { service = ser; break; } } } if (service == null) { return; } var connection = new RfcommRXConnection(service, ConnectionGroup); OnConnectionReceived?.Invoke(this, connection); } }
private void ServiceProvier_OnConnectionReceived(object sender, IRfcommConnection e) { RfcommRXConnection rxConnection = new RfcommRXConnection(e, ConnectionGroup); ConnectionReceived?.Invoke(this, rxConnection); }