Я пытаюсь подключить устройство Bluetooth с помощью Windows Phone (8.1) с помощью StreamSocket-Class.Доступ к потоковым сокетам запрещен Windows Phone 8.1 Bluetooth
Теперь каждый раз, когда я вызываю socket.CallAsync (HostName, RemoteServiceName), я получаю ошибку AccessDenied. Я активировал датчик приближения в AppManifest.
Вот код:
private async void ConnectToDevice()
{
if (_socket != null)
{
// Disposing the socket with close it and release all resources associated with the socket
_socket.Dispose();
}
try
{
_socket = new StreamSocket();
// Note: If either parameter is null or empty, the call will throw an exception
await _socket.ConnectAsync(_currentPeer.HostName, "{00001101-0000-1000-8000-00805f9b34fb}");
// If the connection was successful, the RemoteAddress field will be populated
MessageDialog md = new MessageDialog(_socket.Information.RemoteAddress.DisplayName);
await md.ShowAsync();
Start.IsEnabled = true;
}
catch (Exception ex)
{
MessageDialog md = new MessageDialog("Connection failed");
await md.ShowAsync();
_socket.Dispose();
_socket = null;
}
}
Спасибо за вашу помощь!
ли вы добавить объявление для вашего устройства в разделе DeviceCapabilities в appxmanifest? – Ali250
Да, я активировал Proximity для Bluetooth и Интернета (Client & Server) для соединения Socket. – Daniel