1

I have a problem with StreamSocket's by Bluetooth connection.

I have a phone Nokia Lumia 920 and some bluetooth headset. This headset have proprietary service. I know uuid of this service.

I implemented code for communication with this service.

PeerFinder.AlternateIdentities["Bluetooth:Paired"] = ""; var peers = await PeerFinder.FindAllPeersAsync(); StreamSocket socket = new StreamSocket(); var uuid = "there is uuid"; await socket.ConnectAsync(peers[0].HostName, uuid, SocketProtectionLevel.PlainSocket);

This code work success.

Then I send bytes message to headset by IOutputStream.

DataWriter dataWriter = new DataWriter(socket.OutputStream); byte[] a = {0x01, 0x01 , 0x10, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}; dataWriter.WriteBytes(a); await dataWriter.StoreAsync();

This code work success.

Then I have to get bytes message.

DataReader dataReader = new DataReader(socket.InputStream); dataReader.InputStreamOptions = InputStreamOptions.Partial; await dataReader.LoadAsync(10); while (dataReader.UnconsumedBufferLength > 0) { byte bb = dataReader.ReadByte(); }

This code don't work success.

In the line

await dataReader.LoadAsync(10); app hangs here. But the response must necessarily be.

Why is this a problem?

Do sockets support communication through Bluetooth by uuid in windows phone 8?

Can you help me?

Thank you all.

4

0 回答 0