Based on Windows Mobile 5.0 platform to realize the design of SmartPhone bluetooth application system

Bluetooth technology is a technology that solves short-distance wireless communication. Its advantage is that it can get rid of the shackles of cable connections between devices, and it can interconnect different devices with Bluetooth interfaces within a distance of 10 to 100m. Therefore, Bluetooth is Short technology has very broad applications in short-distance data transmission.

1.introduction

Bluetooth technology is a technology that solves short-distance wireless communication. Its advantage is that it can get rid of the shackles of cable connections between devices, and it can interconnect different devices with Bluetooth interfaces within a distance of 10 to 100m. Therefore, Bluetooth is Short technology has very broad applications in short-distance data transmission.

The Windows Mobile system is an embedded operating system designed by Microsoft for smart mobile terminal devices. The Windows Mobile system is mainly aimed at two major handheld device fields: Pocket PC and Smartphone. With the development of technology, Windows Mobile for Smartphone is the system of smart phones. It is more and more widely used, and the Bluetooth module is widely embedded, which provides necessary conditions for the development of Bluetooth application systems based on SmartPhone.

This article designs and implements the SmartPhone bluetooth remote control system under the Windows Mobile 5.0 platform and the .NET CF environment, and successfully realizes the remote playback and control of the slides in the PC (or notebook) by the Smartphone. Compared with the current products on the market, The system does not require the purchase of additional hardware equipment, only the use of existing equipment, has a wide range of application prospects in the SmartPhone platform.

2. Bluetooth communication protocol stack in Windows Mobile

The bottom part of the Bluetooth communication protocol stack under the Windows Mobile system includes wireless frequency hopping, Base Band and Link Manager. Base Band is responsible for frequency hopping and the transmission of Bluetooth data and information frames to ensure the physical connection of radio frequency between each Bluetooth device unit in the Piconet network. This layer uses query and paging processes to synchronize the sending frequency and clock between different devices , Baseband data packet provides two physical connection modes: synchronous directional connection SCO and asynchronous non-directional connection ACL, which can realize multiple data transmission on the same radio frequency. Link Manager Protocol is responsible for the establishment and removal of connections between Bluetooth components, as well as link security and control such as identity authentication and encryption. Its structure is shown in Figure 1.

Based on Windows Mobile 5.0 platform to realize the design of SmartPhone bluetooth application system

HCI (Host Controller InteRFace) is divided into hardware and software parts. The hardware part is used to transmit HCI commands to the hardware core layer of Bluetooth. The software part is the basic interface for accessing Bluetooth devices and can control the connection and transmission of Bluetooth. The Logical Link Control Adaptation Protocol (L2CAP) is an adaptation protocol between the high-level protocol and the low-level protocol, which provides data services and classification extraction for the high-level through the multiplexing, demultiplexing and reorganization of the protocol. The SDP protocol is used to query device information, services, and service characteristics, and establish a connection between Bluetooth devices after querying. There are two ways to choose when implementing Bluetooth communication at the application layer: One is to use an analog serial port. In Windows Mobile, it is not a real serial port but a virtual serial port. This virtual serial port is built on the RFCOMM channel, and the virtual serial port is used to simulate RS. -232 Serial emulation protocol for control and data signals, when operating a virtual serial port, it is like operating a real serial port. The second communication method uses the Winsock protocol. Winsock’s support for Bluetooth depends on the Winsock protocol stack installed in the device. Using a virtual serial port to realize communication between Bluetooth devices is more convenient and faster when the data communication volume is not large, so the first communication method adopted in this design.

3.System design and implementation

3.1 System structure

The system is divided into SmartPhone terminal and PC terminal. Firstly, the SmartPhone terminal and the PC terminal establish a Bluetooth communication connection through the virtual serial port, and then the SmartPhone terminal sends the file opening, slide show, page turning, closing, window enlargement, window reduction, and file closing instructions to the PC terminal through the keyboard or touch screen. After receiving the instruction, the PC will call the background Office Powerpoint control program to realize the corresponding operation of Powerpoint. At the same time, the PC will send back the status information of Powerpoint playback and Display it on the SmartPhone.

