Hello group,
I'm new here so sorry for probably stupid questions. I was trying to make use of my N95's SIM access profile, but I cannot come across some problems. I was using some lines found in another post here. So basically I'm doing this:
SelectBluetoothDeviceDialog sbdd = new SelectBluetoothDeviceDialog();
DialogResult res = sbdd.ShowDialog();
BluetoothAddress btAddr = sbdd.SelectedDevice.DeviceAddress;
BluetoothDeviceInfo btDevice = new BluetoothDeviceInfo(btAddr);
BluetoothEndPoint bep = new BluetoothEndPoint(btDevice.DeviceAddress, BluetoothService.SimAccess);
BluetoothClient client = new BluetoothClient();
client.Connect(bep);
NetworkStream stream = client.GetStream();
byte[ buffer = new byte[ { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x18, 0x00, 0x00 };
stream.Write(buffer, 0, buffer.Length);
Dialog and Connect - OK. Write fails with Socket Error 10053.
InnerException: System.Net.Sockets.SocketException
Message="Eine bestehende Verbindung wurde softwaregesteuert\r\ndurch den Hostcomputer abgebrochen"
Source="System"
ErrorCode=10053
NativeErrorCode=10053
StackTrace:
bei System.Net.Sockets.Socket.Send(Byte[ buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
bei System.Net.Sockets.NetworkStream.Write(Byte[ buffer, Int32 offset, Int32 size)
InnerException:
I've tried various things, e.g. adding this
client.Client.SetSocketOption((SocketOptionLevel)BluetoothSocketOptionLevel.RFComm, (SocketOptionName)BluetoothSocketOptionName.Encrypt, true);
client.Client.SetSocketOption((
SocketOptionLevel)BluetoothSocketOptionLevel.RFComm, (SocketOptionName) BluetoothSocketOptionName.XPAuthenticate, true);
right before connecting or trying to read instead of writing. The read result is empty, btw. So I'm currently not sure, what to do after CONNECT. The buffer, I'm trying to send down, is a CONNECT_REQ (afaik).
Anybody able to help?
BTW: Reviewing this I inspected the client object after connect. The property "connected" is false... Seems to be not connected at all?
Regards