简体   繁体   中英

How to read bluetooth data from Windows CE to bluetooth Device

I have a Windows Mobile/CE 6 device that needs to read RFID data from a bluetooth RFID wand in a custom .NET 3.5 CF application. Tried many different solutions and trying to make 32Feet's InTheHand bluetooth library work. I can get the device to pair and connect just fine, but when I send commands to the unit and try to read from the stream, it always results in an exception of "Operation time-out". Any tips or help is much appreciated.

var endpoint = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.SerialPort);
var client = new BluetoothClient();
client.Connect(endpoint); // Connects just fine!
var stream = client.GetStream();

using (var sw = new StreamWriter(stream))
{
   sw.Write("l");
}

if (stream.CanRead) // Always False
{
   using (var sr = new StreamReader(stream))
   {
      var exi = sr.Peek();
      var p = sr.ReadToEnd();
      var pp = sr.ReadLine();
   }
}

1.

I would first check, if there is any communication possible using the standard tools. Possibly the RFID does not work as you think.

Connect the BT RFID using the BT applet and add a new outgoing Serial Port also in the BT applet. Then use PocketPuTTY or another serial terminal tool to communicate with the RFID module. If that works, you can go on and start using 32feet.

2.

Will the RFID answer on a simple char or does it need a CR/LF on received data?

3.

Test the communication from a PC following 1. usning a Hyperterminal like app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM