views:

364

answers:

2

My client needs a Pocket PC application to remotely configure an industrial sensor via Bluetooth. The sensor is equipped with a small Bluetooth SPP module. The application should run on Pocket PCs running Windows Mobile. As I'm familiar with .NET application development on the desktop but not on mobile devices, I'd ask for a bit of advice on how to get started with this.

I've had a look at the book "Microsoft Mobile Development Handbook", which says that device manufacturers can use the Bluetooth Stack of their choice (sounds bad). The 32feet library is also mentioned. But it's still unclear to me whether there is a way to write a device-independent application that uses the Bluetooth Serial Port Profile (SPP). Any thoughts?

+1  A: 

The difference between Microsoft and Widcomm BT stacks (AFAIK there is no other on WinMobile) is mainly in device discovery and pairing APIs. See these two articles. If your client uses a single kind of PPCs just use the installed stack. If you have to do that from any WinMobile device you will have to detect which is installed and support both.

Once the PPC is paired with the other device, call ::CreateFile() with the '::COMn' file name of the connection, ::WriteFile() your commands and ReadFile() the answers.

Note that a BT connection can be lost at any moment so you should handle that.

cheers, AR

Alain Rist
Thanks for the useful tips. I will be using the BT connection as a RS232 replacement, and the fact that the connection can be lost anytime is indeed something I have to think about.
geschema
If there is any industrial security issue implied, I would not recommend switching from wired to BT. cheers :)
Alain Rist
Alain - you're right, there's always a security risk when switching from wired to wireless. But I understand that BT offers some mechanisms like "non-discoverable mode", encryption and authentication which should be enough to protect the system from unintentional intrusions.
geschema
My concern is on reliability. A physical wire can be regularly inspected and tested, the wireless connector is built on demand so there is no way to ensure it will be OK next time.
Alain Rist
That's a valid concern. In my case, the BT interface is only for service (i.e. configuring/checking the sensor every once in a while). It's used as a convenient replacement for a cable connection to devices that are physically difficult to access.
geschema
+1  A: 

I'm the maintainer of the 32feet.NET library and added its Widcomm support.

The library provides simple access to a RFCOMM/SPP service on a remote machine with a sockets/stream API, regardless of whether it's the MSFT or Widcomm stack on the local device. See the "General Bluetooth connections" section at http://www.alanjmcf.me.uk/comms/bluetooth/32feet.NET%20--%20User%20Guide.html

alanjmcf
Thanks a lot, I'll give your library a try. Sounds like it might save me a lot of time :-)
geschema