Thursday, September 25, 2008

Publishing a Bluetooth Serial Port Profile on a Windows Mobile phone

Some Windows Mobile partners asked me lately about publishing Serial Port Profile on a Windows Mobile phone. We know that a Windows Mobile phone usually publishes DUN (Dial-up Networking) service, which is based on SPP. What if you want to publish an additional SPP so your phone and the desktop can have an additional communication channel?

In Windows Mobile AKU 6, you can find a sample program (public\common\sdk\samples\bluetooth\bthnscreate) that demonstrates how to use a profile record file (.rec) to generate C code that can be used to publish a service on a device. However, the sample does not provide a rec file for SPP.

Well, here is an example of SPP record file you can use. For details of this record file format, you should get a copy of Bluetooth Profile specification and read Part K:5 Serial Port Profile.

-------------------------------------------------------------------------------------------

1 SEQUENCE

; SPP class ID

UUID16 1101

END

4 SEQUENCE

SEQUENCE

; L2CAP protocol identifier

UUID16 100

END

SEQUENCE

; RFCOMM protocol identifier

UUID16 3

; NOTE: SPP is not guaranteed to run on RFCOMM channel A.

; This value may need to change at run time to appropriate channel.

UINT8 A

END

END

6 SEQUENCE

; language base ID information

UINT16 656E

UINT16 6A

UINT16 100

END

100 STRING SPP

-------------------------------------------------------------------------------------------

Using the bthncreate tool with this record file, you can create a C source file. Then if you follow the WSASetService() example at the bottom of the page (http://msdn2.microsoft.com/en-us/library/aa450140.aspx), you can quickly write some code to call WSASetService with the rgbSdpRecord[] array in the created C source file. Of course, before you call WSASetService, you must first initialize winsock by calling WSAStartup, and clean up by calling WSACleanup.

Here the caveat is that once the phone publishes an additional SPP, the Bluetooth stack on the desktop will automatically create an incoming port and an outgoing port once they are paired. This makes legacy applications on the desktop continue to perform virtual com port based communication.

Of course, an easier way to create a channel for communication between a Windows Mobile device and a Windows desktop is to use Bluetooth socket. Please see http://msdn2.microsoft.com/en-us/library/aa362928%28VS.85%29.aspx (desktop BT socket) and http://msdn2.microsoft.com/en-us/library/aa362928%28VS.85%29.aspx (Windows CE BT socket) for details.

6 Comments:

Anonymous Anonymous said...

you are truly a excellent webmaster. The site loading velocity is incredible.
It seems that you're doing any unique trick. In addition, The contents are masterwork. you have performed a magnificent task on this subject!

my web-site wordpress video kurs
my site: wordpress design company

6:31 AM  
Anonymous Anonymous said...

Hey there I am so grateful I found your website, I really found you by error, while I was searching on Yahoo for something else,
Regardless I am here now and would just like to say thanks for a fantastic post and a all round entertaining
blog (I also love the theme/design), I don't have time to look over it all at the minute but I have saved it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent job.

Also visit my website :: bücher zum abnehmen

12:11 AM  
Anonymous Anonymous said...

I'm now not sure the place you are getting your information, however good topic. I needs to spend some time finding out much more or understanding more. Thanks for great information I was searching for this info for my mission.

Stop by my site ... was ist die beste altersvorsorge

2:46 AM  
Anonymous Anonymous said...

Hey I know this is off topic but I was wondering if you knew of any
widgets I could add to my blog that automatically tweet my newest twitter updates.
I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

My webpage :: Aroma Oel Massage

1:58 AM  
Anonymous Anonymous said...

Wow, this piece of writing is nice, my sister is analyzing such things, therefore I am going
to let know her.

My page: wordpress blog erstellen
My web page: wordpress theme installieren

4:32 PM  
Anonymous Anonymous said...

Good way of describing, and pleasant post to get information
regarding my presentation focus, which i am going
to deliver in college.

My web-site :: paleo diät

11:53 PM  

Post a Comment

<< Home