I connected the Windows Phone 8 with arudino using bluetooth as given in sample here
This is working okay for Windows Phone 8 but when i retarget the app to Windows Phone Silverlight 8.1, i am getting Debugger.Break and on continue,i get exception "exception has been thrown by target of invocation".
I used code:
PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
var pairedDevices = await PeerFinder.FindAllPeersAsync();
if (pairedDevices.Count == 0)
{
Debug.WriteLine("No paired devices were found.");
}
else
{
foreach (var pairedDevice in pairedDevices)
{
if (pairedDevice.DisplayName == DeviceName.Text)
{
connectionManager.Connect(pairedDevice.HostName);
ConnectAppToDeviceButton.Content = "Connected";
DeviceName.IsReadOnly = true;
ConnectAppToDeviceButton.IsEnabled = false;
continue;
}
}
}
Where connect function is defined as:
public async void Connect(HostName deviceHostName)
{
if (socket != null)
{
await socket.ConnectAsync(deviceHostName, "1");
dataReader = new DataReader(socket.InputStream);
dataReadWorker.RunWorkerAsync();
dataWriter = new DataWriter(socket.OutputStream);
}
}
Please Help Me.