Skip to content

Commit

Permalink
update example from latest codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
tiniuclx committed Feb 12, 2024
1 parent fdac857 commit e3289f7
Show file tree
Hide file tree
Showing 24 changed files with 1,056 additions and 406 deletions.
43 changes: 27 additions & 16 deletions EXAMPLE/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ set(KNX_IOT_STACK_REF master CACHE STRING "The branch of the KNX IoT Stack to us
set(USE_GITLAB OFF CACHE BOOL "use gitlab as source for KNX IoT Stack")

if(CASCODA_USE_PRIVATE_SDK)
set(CASCODA_REPO cascoda-sdk-priv)
set(CASCODA_SDK_REPO https://github.com/Cascoda/cascoda-sdk-priv.git CACHE STRING "")
else()
set(CASCODA_REPO cascoda-sdk)
set(CASCODA_SDK_REPO https://github.com/Cascoda/cascoda-sdk.git CACHE STRING "")
endif()
set(CASCODA_SDK_REPO https://github.com/Cascoda/${CASCODA_REPO}.git)

set(CASCODA_REPO cascoda-sdk)

if(USE_GITLAB)
set(KNX_REPO knx-iot-stack-gitlab)
set(KNX_IOT_STACK_REPO https://gitlab.knx.org/shared-projects/knx-iot-point-api-public-stack/)
set(KNX_IOT_STACK_REPO https://gitlab.knx.org/shared-projects/knx-iot-point-api-public-stack/ CACHE STRING "")
else()
set(KNX_REPO knx-iot-stack)
set(KNX_IOT_STACK_REPO https://github.com/KNX-IOT/KNX-IOT-STACK.git)
set(KNX_IOT_STACK_REPO https://github.com/KNX-IOT/KNX-IOT-STACK.git CACHE STRING "")
endif()

# KNX IoT Stack
Expand Down Expand Up @@ -86,7 +87,8 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
FetchContent_MakeAvailable(${KNX_REPO})

add_executable(knx_iot_example
${PROJECT_SOURCE_DIR}/knx_iot_example.c )
${PROJECT_SOURCE_DIR}/knx_iot_example.c
${PROJECT_SOURCE_DIR}/knx_iot_example_virtual.c)
target_link_libraries(knx_iot_example kisClientServer)

if(WIN32)
Expand All @@ -101,7 +103,8 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
add_executable(knx_iot_example_gui WIN32
${PROJECT_SOURCE_DIR}/knx_iot_example_gui.cpp
# ${PROJECT_SOURCE_DIR}/knx_iot_example_logic.c
${PROJECT_SOURCE_DIR}/knx_iot_example.c)
${PROJECT_SOURCE_DIR}/knx_iot_example.c
${PROJECT_SOURCE_DIR}/knx_iot_example_virtual.c)
target_link_libraries(knx_iot_example_gui wx::net wx::core wx::base kisClientServer)
# enable flag to compile the console in, so that the printf of the stack are shown.
target_compile_definitions(knx_iot_example_gui PUBLIC KNX_GUI)
Expand All @@ -113,9 +116,11 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
endif()




else()
set(CASCODA_CHILI2_CONFIG_STRING "DEV_BOARD" CACHE STRING "KNX only supported on Devboard" FORCE)
set(CASCODA_CHILI2_REV "1" CACHE STRING "KNX only supported for Chili2 Rev 1" FORCE)
set(CASCODA_CHILI2_CONFIG_STRING "DEV_BOARD" CACHE STRING "KNX only supported on Devboard")
set(CASCODA_CHILI2_REV "1" CACHE STRING "KNX only supported for Chili2 Rev 1")
set(CASCODA_OTA_UPGRADE_ENABLED 0 CACHE BOOL "Enables OTA upgrade")
set(USE_DEMO_MODE OFF CACHE BOOL "demo mode (no reset)")
option(CASCODA_BUILD_KNX "Enable the KNX-IoT Port" ON)
Expand All @@ -132,8 +137,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_iot_example_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_wakeful_main.c
# ${PROJECT_SOURCE_DIR}/KNX_EXAMPLE.c
#
)
target_link_libraries(knx_iot_example_ed
kisClientServer
Expand All @@ -152,8 +155,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_iot_example_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_wakeful_main.c
# ${PROJECT_SOURCE_DIR}/KNX_EXAMPLE.c
#
)
target_link_libraries(knx_iot_example_reed
kisClientServer
Expand All @@ -172,8 +173,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_iot_example_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_sleepy_main.c
# ${PROJECT_SOURCE_DIR}/KNX_EXAMPLE.c
#
)
target_link_libraries(knx_iot_example_sleepy
kisClientServer
Expand All @@ -184,6 +183,9 @@ else()
cascoda-bm-devboard
)

# include device cmake files, after all the targets have been created so that they may be altered within


if(USE_DEMO_MODE)
target_compile_definitions(knx_iot_example_ed PUBLIC DEMO_MODE)
target_compile_definitions(knx_iot_example_reed PUBLIC DEMO_MODE)
Expand All @@ -199,7 +201,7 @@ else()
set(STACK_SIZE_KB "5" CACHE STRING "Number of KB to alloc stack")
endif()
if(NOT DEFINED HEAP_SIZE_BASE_KB)
set(HEAP_SIZE_BASE_KB "40" CACHE STRING "Number of KB to alloc heap")
set(HEAP_SIZE_BASE_KB "20" CACHE STRING "Number of KB to alloc heap")
endif()
math(EXPR STACK_SIZE "1024 * ${STACK_SIZE_KB}")
math(EXPR HEAP_SIZE_ED "1024 * (${HEAP_SIZE_BASE_KB})")
Expand Down Expand Up @@ -239,12 +241,21 @@ else()


if (NOT TARGET copy-ldrom)
if (CASCODA_BM_INTERFACE STREQUAL "USB")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_hid)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin
)
elseif (CASCODA_BM_INTERFACE STREQUAL "UART")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_uart)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart.bin ${PROJECT_BINARY_DIR}/bin
)
endif()
endif()

if (CASCODA_OTA_UPGRADE_ENABLED EQUAL 1)
Expand Down
21 changes: 13 additions & 8 deletions EXAMPLE/TopLevelCMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ project(knx_iot_demos)

option(CASCODA_USE_PRIVATE_SDK "" OFF)

if(CASCODA_USE_PRIVATE_SDK)
set(CASCODA_REPO cascoda-sdk-priv)
else()
set(CASCODA_REPO cascoda-sdk)
endif()
set(CASCODA_REPO cascoda-sdk)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
if (CASCODA_BM_INTERFACE STREQUAL "USB")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_hid)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin/ldrom_hid
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin/ldrom_hid.bin
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin
)
elseif (CASCODA_BM_INTERFACE STREQUAL "UART")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_uart)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart.bin ${PROJECT_BINARY_DIR}/bin
)
endif()

