Point-to-point Bluetooth communication on Windows Mobile

Source: Internet
Author: User

The lab implements short-distance communication. Bluetooth is one of the main technologies. During the Postgraduate review, the big boss told us that the origin of Bluetooth is related to a person playing the piano, Because Bluetooth uses a frequency hopping, this is related to the beating of fingers between keys. The collision between different disciplines may have some amazing sparks.

In Windows Mobile On the platform, how can we implement Bluetooth communication? Many people have already done this, for example Winbile Forum" UseC #To develop. Net cfBluetooth Communication Module ", Codeproject " Bluetooth connection in Windows Mobile 5.0 using inthehand-C # And Bluetooth simulation in C # With serial ports And so on.

In fact Windows Mobile 6.0 professional SDK Then, the built-in Sample There is an example of Bluetooth communication, including Bluetooth device discovery , Chatting over Bluetooth And Bluetooth game . The first two are C ++ Write, the third is to use C # . Bluetooth device discovery Yes WinSock 2 API To realize the discovery of Bluetooth devices. Chatting over Bluetooth Establishes point-to-point communication between two bluetooth devices. Bluetooth game Is to use Bluetooth technology, establish a connection between the two devices, and then play the game. There are exactly two at hand Bluetooth One is Wm5 System, one is Wm6 So I decided to try it. Chatting over Bluetooth .

OpenChatting over BluetoothProject, found that this is based on the dialog boxMFCTo perform the following operations on Bluetooth:Bthutils. cpp", Including discovering devices, establishing connections, and sending data. The main functions are as follows::

Code
1 Int Discoverdevices ();
2 Int Getnumdevices (){ Return M_inumdevices ;};
3 Int Getdeviceinfo (deviceinfo * Ppeerdevicesinfo );
4 Int Getlocaldevicename (deviceinfo * Plocaldeviceinfo );
5 Int Getdeviceinfo (deviceinfo * Ppeerdeviceinfo, Int Iselecteditem );
6 Int Openserverconnection (byte * Rgbsdprecord, Int Csdprecord, Int Ichanneloffset, Void ( * Funcptr) (wchar * ));
7 Int Sendmessagetoserver (wchar * Strguid, wchar * Szmessage, Int Iselecteddeviceindex );
8

 

InProgramAfter the device is started, search for a nearby bluetooth device. After the search process is complete, display the device name and Bluetooth address in the drop-down list, then you can send and receive messages in two ways. The program running interface is shown in figure1As shown in:

Figure1:Wm5AndWm6Program running interface on

Note that if the "visible to other devices" option is not checked during Bluetooth configuration, you only need to turn the Bluetooth on, as shown in figure2As shown in:

Figure2: Bluetooth is on

The application prompts that messages cannot be sent. After "visible to other devices" is selected, the communication will be normal, as shown in figure3As shown in:

Figure3: Bluetooth is visible

Reference link:

UseC #To develop. Net cfBluetooth Communication Module

Bluetooth connection in Windows Mobile 5.0 using inthehand-C #

Bluetooth simulation in C # With serial ports

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.