Skip to content

An example of how to develop an application on top of the open-source KNX-IoT stack

Notifications You must be signed in to change notification settings

KNX-IOT/Example-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Windows sync

Example KNX Application

Introduction

This repository contains a barebones example of what you need to do in order to build an application on top of the open-source KNX IoT Point API stack.

Note that the example-application is not designed to be a fully functional KNX IoT Point API device.

Application info

resource url functional block/dpa GET POST
/p/o_1_1 urn:knx:dpa.421.61 Yes Yes

Prerequisites

In order to build this example project, you will need the following to be installed on your system:

  • C compiler (GCC on Linux, Visual Studio on Windows)
  • CMake
  • A generator that CMake can use - make on Linux, Visual Studio on Windows.

Build instructions

Linux

# Download this repository
# from github :
git clone https://github.com/KNX-IOT/Example-Application.git
# from gitlab :
# git clone https://gitlab.knx.org/shared-projects/knx-iot-point-api-example-application.git
# Change directory to the newly created dir
cd Example-Application
# Create build directory & go there
mkdir build
cd build/
# Generate CMake build system. "../" is the path to the previous
# directory, which contains the CMakeLists.txt script.
cmake ../
# Build & run the example application
make example_sensor
./example_sensor

Windows

Please make sure that you have a working Visual Studio build system before proceeding with the following steps.

  1. In Powershell, type the following commands:

    # Download this repository
    # from github :
    git clone https://github.com/KNX-IOT/Example-Application.git
    # from gitlab :
    # git clone https://gitlab.knx.org/shared-projects/knx-iot-point-api-example-application.git
    # Change directory to the newly created dir
    cd Example-Application
    # Create build directory & go there
    mkdir build
    cd build/
    # Generate CMake build system. "../" is the path to the previous
    # directory, which contains the CMakeLists.txt script.
    cmake ../

    Note: This will generate several solution files in the build folder .sln.

  2. Open (in the build folder) the example-application.sln with Visual Studio.

  3. Build the targets as usual, by selecting Build -> Build Solution within the Visual Studio menu bar.

Note: more info at the KNX-IoT guide on building for Windows.

Extending the example application

The CMake build system is made aware of the example application thanks to the call to add_executable inside CMakeLists.txt. If you want to add further executables, you must add new calls to add_executable and point them to a different .c file.

The call to target_link_libraries is what brings in the KNX-IoT stack in. It instructs the build system to link against a static library containing all KNX IoT Point API functionality, and also lets you #include KNX headers within the executable that links to this library.