3.2 Data transmission between Bluetooth devices

Before the SmartPhone uses the Bluetooth module to communicate with the PC, it must first search for the Bluetooth device on the PC to obtain the device’s name, address, and services provided. In the previous system design, the device query needs to call the relevant Bluetooth API function to traverse to obtain the Bluetooth device information within the communication range, and store the result information in the WSAQUERYSET data structure defined by the system, and then register the virtual serial port to realize the device The entire process of Bluetooth serial communication is complicated and error-prone, or some systems simply use manual designation. This system adopts a new method to query the related Bluetooth device name, service and virtual serial port number by reading the system registry. In the Windows Mobile 5.0 platform, the registry HKEY_LOCAL_MACHINESOFTWAREMicrosoftBluetoothDevice stores the device name, 16-character ID number and device CLASS of the Bluetooth device, while HKEY_LOCAL_MACHINESOFTWAREMicrosoftBluetoothSerialPorts stores the virtual serial port number used by the Bluetooth connection, but does not include the system reserved The serial port ID. Under this key value, the system sets a Bluetooth serial port number for each matched device, and the new virtual serial port number of the device can be set by specifying the “New Outgoing Port” value.

Using this new mechanism does not need to use the traditional RegisterDevice() method to register the virtual serial port number and then use it, but to use it by querying or setting the registry without conflicting with other serial ports. After obtaining the information of the device and virtual serial port number through the above methods, the information is then used to realize the Bluetooth communication between the SmartPhone and the PC. The flow chart of the communication process is shown in Figure 2:

Based on Windows Mobile 5.0 platform to realize the design of SmartPhone bluetooth application system

3.3 Powerpoint control solution

The system uses convenient and flexible Microsoft Office automation methods to incorporate Office functions into custom solutions. Office is based on COM, so it must use COM programming. The COM Interop set is used in the .NET Framework to communicate with the early COM. The role of COM Interop is to add a “filler” between the .NET code and the COM object. When adding a reference to the COM server in the project, .NET uses the type information to generate runtime library callable wrapper (RCW) code. These managed codes will be compiled into a separate Interop assembly and accessed by the .NET Framework. RCW will act as an intermediary between the managed code and the COM server.

Since the OFFICE COM server can support .NET, it can provide a main Interop assembly (PIA) that is installed and registered in the global assembly cache. These assemblies are shared assemblies, and PIA is regarded as the best way to reference early COM servers in .NET projects.

The Interop assembly created from the type library uses early binding to communicate with the COM project. In order to keep the binding details in a common state, in addition to binding, another important issue is object instantiation. If the Interop assembly is used, the RCW of the Office application will control the instantiation of the object when the New operator is used. RCW implicitly calls the corresponding COM routine to create a new instance of the application for use by the code.

This system implements the Office automation process by referencing the interoperability assembly Microsoft.Office.Interop. PowerPoint, and uses .NET to write applications to control the Powerpoint application on the PC side. The PC receives the instructions from the SmartPhone through Bluetooth communication, uses the automation function of Powerpoint to realize the control functions such as opening, closing, zooming, and playback of the document, and returns the total number of Powerpoint pages obtained, the current playback page and other information to the SmartPhone Display at the end. In theory, almost all operations performed manually through the user interface can be performed through this solution. The main control codes are as follows:

Based on Windows Mobile 5.0 platform to realize the design of SmartPhone bluetooth application system

4.Concluding remarks

This article puts forward a corresponding solution for the Bluetooth remote control system, which is designed and developed. After the completion of the system, it has been tested and ran well, and it can be easily and quickly implemented to remotely control Powerpoint. According to the design framework and method given above, after the system is expanded, it can completely realize the remote control of other kinds of application software and realize the universal bluetooth remote control system.

The innovation of this article is that the system adopts a brand-new method to obtain the parameters required for Bluetooth communication, which is simpler, more convenient and less error-prone than traditional methods. And the system uses Office automation technology to achieve full control of powerpoint, the system does not need to purchase additional hardware equipment, only the use of existing equipment, has a wide range of application prospects in the SmartPhone platform.

The Links:   NL2432HC17-05B 2MBI75N-120

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *