Implement Bluetooth serial port driver in Windows CE

Source: Internet
Author: User

Windows CEImplementation of the Bluetooth serial port driver


[Date: 2006-10-19]

Source: Internet Author: Anonymous

[Font: large, medium, and small]

Windows CE, as a typical embedded operating system, is typical for other embedded systems such as pSOS + and Nucleus us by porting Bluetooth applications to Widows CE. Because the file transmission application on OBEX is built on the Bluetooth simulation serial port of RFCOMM implementation, this article introduces the implementation of the Bluetooth virtual serial port driver of OBEX file transmission.
  
  1 Windows CE Device Driver Overview
  
Windows CE supports a wide range of device drivers based on various CE platforms. Currently, it provides four device models, two of which are dedicated to Windows CE and the other two are from other operating systems. Two Models Based on Windows CE are the local device driver and stream interface driver. Two external models are used for drivers of the Universal Serial Bus (USB) and network drive interface standard (NDIS.
  
Because the Bluetooth protocol is a simulated serial port in wireless technology, many applications of OBEX in Bluetooth are based on the simulated serial port. The stream interface driver uses a set of Stream interface functions to allow applications to interface devices through special files in the file system, therefore, the functionality of the Bluetooth simulation serial port is more suitable for the structure of the stream interface driver.
   
  
  2 Implementation of Bluetooth serial port driver in Windows CE
  
Although the implementation of the driver program of the bluetooth device adopts the stream interface driver program design, because the basic structure and principle of the two drivers are similar, the following describes the structure of the driver program of the local device, you can better understand the implementation principle of the driver of the bluetooth device.
  
  2.1 local device driver structure
  
The sample device drivers in Windows CE are divided into two types: Monolithic device driver and Layered Devicedriver ). The single-chip driver is based on a single chip. The chip directly transmits the functionality of the hardware device to the operating system through the device driver interface. Compared with a single-chip driver, a layered driver consists of two set layers: the upper layer is the model Device Driver (MDD), and the lower layer is the platform Driver (PDD ). This article uses a layered driver to connect the Bluetooth hardware to the file transfer application above. Figure 1 illustrates how the two drivers are integrated in the Windows CE operating system.
  
The Device Driver Interface (DDI) is a function set implemented in MDD. The GWES module calls the device driver through this interface. The device driver server provides the interface (DDSI) is a function set implemented in PDD and called by MDD. Because Microsoft provides all Source Code related to the MDD module, you do not need to make any changes to this part. You only need to build a public library between your PDD module and the MDD failover chain.
  
After understanding the structure of the driver of the local device, it is not difficult to see from the right side of Figure 1 that the stream interface driver only uses the stream interface as their DDI. In this case, there is no need to connect these drivers to the GWES module plugin. They exist in normal DLL mode and are called as needed.
  
  2.2 Bluetooth simulation serial port driver implementation
  
The Bluetooth simulation serial port uses the Bluetooth RFCOMM Protocol to implement wireless serial communication without cables. Like the driver of the local device, the serial port driver that implements the stream interface only needs to implement the Bluetooth PDD module.
  
The PDD module consists of four parts: The first part is all the DDSI interfaces that must be implemented by themselves; the second part is the Bluetooth protocol stack including FRCOMM, SDP, L2CAP and HCI entities; the third part is that the HCI transmission layer connects to the Bluetooth hardware through UART or USB interfaces. The last part is the graphic interface and control port module provided for the Bluetooth Application, it is used to initialize the entire protocol stack, initialize the Bluetooth hardware, search for nearby bluetooth devices, and discover services on specified devices. 2.
  
In the system structure of the serial port driver simulated by bluetooth shown in figure 2, the device management program is a user-Layer Program and runs continuously on a Windows CE-based platform. The Device Manager is not a part of the kernel, but is a separate part that affects the kernel, registry, and note interface driver DLL. It mainly performs the following tasks:
  
HWOBJ export thobj = {/* description of the characteristics of the Bluetooth simulation serial port */
  
(PDEVICE_LIST) & SerDL,
  
THREAD_IN_PDD,/* All interrupt processing is handled by the PDD Layer */
  
0,
  
NULL,
  
(PHW_VTBL) & BluetoothVTbl/* List of all the standard serial DDSI functions to be implemented */
  
};
  
HWOBJ descrithctrlobj = {/* describe the characteristics of the Bluetooth control port */
  
(PDEVICE_LIST) & SerDL,
  
THREAD_IN_PDD,
  
0,
  
NULL,
  
(PHW_VTBL) & CTRLVTb1
  
};
  
PHWOBJ rgpHWObjects [] = {/* array containing two PDD instances */
  
& BluetoothObj,
  
& Define thctrlobj
  
};
  
DEVICE_LIST SerDL = {/* All serial devices in the device driver */
  
"CESerial. dll",/* Name of the serial port driver */
  
Sizeof (rgpHWObjects)/sizeof (PHWOBJ),/* Number of Serial Port Devices */
  
RegHWObjects
  
};
  
PDEVICE_LIST GetSerialObject (VOID)
  
{
  
Return (& SerDL );
  
}
  
  
After registering two serial ports in the serial port driver, you need to implement the flow interface function corresponding to the two PDD instances. Microsoft provides an HWOBJ (Haredware Object) type serial Object table for the serial PDD module to be implemented. This structure lists all interface function pointers that implement serial drive. See the following description:
  
Typedef struct _ HW_VTBL {
  
PVOID (* HWInit) (ULONG Identifier, PVOID pMDDCon-text, PHWOBJ pHWObj );
  
...,
  
...,
  
BOOL (* HWIoct1) (PVOID pHead, DWORD dwCode,
  
PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD
  
DwLenOut, PDWORDpdwActualOut );
  
} HW_VTBL, * PHW_VTBL;
  
You can change the function set or function name by modifying the serial object table of the serial port PDD. The following structure defines the name of the DDSI function of the Bluetooth simulation serial port.
  
Const HW_VTBL rjthvtbl = {
  
BluetoothInitSerial,
  
...,
  
...,
  
BluetoothIoctl
  
};
  
Similarly, the structure variable CTRLVTbl is used to define the DDSI function name list of the control port. As this serial port device is used for internal implementation of special functions, only the main function names that need to be concerned are listed below.
  
Const HW_VTBL CTRLVTbl = {
  
CTRLInitSerial,
  
CTRLDeinit,
  
CTRLOpen,
  
CTRLClose,
  
...,
  
...,
  
CTRLIoctl
  
};
  
Bluetooth, as an engine driving the new economy, will play a huge role in promoting the arrival of the "post-PC" era dominated by embedded systems, it will also face challenges from wireless communication technologies such as IrDA, 802.11, and HomeRF. The successful introduction of OBEX to Bluetooth makes it possible to transfer files, synchronization, printing, and other applications to Bluetooth communication devices working in the embedded system. Therefore, it plays an important role in Bluetooth.

 

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.