.NET 2 CF WM5 Bluetooth trouble

D

dgretlein

Greetings -

I found your name on this MSDN chat:
..NET Compact Framework and Smart Device Programming (October 11, 2005)


I have an issue and it is driving me crazy !!! I have been developing
with VB6 forever it seems like ( cut my teeth on assembly and C code
development ).

My delima has confused me ..... and I am wondering if you would help me
along. I am stuck on not being about to fire a data received event.

I have been working on a Bluetooth application for an Dell Axim x51
PDA, developing in C# in VS2005, using .NET CF 2.0, WM5.

I there is a Bluetooth manager on the PDA that shows me two COM ports (
COM7 Incoming port and COM8 Outgoing port ).

My code can "discover" the Bluetooth radio device and connect. I can
send data to the device, but cannot get any of my serialPort receive
event handlers to fire when I am pretty darn certain data is coming.
When I close the app, the connection closes as it should and the BT
radio disconnects cleanly.

Here is where I am stuck. I have created serialPort1 and serialPort2
objects and configured the setting via the properties page. I have a
menu item that does

serialPort1.Open();
serialPort2.Open();

and the LED on the BT radio lights up and stays discovered. As I said,
I send data reliably and repeatably.


I have read a few threads of developers having similar problems, but I
have not found any solutions. I have the receive code below.

private void serialPort1_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e) {
string line = serialPort1.ReadExisting();
receivedData = line;
txtReceive.Invoke(new
EventHandler(dataReceivedEventPort1));
}

private void dataReceivedEventPort1(object o, EventArgs e)
{
//writeToConsole(receivedData);
txtReceive.Text = receivedData;
}
 
P

Peter Foot [MVP]

Incoming and Outgoing serial ports do not represent the separate directions
of data travel but rather who originally opens the connection.
For example if you create an outgoing connection to a GPS device you would
setup an outgoing serial port to that bonded device, then open the virtual
com port and receive data on that port. The incoming port is only used when
another device wants to connect to the serial port profile on your device.
In the case of a "dumb" device like a GPS you have to initiate the
connection, it won't try to connect to your PDA.

But my second suggestion would be to use Sockets rather than serial ports
since this cuts out the additional steps of bonding and setting up the
virtual COM ports. See http://32feet.net for a .NET Bluetooth sockets
implementation.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top