diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 918b7ca46..cae647628 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -23,10 +23,10 @@ // Client mode values (comment/uncomment as needed) #define MODE "client" -#define CONNECT "" // If empty, it will scout +#define LOCATOR "" // If empty, it will scout // Peer mode values (comment/uncomment as needed) // #define MODE "peer" -// #define CONNECT "udp/224.0.0.225:7447#iface=en0" +// #define LOCATOR "udp/224.0.0.225:7447#iface=en0" #define KEYEXPR "demo/example/**" #define VALUE "" @@ -79,8 +79,12 @@ void setup() { z_owned_config_t config; z_config_default(&config); zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_MODE_KEY, MODE); - if (strcmp(CONNECT, "") != 0) { - zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, CONNECT); + if (strcmp(LOCATOR, "") != 0) { + if (strcmp(MODE, "client") == 0) { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, LOCATOR); + } else { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_LISTEN_KEY, LOCATOR); + } } // Open Zenoh session diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index fcfb5f975..93174dd5c 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -38,10 +38,10 @@ static int s_retry_count = 0; #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" -#define CONNECT "" // If empty, it will scout +#define LOCATOR "" // If empty, it will scout #elif CLIENT_OR_PEER == 1 #define MODE "peer" -#define CONNECT "udp/224.0.0.225:7447#iface=en0" +#define LOCATOR "udp/224.0.0.225:7447#iface=en0" #else #error "Unknown Zenoh operation mode. Check CLIENT_OR_PEER value." #endif @@ -140,8 +140,12 @@ void app_main() { z_owned_config_t config; z_config_default(&config); zp_config_insert(z_loan_mut(config), Z_CONFIG_MODE_KEY, MODE); - if (strcmp(CONNECT, "") != 0) { - zp_config_insert(z_loan_mut(config), Z_CONFIG_CONNECT_KEY, CONNECT); + if (strcmp(LOCATOR, "") != 0) { + if (strcmp(MODE, "client") == 0) { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, LOCATOR); + } else { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_LISTEN_KEY, LOCATOR); + } } // Open Zenoh session diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index c7969b3b1..a9dcce783 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -20,10 +20,10 @@ #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" -#define CONNECT "" // If empty, it will scout +#define LOCATOR "" // If empty, it will scout #elif CLIENT_OR_PEER == 1 #define MODE "peer" -#define CONNECT "udp/224.0.0.225:7447#iface=en0" +#define LOCATOR "udp/224.0.0.225:7447#iface=en0" #else #error "Unknown Zenoh operation mode. Check CLIENT_OR_PEER value." #endif @@ -61,10 +61,13 @@ int main(int argc, char **argv) { z_owned_config_t config; z_config_default(&config); zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_MODE_KEY, MODE); - if (strcmp(CONNECT, "") != 0) { - zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, CONNECT); + if (strcmp(LOCATOR, "") != 0) { + if (strcmp(MODE, "client") == 0) { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, LOCATOR); + } else { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_LISTEN_KEY, LOCATOR); + } } - // Open Zenoh session printf("Opening Zenoh Session..."); z_owned_session_t s; diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index c56049899..f08479d4b 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -21,10 +21,10 @@ #define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode #if CLIENT_OR_PEER == 0 #define MODE "client" -#define CONNECT "" // If empty, it will scout +#define LOCATOR "" // If empty, it will scout #elif CLIENT_OR_PEER == 1 #define MODE "peer" -#define CONNECT "udp/224.0.0.225:7447#iface=en0" +#define LOCATOR "udp/224.0.0.225:7447#iface=en0" #else #error "Unknown Zenoh operation mode. Check CLIENT_OR_PEER value." #endif @@ -57,8 +57,13 @@ int main(int argc, char **argv) { z_owned_config_t config; z_config_default(&config); zp_config_insert(z_loan_mut(config), Z_CONFIG_MODE_KEY, MODE); - if (strcmp(CONNECT, "") != 0) { - zp_config_insert(z_loan_mut(config), Z_CONFIG_CONNECT_KEY, CONNECT); + + if (strcmp(LOCATOR, "") != 0) { + if (strcmp(MODE, "client") == 0) { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_CONNECT_KEY, LOCATOR); + } else { + zp_config_insert(z_config_loan_mut(&config), Z_CONFIG_LISTEN_KEY, LOCATOR); + } } // Open Zenoh session