I tried to make a bluetooth app with some (a lot of :P) help from the internet. It just send byte[7] command (called "tosend" in proj) to device and receive also byte[7] commands by listener.
I'm searching devices from range, get all data (address etc) and it goes well (slow, but well). Then I'm doubleclicking on the list to select one device and start the client connect thread:
private void CCT()
{
BluetoothClient Client = new BluetoothClient();
udConsole("CCT started.");
Client.BeginConnect(info.DeviceAddress, mUUID, new AsyncCallback(Callback), Client);
//"info" is just a BluetoothDeviceInfo (of selected device)
}
private void Callback(IAsyncResult res)
{
BluetoothClient Client = (BluetoothClient)res.AsyncState;
Client.EndConnect(res);
Stream str = Client.GetStream(); //<- error is here
str.ReadTimeout = 1000;
while (true)
{
while (!initializeSending) ;
Client.GetStream().Write(tosend, 0, tosend.Length);
}
}
I can't send anything because once I see the error with invalid argument, other with invalid address (when I see that address is OK).
Both devices are paired all the time! And bluetooth is working well ^^
What's going on :(? I spent a lot of time with searching the solution, but nothing worked for me.