diff --git a/examples/arduino/z_pub.ino b/examples/arduino/z_pub.ino index 81f3745b2..763d69ee2 100644 --- a/examples/arduino/z_pub.ino +++ b/examples/arduino/z_pub.ino @@ -16,6 +16,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 // WiFi-specific parameters #define SSID "SSID" #define PASS "PASS" @@ -107,3 +108,9 @@ void loop() { delay(1000); } +#else +void setup() { + Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it."); +} +void loop() {} +#endif diff --git a/examples/espidf/z_pub.c b/examples/espidf/z_pub.c index 112429cbd..b55336f94 100644 --- a/examples/espidf/z_pub.c +++ b/examples/espidf/z_pub.c @@ -25,6 +25,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 #define ESP_WIFI_SSID "SSID" #define ESP_WIFI_PASS "PASS" #define ESP_MAXIMUM_RETRY 5 @@ -163,3 +164,8 @@ void app_main() { z_close(z_move(s)); printf("OK!\n"); } +#else +void app_main() { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); +} +#endif diff --git a/examples/mbed/z_pub.cpp b/examples/mbed/z_pub.cpp index 8720faaa3..b51127a37 100644 --- a/examples/mbed/z_pub.cpp +++ b/examples/mbed/z_pub.cpp @@ -16,6 +16,7 @@ #include #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" @@ -85,3 +86,9 @@ int main(int argc, char **argv) { return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 775420bd7..d3853d475 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -21,7 +21,7 @@ #include "zenoh-pico.h" #include "zenoh-pico/system/platform.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 // WARNING: for the sake of this example we are using "internal" structs and functions (starting with "_"). // Synchronisation primitives are planned to be added to the API in the future. _z_condvar_t cond; @@ -168,7 +168,9 @@ struct args_t parse_args(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index a79fb7285..0a9ee2d26 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -15,7 +15,7 @@ #include "stdio.h" #include "zenoh-pico.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 void callback(const z_sample_t* sample, void* context) { z_publisher_t pub = z_loan(*(z_owned_publisher_t*)context); z_publisher_put(pub, sample->payload.start, sample->payload.len, NULL); @@ -71,7 +71,9 @@ int main(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index e4f96b7ea..35df1383d 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -22,6 +22,7 @@ #include "zenoh-pico/system/platform.h" +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; char *const default_value = "Pub from Pico!"; @@ -117,3 +118,9 @@ int main(int argc, char **argv) { } return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index f2b0fef79..7dda9936e 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -19,6 +19,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; @@ -103,3 +104,9 @@ int main(int argc, char **argv) { free(buf); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index 0445d48f9..557a128a5 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -19,6 +19,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; @@ -101,3 +102,9 @@ int main(int argc, char **argv) { z_close(z_move(s)); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 18c296a7d..451a8fc30 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -22,7 +22,7 @@ #include "zenoh-pico/api/primitives.h" #include "zenoh-pico/system/platform.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 _z_condvar_t cond; _z_mutex_t mutex; @@ -168,7 +168,9 @@ struct args_t parse_args(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index d7671b38d..b175c49b0 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -16,7 +16,7 @@ #include "zenoh-pico.h" #include "zenoh-pico/api/primitives.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 void callback(const z_sample_t* sample, void* context) { z_publisher_t pub = z_publisher_loan((z_owned_publisher_t*)context); z_publisher_put(pub, sample->payload.start, sample->payload.len, NULL); @@ -45,7 +45,14 @@ int main(int argc, char** argv) { printf("Unable to start read and lease tasks"); return -1; } - +#else +int main(void) { + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); + return -1; +} +#endif z_keyexpr_t pong = z_keyexpr_unchecked("test/pong"); z_owned_publisher_t pub = z_declare_publisher(z_session_loan(&session), pong, NULL); if (!z_publisher_check(&pub)) { @@ -74,7 +81,9 @@ int main(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index 8ee66dfdb..0e0c22f1f 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -19,6 +19,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; @@ -106,3 +107,9 @@ int main(int argc, char **argv) { free(buf); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/unix/c99/z_pub_st.c b/examples/unix/c99/z_pub_st.c index 96eeba2a4..237a892d9 100644 --- a/examples/unix/c99/z_pub_st.c +++ b/examples/unix/c99/z_pub_st.c @@ -19,6 +19,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; @@ -103,3 +104,9 @@ int main(int argc, char **argv) { free(buf); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index be22b6eea..20d13fb11 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -19,6 +19,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; @@ -101,3 +102,9 @@ int main(int argc, char **argv) { z_close(z_session_move(&s)); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index 247b18eb7..da6cb75db 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -21,7 +21,7 @@ #include "zenoh-pico.h" #include "zenoh-pico/system/platform.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 _z_condvar_t cond; _z_mutex_t mutex; @@ -165,7 +165,9 @@ struct args_t parse_args(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index a79fb7285..0a9ee2d26 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -15,7 +15,7 @@ #include "stdio.h" #include "zenoh-pico.h" -#if Z_FEATURE_SUBSCRIPTION == 1 +#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 void callback(const z_sample_t* sample, void* context) { z_publisher_t pub = z_loan(*(z_owned_publisher_t*)context); z_publisher_put(pub, sample->payload.start, sample->payload.len, NULL); @@ -71,7 +71,9 @@ int main(int argc, char** argv) { } #else int main(void) { - printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); + printf( + "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " + "requires them.\n"); return -1; } #endif \ No newline at end of file diff --git a/examples/windows/z_pub.c b/examples/windows/z_pub.c index 31bf582db..aecc29806 100644 --- a/examples/windows/z_pub.c +++ b/examples/windows/z_pub.c @@ -18,6 +18,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { (void)(argc); (void)(argv); @@ -74,3 +75,9 @@ int main(int argc, char **argv) { free(buf); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif diff --git a/examples/windows/z_pub_st.c b/examples/windows/z_pub_st.c index 55475ad22..4623098ae 100644 --- a/examples/windows/z_pub_st.c +++ b/examples/windows/z_pub_st.c @@ -18,6 +18,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { (void)(argc); (void)(argv); @@ -70,3 +71,9 @@ int main(int argc, char **argv) { free(buf); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 464eab495..dff826725 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -18,6 +18,7 @@ #include #include +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { (void)(argc); (void)(argv); @@ -68,3 +69,9 @@ int main(int argc, char **argv) { z_close(z_move(s)); return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/examples/zephyr/z_pub.c b/examples/zephyr/z_pub.c index 606311860..09623fd49 100644 --- a/examples/zephyr/z_pub.c +++ b/examples/zephyr/z_pub.c @@ -31,6 +31,7 @@ #define KEYEXPR "demo/example/zenoh-pico-pub" #define VALUE "[STSTM32]{nucleo-F767ZI} Pub from Zenoh-Pico!" +#if Z_FEATURE_PUBLICATION == 1 int main(int argc, char **argv) { sleep(5); @@ -82,3 +83,9 @@ int main(int argc, char **argv) { return 0; } +#else +int main(void) { + printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); + return -1; +} +#endif \ No newline at end of file diff --git a/src/net/primitives.c b/src/net/primitives.c index 74e74591a..7f0123695 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -96,7 +96,6 @@ int8_t _z_undeclare_resource(_z_session_t *zn, uint16_t rid) { return ret; } - #if Z_FEATURE_PUBLICATION == 1 /*------------------ Publisher Declaration ------------------*/ _z_publisher_t *_z_declare_publisher(_z_session_t *zn, _z_keyexpr_t keyexpr, z_congestion_control_t congestion_control,