/simplest_ble

Use SimpleBLE on Windows ASAP

Primary LanguageC++

How to use SimpleBLE on windows

Following these steps, you will be able to build a C++ app on Windows that runs the notify example from the SimpleBLE repo.

Options

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.

Target Audience šŸ«µ

  • You have installed Visual Studio before
  • You enjoy VSCode extensions
  • You want to use SimpleBLE right now

Setup PC

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.

CMake

  1. Open powershell and run winget install -e --id Kitware.CMake and follow the prompts

Visual Studio

  1. Download the Visual Studio 2022 Installer
  2. Once in the "Workloads" section of the installer, select "Desktop development with C++" and install the defaults
  3. TODO determine if necessary to add C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\ to Environment Variables PATH

Visual Studio Code

While it is possible to do this in Visual Studio 2022, it is much simpler in VSCode.

  1. Download the Visual Studio Code Installer
  2. Once installed, install the suggested C/C++ extensions (3 total) and CMake extensions (2 total)
  3. TODO determine if necessary to -> Ctrl+Shift+P -> CMake: Configure in VSCode

Create Project

  1. Create a project directory and open it in VSCode
  2. Copy the following files from this repo to the root of the project directory:
    • CMakeLists.txt - choose the .txt from this repo for the option (vcpkg or git) that you chose and remove the suffix (Modified from this)
    • main.cpp (Modified from this)
  3. Create the following directories at the root of the project directory:
    • common
    • lib (Only for git option)
  4. Into common, copy the 2 files from this repo's common directory (Which were copied from here)

šŸŸ¢ vcpkg option: Install SimpleBLE

  1. Open a shell in your vcpkg directory (Where you cloned it)
  2. ./vcpkg install simpleble

šŸ”µ git option: Clone 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.

  1. Open a shell at the project root in VSCode (Ctrl+J) and cd lib
  2. git clone https://github.com/OpenBluetoothToolbox/SimpleBLE.git

Build and Run

  1. Open a shell at the project root
  2. mkdir build
  3. cd build
  4. cmake ..
  5. msbuild .\test_app.vcxproj /property:Configuration=Release
  6. .\Release\test_app.exe
  7. 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