Bluetooth PC software design Bluetooth headphones
Bluetooth PC software design Bluetooth headphones
The PC side adopts object-oriented C++ programming, and realizes the basic data transmission control program based on Bluetooth HCI layer communication under the VC++60 development platform. The operating system on the PC side is XP, and the Bluetooth device used is a Bluetooth USB adapter. The Bluetooth USB adapter and the PC are connected and communicated through a USB interface, so the data transmission uses the Bluetooth HCIUSB transport layer. USB is a serial interface standard published and promoted by the "Universal Serial Bus Implementation Forum" organization. Instead of developing a new protocol for the USB interface, Bluetooth uses the existing USB protocol. In terms of drivers, on the one hand, the xP system itself will provide the underlying hardware drivers and simple upper-layer applications. After the Bluetooth USB adapter is connected to the PC, it will be automatically loaded. On the other hand, different Bluetooth chip manufacturers will provide different Hardware drivers for Bluetooth USB adapters to facilitate application-specific development by technicians. Since the XP system comes with The driver is directly application-oriented and shields the HCL layer, so the Bluetooth USB driver csrbc01inf provided by CSR is used here, and a series of control words are attached to this driver. After installing the Bluetooth USB adapter, in the VC++6.0 programming platform, using the Windows API function, combined with a series of control words provided by the driver, can realize the access to the Bluetooth USB adapter. <a style="opacity:0.0;color:#ffffff">Bluetooth headphones</a>
The steps and processes of developing Bluetooth communication on the PC side based on the HCIUSB transport layer are similar to the above-mentioned development of the microcontroller based on the Bluetooth HCIUART layer. They all follow the general communication process of the Bluetooth HCI layer, and the difference lies in the use of the HCI transport layer. When using the HCI USB transport layer to transmit, data is sent and received through USB endpoints. USB endpoints are divided into four categories, namely control endpoints, block endpoints, interrupt endpoints and synchronization endpoints. Different endpoints implement different functions. The control endpoint is used to configure and control the USB device, where it can be used by the host (PC) to control the host
The device (Bluetooth USB adapter) sends HCI command packets. Block endpoints are used to transmit ACL data packets. The interrupt endpoint is used to ensure the timely reception of HCI event packets. The isochronous endpoint is used to transmit SCO data packets. It can be seen that when using the USB transport layer, different HC1 packets can be distinguished by different endpoint types, so there is no need to add a packet indicator in front of the packet like the HCIUART transport layer. <a style="opacity:0.0;color:#ffffff">Bluetooth headphones</a>
The realization of the program adopts dialog-based MFC programming. A USBStack class is constructed in the program to control the Bluetooth USB adapter, including opening the device, sending HCI command packets, sending and receiving ACL data packets, and receiving HCI event packets. In the whole life cycle of the program, define a global variable mbt of USBStack to identify the current Bluetooth device. <a style="opacity:0.0;color:#ffffff">Bluetooth headphones</a> <a style="opacity:0.0;color:#ffffff">Bluetooth headphones</a> <a style="opacity:0.0;color:#ffffff">Bluetooth headphones</a>