xref: /btstack/port/windows-h4/README.md (revision 98918ebd93a53d7aa0542734869acf064936895c)
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
7*98918ebdSMatthias 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
9*98918ebdSMatthias Ringwald## Visual Studio 2022
103cda7aedSMatthias Ringwald
11*98918ebdSMatthias RingwaldVisual Studio can directly open the provided `port/windows-windows-h4/CMakeLists.txt` and allows to compile and run all examples.
12*98918ebdSMatthias Ringwald
13*98918ebdSMatthias Ringwald## mingw64
14*98918ebdSMatthias Ringwald
15*98918ebdSMatthias RingwaldIt can also be compiles with a regular Unix-style toolchain like [mingw-w64](https://www.mingw-w64.org).
16*98918ebdSMatthias 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.'
17*98918ebdSMatthias Ringwald
18*98918ebdSMatthias 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
23b5674ee2SMatthias Ringwald    $ pacman -S make
24b5674ee2SMatthias Ringwald    $ pacman -S mingw-w64-x86_64-toolchain
253cda7aedSMatthias Ringwald    $ pacman -S python
265b53c16eSMatthias Ringwald    $ pacman -S winpty
273cda7aedSMatthias Ringwald
28*98918ebdSMatthias Ringwald### Compilation
293cda7aedSMatthias Ringwald
30*98918ebdSMatthias RingwaldWith mingw64-w64 installed, just go to the port/windows-h4 directory and run make
313cda7aedSMatthias Ringwald
32*98918ebdSMatthias Ringwald    $ cd port/windows-h4
333cda7aedSMatthias Ringwald    $ make
343cda7aedSMatthias Ringwald
350af1bfd9SMatthias RingwaldNote: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails
360af1bfd9SMatthias Ringwaldas `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now.
370af1bfd9SMatthias Ringwald
383cda7aedSMatthias Ringwald## Console Output
393cda7aedSMatthias Ringwald
40c7558746SMatthias 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:
41c7558746SMatthias Ringwald
42*98918ebdSMatthias Ringwald    $ winpty ./gatt_counter.exe
43*98918ebdSMatthias Ringwald
44*98918ebdSMatthias RingwaldThe packet log will be written to hci_dump.pklg
453cda7aedSMatthias Ringwald
46