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.
resource url | functional block/dpa | GET | POST |
---|---|---|---|
/p/o_1_1 | urn:knx:dpa.421.61 | Yes | Yes |
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.
# 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
Please make sure that you have a working Visual Studio build system before proceeding with the following steps.
-
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
. -
Open (in the build folder) the
example-application.sln
with Visual Studio. -
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.
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.