开发者

bluetooth device to windows API via com port

So I have a bluetooth device, this device uses SPP to transfer data between the PC and itself. It connects fine through Windows as a bluetooth device. I can find it, enter the paring code and assign it to a COM port. Now I want to be able to send data through the com port using Windows API but it is refusing to do so.

I suspect that I need to setup the COMMCONFIG Structure correctly (see below) http://msdn.microsoft.com/en-us/library/aa363188(VS.85).aspx

Unfortunately I have no idea what is the proper setting. I know SPP is supposed to emulate the RS-232 communication... so maybe I开发者_开发技巧 have to study up on that to figure out the right setting? Or is there some automatic way to set the COMMCONFIG structure.


I seriously doubt it. If it would be used then you'll have no chance at guessing at the custom provider data without docs from the driver author. Pay attention to the handshake signals, serial port devices routinely ignore anything sent to them when the DTR signal is turned off. And not send anything back with DTR off. A driver would emulate that. Use EscapeCommFunction() to turn them on. Also try a serial comm program like HyperTerminal or Putty to test this so you can isolate the source of the problem.


Why not use the Bluetooth sockets API? No need for troublesome (virtual) COM ports then.

If you're using managed code then see my library 32feet.NET

If using native code, use SOCKADDR_BTH with Winsock connect etc, see e.g. Bluetooth and connect (Windows) Then you can use the standard Winsock send/recv API


Ok, I found that you can use the GetCommConfig and GetCommState functions to figure out the settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