1c7558746SMatthias Ringwald# BTstack Port for Windows Systems with Bluetooth Controller connected via Serial Port 2c7558746SMatthias Ringwald 3c7558746SMatthias RingwaldThe Windows-H4 port uses the native run loop and allows to use Bluetooth Controllers connected via Serial Port. 4c7558746SMatthias Ringwald 5c7558746SMatthias RingwaldMake sure to manually reset the Bluetooth Controller before starting any of the examples. 6c7558746SMatthias Ringwald 798918ebdSMatthias 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). 83cda7aedSMatthias Ringwald 998918ebdSMatthias Ringwald## Visual Studio 2022 103cda7aedSMatthias Ringwald 1198918ebdSMatthias RingwaldVisual Studio can directly open the provided `port/windows-windows-h4/CMakeLists.txt` and allows to compile and run all examples. 1298918ebdSMatthias Ringwald 1398918ebdSMatthias Ringwald## mingw64 1498918ebdSMatthias Ringwald 1598918ebdSMatthias RingwaldIt can also be compiles with a regular Unix-style toolchain like [mingw-w64](https://www.mingw-w64.org). 1698918ebdSMatthias 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.' 1798918ebdSMatthias Ringwald 1898918ebdSMatthias RingwaldWe've used the Msys2 package available from the [downloads page](https://www.mingw-w64.org/downloads/) on Windows 10, 64-bit and use the MSYS2 MinGW 64-bit start menu item to compile 64-bit binaries. 193cda7aedSMatthias Ringwald 20b5674ee2SMatthias RingwaldIn the MSYS2 shell, you can install everything with pacman: 213cda7aedSMatthias Ringwald 223cda7aedSMatthias Ringwald $ pacman -S git 23*9085f7a5SMatthias Ringwald $ pacman -S cmake 24b5674ee2SMatthias Ringwald $ pacman -S make 25b5674ee2SMatthias Ringwald $ pacman -S mingw-w64-x86_64-toolchain 26*9085f7a5SMatthias Ringwald $ pacman -S mingw-w64-x86_64-portaudio 273cda7aedSMatthias Ringwald $ pacman -S python 285b53c16eSMatthias Ringwald $ pacman -S winpty 293cda7aedSMatthias Ringwald 30*9085f7a5SMatthias Ringwald### Compilation with CMake 313cda7aedSMatthias Ringwald 32*9085f7a5SMatthias RingwaldWith mingw64-w64 installed, just go to the port/windows-h4 directory and use CMake as usual 333cda7aedSMatthias Ringwald 3498918ebdSMatthias Ringwald $ cd port/windows-h4 35*9085f7a5SMatthias Ringwald $ mkdir build 36*9085f7a5SMatthias Ringwald $ cd build 37*9085f7a5SMatthias Ringwald $ cmake .. 383cda7aedSMatthias Ringwald $ make 393cda7aedSMatthias Ringwald 400af1bfd9SMatthias RingwaldNote: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails 410af1bfd9SMatthias Ringwaldas `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now. 420af1bfd9SMatthias Ringwald 433cda7aedSMatthias Ringwald## Console Output 443cda7aedSMatthias Ringwald 45c7558746SMatthias 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: 46c7558746SMatthias Ringwald 4798918ebdSMatthias Ringwald $ winpty ./gatt_counter.exe 4898918ebdSMatthias Ringwald 4998918ebdSMatthias RingwaldThe packet log will be written to hci_dump.pklg 503cda7aedSMatthias Ringwald 51