cmpxchg8b
cmpxchg8b

Reputation: 691

Connect to bluetooth device without opening a socket

I've got a background task registered that will handle a (rfcomm) bluetooth connection as soon as my bluetooth device connects. Now, what I want to do is make a "Connect" button, just like the one in the Gadgets app. It should force the device to connect to my bluetooth device without opening a socket, so that the background task can handle it.

How do I do this?

Upvotes: 1

Views: 517

Answers (1)

lindexi
lindexi

Reputation: 4327

The BlueTooth should use the StreamSocket and it should use the socket.

    async void send(string str)
    {
        StreamSocket socket = await PeerFinder.ConnectAsync(peer);
        DataWriter data_writer=new DataWriter(socket.OutputStream);
        data_writer.WriteString(str);
        await data_writer.StoreAsync();
    }

Upvotes: 1

Related Questions