Windows Mobile Bluetooth programming with Winsock: I


Lin Zhong





Click here to download


SSA gives the code for 1) Windows Mobile to connect to a peripheral and 2) Windows Mobile to accept a connection from a peripheral. In 1), Windows Mobile is Master and Client; in 2), it is Slave and Server.


Examples with explanation

Inquiry (Discover other devices)


Connect to a Bluetooth peripheral from Windows Mobile


In projects, Windows Mobile needs to use inquiry (discovery process) to obtain the Bluetooth physical address (BT_ADDR). Since we only use RFCOMM and Serial Port profile, there is no need for service discovery. Use RFCOMM_PROTOCOL_UUID for serviceClassId. Connections can be established using the Bluetooth physical address.


Once the connection is established, Windows Mobile communicates with the peripheral use Winsock functions: send() and recv(). Create a thread for each of them.


Data interpretation

Now, you need to write program to interpret the data exchanged between Windows Mobile and the peripheral. Basically, you need to write an application-layer protocol. Refer to this paper for an example.