How to use SimpleBLE on
Following these steps, you will be able to build a C++ app on Windows that runs the notify example from the SimpleBLE repo.
Included
🟢 vcpkg (cleanest) - install vcpkg following these instructions
🔵 git - you will need a working installation of git
Not-included
🔴 SimpleBLE release package - never get it to work on Windows, so if someone knows how to, please share!
🟡 installing to Program Files - it is easy enough to install following the instructions, but was never able to get CMake to work with this method (share if you know how!)
In the current state of this repo, it is configured for the vcpkg option. So, if you can already build C++ apps with CMake on Windows and have vcpkg installed, you can clone and skip to the end. If not, these instructions will set you up for that.
- You have installed Visual Studio before
- You enjoy VSCode extensions
- You want to use SimpleBLE right now
Linux is much more forgiving than Windows when it comes to C++. For instance, if you have workplace firewall that won't allow for the full download of "Visual Studio Desktop development with C++", then these instructions won't work for you. Also, admin permissions, environment variables and library paths.
- Open powershell and run
winget install -e --id Kitware.CMake
and follow the prompts
- Download the Visual Studio 2022 Installer
- Once in the "Workloads" section of the installer, select "Desktop development with C++" and install the defaults
- TODO determine if necessary to add
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\
to Environment Variables PATH
While it is possible to do this in Visual Studio 2022, it is much simpler in VSCode.
- Download the Visual Studio Code Installer
- Once installed, install the suggested C/C++ extensions (3 total) and CMake extensions (2 total)
- TODO determine if necessary to -> Ctrl+Shift+P ->
CMake: Configure
in VSCode
- Create a project directory and open it in VSCode
- Copy the following files from this repo to the root of the project directory:
- Create the following directories at the root of the project directory:
- common
- lib (Only for git option)
- Into
common
, copy the 2 files from this repo'scommon
directory (Which were copied from here)
- Open a shell in your vcpkg directory (Where you cloned it)
./vcpkg install simpleble
Not all files/dirs are needed here, but it can be cleaned up later. You will want to delete the .git
directory inside the cloned repo, though.
- Open a shell at the project root in VSCode (Ctrl+J) and
cd lib
git clone https://github.com/OpenBluetoothToolbox/SimpleBLE.git
- Open a shell at the project root
mkdir build
cd build
cmake ..
msbuild .\test_app.vcxproj /property:Configuration=Release
.\Release\test_app.exe
- Tinker and make the app you desire!
Notes
- Build with
cmake .. -DCMAKE_TOOLCHAIN_FILE=F:/vcpkg/scripts/buildsystems/vcpkg.cmake\
to include necessary libs for a Debug build