From 4c7f14159175aabddc5a18528a03a1c5aa1ee005 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 31 Oct 2023 10:25:05 +0100 Subject: [PATCH] fix: update freertos examples with modular features --- examples/freertos_plus_tcp/CMakeLists.txt | 4 ++++ examples/freertos_plus_tcp/include/FreeRTOSConfig.h | 2 +- examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h | 2 +- examples/freertos_plus_tcp/z_get.c | 10 ++++++++-- examples/freertos_plus_tcp/z_pub.c | 8 +++++++- examples/freertos_plus_tcp/z_pub_st.c | 8 +++++++- examples/freertos_plus_tcp/z_pull.c | 8 +++++++- examples/freertos_plus_tcp/z_put.c | 8 +++++++- examples/freertos_plus_tcp/z_queryable.c | 8 +++++++- examples/freertos_plus_tcp/z_scout.c | 2 +- examples/freertos_plus_tcp/z_sub.c | 7 ++++++- examples/freertos_plus_tcp/z_sub_st.c | 7 ++++++- 12 files changed, 62 insertions(+), 12 deletions(-) diff --git a/examples/freertos_plus_tcp/CMakeLists.txt b/examples/freertos_plus_tcp/CMakeLists.txt index 8130e0a23..ba0b53501 100644 --- a/examples/freertos_plus_tcp/CMakeLists.txt +++ b/examples/freertos_plus_tcp/CMakeLists.txt @@ -64,6 +64,10 @@ target_link_libraries(zenohpico target_compile_definitions(zenohpico PUBLIC Z_FEATURE_MULTI_THREAD=1 + Z_FEATURE_PUBLICATION=1 + Z_FEATURE_SUBSCRIPTION=1 + Z_FEATURE_QUERY=1 + Z_FEATURE_QUERYABLE=1 Z_FEATURE_LINK_TCP=1 Z_FEATURE_SCOUTING_UDP=1 Z_FEATURE_LINK_UDP_UNICAST=1 diff --git a/examples/freertos_plus_tcp/include/FreeRTOSConfig.h b/examples/freertos_plus_tcp/include/FreeRTOSConfig.h index cbd027ce3..faeb5bbd5 100644 --- a/examples/freertos_plus_tcp/include/FreeRTOSConfig.h +++ b/examples/freertos_plus_tcp/include/FreeRTOSConfig.h @@ -20,7 +20,7 @@ #define configUSE_PREEMPTION 1 #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES (56) -#define configMINIMAL_STACK_SIZE ((uint16_t) PTHREAD_STACK_MIN) +#define configMINIMAL_STACK_SIZE ((uint16_t)PTHREAD_STACK_MIN) #define configMAX_TASK_NAME_LEN (16) #define configUSE_16_BIT_TICKS 0 #define configQUEUE_REGISTRY_SIZE 0 diff --git a/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h b/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h index 2070ad000..430e92b4d 100644 --- a/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h +++ b/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h @@ -48,7 +48,7 @@ // Set ipconfigBUFFER_PADDING on 64-bit platforms #if INTPTR_MAX == INT64_MAX - #define ipconfigBUFFER_PADDING 14U +#define ipconfigBUFFER_PADDING 14U #endif #endif /* FREERTOS_IP_CONFIG_H */ \ No newline at end of file diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 8a0f74b4f..3a95518c1 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -16,6 +16,7 @@ #include "FreeRTOS.h" +#if Z_FEATURE_QUERY == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -47,7 +48,7 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) { } } -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -92,4 +93,9 @@ void app_main() { zp_stop_lease_task(z_loan(s)); z_close(z_move(s)); -} \ No newline at end of file +} +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); +} +#endif \ No newline at end of file diff --git a/examples/freertos_plus_tcp/z_pub.c b/examples/freertos_plus_tcp/z_pub.c index 969202074..f53a786da 100644 --- a/examples/freertos_plus_tcp/z_pub.c +++ b/examples/freertos_plus_tcp/z_pub.c @@ -16,6 +16,7 @@ #include "FreeRTOS.h" +#if Z_FEATURE_PUBLICATION == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -30,7 +31,7 @@ #define KEYEXPR "demo/example/zenoh-pico-pub" #define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!" -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -104,3 +105,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); +} +#endif diff --git a/examples/freertos_plus_tcp/z_pub_st.c b/examples/freertos_plus_tcp/z_pub_st.c index f31516b72..03311e25c 100644 --- a/examples/freertos_plus_tcp/z_pub_st.c +++ b/examples/freertos_plus_tcp/z_pub_st.c @@ -16,6 +16,7 @@ #include "FreeRTOS.h" +#if Z_FEATURE_PUBLICATION == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -30,7 +31,7 @@ #define KEYEXPR "demo/example/zenoh-pico-pub" #define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!" -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -72,3 +73,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); +} +#endif diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index b6d5d84f8..601bfe720 100644 --- a/examples/freertos_plus_tcp/z_pull.c +++ b/examples/freertos_plus_tcp/z_pull.c @@ -14,6 +14,7 @@ #include +#if Z_FEATURE_PUBLICATION == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -35,7 +36,7 @@ void data_handler(const z_sample_t *sample, void *ctx) { z_drop(z_move(keystr)); } -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -77,3 +78,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); +} +#endif diff --git a/examples/freertos_plus_tcp/z_put.c b/examples/freertos_plus_tcp/z_put.c index f8913146d..43c6a4975 100644 --- a/examples/freertos_plus_tcp/z_put.c +++ b/examples/freertos_plus_tcp/z_put.c @@ -14,6 +14,7 @@ #include +#if Z_FEATURE_PUBLICATION == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -28,7 +29,7 @@ #define KEYEXPR "demo/example/zenoh-pico-put" #define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!" -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -74,3 +75,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); +} +#endif diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 1a9f19514..de60b9c53 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -14,6 +14,7 @@ #include +#if Z_FEATURE_QUERYABLE == 1 #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" @@ -43,7 +44,7 @@ void query_handler(const z_query_t *query, void *ctx) { z_drop(z_move(keystr)); } -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -89,3 +90,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); +} +#endif \ No newline at end of file diff --git a/examples/freertos_plus_tcp/z_scout.c b/examples/freertos_plus_tcp/z_scout.c index c73785779..0f3087eee 100644 --- a/examples/freertos_plus_tcp/z_scout.c +++ b/examples/freertos_plus_tcp/z_scout.c @@ -82,7 +82,7 @@ void drop(void *context) { } } -void app_main() { +void app_main(void) { int *context = (int *)pvPortMalloc(sizeof(int)); *context = 0; z_owned_scouting_config_t config = z_scouting_config_default(); diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index 62e39ba59..d62e3cc29 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -35,7 +35,7 @@ void data_handler(const z_sample_t *sample, void *ctx) { z_drop(z_move(keystr)); } -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -75,3 +75,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); +} +#endif diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index b051ed467..f9a373cb9 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -35,7 +35,7 @@ void data_handler(const z_sample_t *sample, void *ctx) { z_drop(z_move(keystr)); } -void app_main() { +void app_main(void) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { @@ -67,3 +67,8 @@ void app_main() { z_close(z_move(s)); } +#else +void app_main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); +} +#endif