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

Rename z_hello_locators to zp_hello_locators and add zenoh-c compatible z_hello_locators #677

Merged
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
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ Primitives
.. autocfunction:: primitives.h::z_hello_zid
.. autocfunction:: primitives.h::z_hello_whatami
.. autocfunction:: primitives.h::z_hello_locators
.. autocfunction:: primitives.h::zp_hello_locators
.. autocfunction:: primitives.h::z_whatami_to_view_string
.. autocfunction:: primitives.h::z_scout
.. autocfunction:: primitives.h::z_open
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_scout.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void fprinthello(const z_loaned_hello_t *hello) {
Serial.print(", whatami: ");
fprintwhatami(z_hello_whatami(hello));
Serial.print(", locators: ");
fprintlocators(z_hello_locators(hello));
fprintlocators(zp_hello_locators(hello));
Serial.println(" }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_scout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) {
fprintf(stream, ", whatami: ");
fprintwhatami(stream, z_hello_whatami(hello));
fprintf(stream, ", locators: ");
fprintlocators(stream, z_hello_locators(hello));
fprintlocators(stream, zp_hello_locators(hello));
fprintf(stream, " }");
}

Expand Down
15 changes: 13 additions & 2 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -1479,14 +1479,25 @@ z_id_t z_hello_zid(const z_loaned_hello_t *hello);
z_whatami_t z_hello_whatami(const z_loaned_hello_t *hello);

/**
* Constructs an array of locators of Zenoh entity that sent hello message.
* Returns an array of locators of Zenoh entity that sent hello message.
*
* Parameters:
* hello: Pointer to a :c:type:`z_loaned_hello_t` message.
* Return:
* :c:type:`z_loaned_string_array_t` containing locators.
*/
const z_loaned_string_array_t *z_hello_locators(const z_loaned_hello_t *hello);
const z_loaned_string_array_t *zp_hello_locators(const z_loaned_hello_t *hello);

/**
* Constructs an array of locators of Zenoh entity that sent hello message.
* Note that it is a method for zenoh-c compatiblity, in zenoh-pico :c:func:`zp_hello_locators`
* can be used.
*
* Parameters:
* hello: Pointer to a :c:type:`z_loaned_hello_t` message.
* locators_out: An uninitialized memory location where :c:type:`z_owned_string_array_t` will be constructed.
*/
void z_hello_locators(const z_loaned_hello_t *hello, z_owned_string_array_t *locators_out);

/**
* Constructs a non-owned non-null-terminated string from the kind of zenoh entity.
Expand Down
6 changes: 5 additions & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,11 @@ z_id_t z_hello_zid(const z_loaned_hello_t *hello) { return hello->_zid; }

z_whatami_t z_hello_whatami(const z_loaned_hello_t *hello) { return hello->_whatami; }

const z_loaned_string_array_t *z_hello_locators(const z_loaned_hello_t *hello) { return &hello->_locators; }
const z_loaned_string_array_t *zp_hello_locators(const z_loaned_hello_t *hello) { return &hello->_locators; }

void z_hello_locators(const z_loaned_hello_t *hello, z_owned_string_array_t *locators_out) {
z_string_array_clone(locators_out, &hello->_locators);
}

static const char *WHAT_AM_I_TO_STRING_MAP[8] = {
"Other", // 0
Expand Down
Loading