134fd36daSMatthias Ringwald# BTstack Port for Windows Systems using the WinUSB Driver 2a1a1af71SMatthias Ringwald 3c7558746SMatthias RingwaldThe Windows-WinUSB port uses the native run loop and WinUSB API to access a USB Bluetooth dongle. 4a1a1af71SMatthias Ringwald 598918ebdSMatthias RingwaldThe port provides both a regular Makefile as well as a CMake build file. It uses native Win32 APIs for file access and does not require the Cygwin or mingw64 build/runtine. All examples can also be build with Visual Studio 2022 (e.g. Community Edition). 698918ebdSMatthias Ringwald 73cda7aedSMatthias Ringwald## Access to Bluetooth USB Dongle with Zadig 83cda7aedSMatthias Ringwald 9a1a1af71SMatthias RingwaldTo allow libusb or WinUSB to access an USB Bluetooth dongle, you need to install a special device driver to make it accessible to user space processes. 10a1a1af71SMatthias Ringwald 11a1a1af71SMatthias RingwaldIt works like this: 123cda7aedSMatthias Ringwald 13c7558746SMatthias Ringwald- Download [Zadig](http://zadig.akeo.ie) 14c7558746SMatthias Ringwald- Start Zadig 15a1a1af71SMatthias Ringwald- Select Options -> “List all devices” 16a1a1af71SMatthias Ringwald- Select USB Bluetooth dongle in the big pull down list 17a1a1af71SMatthias Ringwald- Select WinUSB (libusb) in the right pull pull down list 18a1a1af71SMatthias Ringwald- Select “Replace Driver” 19a1a1af71SMatthias Ringwald 2098918ebdSMatthias Ringwald## Visual Studio 2022 213cda7aedSMatthias Ringwald 2298918ebdSMatthias RingwaldVisual Studio can directly open the provided `port/windows-windows-h4-zephyr/CMakeLists.txt` and allows to compile and run all examples. 233cda7aedSMatthias Ringwald 2498918ebdSMatthias Ringwald## mingw64 2598918ebdSMatthias Ringwald 2698918ebdSMatthias RingwaldIt can also be compiles with a regular Unix-style toolchain like [mingw-w64](https://www.mingw-w64.org). 2798918ebdSMatthias Ringwaldmingw64-w64 is based on [MinGW](https://en.wikipedia.org/wiki/MinGW), which '...provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs.' 283cda7aedSMatthias Ringwald 29b5674ee2SMatthias RingwaldIn the MSYS2 shell, you can install everything with pacman: 303cda7aedSMatthias Ringwald 313cda7aedSMatthias Ringwald $ pacman -S git 32*9085f7a5SMatthias Ringwald $ pacman -S cmake 33b5674ee2SMatthias Ringwald $ pacman -S make 34b5674ee2SMatthias Ringwald $ pacman -S mingw-w64-x86_64-toolchain 35*9085f7a5SMatthias Ringwald $ pacman -S mingw-w64-x86_64-portaudio 363cda7aedSMatthias Ringwald $ pacman -S python 375b53c16eSMatthias Ringwald $ pacman -S winpty 383cda7aedSMatthias Ringwald 39*9085f7a5SMatthias Ringwald### Compilation with CMake 403cda7aedSMatthias Ringwald 41*9085f7a5SMatthias RingwaldWith mingw64-w64 installed, just go to the port/windows-h4 directory and use CMake as usual 423cda7aedSMatthias Ringwald 43*9085f7a5SMatthias Ringwald $ cd port/windows-h4 44*9085f7a5SMatthias Ringwald $ mkdir build 45*9085f7a5SMatthias Ringwald $ cd build 46*9085f7a5SMatthias Ringwald $ cmake .. 473cda7aedSMatthias Ringwald $ make 483cda7aedSMatthias Ringwald 490af1bfd9SMatthias RingwaldNote: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails 500af1bfd9SMatthias Ringwaldas `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now. 510af1bfd9SMatthias Ringwald 523cda7aedSMatthias Ringwald## Console Output 533cda7aedSMatthias Ringwald 54a1a1af71SMatthias RingwaldWhen running the examples in the MSYS2 shell, the console input (via btstack_stdin_support) doesn't work. It works in the older MSYS and also the regular CMD.exe environment. Another option is to install WinPTY and then start the example via WinPTY like this: 55a1a1af71SMatthias Ringwald 563cda7aedSMatthias Ringwald $ winpty ./spp_and_le_counter.exe 57a1a1af71SMatthias Ringwald 58