none
Bluetooth Communication between Windows Phone 8 and PC

    Question

  • I want to transfer data from a Windows Phone 8 to a WPF App with bluetooth. I do not want to use 32Feet library.

    The Windows Phone Part is clear.

    The PeerFinder Class does not exist in WPF. How can I listen to incoming messages from a WPF Application? Sockets?

    Any sample code? Links?

    Thanks very much in advance.

    Stefan

    Friday, December 27, 2013 8:08 AM

Answers

  • Yes, sockets are the only way.

    if you can open a stream socket with the bluetooth connection, you are in luck.

    Use the TcpListener class on your WPF app to listen for incoming connections

    http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener%28v=vs.110%29.aspx

    Additionally, you can also use the serial port class (this one is a little more lower level, but it works)

    http://msdn.microsoft.com/en-us/library/system.io.ports.serialport%28v=vs.110%29.aspx

    I would go for the sockets though, since it can work with ad-hoc wifi as well.

    sample for the WPF side of the story

    http://msdn.microsoft.com/en-us/library/fx6588te%28v=vs.110%29.aspx

    sample for the phone part of the story (ignore the windows store app in the first half)

    http://social.technet.microsoft.com/wiki/contents/articles/20495.how-to-transfer-files-between-a-windows-store-app-and-any-windows-phone-app.aspx


    Friday, December 27, 2013 11:51 AM

All replies

  • Yes, sockets are the only way.

    if you can open a stream socket with the bluetooth connection, you are in luck.

    Use the TcpListener class on your WPF app to listen for incoming connections

    http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener%28v=vs.110%29.aspx

    Additionally, you can also use the serial port class (this one is a little more lower level, but it works)

    http://msdn.microsoft.com/en-us/library/system.io.ports.serialport%28v=vs.110%29.aspx

    I would go for the sockets though, since it can work with ad-hoc wifi as well.

    sample for the WPF side of the story

    http://msdn.microsoft.com/en-us/library/fx6588te%28v=vs.110%29.aspx

    sample for the phone part of the story (ignore the windows store app in the first half)

    http://social.technet.microsoft.com/wiki/contents/articles/20495.how-to-transfer-files-between-a-windows-store-app-and-any-windows-phone-app.aspx


    Friday, December 27, 2013 11:51 AM
  • Thanks for infos and links!

    Stefan

    Friday, December 27, 2013 12:21 PM
  • I used the samples from the links.

    I just do not get a connection from Windows Phone. The WPF Server App gets nothing connecting. My firewall is not claiming an access.

    Which Windows Phone Sample would you use to get access from WP8 to WPF App?

    WPF : TcpListener

    WP8 : ?

    Is there something wrong with my network or firewall?

    I use a USB Bluetooth Adapter.

    Thanks

    Stefan

    Friday, December 27, 2013 4:58 PM
  • is your device discoverable?

    Did you paired the device and the laptop/desktop?

    In wp8 you simply use a tcp socket to initate the connection to the listener.

    Friday, December 27, 2013 7:42 PM
  • discoverable: on the phone I see under settings/bluetoooth my computer "atman".

    how do i know that laptop is paired with my phone? May be.

    So what ist the problem that I do not get a connection?

    Friday, December 27, 2013 8:19 PM
  • I don't know.

    The phone should tell you under bluetooth settings if the computer is paired with it.Pairing involves the use of some pass key to identify the devices.

    Saturday, December 28, 2013 10:19 AM
  • So I startet a new Solution with two WPF Projects, first TcpListener Project and second TcpClient Project. The Connection worked in this Scenario and message could be received.

    When I tried with WP8, there is always a SocketError ("HostNotFound").

    with this method and Parameters : hostName = "ATMAN", portNumber = 8253

    public string Connect(string hostName, int portNumber)
            {
                string result = string.Empty;
    
                // Create DnsEndPoint. The hostName and port are passed in to this method.
                DnsEndPoint hostEntry = new DnsEndPoint(hostName, portNumber, AddressFamily.InterNetwork);
    
                // IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.1.39"), portNumber);
    
                // Create a stream-based, TCP socket using the InterNetwork Address Family. 
                _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                
                // Create a SocketAsyncEventArgs object to be used in the connection request
                SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
                socketEventArg.RemoteEndPoint = hostEntry;

    Do you know why the host is not found?

    Thanks

    Stefan

    Sunday, December 29, 2013 1:13 PM
  • Have you paired the phone with the PC or not?

    Go to the phone>settings>bluetooth

    see the computer name in there, tap on it to pair.

    Sunday, December 29, 2013 1:20 PM
  • Yes it is paired, I see it the Settings of Bluetooth: The Computer Name "Atman" is there. Under Atman the comment is "Music connected", bzw "Musik verbunden". Is there only a way of Transfer Music?

    Thanks for help!

    Stefan

    Sunday, December 29, 2013 1:25 PM
  • I can't help you anymore unless i have your phone and your computer so i can see what is going on.

    if something else is using your Bluetooth connection, it won';t work. Bluetooth is a very fragile communication protocol.

    Sunday, December 29, 2013 7:37 PM