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 );
...,
...,
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.
From: http://motion.chinaitlab.com/WINCE/30567.html