if (CASCODA_OTA_UPGRADE_ENABLED EQUAL 1)
add_custom_target(copy-ota-bootloader ALL DEPENDS ota-bootloader)
Expand Down
Empty file modified EXAMPLE/arm_gcc_m2351.cmake
100755 → 100644
Empty file.
7 changes: 5 additions & 2 deletions EXAMPLE/build.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

mkdir -p build
cd build
cmake .. -DOC_DNS_SD_ENABLED=OFF -DOC_OSCORE_ENABLED=ON -DUSE_CONSOLE=ON
cmake .. -DOC_DNS_SD_ENABLED=ON -DOC_OSCORE_ENABLED=ON -DUSE_CONSOLE=ON
# build step
cmake --build .
# default is all targets
#cmake --build .
cmake --build . --target knx_iot_example
cmake --build . --target knx_iot_example_gui
5 changes: 5 additions & 0 deletions EXAMPLE/build_info.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ CLI:

- knx_iot_example Application (CLI) using the following files:
- knx_iot_example.c
- knx_iot_example_virtual.c
- knx_iot_example.h

Windows GUI using WxWidgets:

- knx_iot_example_gui Application (wxWidgets) using the following files:
- knx_iot_example.c
- knx_iot_example_virtual.c
- knx_iot_example.h
- knx_iot_example.cpp

Expand Down Expand Up @@ -90,6 +92,7 @@ handling the GUI (wxWidgets) and embedded (chili) to connect to the hardware.
|------| --------------------| -------- | -------------| ---------------|-----------|
| "/p/o_1_1" | LED_1 | 1 |urn:knx:dpa.417.61 | if.a | |
| "/p/o_2_2" | PB_1 | 1 |urn:knx:dpa.421.61 | if.s | |
| "/p/o_3_3" | InfoOnOff_1 | 1 |urn:knx:dpa.417.51 | if.s | |

### Parameters

Expand All @@ -112,12 +115,14 @@ Next to the mandatory metadata fields the following datapoint specific metadata
|------| ----------------| ---------| --------- |
| "/p/o_1_1" | LED_1 | desc |On/Off switch 1 |
| "/p/o_2_2" | PB_1 | desc |On/Off push button 1 |
| "/p/o_3_3" | InfoOnOff_1 | desc |Feedback 1 |

For querying the metadata items implemented one can use the following commands:

```
GET /p/o_1_1?m=*
GET /p/o_2_2?m=*
GET /p/o_3_3?m=*
```
## Development Board Jumper settings
|Jumper | Setting | Usage |
Expand Down
Empty file modified EXAMPLE/build_unsecured.sh
100755 → 100644
Empty file.
Empty file modified EXAMPLE/build_win_bin_mingw.sh
100755 → 100644
Empty file.
Empty file modified EXAMPLE/build_win_bin_ninja.sh
100755 → 100644
Empty file.
Empty file modified EXAMPLE/build_win_bin_ninja_unsecured.sh
100755 → 100644
Empty file.
Empty file modified EXAMPLE/configure-build.ps1
100755 → 100644
Empty file.
Empty file modified EXAMPLE/install-toolchain.ps1
100755 → 100644
Empty file.
Loading

0 comments on commit e3289f7

Please sign in to comment.