1

I have windows console application (written in C#) which needs to receive a string from Android phone (running Java application) via bluetooth. Windows console application is using 32feet.Net library to work with bluetooth.

This is Java code sending the string from Android phone (not important details are omitted for brevity):

 BluetoothDevice targetDevice = getDeveice();
 BluetoothSocket socket = targetDevice.createRfcommSocketToServiceRecord(getUuid()); 
 socket.connect();
 OutputStream outputStream = socket.getOutputStream();
 outputStream.write("MyString".getBytes());

This is C# code to receive the data:

string lgphone = "00:00:00:00:00:00"; // The MAC address of my phone, lets assume we know it
BluetoothAddress addr = BluetoothAddress.Parse(lgphone);
var btEndpoint = new BluetoothEndPoint(addr, new Guid("0000111f-0000-1000-8000-00805f9b34fb"));
var btClient = new BluetoothClient();
btClient.Connect(btEndpoint);
Stream peerStream = btClient.GetStream();
byte[] buf = new byte[1000];
int readLen = peerStream.Read(buf, 0, buf.Length);

BluetoothClient is successfully connected. But peerStream does not have any data :( I can provide more details if needed.

Is general approach correct? Could you advice what could be wrong?

Alex
  • 61
  • 3

0 Answers0