hello,
I'm working on a connection between JSR82 ( Java on a mobile phone) and PC ( C# ( inthehand) ).
The PC works as a server:
-------------------------------------
public static Guid TEXTSERVICE = new Guid("12100000000000000000000000000121");
private Thread thread;
private bool run = true;
private BluetoothListener btl;
private ServiceRecordBuilder SvcBuilder;
public Form1()
{
InitializeComponent();
if (!BluetoothRadio.IsSupported)
{
MessageBox.Show( "No Bluetooth Adapter found!!!");
}
else
{
if (BluetoothRadio.PrimaryRadio.Mode == RadioMode.PowerOff)
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
// Create and start a thread, listening for an incoming text message
thread = new Thread(new ThreadStart(runThread));
thread.Start();
}
}
------------------------
private void runThread()
{
try
{
run = true;
SvcBuilder = new ServiceRecordBuilder();
SvcBuilder.AddServiceClass(BluetoothService.RFCommProtocol);
SvcBuilder.ServiceName = "MyService";
ServiceRecord record = SvcBuilder.ServiceRecord;
btl = new BluetoothListener(TEXTSERVICE, record);
btl.Start();
while (run)
{
BluetoothClient btc = btl.AcceptBluetoothClient();
StreamReader sr = new StreamReader(btc.GetStream());
// Create a delegate for setting the text on the main thread
this.Invoke((MethodInvoker)delegate
{
MessageBox.Show("Message received: ");
});
sr.Close();
}
}
// If the thread gets aborted, an exception is thrown
catch { }
}
}
}
----------------------------
Now I'm able fo find the service ( My Service) on mobile Phone(Java) side , but don't know what I've got to do for sending a message to the server and get one back. In a lot of examples work with a objectnotifier by using RFcomm, but inthehand don't have them, or? Or is there anothersolution for sending messages over bluetooth between C# and Java on a mobile phone?
It would be nice, if someone could help me. I wasted the whole last day for this problem.
ubi