From 9e86cbb214658ad7d73e631cdead4f02a2deeae5 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/z_get.c | 9 ++++++++- examples/freertos_plus_tcp/z_pub.c | 7 +++++++ examples/freertos_plus_tcp/z_pub_st.c | 7 +++++++ examples/freertos_plus_tcp/z_pull.c | 7 +++++++ examples/freertos_plus_tcp/z_queryable.c | 7 +++++++ examples/freertos_plus_tcp/z_sub.c | 6 ++++++ examples/freertos_plus_tcp/z_sub_st.c | 6 ++++++ 8 files changed, 52 insertions(+), 1 deletion(-) 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/z_get.c b/examples/freertos_plus_tcp/z_get.c index 8a0f74b4f..6ce1ea7d4 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" @@ -92,4 +93,10 @@ void app_main() { zp_stop_lease_task(z_loan(s)); z_close(z_move(s)); -} \ No newline at end of file +} +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); + return -2; +} +#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..913910e92 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" @@ -104,3 +105,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -2; +} +#endif diff --git a/examples/freertos_plus_tcp/z_pub_st.c b/examples/freertos_plus_tcp/z_pub_st.c index f31516b72..b2cc8b77c 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" @@ -72,3 +73,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -2; +} +#endif diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index b6d5d84f8..4c3f87646 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" @@ -77,3 +78,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -2; +} +#endif diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 1a9f19514..7fb2dbf3c 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" @@ -89,3 +90,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); + return -2; +} +#endif \ No newline at end of file diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index 62e39ba59..950f7aeab 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -75,3 +75,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + return -2; +} +#endif diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index b051ed467..b9ae96b04 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -67,3 +67,9 @@ void app_main() { z_close(z_move(s)); } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + return -2; +} +#endif