Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subscription token config #264

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/arduino/z_pull.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -108,3 +109,9 @@ void loop() {
delay(5000);
z_subscriber_pull(z_pull_subscriber_loan(&sub));
}
#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.");
}
void loop() {}
#endif
8 changes: 8 additions & 0 deletions examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -104,3 +105,10 @@ void setup() {
}

void loop() { delay(5000); }

#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.");
}
void loop() {}
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -168,3 +169,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_SUBSCRIPTION but this example requires it.\n");
}
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -166,3 +167,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_SUBSCRIPTION but this example requires it.\n");
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <randLIB.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -91,3 +92,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <randLIB.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -89,3 +90,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "zenoh-pico.h"
#include "zenoh-pico/system/platform.h"

#if Z_FEATURE_SUBSCRIPTION == 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;
Expand Down Expand Up @@ -165,3 +166,9 @@ struct args_t parse_args(int argc, char** argv) {
.warmup_ms = warmup_ms,
};
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "stdio.h"
#include "zenoh-pico.h"

#if Z_FEATURE_SUBSCRIPTION == 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);
Expand Down Expand Up @@ -68,3 +69,9 @@ int main(int argc, char** argv) {

z_close(z_move(session));
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -98,3 +99,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -107,3 +108,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -96,3 +97,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
9 changes: 8 additions & 1 deletion examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "zenoh-pico/api/primitives.h"
#include "zenoh-pico/system/platform.h"

#if Z_FEATURE_SUBSCRIPTION == 1
_z_condvar_t cond;
_z_mutex_t mutex;

Expand Down Expand Up @@ -164,4 +165,10 @@ struct args_t parse_args(int argc, char** argv) {
.number_of_pings = number_of_pings,
.warmup_ms = warmup_ms,
};
}
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
9 changes: 8 additions & 1 deletion examples/unix/c99/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "zenoh-pico.h"
#include "zenoh-pico/api/primitives.h"

#if Z_FEATURE_SUBSCRIPTION == 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);
Expand Down Expand Up @@ -70,4 +71,10 @@ int main(int argc, char** argv) {
zp_stop_lease_task(z_session_loan(&session));

z_close(z_session_move(&session));
}
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c99/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -99,3 +100,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c99/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *arg) {
(void)(arg);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -108,3 +109,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c99/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *arg) {
(void)(arg);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -97,3 +98,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
9 changes: 8 additions & 1 deletion examples/windows/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "zenoh-pico.h"
#include "zenoh-pico/system/platform.h"

#if Z_FEATURE_SUBSCRIPTION == 1
_z_condvar_t cond;
_z_mutex_t mutex;

Expand Down Expand Up @@ -161,4 +162,10 @@ struct args_t parse_args(int argc, char** argv) {
.number_of_pings = number_of_pings,
.warmup_ms = warmup_ms,
};
}
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
9 changes: 8 additions & 1 deletion examples/windows/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "stdio.h"
#include "zenoh-pico.h"

#if Z_FEATURE_SUBSCRIPTION == 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);
Expand Down Expand Up @@ -67,4 +68,10 @@ int main(int argc, char** argv) {
zp_stop_lease_task(z_loan(session));

z_close(z_move(session));
}
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/windows/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <stdlib.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -78,3 +79,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/windows/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdlib.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
void data_handler(const z_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr);
Expand Down Expand Up @@ -77,3 +78,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
Loading
Loading