locked
Serial connection via Bluetooth RRS feed

  • Question

  • Hello,

    I would like to know if it is possible to use the bluetooth of the phone as a serial port, in order to establish a serial communication with a bluetooth device.

    Thanks.

    Monday, November 26, 2012 4:41 PM

Answers

  • It is possible to connect to BT devices that use SPP. These are connected to and the serial data stream is passed over effectively RFCOM via a Socket Stream. The Serial stream will just be continues data on the socket

    Connect as you would normally to a paired device

    PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
    var pairedDevices = await PeerFinder.FindAllPeersAsync();

    Create a socket stream

    StreamSocket readSocket = new StreamSocket();
    readSocket.ConnectAsync((PeerInformation)pairedDevices[0], "1"); //Note "1" this is the port number to use for the socket
    DataReader = new DataReader(this._readSocket.InputStream);

    Then read the data on a DataReader with

    LoadAsync
    ReadBytes

    • Marked as answer by aZubi Tuesday, February 5, 2013 2:59 PM
    Friday, February 1, 2013 5:53 PM

All replies