Skip to content

Commit

Permalink
Rework session open
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Apr 19, 2024
1 parent 843eb94 commit 6d0976e
Show file tree
Hide file tree
Showing 66 changed files with 153 additions and 81 deletions.
3 changes: 2 additions & 1 deletion examples/arduino/z_pub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void setup() {

// Open Zenoh session
Serial.print("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
Serial.println("Unable to open session!");
while (1) {
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_pull.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void setup() {

// Open Zenoh session
Serial.print("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
Serial.println("Unable to open session!");
while (1) {
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void setup() {

// Open Zenoh session
Serial.print("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
Serial.println("Unable to open session!");
while (1) {
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_scout.ino
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void setup() {
void loop() {
int *context = (int *)malloc(sizeof(int));
*context = 0;
z_owned_scouting_config_t config = z_scouting_config_default();
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));
Expand Down
3 changes: 2 additions & 1 deletion examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void setup() {

// Open Zenoh session
Serial.print("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
Serial.println("Unable to open session!");
while (1) {
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ void app_main() {

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ void app_main() {

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ void app_main() {

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ void app_main() {

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void app_main() {

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void app_main(void) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return;
Expand Down
6 changes: 4 additions & 2 deletions examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ int main(int argc, char **argv) {
net.connect();

// Initialize Zenoh Session and other parameters
z_owned_config_t config = z_config_default();
z_owned_config_t config;
z_config_default(&config);
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT));
}

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
6 changes: 4 additions & 2 deletions examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ int main(int argc, char **argv) {
net.connect();

// Initialize Zenoh Session and other parameters
z_owned_config_t config = z_config_default();
z_owned_config_t config;
z_config_default(&config);
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT));
}

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
6 changes: 4 additions & 2 deletions examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ int main(int argc, char **argv) {
net.connect();

// Initialize Zenoh Session and other parameters
z_owned_config_t config = z_config_default();
z_owned_config_t config;
z_config_default(&config);
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT));
}

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
6 changes: 4 additions & 2 deletions examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ int main(int argc, char **argv) {
net.connect();

// Initialize Zenoh Session and other parameters
z_owned_config_t config = z_config_default();
z_owned_config_t config;
z_config_default(&config);
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT));
}

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_scout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ int main(void) {

int *context = (int *)malloc(sizeof(int));
*context = 0;
z_owned_scouting_config_t config = z_scouting_config_default();
z_owned_scouting_config_t config;
z_scouting_config_default(&config);
z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context);
printf("Scouting...\n");
z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure));
Expand Down
6 changes: 4 additions & 2 deletions examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ int main(int argc, char **argv) {
net.connect();

// Initialize Zenoh Session and other parameters
z_owned_config_t config = z_config_default();
z_owned_config_t config;
z_config_default(&config);
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT));
}

// Open Zenoh session
printf("Opening Zenoh Session...");
z_owned_session_t s = z_open(z_config_move(&config));
z_owned_session_t s;
z_open(&s, z_config_move(&config));
if (!z_session_check(&s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_get_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ int main(int argc, char** argv) {
z_condvar_init(&cond);
z_owned_config_t config;
z_config_default(&config);
z_owned_session_t session = z_open(z_move(config));
z_owned_session_t session;
z_open(&session, z_move(config));
if (!z_check(session)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ int main(int argc, char** argv) {
(void)argv;
z_owned_config_t config;
z_config_default(&config);
z_owned_session_t session = z_open(z_move(config));
z_owned_session_t session;
z_open(&session, z_move(config));
if (!z_check(session)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ int main(int argc, char **argv) {
}
}
// Open session
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
exit(-1);
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ int main(int argc, char **argv) {
}

printf("Opening session...\n");
z_owned_session_t s = z_open(z_move(config));
z_owned_session_t s;
z_open(&s, z_move(config));
if (!z_check(s)) {
printf("Unable to open session!\n");
return -1;
Expand Down
Loading

0 comments on commit 6d0976e

Please sign in to comment.