Visual Studio Code

This section helps you set up the environment and build an application using Visual Studio Code.

Prerequisites

  1. Visual Studio Code
  2. CMake Tools, or tools from Command-line Prerequisites or Docker Prerequisites

Setup

  1. Clone the Generic Node Sensor Edition GitHub project as mentioned before and checkout the develop branch:
git checkout develop
  1. Select the Open Folder button in Visual Studio Code and navigate to the location of the cloned Generic Node Sensor Edition project.
vscode open folder

Build examples

Visual Studio Code provides multiple methods to build an application. This section contains some commonly used ones.

Using CMake and VSCode CMake tools

After installing CMake Tools, you can add the following CMake configuration to the settings.json file, that is located in the .vscode folder, in order to build the basic application.

{
    "cmake.generator":"Ninja",
    "cmake.configureSettings": {
        "TARGET_APP":"basic",
        "CMAKE_BUILD_TYPE":"Debug",
        "CMAKE_TOOLCHAIN_FILE":"${workspaceFolder}/Software/cross.cmake"
    },
    "cmake.sourceDirectory": "${workspaceFolder}/Software",
    "cmake.buildDirectory":"${workspaceFolder}/Software/build",
}
vscode CMake settings

You can adjust CMake settings according to your environment.

For example, on Windows, you can adjust the generator to MinGW Makefiles instead of Ninja:

"cmake.generator":"MinGW Makefiles",

You can also adjust the TARGET_APP to basic_lorawan or any other application:

"TARGET_APP":"basic_lorawan",

After adjusting your CMake configuration, make sure TOOLCHAIN_PREFIX is configured in the generic-node-se/Software/cross.cmake. See Command-line section for examples.

Finally, you can invoke Cmake: Configure from VSCode Command Palette, followed by Cmake: Build.

vscode CMake build

Using CMake and VSCode Terminal

The Command-line build commands can be used with the Visual Studio Code Integrated Terminal.

vscode terminal

Using Docker

The Docker build commands can be used with Visual Studio Code Docker container plugins.