Skip to content

Commit

Permalink
Add query & queryable token config (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored Oct 13, 2023
1 parent 718d4c5 commit dd8b943
Show file tree
Hide file tree
Showing 32 changed files with 590 additions and 300 deletions.
7 changes: 7 additions & 0 deletions examples/arduino/z_get.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_QUERY == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -118,3 +119,9 @@ void loop() {
Serial.println("Unable to send query.");
}
}
#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.");
}
void loop() {}
#endif
8 changes: 8 additions & 0 deletions examples/arduino/z_queryable.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_QUERYABLE == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -106,3 +107,10 @@ void setup() {
}

void loop() { delay(5000); }

#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.");
}
void loop() {}
#endif
4 changes: 4 additions & 0 deletions examples/espidf/z_get.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_QUERY == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -172,3 +173,6 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); }
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define ESP_MAXIMUM_RETRY 5
#define WIFI_CONNECTED_BIT BIT0

#if Z_FEATURE_QUERYABLE == 1
static bool s_is_wifi_connected = false;
static EventGroupHandle_t s_event_group_handler;
static int s_retry_count = 0;
Expand Down Expand Up @@ -171,3 +172,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_QUERYABLE but this example requires it.\n");
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_get.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_QUERY == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -94,3 +95,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_queryable.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_QUERYABLE == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -94,3 +95,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_get.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_QUERY == 1
void reply_dropper(void *ctx) {
(void)(ctx);
printf(">> Received query final notification\n");
Expand Down Expand Up @@ -129,3 +130,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c11/z_queryable.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_QUERYABLE == 1
const char *keyexpr = "demo/example/zenoh-pico-queryable";
const char *value = "Queryable from Pico!";

Expand Down Expand Up @@ -124,3 +125,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c99/z_get.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_QUERY == 1
void reply_dropper(void *ctx) {
(void)(ctx);
printf(">> Received query final notification\n");
Expand Down Expand Up @@ -129,3 +130,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/unix/c99/z_queryable.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_QUERYABLE == 1
const char *keyexpr = "demo/example/zenoh-pico-queryable";
const char *value = "Queryable from Pico!";

Expand Down Expand Up @@ -120,3 +121,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/windows/z_get.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_QUERY == 1
void reply_dropper(void *ctx) {
(void)(ctx);
printf(">> Received query final notification\n");
Expand Down Expand Up @@ -94,3 +95,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/windows/z_queryable.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_QUERYABLE == 1
const char *keyexpr = "demo/example/zenoh-pico-queryable";
const char *value = "Queryable from Pico!";

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_QUERYABLE but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/zephyr/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <unistd.h>
#include <zenoh-pico.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"
Expand Down Expand Up @@ -88,3 +89,9 @@ int main(int argc, char **argv) {

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

0 comments on commit dd8b943

Please sign in to comment.