public void StartListening(RfcommServiceId serviceId) { _logger.Info("StartListen() in: serviceId={0}", serviceId.AsString()); // Initialize the provider for the hosted RFCOMM service //_provider = RfcommServiceProvider.CreateAsync(serviceId).AsTask().Result; _provider = _factories.ProviderFactory.Invoke(RfcommServiceId.SerialPort); // Create a listener for this service and start listening IStreamSocketListenerWrapper listener = _factories.ListenerFactory.Invoke(); //StreamSocketListener listener = new StreamSocketListener(); listener.ConnectionReceived += OnConnectionReceived; listener.BindServiceNameAsync(serviceId.AsString(), SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication).AsTask().Wait(); // Set the SDP attributes and start advertising //InitializeServiceSdpAttributes(_provider); _provider.StartAdvertising(listener); _logger.Info("StartListen() out"); }