From 7f623656ccea9795a8ba09714b804dc8af8f7eeb Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 4 Oct 2023 14:30:07 +0200 Subject: [PATCH 1/6] style: remove typos in constants and comments --- include/zenoh-pico/api/macros.h | 16 ++++++------- include/zenoh-pico/api/primitives.h | 24 +++++++++---------- include/zenoh-pico/config.h | 8 +++---- include/zenoh-pico/link/link.h | 6 ++--- include/zenoh-pico/net/primitives.h | 2 +- include/zenoh-pico/net/session.h | 2 +- include/zenoh-pico/net/zenoh-pico.h | 1 - include/zenoh-pico/protocol/codec/ext.h | 4 ++-- .../protocol/definitions/transport.h | 16 ++++++------- include/zenoh-pico/utils/string.h | 4 ++-- src/link/endpoint.c | 2 +- src/link/unicast/tcp.c | 2 +- src/link/unicast/ws.c | 2 +- src/protocol/codec.c | 2 +- src/session/query.c | 2 +- src/session/resource.c | 2 +- src/system/arduino/opencr/network.cpp | 4 ++-- src/transport/common/tx.c | 2 +- src/transport/multicast/link/tx.c | 4 ++-- src/transport/unicast/link/rx.c | 4 ++-- src/transport/unicast/link/tx.c | 4 ++-- tests/z_client_test.c | 4 ++-- tests/z_peer_multicast_test.c | 2 +- 23 files changed, 59 insertions(+), 60 deletions(-) diff --git a/include/zenoh-pico/api/macros.h b/include/zenoh-pico/api/macros.h index f6b6077fb..c7cb700a9 100644 --- a/include/zenoh-pico/api/macros.h +++ b/include/zenoh-pico/api/macros.h @@ -46,7 +46,7 @@ z_owned_str_array_t : z_str_array_loan \ )(&x) /** - * Defines a generic function for droping any of the ``z_owned_X_t`` types. + * Defines a generic function for dropping any of the ``z_owned_X_t`` types. * * Parameters: * x: The instance to drop. @@ -75,7 +75,7 @@ * Defines a generic function for making null object of any of the ``z_owned_X_t`` types. * * Returns: - * Returns the unitialized instance of `x`. + * Returns the uninitialized instance of `x`. */ #define z_null(x) (*x = _Generic((x), \ z_owned_session_t * : z_session_null, \ @@ -193,7 +193,7 @@ * Defines a generic function for making null object of any of the ``z_owned_X_t`` types. * * Returns: - * Returns the unitialized instance of `x`. + * Returns the uninitialized instance of `x`. */ #define z_null(x) (*x = _Generic((x), \ z_owned_session_t * : z_session_null, \ @@ -216,15 +216,15 @@ // clang-format on -#define _z_closure_overloader(callback, droper, ctx, ...) \ - { .call = callback, .drop = droper, .context = ctx } +#define _z_closure_overloader(callback, dropper, ctx, ...) \ + { .call = callback, .drop = dropper, .context = ctx } /** * Defines a variadic macro to ease the definition of callback closures. * * Parameters: * callback: the typical ``callback`` function. ``context`` will be passed as its last argument. - * droper: allows the callback's state to be freed. ``context`` will be passed as its last argument. + * dropper: allows the callback's state to be freed. ``context`` will be passed as its last argument. * context: a pointer to an arbitrary state. * * Returns: @@ -334,8 +334,8 @@ inline void z_call(const z_owned_closure_zid_t &closure, const z_id_t *zid) { z_closure_zid_call(&closure, zid); } // clang-format on -#define _z_closure_overloader(callback, droper, ctx, ...) \ - { .context = const_cast(static_cast(ctx)), .call = callback, .drop = droper } +#define _z_closure_overloader(callback, dropper, ctx, ...) \ + { .context = const_cast(static_cast(ctx)), .call = callback, .drop = dropper } #define z_closure(...) _z_closure_overloader(__VA_ARGS__, NULL, NULL) #define z_move(x) (&x) diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 9b0307df3..9b44c2c0e 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -73,7 +73,7 @@ z_keyexpr_t z_keyexpr_unchecked(const char *name); /** * Get null-terminated string departing from a :c:type:`z_keyexpr_t`. * - * If given keyexpr contains a declared keyexpr, the resulting owned string will be unitialized. + * If given keyexpr contains a declared keyexpr, the resulting owned string will be uninitialized. * In that case, the user must use :c:func:`zp_keyexpr_resolve` to resolve the nesting declarations * and get its full expanded representation. * @@ -99,7 +99,7 @@ z_bytes_t z_keyexpr_as_bytes(z_keyexpr_t keyexpr); /** * Constructs a null-terminated string departing from a :c:type:`z_keyexpr_t` for a given :c:type:`z_session_t`. - * The user is responsible of droping the returned string using ``z_free``. + * The user is responsible of dropping the returned string using ``z_free``. * * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` to resolve the keyexpr. @@ -471,7 +471,7 @@ z_query_consolidation_t z_query_consolidation_latest(void); * Monotonic consolidation. * * This strategy offers the best latency. Replies are directly transmitted to the application when received - * without needing to wait for all replies. This mode does not garantee that there will be no duplicates. + * without needing to wait for all replies. This mode does not guarantee that there will be no duplicates. * * Returns: * Returns the constructed :c:type:`z_query_consolidation_t`. @@ -481,7 +481,7 @@ z_query_consolidation_t z_query_consolidation_monotonic(void); /** * No consolidation. * - * This strategy is usefull when querying timeseries data bases or when using quorums. + * This strategy is useful when querying timeseries data bases or when using quorums. * * Returns: * Returns the constructed :c:type:`z_query_consolidation_t`. @@ -697,7 +697,7 @@ _OWNED_FUNCTIONS_CLOSURE(z_owned_closure_zid_t, closure_zid) * * Parameters: * config: A moved instance of :c:type:`z_owned_scouting_config_t` containing the set properties to configure the - * scouting. callback: A moved instance of :c:type:`z_owned_closure_hello_t` containg the callbacks to be called. + * scouting. callback: A moved instance of :c:type:`z_owned_closure_hello_t` containing the callbacks to be called. * * Returns: * Returns ``0`` if the scouting is successful triggered, or a ``negative value`` otherwise. @@ -748,7 +748,7 @@ int8_t z_close(z_owned_session_t *zs); * * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` to inquiry. - * callback: A moved instance of :c:type:`z_owned_closure_zid_t` containg the callbacks to be called. + * callback: A moved instance of :c:type:`z_owned_closure_zid_t` containing the callbacks to be called. * * Returns: * Returns ``0`` if the info is successful triggered, or a ``negative value`` otherwise. @@ -763,7 +763,7 @@ int8_t z_info_peers_zid(const z_session_t zs, z_owned_closure_zid_t *callback); * * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` to inquiry. - * callback: A moved instance of :c:type:`z_owned_closure_zid_t` containg the callbacks to be called. + * callback: A moved instance of :c:type:`z_owned_closure_zid_t` containing the callbacks to be called. * * Returns: * Returns ``0`` if the info is successful triggered, or a ``negative value`` otherwise. @@ -844,8 +844,8 @@ z_get_options_t z_get_options_default(void); * zs: A loaned instance of the the :c:type:`z_session_t` through where data will be put. * keyexpr: A loaned instance of :c:type:`z_keyexpr_t` to put. * parameters: Pointer to the parameters as a null-terminated string. - * callback: A moved instance of :c:type:`z_owned_closure_reply_t` containg the callbacks to be called. - * options: The get options to be aplied in the distributed query. + * callback: A moved instance of :c:type:`z_owned_closure_reply_t` containing the callbacks to be called. + * options: The get options to be applied in the distributed query. * * Returns: * Returns ``0`` if the put operation is successful, or a ``negative value`` otherwise. @@ -1078,7 +1078,7 @@ z_pull_subscriber_options_t z_pull_subscriber_options_default(void); * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` where to declare the subscriber. * keyexpr: A loaned instance of :c:type:`z_keyexpr_t` to associate with the subscriber. - * callback: A moved instance of :c:type:`z_owned_closure_sample_t` containg the callbacks to be called and the + * callback: A moved instance of :c:type:`z_owned_closure_sample_t` containing the callbacks to be called and the * context to pass to them. options: The options to apply to the pull subscriber. If ``NULL`` is passed, the default * options will be applied. * @@ -1142,7 +1142,7 @@ z_queryable_options_t z_queryable_options_default(void); * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` where to declare the subscriber. * keyexpr: A loaned instance of :c:type:`z_keyexpr_t` to associate with the subscriber. - * callback: A moved instance of :c:type:`z_owned_closure_query_t` containg the callbacks to be called and the context + * callback: A moved instance of :c:type:`z_owned_closure_query_t` containing the callbacks to be called and the context * to pass to them. options: The options to apply to the queryable. If ``NULL`` is passed, the default options will be * applied. * @@ -1246,7 +1246,7 @@ z_value_t z_reply_err(const z_owned_reply_t *reply); */ _Bool z_value_is_initialized(z_value_t *value); -/************* Multi Thread Taks helpers **************/ +/************* Multi Thread Tasks helpers **************/ /** * Constructs the default values for the session read task. * diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h index 2bbb9abc2..21fa2063a 100644 --- a/include/zenoh-pico/config.h +++ b/include/zenoh-pico/config.h @@ -57,7 +57,7 @@ #define Z_CONFIG_PASSWORD_KEY 0x44 /** - * Activates/Desactivates multicast scouting. + * Activates/Deactivates multicast scouting. * Accepted values : `false`, `true`. * Default value : `true`. */ @@ -223,20 +223,20 @@ #endif /** - * Defaulf maximum batch size possible to be received or sent. + * Default maximum batch size possible to be received or sent. */ #ifndef Z_BATCH_UNICAST_SIZE #define Z_BATCH_UNICAST_SIZE 65535 #endif /** - * Defaulf maximum batch size possible to be received or sent. + * Default maximum batch size possible to be received or sent. */ #ifndef Z_BATCH_MULTICAST_SIZE #define Z_BATCH_MULTICAST_SIZE 8192 #endif /** - * Defaulf maximum size for fragmented messages. + * Default maximum size for fragmented messages. */ #ifndef Z_FRAG_MAX_SIZE #define Z_FRAG_MAX_SIZE 300000 diff --git a/include/zenoh-pico/link/link.h b/include/zenoh-pico/link/link.h index e28d8d89d..10a892982 100644 --- a/include/zenoh-pico/link/link.h +++ b/include/zenoh-pico/link/link.h @@ -47,18 +47,18 @@ * * Enumerators: * Z_LINK_CAPABILITY_NONE: Bitmask to define that link has no capabilities. - * Z_LINK_CAPABILITY_RELIEABLE: Bitmask to define and check if link is reliable. + * Z_LINK_CAPABILITY_RELIABLE: Bitmask to define and check if link is reliable. * Z_LINK_CAPABILITY_STREAMED: Bitmask to define and check if link is streamed. * Z_LINK_CAPABILITY_MULTICAST: Bitmask to define and check if link is multicast. */ typedef enum { Z_LINK_CAPABILITY_NONE = 0x00, // 0 - Z_LINK_CAPABILITY_RELIEABLE = 0x01, // 1 << 0 + Z_LINK_CAPABILITY_RELIABLE = 0x01, // 1 << 0 Z_LINK_CAPABILITY_STREAMED = 0x02, // 1 << 1 Z_LINK_CAPABILITY_MULTICAST = 0x04 // 1 << 2 } _z_link_capabilities_t; -#define _Z_LINK_IS_RELIABLE(X) ((X & Z_LINK_CAPABILITY_RELIEABLE) == Z_LINK_CAPABILITY_RELIEABLE) +#define _Z_LINK_IS_RELIABLE(X) ((X & Z_LINK_CAPABILITY_RELIABLE) == Z_LINK_CAPABILITY_RELIABLE) #define _Z_LINK_IS_STREAMED(X) ((X & Z_LINK_CAPABILITY_STREAMED) == Z_LINK_CAPABILITY_STREAMED) #define _Z_LINK_IS_MULTICAST(X) ((X & Z_LINK_CAPABILITY_MULTICAST) == Z_LINK_CAPABILITY_MULTICAST) diff --git a/include/zenoh-pico/net/primitives.h b/include/zenoh-pico/net/primitives.h index 1ebcf43aa..38a2affb4 100644 --- a/include/zenoh-pico/net/primitives.h +++ b/include/zenoh-pico/net/primitives.h @@ -34,7 +34,7 @@ * what: A what bitmask of zenoh entities kind to scout for. * zid: The ZenohID of the scouting origin. * locator: The locator where to scout. - * timeout: The time that should be spent scouting before returnng the results. + * timeout: The time that should be spent scouting before returning the results. */ void _z_scout(const z_what_t what, const _z_id_t zid, const char *locator, const uint32_t timeout, _z_hello_handler_t callback, void *arg_call, _z_drop_handler_t dropper, void *arg_drop); diff --git a/include/zenoh-pico/net/session.h b/include/zenoh-pico/net/session.h index 19c90adee..bebe7608c 100644 --- a/include/zenoh-pico/net/session.h +++ b/include/zenoh-pico/net/session.h @@ -90,7 +90,7 @@ void _z_close(_z_session_t *session); */ _z_config_t *_z_info(const _z_session_t *session); -/*------------------ Zenoh-Pico Session Management Auxiliar------------------*/ +/*------------------ Zenoh-Pico Session Management Auxiliary ------------------*/ /** * Read from the network. This function should be called manually called when * the read loop has not been started, e.g., when running in a single thread. diff --git a/include/zenoh-pico/net/zenoh-pico.h b/include/zenoh-pico/net/zenoh-pico.h index 80d1f89c2..b90fcf05a 100644 --- a/include/zenoh-pico/net/zenoh-pico.h +++ b/include/zenoh-pico/net/zenoh-pico.h @@ -20,7 +20,6 @@ #include "zenoh-pico/net/primitives.h" #include "zenoh-pico/net/publish.h" #include "zenoh-pico/net/query.h" -#include "zenoh-pico/net/resource.h" #include "zenoh-pico/net/session.h" #include "zenoh-pico/net/subscribe.h" diff --git a/include/zenoh-pico/protocol/codec/ext.h b/include/zenoh-pico/protocol/codec/ext.h index 428842aa1..d8c086566 100644 --- a/include/zenoh-pico/protocol/codec/ext.h +++ b/include/zenoh-pico/protocol/codec/ext.h @@ -28,7 +28,7 @@ int8_t _z_msg_ext_decode_na(_z_msg_ext_t *ext, _z_zbuf_t *zbf, _Bool *has_next); int8_t _z_msg_ext_vec_encode(_z_wbuf_t *wbf, const _z_msg_ext_vec_t *extensions); int8_t _z_msg_ext_vec_decode(_z_msg_ext_vec_t *extensions, _z_zbuf_t *zbf); /** - * Iterates through the extensions in `zbf`, assuming at least one is present at its begining + * Iterates through the extensions in `zbf`, assuming at least one is present at its beginning * (calling this function otherwise is UB). Short-circuits if `callback` returns a non-zero value. * * `callback` will receive `context` as its second argument, and may "steal" its first argument by @@ -36,7 +36,7 @@ int8_t _z_msg_ext_vec_decode(_z_msg_ext_vec_t *extensions, _z_zbuf_t *zbf); */ int8_t _z_msg_ext_decode_iter(_z_zbuf_t *zbf, int8_t (*callback)(_z_msg_ext_t *, void *), void *context); /** - * Iterates through the extensions in `zbf`, assuming at least one is present at its begining. + * Iterates through the extensions in `zbf`, assuming at least one is present at its beginning. * Returns `_Z_ERR_MESSAGE_EXTENSION_MANDATORY_AND_UNKNOWN` if a mandatory extension is found, * `_Z_RES_OK` otherwise. */ diff --git a/include/zenoh-pico/protocol/definitions/transport.h b/include/zenoh-pico/protocol/definitions/transport.h index 32b8dd82a..f92bd3ae3 100644 --- a/include/zenoh-pico/protocol/definitions/transport.h +++ b/include/zenoh-pico/protocol/definitions/transport.h @@ -111,7 +111,7 @@ // +---------------+ // // (#) ZID length. If Flag(I)==1 it indicates how many bytes are used for the ZenohID bytes. -// A ZenohID is minimum 1 byte and maximum 16 bytes. Therefore, the actual lenght is computed as: +// A ZenohID is minimum 1 byte and maximum 16 bytes. Therefore, the actual length is computed as: // real_zid_len := 1 + zid_len // // (*) What. It indicates a bitmap of WhatAmI interests. @@ -138,7 +138,7 @@ void _z_s_msg_scout_clear(_z_s_msg_scout_t *msg); // 1) in response to a SCOUT message; // 2) to (periodically) advertise (e.g., on multicast) the Peer and the locators it is reachable at; // 3) in a already established session to update the corresponding peer on the new capabilities -// (i.e., whatmai) and/or new set of locators (i.e., added or deleted). +// (i.e., whatami) and/or new set of locators (i.e., added or deleted). // Locators are expressed as: // // udp/192.168.0.2:1234 @@ -285,7 +285,7 @@ void _z_t_msg_join_clear(_z_t_msg_join_t *msg); // // (#) ZID length. It indicates how many bytes are used for the ZenohID bytes. // A ZenohID is minimum 1 byte and maximum 16 bytes. Therefore, the actual -// lenght is computed as: +// length is computed as: // real_zid_len := 1 + zid_len // // (+) Sequence Number/ID resolution. It indicates the resolution and @@ -315,11 +315,11 @@ typedef struct { void _z_t_msg_init_clear(_z_t_msg_init_t *msg); /*------------------ Open Message ------------------*/ -// NOTE: 16 bits (2 bytes) may be prepended to the serialized message indicating the total lenght -// in bytes of the message, resulting in the maximum lenght of a message being 65_535 bytes. +// NOTE: 16 bits (2 bytes) may be prepended to the serialized message indicating the total length +// in bytes of the message, resulting in the maximum length of a message being 65_535 bytes. // This is necessary in those stream-oriented transports (e.g., TCP) that do not preserve // the boundary of the serialized messages. The length is encoded as little-endian. -// In any case, the lenght of a message must not exceed 65_535 bytes. +// In any case, the length of a message must not exceed 65_535 bytes. // // The OPEN message is sent on a link to finally open an initialized session with the peer. // @@ -361,7 +361,7 @@ void _z_t_msg_open_clear(_z_t_msg_open_t *msg); // // The CLOSE message is sent in any of the following two cases: // 1) in response to an OPEN message which is not accepted; -// 2) at any time to arbitrarly close the session with the corresponding peer. +// 2) at any time to arbitrarily close the session with the corresponding peer. // // Flags: // - S: Session Close if S==1 Session close or S==0 Link close @@ -451,7 +451,7 @@ void _z_t_msg_frame_clear(_z_t_msg_frame_t *msg); /*------------------ Fragment Message ------------------*/ // The Fragment message is used to transmit on the wire large Zenoh Message that require fragmentation -// because they are larger thatn the maximum batch size (i.e. 2^16-1) and/or the link MTU. +// because they are larger than the maximum batch size (i.e. 2^16-1) and/or the link MTU. // // The [`Fragment`] message flow is the following: // diff --git a/include/zenoh-pico/utils/string.h b/include/zenoh-pico/utils/string.h index 89f8e7cf7..43cd2d63f 100644 --- a/include/zenoh-pico/utils/string.h +++ b/include/zenoh-pico/utils/string.h @@ -30,7 +30,7 @@ typedef struct { * The reverse equivalent of libc's `strstr`. * * Returns NULL if the needle is not found. - * If found, the return pointer will point to the end of the last occuring + * If found, the return pointer will point to the end of the last occurring * needle within the haystack. */ char const *_z_rstrstr(const char *haystack_start, const char *haystack_end, const char *needle); @@ -39,7 +39,7 @@ char const *_z_rstrstr(const char *haystack_start, const char *haystack_end, con * A non-null-terminated haystack equivalent of libc's `strstr`. * * Returns NULL if the needle is not found. - * If found, the return pointer will point to the start of the first occurence + * If found, the return pointer will point to the start of the first occurrence * of the needle within the haystack. */ char const *_z_strstr(char const *haystack_start, char const *haystack_end, const char *needle_start); diff --git a/src/link/endpoint.c b/src/link/endpoint.c index 722887ffd..a4348db71 100644 --- a/src/link/endpoint.c +++ b/src/link/endpoint.c @@ -192,7 +192,7 @@ size_t _z_locator_strlen(const _z_locator_t *l) { size_t md_len = _z_locator_metadata_strlen(&l->_metadata); if (md_len > (size_t)0) { ret = ret + (size_t)1; // Locator metadata separator - ret = ret + md_len; // Locator medatada content + ret = ret + md_len; // Locator metadata content } } return ret; diff --git a/src/link/unicast/tcp.c b/src/link/unicast/tcp.c index f05980924..c6af264d2 100644 --- a/src/link/unicast/tcp.c +++ b/src/link/unicast/tcp.c @@ -156,7 +156,7 @@ uint16_t _z_get_link_mtu_tcp(void) { int8_t _z_new_link_tcp(_z_link_t *zl, _z_endpoint_t *endpoint) { int8_t ret = _Z_RES_OK; - zl->_capabilities = Z_LINK_CAPABILITY_RELIEABLE | Z_LINK_CAPABILITY_STREAMED; + zl->_capabilities = Z_LINK_CAPABILITY_RELIABLE | Z_LINK_CAPABILITY_STREAMED; zl->_mtu = _z_get_link_mtu_tcp(); zl->_endpoint = *endpoint; diff --git a/src/link/unicast/ws.c b/src/link/unicast/ws.c index 5d1119d8d..cd7edd673 100644 --- a/src/link/unicast/ws.c +++ b/src/link/unicast/ws.c @@ -157,7 +157,7 @@ uint16_t _z_get_link_mtu_ws(void) { int8_t _z_new_link_ws(_z_link_t *zl, _z_endpoint_t *endpoint) { int8_t ret = _Z_RES_OK; - zl->_capabilities = Z_LINK_CAPABILITY_RELIEABLE; + zl->_capabilities = Z_LINK_CAPABILITY_RELIABLE; zl->_mtu = _z_get_link_mtu_ws(); zl->_endpoint = *endpoint; diff --git a/src/protocol/codec.c b/src/protocol/codec.c index e05d7ba28..a67bd20db 100644 --- a/src/protocol/codec.c +++ b/src/protocol/codec.c @@ -319,7 +319,7 @@ int8_t _z_bytes_val_decode_na(_z_bytes_t *bs, _z_zbuf_t *zbf) { int8_t ret = _Z_RES_OK; if (ret == _Z_RES_OK) { - if (_z_zbuf_len(zbf) >= bs->len) { // Check if we have enought bytes to read + if (_z_zbuf_len(zbf) >= bs->len) { // Check if we have enough bytes to read *bs = _z_bytes_wrap(_z_zbuf_get_rptr(zbf), bs->len); // Decode without allocating _z_zbuf_set_rpos(zbf, _z_zbuf_get_rpos(zbf) + bs->len); // Move the read position } else { diff --git a/src/session/query.c b/src/session/query.c index 17a8667db..52caa9beb 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -201,7 +201,7 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons // No need to store the whole reply in the monotonic mode. _z_reply_t partial_reply; (void)memset(&partial_reply, 0, - sizeof(_z_reply_t)); // Avoid warnings on uninitialised values on the reply + sizeof(_z_reply_t)); // Avoid warnings on uninitialized values on the reply partial_reply.data.sample.keyexpr = _z_keyexpr_duplicate(reply.data.sample.keyexpr); pen_rep->_reply = partial_reply; } else { diff --git a/src/session/resource.c b/src/session/resource.c index d997b5b4b..30c29702e 100644 --- a/src/session/resource.c +++ b/src/session/resource.c @@ -98,7 +98,7 @@ _z_keyexpr_t __z_get_expanded_key_from_key(_z_resource_list_t *xs, const _z_keye // or will release the suffix as well } - // Recursevely go through all the RIDs + // Recursively go through all the RIDs _z_zint_t id = keyexpr->_id; uint16_t mapping = _z_keyexpr_mapping_id(keyexpr); while (id != Z_RESOURCE_ID_NONE) { diff --git a/src/system/arduino/opencr/network.cpp b/src/system/arduino/opencr/network.cpp index 8dfecbcec..1912d7cfb 100644 --- a/src/system/arduino/opencr/network.cpp +++ b/src/system/arduino/opencr/network.cpp @@ -186,7 +186,7 @@ void _z_close_udp_unicast(_z_sys_net_socket_t *sock) { size_t _z_read_udp_unicast(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len) { // Block until something to read - // FIXME: provide somekind of timeout functionality + // FIXME: provide some kind of timeout functionality ssize_t rb = 0; do { rb = sock._udp->parsePacket(); @@ -282,7 +282,7 @@ void _z_close_udp_multicast(_z_sys_net_socket_t *sockrecv, _z_sys_net_socket_t * size_t _z_read_udp_multicast(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len, const _z_sys_net_endpoint_t lep, _z_bytes_t *addr) { // Block until something to read - // FIXME: provide somekind of timeout functionality + // FIXME: provide some kind of timeout functionality ssize_t rb = 0; do { rb = sock._udp->parsePacket(); diff --git a/src/transport/common/tx.c b/src/transport/common/tx.c index a1144be24..f3625250e 100644 --- a/src/transport/common/tx.c +++ b/src/transport/common/tx.c @@ -88,7 +88,7 @@ int8_t _z_link_send_t_msg(const _z_link_t *zl, const _z_transport_message_t *t_m // Encode the session message ret = _z_transport_message_encode(&wbf, t_msg); if (ret == _Z_RES_OK) { - // Write the message legnth in the reserved space if needed + // Write the message length in the reserved space if needed if (_Z_LINK_IS_STREAMED(zl->_capabilities) == true) { size_t len = _z_wbuf_len(&wbf) - _Z_MSG_LEN_ENC_SIZE; for (uint8_t i = 0; i < _Z_MSG_LEN_ENC_SIZE; i++) { diff --git a/src/transport/multicast/link/tx.c b/src/transport/multicast/link/tx.c index 67e4e35bd..991f878f3 100644 --- a/src/transport/multicast/link/tx.c +++ b/src/transport/multicast/link/tx.c @@ -54,7 +54,7 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport // Encode the session message ret = _z_transport_message_encode(&ztm->_wbuf, t_msg); if (ret == _Z_RES_OK) { - // Write the message legnth in the reserved space if needed + // Write the message length in the reserved space if needed __unsafe_z_finalize_wbuf(&ztm->_wbuf, _Z_LINK_IS_STREAMED(ztm->_link._capabilities)); // Send the wbuf on the socket ret = _z_link_send_wbuf(&ztm->_link, &ztm->_wbuf); @@ -105,7 +105,7 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m if (ret == _Z_RES_OK) { ret = _z_network_message_encode(&ztm->_wbuf, n_msg); // Encode the network message if (ret == _Z_RES_OK) { - // Write the message legnth in the reserved space if needed + // Write the message length in the reserved space if needed __unsafe_z_finalize_wbuf(&ztm->_wbuf, _Z_LINK_IS_STREAMED(ztm->_link._capabilities)); ret = _z_link_send_wbuf(&ztm->_link, &ztm->_wbuf); // Send the wbuf on the socket diff --git a/src/transport/unicast/link/rx.c b/src/transport/unicast/link/rx.c index bac48d82e..6604e71ea 100644 --- a/src/transport/unicast/link/rx.c +++ b/src/transport/unicast/link/rx.c @@ -97,7 +97,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans // Check if the SN is correct if (_Z_HAS_FLAG(t_msg->_header, _Z_FLAG_T_FRAME_R) == true) { // @TODO: amend once reliability is in place. For the time being only - // monothonic SNs are ensured + // monotonic SNs are ensured if (_z_sn_precedes(ztu->_sn_res, ztu->_sn_rx_reliable, t_msg->_body._frame._sn) == true) { ztu->_sn_rx_reliable = t_msg->_body._frame._sn; } else { @@ -133,7 +133,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans _Bool drop = false; if ((_z_wbuf_len(dbuf) + t_msg->_body._fragment._payload.len) > Z_FRAG_MAX_SIZE) { - // Filling the wbuf capacity as a way to signling the last fragment to reset the dbuf + // Filling the wbuf capacity as a way to signal the last fragment to reset the dbuf // Otherwise, last (smaller) fragments can be understood as a complete message _z_wbuf_write_bytes(dbuf, t_msg->_body._fragment._payload.start, 0, _z_wbuf_space_left(dbuf)); drop = true; diff --git a/src/transport/unicast/link/tx.c b/src/transport/unicast/link/tx.c index 3375d08e9..8f825b7e4 100644 --- a/src/transport/unicast/link/tx.c +++ b/src/transport/unicast/link/tx.c @@ -57,7 +57,7 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes // Encode the session message ret = _z_transport_message_encode(&ztu->_wbuf, t_msg); if (ret == _Z_RES_OK) { - // Write the message legnth in the reserved space if needed + // Write the message length in the reserved space if needed __unsafe_z_finalize_wbuf(&ztu->_wbuf, _Z_LINK_IS_STREAMED(ztu->_link._capabilities)); // Send the wbuf on the socket ret = _z_link_send_wbuf(&ztu->_link, &ztu->_wbuf); @@ -108,7 +108,7 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg if (ret == _Z_RES_OK) { ret = _z_network_message_encode(&ztu->_wbuf, n_msg); // Encode the network message if (ret == _Z_RES_OK) { - // Write the message legnth in the reserved space if needed + // Write the message length in the reserved space if needed __unsafe_z_finalize_wbuf(&ztu->_wbuf, _Z_LINK_IS_STREAMED(ztu->_link._capabilities)); if (ztu->_wbuf._ioss._len == 1) { diff --git a/tests/z_client_test.c b/tests/z_client_test.c index 80ca3c2e5..0c42ab132 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -199,7 +199,7 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); - // Write data from firt session + // Write data from first session size_t len = MSG_LEN; uint8_t *payload = (uint8_t *)z_malloc(len); memset(payload, 1, MSG_LEN); @@ -256,7 +256,7 @@ int main(int argc, char **argv) { assert(queries >= expected); queries = 0; - // Wait to receive all the expectred replies + // Wait to receive all the expected replies now = z_clock_now(); while (replies < expected) { assert(z_clock_elapsed_s(&now) < TIMEOUT); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 29b05223a..e1ede7104 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) { subs2 = _z_list_push(subs2, sub); } - // Write data from firt session + // Write data from first session size_t len = MSG_LEN; uint8_t *payload = (uint8_t *)z_malloc(len); memset(payload, 1, MSG_LEN); From b2ac6bc1f3d3ade287e7ac0307dea5c793e50211 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 5 Oct 2023 16:21:20 +0200 Subject: [PATCH 2/6] style: add missing disclaimers --- examples/unix/c11/z_ping.c | 14 ++++++++++++++ examples/unix/c11/z_pong.c | 14 ++++++++++++++ examples/unix/c11/z_scout.c | 1 - examples/unix/c99/z_ping.c | 14 ++++++++++++++ examples/unix/c99/z_pong.c | 14 ++++++++++++++ examples/windows/z_ping.c | 14 ++++++++++++++ examples/windows/z_pong.c | 14 ++++++++++++++ examples/windows/z_scout.c | 1 - src/protocol/codec/core.c | 15 +++++++++++++++ src/protocol/core.c | 14 ++++++++++++++ src/protocol/definitions/message.c | 14 ++++++++++++++ src/protocol/definitions/network.c | 14 ++++++++++++++ src/protocol/definitions/transport.c | 14 ++++++++++++++ 13 files changed, 155 insertions(+), 2 deletions(-) diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 4db578c7e..dc9cbf4f7 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include #include #include diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 503c37e25..8acf09564 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "stdio.h" #include "zenoh-pico.h" diff --git a/examples/unix/c11/z_scout.c b/examples/unix/c11/z_scout.c index 751609db1..3a6950aad 100644 --- a/examples/unix/c11/z_scout.c +++ b/examples/unix/c11/z_scout.c @@ -1,4 +1,3 @@ - // // Copyright (c) 2022 ZettaScale Technology // diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 379afd986..cbae19ccb 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include #include #include diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 1f0955d56..53f6d14ee 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "stdio.h" #include "zenoh-pico.h" #include "zenoh-pico/api/primitives.h" diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index fe25ed3c9..dcfb1fc8e 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include #include #include diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index c0d1cd0b0..698c086f7 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "stdio.h" #include "zenoh-pico.h" diff --git a/examples/windows/z_scout.c b/examples/windows/z_scout.c index 8d7feea64..378a61327 100644 --- a/examples/windows/z_scout.c +++ b/examples/windows/z_scout.c @@ -1,4 +1,3 @@ - // // Copyright (c) 2022 ZettaScale Technology // diff --git a/src/protocol/codec/core.c b/src/protocol/codec/core.c index 403c28d8c..90ad38a4a 100644 --- a/src/protocol/codec/core.c +++ b/src/protocol/codec/core.c @@ -1,6 +1,21 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "zenoh-pico/protocol/codec/core.h" #include "zenoh-pico/protocol/iobuf.h" + int8_t _z_zbuf_read_exact(_z_zbuf_t *zbf, uint8_t *dest, size_t length) { if (length > _z_zbuf_len(zbf)) { return _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; diff --git a/src/protocol/core.c b/src/protocol/core.c index c5cfc0c3f..b937f1e89 100644 --- a/src/protocol/core.c +++ b/src/protocol/core.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "zenoh-pico/protocol/core.h" #include "zenoh-pico/api/primitives.h" diff --git a/src/protocol/definitions/message.c b/src/protocol/definitions/message.c index fc6b14491..e3865635f 100644 --- a/src/protocol/definitions/message.c +++ b/src/protocol/definitions/message.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "zenoh-pico/protocol/definitions/message.h" #include "zenoh-pico/collections/bytes.h" diff --git a/src/protocol/definitions/network.c b/src/protocol/definitions/network.c index af852e4e2..56855657c 100644 --- a/src/protocol/definitions/network.c +++ b/src/protocol/definitions/network.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "zenoh-pico/protocol/definitions/network.h" #include "zenoh-pico/api/constants.h" diff --git a/src/protocol/definitions/transport.c b/src/protocol/definitions/transport.c index 3be09369f..6960672a4 100644 --- a/src/protocol/definitions/transport.c +++ b/src/protocol/definitions/transport.c @@ -1,3 +1,17 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + #include "zenoh-pico/protocol/definitions/transport.h" #include "zenoh-pico/collections/bytes.h" From 9a7472d9ff81a352f1b125cffd92cc77c2e40b62 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 5 Oct 2023 16:21:56 +0200 Subject: [PATCH 3/6] chore: run clang-format --- include/zenoh-pico/api/primitives.h | 6 +++--- include/zenoh-pico/link/link.h | 6 +++--- tests/z_keyexpr_test.c | 15 +++++---------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 9b44c2c0e..68861d6f9 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -1142,9 +1142,9 @@ z_queryable_options_t z_queryable_options_default(void); * Parameters: * zs: A loaned instance of the the :c:type:`z_session_t` where to declare the subscriber. * keyexpr: A loaned instance of :c:type:`z_keyexpr_t` to associate with the subscriber. - * callback: A moved instance of :c:type:`z_owned_closure_query_t` containing the callbacks to be called and the context - * to pass to them. options: The options to apply to the queryable. If ``NULL`` is passed, the default options will be - * applied. + * callback: A moved instance of :c:type:`z_owned_closure_query_t` containing the callbacks to be called and the + * context to pass to them. options: The options to apply to the queryable. If ``NULL`` is passed, the default options + * will be applied. * * Returns: * A :c:type:`z_owned_queryable_t` with either a valid queryable or a failing queryable. diff --git a/include/zenoh-pico/link/link.h b/include/zenoh-pico/link/link.h index 10a892982..3f0400b20 100644 --- a/include/zenoh-pico/link/link.h +++ b/include/zenoh-pico/link/link.h @@ -52,10 +52,10 @@ * Z_LINK_CAPABILITY_MULTICAST: Bitmask to define and check if link is multicast. */ typedef enum { - Z_LINK_CAPABILITY_NONE = 0x00, // 0 + Z_LINK_CAPABILITY_NONE = 0x00, // 0 Z_LINK_CAPABILITY_RELIABLE = 0x01, // 1 << 0 - Z_LINK_CAPABILITY_STREAMED = 0x02, // 1 << 1 - Z_LINK_CAPABILITY_MULTICAST = 0x04 // 1 << 2 + Z_LINK_CAPABILITY_STREAMED = 0x02, // 1 << 1 + Z_LINK_CAPABILITY_MULTICAST = 0x04 // 1 << 2 } _z_link_capabilities_t; #define _Z_LINK_IS_RELIABLE(X) ((X & Z_LINK_CAPABILITY_RELIABLE) == Z_LINK_CAPABILITY_RELIABLE) diff --git a/tests/z_keyexpr_test.c b/tests/z_keyexpr_test.c index 9b9567f7a..d4cf921ef 100644 --- a/tests/z_keyexpr_test.c +++ b/tests/z_keyexpr_test.c @@ -20,8 +20,7 @@ #undef NDEBUG #include -int main(void) -{ +int main(void) { assert(_z_keyexpr_intersects("a", strlen("a"), "a", strlen("a"))); assert(_z_keyexpr_intersects("a/b", strlen("a/b"), "a/b", strlen("a/b"))); assert(_z_keyexpr_intersects("*", strlen("*"), "abc", strlen("abc"))); @@ -339,8 +338,7 @@ int main(void) // clang-format on - for (int i = 0; i < N; i++) - { + for (int i = 0; i < N; i++) { const char *ke = input[i]; char *canon = (char *)malloc(128); memset(canon, 0, 128); @@ -350,15 +348,13 @@ int main(void) printf("%s ", ke); printf(" Status: %d : %d\n", status, expected[i]); assert(status == expected[i]); - if (status == Z_KEYEXPR_CANON_SUCCESS) - { + if (status == Z_KEYEXPR_CANON_SUCCESS) { printf(" Match: %.*s : %s\n", (int)canon_len, canon, canonized[i]); assert(strncmp(canonized[i], canon, canon_len) == 0); } } - for (int i = 0; i < N; i++) - { + for (int i = 0; i < N; i++) { const char *ke = input[i]; char *canon = (char *)malloc(128); memset(canon, 0, 128); @@ -368,8 +364,7 @@ int main(void) printf("%s ", ke); printf(" Status: %d : %d", status, expected[i]); assert(status == expected[i]); - if (status == Z_KEYEXPR_CANON_SUCCESS) - { + if (status == Z_KEYEXPR_CANON_SUCCESS) { printf(" Match: %.*s : %s", (int)canon_len, canon, canonized[i]); assert(strcmp(canonized[i], canon) == 0); } From 45e80f7e7053b16bfd7cc6af0cf4efc88a5e50d0 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 5 Oct 2023 16:22:12 +0200 Subject: [PATCH 4/6] chore: remove empty source file --- src/protocol/definitions/core.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/protocol/definitions/core.c diff --git a/src/protocol/definitions/core.c b/src/protocol/definitions/core.c deleted file mode 100644 index e69de29bb..000000000 From c84c0921e50360f6fa35894efbdde71be0ecc399 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 9 Oct 2023 10:05:11 +0200 Subject: [PATCH 5/6] refactor: rename feature config tokens --- extra_script.py | 2 +- include/zenoh-pico/config.h | 162 +++++++++--------- include/zenoh-pico/link/config/bt.h | 2 +- include/zenoh-pico/link/config/serial.h | 2 +- include/zenoh-pico/link/config/tcp.h | 2 +- include/zenoh-pico/link/config/udp.h | 2 +- include/zenoh-pico/link/config/ws.h | 2 +- include/zenoh-pico/link/endpoint.h | 10 +- include/zenoh-pico/link/link.h | 20 +-- include/zenoh-pico/link/manager.h | 12 +- include/zenoh-pico/net/session.h | 8 +- include/zenoh-pico/session/session.h | 4 +- include/zenoh-pico/system/link/bt.h | 2 +- include/zenoh-pico/system/link/serial.h | 2 +- include/zenoh-pico/system/link/tcp.h | 2 +- include/zenoh-pico/system/link/udp.h | 2 +- include/zenoh-pico/system/link/ws.h | 2 +- include/zenoh-pico/system/platform.h | 4 +- .../system/platform/arduino/esp32.h | 16 +- .../system/platform/arduino/opencr.h | 10 +- .../zenoh-pico/system/platform/emscripten.h | 8 +- include/zenoh-pico/system/platform/espidf.h | 10 +- include/zenoh-pico/system/platform/mbed.h | 12 +- include/zenoh-pico/system/platform/unix.h | 8 +- include/zenoh-pico/system/platform/void.h | 4 +- include/zenoh-pico/system/platform/windows.h | 8 +- include/zenoh-pico/system/platform/zephyr.h | 10 +- include/zenoh-pico/transport/transport.h | 16 +- src/api/api.c | 40 ++--- src/link/config/bt.c | 2 +- src/link/config/serial.c | 2 +- src/link/config/tcp.c | 2 +- src/link/config/udp.c | 2 +- src/link/config/ws.c | 2 +- src/link/endpoint.c | 40 ++--- src/link/link.c | 14 +- src/link/multicast/bt.c | 2 +- src/link/multicast/udp.c | 2 +- src/link/unicast/serial.c | 2 +- src/link/unicast/tcp.c | 2 +- src/link/unicast/udp.c | 2 +- src/link/unicast/ws.c | 2 +- src/net/session.c | 46 ++--- src/session/query.c | 48 +++--- src/session/queryable.c | 52 +++--- src/session/resource.c | 56 +++--- src/session/scout.c | 10 +- src/session/subscription.c | 52 +++--- src/session/tx.c | 8 +- src/session/utils.c | 16 +- src/system/arduino/esp32/network.cpp | 12 +- src/system/arduino/esp32/system.c | 4 +- src/system/arduino/opencr/network.cpp | 12 +- src/system/arduino/opencr/system.c | 6 +- src/system/emscripten/network.c | 10 +- src/system/emscripten/system.c | 4 +- src/system/espidf/network.c | 12 +- src/system/espidf/system.c | 4 +- src/system/mbed/network.cpp | 12 +- src/system/mbed/system.cpp | 4 +- src/system/unix/network.c | 12 +- src/system/unix/system.c | 4 +- src/system/windows/network.c | 12 +- src/system/windows/system.c | 4 +- src/system/zephyr/network.c | 14 +- src/system/zephyr/system.c | 4 +- src/transport/common/join.c | 4 +- src/transport/common/lease.c | 16 +- src/transport/common/read.c | 16 +- src/transport/common/tx.c | 12 +- src/transport/manager.c | 16 +- src/transport/multicast/link/rx.c | 22 +-- src/transport/multicast/link/task/join.c | 4 +- src/transport/multicast/link/task/lease.c | 8 +- src/transport/multicast/link/task/read.c | 8 +- src/transport/multicast/link/tx.c | 24 +-- src/transport/transport.c | 100 +++++------ src/transport/unicast/link/rx.c | 12 +- src/transport/unicast/link/task/lease.c | 8 +- src/transport/unicast/link/task/read.c | 8 +- src/transport/unicast/link/tx.c | 24 +-- 81 files changed, 581 insertions(+), 579 deletions(-) diff --git a/extra_script.py b/extra_script.py index 391eb8047..3d4780ca8 100644 --- a/extra_script.py +++ b/extra_script.py @@ -57,7 +57,7 @@ "-", "-", "-"] - CPPDEFINES = ["ZENOH_ARDUINO_OPENCR", "ZENOH_C_STANDARD=99", "Z_MULTI_THREAD=0"] + CPPDEFINES = ["ZENOH_ARDUINO_OPENCR", "ZENOH_C_STANDARD=99", "Z_FEATURE_MULTI_THREAD=0"] elif FRAMEWORK == 'espidf': SRC_FILTER = ["+<*>", diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h index 21fa2063a..fa2a3ff2a 100644 --- a/include/zenoh-pico/config.h +++ b/include/zenoh-pico/config.h @@ -102,117 +102,148 @@ #define Z_CONFIG_ADD_TIMESTAMP_KEY 0x4A #define Z_CONFIG_ADD_TIMESTAMP_DEFAULT "false" -/*------------------ Compile-time configuration properties ------------------*/ +/*------------------ Compile-time feature configuration ------------------*/ + /** - * Default length for Zenoh ID. Maximum size is 16 bytes. - * This configuration will only be applied to Zenoh IDs generated by Zenoh-Pico. + * Enable multi-thread support. */ -#ifndef Z_ZID_LENGTH -#define Z_ZID_LENGTH 16 +#ifndef Z_FEATURE_MULTI_THREAD +#define Z_FEATURE_MULTI_THREAD 1 #endif -#ifndef Z_TSID_LENGTH -#define Z_TSID_LENGTH 16 +/** + * Enable dynamic memory allocation. + */ +#ifndef Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION +#define Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION 0 #endif /** - * Protocol version identifier. - * Do not change this value. + * Enable TCP links. */ -#ifndef Z_PROTO_VERSION -#define Z_PROTO_VERSION 0x08 +#ifndef Z_FEATURE_LINK_TCP +#define Z_FEATURE_LINK_TCP 1 #endif /** - * Default session lease in milliseconds. + * Enable Bluetooth links. */ -#ifndef Z_TRANSPORT_LEASE -#define Z_TRANSPORT_LEASE 10000 +#ifndef Z_FEATURE_LINK_BLUETOOTH +#define Z_FEATURE_LINK_BLUETOOTH 0 #endif /** - * Default session lease expire factor. + * Enable WebSocket links. */ -#ifndef Z_TRANSPORT_LEASE_EXPIRE_FACTOR -#define Z_TRANSPORT_LEASE_EXPIRE_FACTOR 3.5 +#ifndef Z_FEATURE_LINK_WS +#define Z_FEATURE_LINK_WS 0 #endif /** - * Default multicast session join interval in milliseconds. + * Enable Serial links. */ -#ifndef Z_JOIN_INTERVAL -#define Z_JOIN_INTERVAL 2500 +#ifndef Z_FEATURE_LINK_SERIAL +#define Z_FEATURE_LINK_SERIAL 0 #endif /** - * Default socket timeout in milliseconds. + * Enable UDP Scouting. */ -#ifndef Z_CONFIG_SOCKET_TIMEOUT -#define Z_CONFIG_SOCKET_TIMEOUT 100 +#ifndef Z_FEATURE_SCOUTING_UDP +#define Z_FEATURE_SCOUTING_UDP 1 #endif -#ifndef Z_SN_RESOLUTION -#define Z_SN_RESOLUTION 0x02 +/** + * Enable UDP Multicast links. + */ +#ifndef Z_FEATURE_LINK_UDP_MULTICAST +#define Z_FEATURE_LINK_UDP_MULTICAST 1 #endif -#ifndef Z_REQ_RESOLUTION -#define Z_REQ_RESOLUTION 0x02 +/** + * Enable UDP Unicast links. + */ +#ifndef Z_FEATURE_LINK_UDP_UNICAST +#define Z_FEATURE_LINK_UDP_UNICAST 1 #endif /** - * Enable multi-thread support. + * Enable Multicast Transport. */ -#ifndef Z_MULTI_THREAD -#define Z_MULTI_THREAD 1 +#ifndef Z_FEATURE_MULTICAST_TRANSPORT +#if Z_FEATURE_SCOUTING_UDP == 0 && Z_FEATURE_LINK_BLUETOOTH == 0 && Z_FEATURE_LINK_UDP_MULTICAST == 0 +#define Z_FEATURE_MULTICAST_TRANSPORT 0 +#else +#define Z_FEATURE_MULTICAST_TRANSPORT 1 +#endif #endif /** - * Enable TCP links. + * Enable Unicast Transport. */ -#ifndef Z_LINK_TCP -#define Z_LINK_TCP 1 +#ifndef Z_FEATURE_UNICAST_TRANSPORT +#if Z_FEATURE_LINK_TCP == 0 && Z_FEATURE_LINK_UDP_UNICAST == 0 && Z_FEATURE_LINK_SERIAL == 0 && Z_FEATURE_LINK_WS == 0 +#define Z_FEATURE_UNICAST_TRANSPORT 0 +#else +#define Z_FEATURE_UNICAST_TRANSPORT 1 +#endif #endif +/*------------------ Compile-time configuration properties ------------------*/ /** - * Enable UDP Multicast links. + * Default length for Zenoh ID. Maximum size is 16 bytes. + * This configuration will only be applied to Zenoh IDs generated by Zenoh-Pico. */ -#ifndef Z_LINK_UDP_MULTICAST -#define Z_LINK_UDP_MULTICAST 1 +#ifndef Z_ZID_LENGTH +#define Z_ZID_LENGTH 16 +#endif + +#ifndef Z_TSID_LENGTH +#define Z_TSID_LENGTH 16 #endif /** - * Enable UDP Unicast links. + * Protocol version identifier. + * Do not change this value. */ -#ifndef Z_LINK_UDP_UNICAST -#define Z_LINK_UDP_UNICAST 1 +#ifndef Z_PROTO_VERSION +#define Z_PROTO_VERSION 0x08 #endif /** - * Enable Bluetooth links. + * Default session lease in milliseconds. */ -#ifndef Z_LINK_BLUETOOTH -#define Z_LINK_BLUETOOTH 0 +#ifndef Z_TRANSPORT_LEASE +#define Z_TRANSPORT_LEASE 10000 #endif /** - * Enable Serial links. + * Default session lease expire factor. */ -#ifndef Z_LINK_SERIAL -#define Z_LINK_SERIAL 0 +#ifndef Z_TRANSPORT_LEASE_EXPIRE_FACTOR +#define Z_TRANSPORT_LEASE_EXPIRE_FACTOR 3.5 #endif /** - * Enable WebSocket links. + * Default multicast session join interval in milliseconds. */ -#ifndef Z_LINK_WS -#define Z_LINK_WS 0 +#ifndef Z_JOIN_INTERVAL +#define Z_JOIN_INTERVAL 2500 #endif /** - * Enable UDP Scouting. + * Default socket timeout in milliseconds. */ -#ifndef Z_SCOUTING_UDP -#define Z_SCOUTING_UDP 1 +#ifndef Z_CONFIG_SOCKET_TIMEOUT +#define Z_CONFIG_SOCKET_TIMEOUT 100 +#endif + +#ifndef Z_SN_RESOLUTION +#define Z_SN_RESOLUTION 0x02 +#endif + +#ifndef Z_REQ_RESOLUTION +#define Z_REQ_RESOLUTION 0x02 #endif /** @@ -242,33 +273,4 @@ #define Z_FRAG_MAX_SIZE 300000 #endif -/** - * Enable dynamic memory allocation. - */ -#ifndef Z_DYNAMIC_MEMORY_ALLOCATION -#define Z_DYNAMIC_MEMORY_ALLOCATION 0 -#endif - -/** - * Enable Multicast Transport. - */ -#ifndef Z_MULTICAST_TRANSPORT -#if Z_SCOUTING_UDP == 0 && Z_LINK_BLUETOOTH == 0 && Z_LINK_UDP_MULTICAST == 0 -#define Z_MULTICAST_TRANSPORT 0 -#else -#define Z_MULTICAST_TRANSPORT 1 -#endif -#endif - -/** - * Enable Unicast Transport. - */ -#ifndef Z_UNICAST_TRANSPORT -#if Z_LINK_TCP == 0 && Z_LINK_UDP_UNICAST == 0 && Z_LINK_SERIAL == 0 && Z_LINK_WS == 0 -#define Z_UNICAST_TRANSPORT 0 -#else -#define Z_UNICAST_TRANSPORT 1 -#endif -#endif - #endif /* INCLUDE_ZENOH_PICO_CONFIG_H */ diff --git a/include/zenoh-pico/link/config/bt.h b/include/zenoh-pico/link/config/bt.h index ae24fa245..40827e76c 100644 --- a/include/zenoh-pico/link/config/bt.h +++ b/include/zenoh-pico/link/config/bt.h @@ -19,7 +19,7 @@ #include "zenoh-pico/config.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #define BT_CONFIG_ARGC 3 diff --git a/include/zenoh-pico/link/config/serial.h b/include/zenoh-pico/link/config/serial.h index 3b5fd16a6..85270be62 100644 --- a/include/zenoh-pico/link/config/serial.h +++ b/include/zenoh-pico/link/config/serial.h @@ -20,7 +20,7 @@ #include "zenoh-pico/config.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #define SERIAL_CONFIG_ARGC 1 diff --git a/include/zenoh-pico/link/config/tcp.h b/include/zenoh-pico/link/config/tcp.h index a5d758544..ed57e7700 100644 --- a/include/zenoh-pico/link/config/tcp.h +++ b/include/zenoh-pico/link/config/tcp.h @@ -19,7 +19,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/config.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 #define TCP_CONFIG_ARGC 1 diff --git a/include/zenoh-pico/link/config/udp.h b/include/zenoh-pico/link/config/udp.h index 877896493..ab8875d5e 100644 --- a/include/zenoh-pico/link/config/udp.h +++ b/include/zenoh-pico/link/config/udp.h @@ -18,7 +18,7 @@ #include "zenoh-pico/collections/intmap.h" #include "zenoh-pico/collections/string.h" -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 #define UDP_CONFIG_ARGC 3 diff --git a/include/zenoh-pico/link/config/ws.h b/include/zenoh-pico/link/config/ws.h index 1551bc31e..82ef8d596 100644 --- a/include/zenoh-pico/link/config/ws.h +++ b/include/zenoh-pico/link/config/ws.h @@ -19,7 +19,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/config.h" -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 #define WS_CONFIG_TOUT_KEY 0x01 #define WS_CONFIG_TOUT_STR "tout" diff --git a/include/zenoh-pico/link/endpoint.h b/include/zenoh-pico/link/endpoint.h index c3cf1b42a..bd7c8cbc3 100644 --- a/include/zenoh-pico/link/endpoint.h +++ b/include/zenoh-pico/link/endpoint.h @@ -22,19 +22,19 @@ #include "zenoh-pico/utils/result.h" /*------------------ Locator ------------------*/ -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 #define TCP_SCHEMA "tcp" #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 #define UDP_SCHEMA "udp" #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #define BT_SCHEMA "bt" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #define SERIAL_SCHEMA "serial" #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 #define WS_SCHEMA "ws" #endif diff --git a/include/zenoh-pico/link/link.h b/include/zenoh-pico/link/link.h index 3f0400b20..9a49f2862 100644 --- a/include/zenoh-pico/link/link.h +++ b/include/zenoh-pico/link/link.h @@ -20,23 +20,23 @@ #include "zenoh-pico/protocol/iobuf.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 #include "zenoh-pico/system/link/tcp.h" #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 #include "zenoh-pico/system/link/udp.h" #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #include "zenoh-pico/system/link/bt.h" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #include "zenoh-pico/system/link/serial.h" #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 #include "zenoh-pico/system/link/ws.h" #endif @@ -77,19 +77,19 @@ typedef struct _z_link_t { _z_endpoint_t _endpoint; union { -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 _z_tcp_socket_t _tcp; #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 _z_udp_socket_t _udp; #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 _z_bt_socket_t _bt; #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 _z_serial_socket_t _serial; #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 _z_ws_socket_t _ws; #endif } _socket; diff --git a/include/zenoh-pico/link/manager.h b/include/zenoh-pico/link/manager.h index fefeea002..f494784e4 100644 --- a/include/zenoh-pico/link/manager.h +++ b/include/zenoh-pico/link/manager.h @@ -19,27 +19,27 @@ #include "zenoh-pico/config.h" #include "zenoh-pico/link/link.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 int8_t _z_endpoint_tcp_valid(_z_endpoint_t *ep); int8_t _z_new_link_tcp(_z_link_t *zl, _z_endpoint_t *ep); #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_endpoint_udp_unicast_valid(_z_endpoint_t *ep); int8_t _z_new_link_udp_unicast(_z_link_t *zl, _z_endpoint_t ep); #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_endpoint_udp_multicast_valid(_z_endpoint_t *ep); int8_t _z_new_link_udp_multicast(_z_link_t *zl, _z_endpoint_t ep); #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 int8_t _z_endpoint_bt_valid(_z_endpoint_t *ep); int8_t _z_new_link_bt(_z_link_t *zl, _z_endpoint_t ep); #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 int8_t _z_endpoint_serial_valid(_z_endpoint_t *ep); int8_t _z_new_link_serial(_z_link_t *zl, _z_endpoint_t ep); #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 int8_t _z_endpoint_ws_valid(_z_endpoint_t *ep); int8_t _z_new_link_ws(_z_link_t *zl, _z_endpoint_t *ep); #endif diff --git a/include/zenoh-pico/net/session.h b/include/zenoh-pico/net/session.h index bebe7608c..a23fb84dc 100644 --- a/include/zenoh-pico/net/session.h +++ b/include/zenoh-pico/net/session.h @@ -28,9 +28,9 @@ * A zenoh-net session. */ typedef struct { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_t _mutex_inner; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Zenoh-pico is considering a single transport per session. _z_transport_t _tp; @@ -122,7 +122,7 @@ int8_t _zp_send_keep_alive(_z_session_t *z); */ int8_t _zp_send_join(_z_session_t *z); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /** * Start a separate task to read from the network and process the messages * as soon as they are received. Note that the task can be implemented in @@ -172,6 +172,6 @@ int8_t _zp_start_lease_task(_z_session_t *z); * ``0`` in case of success, ``-1`` in case of failure. */ int8_t _zp_stop_lease_task(_z_session_t *z); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 #endif /* INCLUDE_ZENOH_PICO_NET_SESSION_H */ diff --git a/include/zenoh-pico/session/session.h b/include/zenoh-pico/session/session.h index 8b394e844..a6102da23 100644 --- a/include/zenoh-pico/session/session.h +++ b/include/zenoh-pico/session/session.h @@ -170,10 +170,10 @@ _Z_ELEM_DEFINE(_z_pending_query, _z_pending_query_t, _z_noop_size, _z_pending_qu _Z_LIST_DEFINE(_z_pending_query, _z_pending_query_t) typedef struct { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_t _mutex; _z_condvar_t _cond_var; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_reply_data_list_t *_replies; } _z_pending_query_collect_t; diff --git a/include/zenoh-pico/system/link/bt.h b/include/zenoh-pico/system/link/bt.h index 86fe2bbcf..b155e34b3 100644 --- a/include/zenoh-pico/system/link/bt.h +++ b/include/zenoh-pico/system/link/bt.h @@ -19,7 +19,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/config.h" -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #ifdef __cplusplus extern "C" { diff --git a/include/zenoh-pico/system/link/serial.h b/include/zenoh-pico/system/link/serial.h index 1fa81c7af..954fd2911 100644 --- a/include/zenoh-pico/system/link/serial.h +++ b/include/zenoh-pico/system/link/serial.h @@ -21,7 +21,7 @@ #include "zenoh-pico/config.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #define _Z_SERIAL_MTU_SIZE 1500 #define _Z_SERIAL_MFS_SIZE _Z_SERIAL_MTU_SIZE + 2 + 4 // MTU + Serial Len + Serial CRC32 diff --git a/include/zenoh-pico/system/link/tcp.h b/include/zenoh-pico/system/link/tcp.h index 382b8b7de..e90b688eb 100644 --- a/include/zenoh-pico/system/link/tcp.h +++ b/include/zenoh-pico/system/link/tcp.h @@ -20,7 +20,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 typedef struct { _z_sys_net_socket_t _sock; diff --git a/include/zenoh-pico/system/link/udp.h b/include/zenoh-pico/system/link/udp.h index a154c20f0..8b6957812 100644 --- a/include/zenoh-pico/system/link/udp.h +++ b/include/zenoh-pico/system/link/udp.h @@ -20,7 +20,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 typedef struct { _z_sys_net_socket_t _sock; diff --git a/include/zenoh-pico/system/link/ws.h b/include/zenoh-pico/system/link/ws.h index feab79328..52edd2f11 100644 --- a/include/zenoh-pico/system/link/ws.h +++ b/include/zenoh-pico/system/link/ws.h @@ -20,7 +20,7 @@ #include "zenoh-pico/collections/string.h" #include "zenoh-pico/system/platform.h" -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 typedef struct { _z_sys_net_socket_t _sock; diff --git a/include/zenoh-pico/system/platform.h b/include/zenoh-pico/system/platform.h index 07e1f009e..4a8697800 100644 --- a/include/zenoh-pico/system/platform.h +++ b/include/zenoh-pico/system/platform.h @@ -56,7 +56,7 @@ void *z_malloc(size_t size); void *z_realloc(void *ptr, size_t size); void z_free(void *ptr); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Thread ------------------*/ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg); int8_t _z_task_join(_z_task_t *task); @@ -77,7 +77,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv); int8_t _z_condvar_signal(_z_condvar_t *cv); int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time); diff --git a/include/zenoh-pico/system/platform/arduino/esp32.h b/include/zenoh-pico/system/platform/arduino/esp32.h index bac42aa72..569efe46f 100644 --- a/include/zenoh-pico/system/platform/arduino/esp32.h +++ b/include/zenoh-pico/system/platform/arduino/esp32.h @@ -19,16 +19,16 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 #include -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef TaskHandle_t _z_task_t; typedef void *_z_task_attr_t; // Not used in ESP32 typedef pthread_mutex_t _z_mutex_t; typedef pthread_cond_t _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; typedef struct timeval z_time_t; @@ -38,13 +38,13 @@ typedef struct HardwareSerial HardwareSerial; // Forward declaration to be us typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 int _fd; #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 BluetoothSerial *_bts; // As pointer to cross the boundary between C and C++ #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 HardwareSerial *_serial; // As pointer to cross the boundary between C and C++ #endif }; @@ -52,7 +52,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 struct addrinfo *_iptcp; #endif }; diff --git a/include/zenoh-pico/system/platform/arduino/opencr.h b/include/zenoh-pico/system/platform/arduino/opencr.h index 23c43f222..2a7488775 100644 --- a/include/zenoh-pico/system/platform/arduino/opencr.h +++ b/include/zenoh-pico/system/platform/arduino/opencr.h @@ -20,12 +20,12 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef void *_z_task_t; typedef void *_z_task_attr_t; typedef void *_z_mutex_t; typedef void *_z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; typedef struct timeval z_time_t; @@ -36,10 +36,10 @@ typedef struct WiFiUDP WiFiUDP; // Forward declaration to be used in _z_s typedef struct { union { -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 WiFiClient *_tcp; // As pointer to cross the boundary between C and C++ #endif -#if Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 WiFiUDP *_udp; // As pointer to cross the boundary between C and C++ #endif _Bool _err; @@ -53,7 +53,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 __z_net_iptcp_addr_t _iptcp; #endif }; diff --git a/include/zenoh-pico/system/platform/emscripten.h b/include/zenoh-pico/system/platform/emscripten.h index a2f340921..fcb732aab 100644 --- a/include/zenoh-pico/system/platform/emscripten.h +++ b/include/zenoh-pico/system/platform/emscripten.h @@ -20,19 +20,19 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef pthread_t _z_task_t; typedef pthread_attr_t _z_task_attr_t; typedef pthread_mutex_t _z_mutex_t; typedef pthread_cond_t _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef double z_clock_t; typedef double z_time_t; typedef struct { union { -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 struct { int _fd; uint32_t _tout; @@ -43,7 +43,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 struct addrinfo *_iptcp; #endif }; diff --git a/include/zenoh-pico/system/platform/espidf.h b/include/zenoh-pico/system/platform/espidf.h index 6c35dd1f0..2ba7773d7 100644 --- a/include/zenoh-pico/system/platform/espidf.h +++ b/include/zenoh-pico/system/platform/espidf.h @@ -22,22 +22,22 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef TaskHandle_t _z_task_t; typedef void *_z_task_attr_t; // Not used in ESP32 typedef pthread_mutex_t _z_mutex_t; typedef pthread_cond_t _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; typedef struct timeval z_time_t; typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 int _fd; #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 uart_port_t _serial; #endif }; @@ -45,7 +45,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 struct addrinfo *_iptcp; #endif }; diff --git a/include/zenoh-pico/system/platform/mbed.h b/include/zenoh-pico/system/platform/mbed.h index ca10d0459..ba18844e8 100644 --- a/include/zenoh-pico/system/platform/mbed.h +++ b/include/zenoh-pico/system/platform/mbed.h @@ -22,12 +22,12 @@ typedef int _z_socket_t; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef void *_z_task_t; // Workaround as MBED is a C++ library typedef void *_z_task_attr_t; // Workaround as MBED is a C++ library typedef void *_z_mutex_t; // Workaround as MBED is a C++ library typedef void *_z_condvar_t; // Workaround as MBED is a C++ library -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef void *z_clock_t; // Not defined typedef struct timeval z_time_t; @@ -40,13 +40,13 @@ typedef struct SocketAddress SocketAddress; // Forward declaration to be used typedef struct { _Bool _err; union { -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 TCPSocket *_tcp; // As pointer to cross the boundary between C and C++ #endif -#if Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 UDPSocket *_udp; // As pointer to cross the boundary between C and C++ #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 BufferedSerial *_serial; // As pointer to cross the boundary between C and C++ #endif }; @@ -55,7 +55,7 @@ typedef struct { typedef struct { _Bool _err; union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 SocketAddress *_iptcp; // As pointer to cross the boundary between C and C++ #endif }; diff --git a/include/zenoh-pico/system/platform/unix.h b/include/zenoh-pico/system/platform/unix.h index 3faa48333..8084e22db 100644 --- a/include/zenoh-pico/system/platform/unix.h +++ b/include/zenoh-pico/system/platform/unix.h @@ -23,19 +23,19 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef pthread_t _z_task_t; typedef pthread_attr_t _z_task_attr_t; typedef pthread_mutex_t _z_mutex_t; typedef pthread_cond_t _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; typedef struct timeval z_time_t; typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 int _fd; #endif }; @@ -43,7 +43,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 struct addrinfo *_iptcp; #endif }; diff --git a/include/zenoh-pico/system/platform/void.h b/include/zenoh-pico/system/platform/void.h index 26197d375..8bebe22f2 100644 --- a/include/zenoh-pico/system/platform/void.h +++ b/include/zenoh-pico/system/platform/void.h @@ -17,12 +17,12 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef void *_z_task_t; typedef void *_z_task_attr_t; typedef void *_z_mutex_t; typedef void *_z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef void *z_clock_t; typedef void *z_time_t; diff --git a/include/zenoh-pico/system/platform/windows.h b/include/zenoh-pico/system/platform/windows.h index f7c7d1ccb..fa5aff62d 100644 --- a/include/zenoh-pico/system/platform/windows.h +++ b/include/zenoh-pico/system/platform/windows.h @@ -20,19 +20,19 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef HANDLE *_z_task_t; typedef void *_z_task_attr_t; // Not used in Windows typedef SRWLOCK _z_mutex_t; typedef CONDITION_VARIABLE _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timeb z_clock_t; typedef struct timeb z_time_t; typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 SOCKET _fd; #endif } _sock; @@ -40,7 +40,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 struct addrinfo *_iptcp; #endif } _ep; diff --git a/include/zenoh-pico/system/platform/zephyr.h b/include/zenoh-pico/system/platform/zephyr.h index 4b318c9d9..c0ad3c378 100644 --- a/include/zenoh-pico/system/platform/zephyr.h +++ b/include/zenoh-pico/system/platform/zephyr.h @@ -30,22 +30,22 @@ #include "zenoh-pico/config.h" -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 typedef pthread_t _z_task_t; typedef pthread_attr_t _z_task_attr_t; typedef pthread_mutex_t _z_mutex_t; typedef pthread_cond_t _z_condvar_t; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; typedef struct timeval z_time_t; typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 int _fd; #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 const struct device *_serial; #endif }; @@ -53,7 +53,7 @@ typedef struct { typedef struct { union { -#if Z_LINK_TCP == 1 || Z_LINK_UDP_MULTICAST == 1 || Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 struct addrinfo *_iptcp; #endif }; diff --git a/include/zenoh-pico/transport/transport.h b/include/zenoh-pico/transport/transport.h index 1982b1b92..6996f4b5a 100644 --- a/include/zenoh-pico/transport/transport.h +++ b/include/zenoh-pico/transport/transport.h @@ -56,11 +56,11 @@ _z_transport_peer_entry_list_t *_z_transport_peer_entry_list_insert(_z_transport typedef struct { // Session associated to the transport -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // TX and RX mutexes _z_mutex_t _mutex_rx; _z_mutex_t _mutex_tx; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_link_t _link; @@ -82,12 +82,12 @@ typedef struct { void *_session; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_task_t *_read_task; _z_task_t *_lease_task; volatile _Bool _read_task_running; volatile _Bool _lease_task_running; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 volatile _Bool _received; volatile _Bool _transmitted; @@ -97,14 +97,14 @@ typedef struct { // Session associated to the transport void *_session; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // TX and RX mutexes _z_mutex_t _mutex_rx; _z_mutex_t _mutex_tx; // Peer list mutex _z_mutex_t _mutex_peer; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_link_t _link; @@ -121,12 +121,12 @@ typedef struct { // Known valid peers _z_transport_peer_entry_list_t *_peers; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_task_t *_read_task; _z_task_t *_lease_task; volatile _Bool _read_task_running; volatile _Bool _lease_task_running; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 volatile _Bool _transmitted; } _z_transport_multicast_t; diff --git a/src/api/api.c b/src/api/api.c index db8d725e9..b673e3659 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -561,7 +561,7 @@ int8_t z_info_peers_zid(const z_session_t zs, z_owned_closure_zid_t *callback) { void *ctx = callback->context; callback->context = NULL; -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zs._val->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { _z_transport_peer_entry_list_t *l = zs._val->_tp._transport._multicast._peers; for (; l != NULL; l = _z_transport_peer_entry_list_tail(l)) { @@ -573,7 +573,7 @@ int8_t z_info_peers_zid(const z_session_t zs, z_owned_closure_zid_t *callback) { } #else (void)zs; -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 if (callback->drop != NULL) { callback->drop(ctx); @@ -586,12 +586,12 @@ int8_t z_info_routers_zid(const z_session_t zs, z_owned_closure_zid_t *callback) void *ctx = callback->context; callback->context = NULL; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zs._val->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { z_id_t id = zs._val->_tp._transport._unicast._remote_zid; callback->call(&id, ctx); } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 if (callback->drop != NULL) { callback->drop(ctx); @@ -739,17 +739,17 @@ z_owned_publisher_t z_declare_publisher(z_session_t zs, z_keyexpr_t keyexpr, con // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { uint16_t id = _z_declare_resource(zs._val, keyexpr); key = _z_rid_with_suffix(id, NULL); } -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 z_publisher_options_t opt = z_publisher_options_default(); if (options != NULL) { @@ -815,9 +815,9 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { char *wild = strpbrk(keyexpr._suffix, "*$"); @@ -833,9 +833,9 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z uint16_t id = _z_declare_resource(zs._val, keyexpr); key = _z_rid_with_suffix(id, wild); } -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_subinfo_t subinfo = _z_subinfo_push_default(); if (options != NULL) { @@ -904,17 +904,17 @@ z_owned_queryable_t z_declare_queryable(z_session_t zs, z_keyexpr_t keyexpr, z_o // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { uint16_t id = _z_declare_resource(zs._val, keyexpr); key = _z_rid_with_suffix(id, NULL); } -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 z_queryable_options_t opt = z_queryable_options_default(); if (options != NULL) { @@ -970,7 +970,7 @@ zp_task_read_options_t zp_task_read_options_default(void) { return (zp_task_read int8_t zp_start_read_task(z_session_t zs, const zp_task_read_options_t *options) { (void)(options); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 return _zp_start_read_task(zs._val); #else (void)(zs); @@ -979,7 +979,7 @@ int8_t zp_start_read_task(z_session_t zs, const zp_task_read_options_t *options) } int8_t zp_stop_read_task(z_session_t zs) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 return _zp_stop_read_task(zs._val); #else (void)(zs); @@ -991,7 +991,7 @@ zp_task_lease_options_t zp_task_lease_options_default(void) { return (zp_task_le int8_t zp_start_lease_task(z_session_t zs, const zp_task_lease_options_t *options) { (void)(options); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 return _zp_start_lease_task(zs._val); #else (void)(zs); @@ -1000,7 +1000,7 @@ int8_t zp_start_lease_task(z_session_t zs, const zp_task_lease_options_t *option } int8_t zp_stop_lease_task(z_session_t zs) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 return _zp_stop_lease_task(zs._val); #else (void)(zs); diff --git a/src/link/config/bt.c b/src/link/config/bt.c index 989817cac..0c633b7cc 100644 --- a/src/link/config/bt.c +++ b/src/link/config/bt.c @@ -15,7 +15,7 @@ #include -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 size_t _z_bt_config_strlen(const _z_str_intmap_t *s) { BT_CONFIG_MAPPING_BUILD diff --git a/src/link/config/serial.c b/src/link/config/serial.c index c0608195d..876174f79 100644 --- a/src/link/config/serial.c +++ b/src/link/config/serial.c @@ -16,7 +16,7 @@ #include -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 size_t _z_serial_config_strlen(const _z_str_intmap_t *s) { SERIAL_CONFIG_MAPPING_BUILD diff --git a/src/link/config/tcp.c b/src/link/config/tcp.c index e5ad017ae..0da276204 100644 --- a/src/link/config/tcp.c +++ b/src/link/config/tcp.c @@ -18,7 +18,7 @@ #include "zenoh-pico/config.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 size_t _z_tcp_config_strlen(const _z_str_intmap_t *s) { TCP_CONFIG_MAPPING_BUILD diff --git a/src/link/config/udp.c b/src/link/config/udp.c index 3629f25be..3dc5f06c6 100644 --- a/src/link/config/udp.c +++ b/src/link/config/udp.c @@ -18,7 +18,7 @@ #include "zenoh-pico/config.h" -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 size_t _z_udp_config_strlen(const _z_str_intmap_t *s) { UDP_CONFIG_MAPPING_BUILD diff --git a/src/link/config/ws.c b/src/link/config/ws.c index ae876596b..14e4c113c 100644 --- a/src/link/config/ws.c +++ b/src/link/config/ws.c @@ -18,7 +18,7 @@ #include "zenoh-pico/config.h" -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 size_t _z_ws_config_strlen(const _z_str_intmap_t *s) { WS_CONFIG_MAPPING_BUILD diff --git a/src/link/endpoint.c b/src/link/endpoint.c index a4348db71..d06a67158 100644 --- a/src/link/endpoint.c +++ b/src/link/endpoint.c @@ -20,19 +20,19 @@ #include "zenoh-pico/config.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 #include "zenoh-pico/link/config/tcp.h" #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 #include "zenoh-pico/link/config/udp.h" #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #include "zenoh-pico/link/config/bt.h" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #include "zenoh-pico/link/config/serial.h" #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 #include "zenoh-pico/link/config/ws.h" #endif /*------------------ Locator ------------------*/ @@ -292,27 +292,27 @@ int8_t _z_endpoint_config_from_str(_z_str_intmap_t *strint, const char *str, con p_start = _z_ptr_char_offset(p_start, 1); // Call the right configuration parser depending on the protocol -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 if (_z_str_eq(proto, TCP_SCHEMA) == true) { ret = _z_tcp_config_from_str(strint, p_start); } else #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 if (_z_str_eq(proto, UDP_SCHEMA) == true) { ret = _z_udp_config_from_str(strint, p_start); } else #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 if (_z_str_eq(proto, BT_SCHEMA) == true) { ret = _z_bt_config_from_str(strint, p_start); } else #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 if (_z_str_eq(proto, SERIAL_SCHEMA) == true) { ret = _z_serial_config_from_str(strint, p_start); } else #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 if (_z_str_eq(proto, WS_SCHEMA) == true) { ret = _z_ws_config_from_str(strint, p_start); } else @@ -329,27 +329,27 @@ size_t _z_endpoint_config_strlen(const _z_str_intmap_t *s, const char *proto) { size_t len = 0; // Call the right configuration parser depending on the protocol -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 if (_z_str_eq(proto, TCP_SCHEMA) == true) { len = _z_tcp_config_strlen(s); } else #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 if (_z_str_eq(proto, UDP_SCHEMA) == true) { len = _z_udp_config_strlen(s); } else #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 if (_z_str_eq(proto, BT_SCHEMA) == true) { len = _z_bt_config_strlen(s); } else #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 if (_z_str_eq(proto, SERIAL_SCHEMA) == true) { len = _z_serial_config_strlen(s); } else #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 if (_z_str_eq(proto, WS_SCHEMA) == true) { len = _z_ws_config_strlen(s); } else @@ -365,27 +365,27 @@ char *_z_endpoint_config_to_str(const _z_str_intmap_t *s, const char *proto) { char *res = NULL; // Call the right configuration parser depending on the protocol -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 if (_z_str_eq(proto, TCP_SCHEMA) == true) { res = _z_tcp_config_to_str(s); } else #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 if (_z_str_eq(proto, UDP_SCHEMA) == true) { res = _z_udp_config_to_str(s); } else #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 if (_z_str_eq(proto, BT_SCHEMA) == true) { res = _z_bt_config_to_str(s); } else #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 if (_z_str_eq(proto, SERIAL_SCHEMA) == true) { res = _z_serial_config_to_str(s); } else #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 if (_z_str_eq(proto, WS_SCHEMA) == true) { res = _z_ws_config_to_str(s); } else diff --git a/src/link/link.c b/src/link/link.c index 5c409e353..1a5f89925 100644 --- a/src/link/link.c +++ b/src/link/link.c @@ -28,27 +28,27 @@ int8_t _z_open_link(_z_link_t *zl, const char *locator) { if (ret == _Z_RES_OK) { // TODO[peer]: when peer unicast mode is supported, this must be revisited // Create transport link -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 if (_z_endpoint_tcp_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_tcp(zl, &ep); } else #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 if (_z_endpoint_udp_unicast_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_udp_unicast(zl, ep); } else #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 if (_z_endpoint_bt_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_bt(zl, ep); } else #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 if (_z_endpoint_serial_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_serial(zl, ep); } else #endif -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 if (_z_endpoint_ws_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_ws(zl, &ep); } else @@ -82,12 +82,12 @@ int8_t _z_listen_link(_z_link_t *zl, const char *locator) { if (ret == _Z_RES_OK) { // TODO[peer]: when peer unicast mode is supported, this must be revisited // Create transport link -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 if (_z_endpoint_udp_multicast_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_udp_multicast(zl, ep); } else #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 if (_z_endpoint_bt_valid(&ep) == _Z_RES_OK) { ret = _z_new_link_bt(zl, ep); } else diff --git a/src/link/multicast/bt.c b/src/link/multicast/bt.c index e269d420e..332e5f9fa 100644 --- a/src/link/multicast/bt.c +++ b/src/link/multicast/bt.c @@ -20,7 +20,7 @@ #include "zenoh-pico/link/manager.h" #include "zenoh-pico/system/link/bt.h" -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #define SPP_MAXIMUM_PAYLOAD 128 diff --git a/src/link/multicast/udp.c b/src/link/multicast/udp.c index 981b1a37f..bcb2a4dc8 100644 --- a/src/link/multicast/udp.c +++ b/src/link/multicast/udp.c @@ -23,7 +23,7 @@ #include "zenoh-pico/system/link/udp.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 char *__z_parse_port_segment_udp_multicast(const char *address) { char *ret = NULL; diff --git a/src/link/unicast/serial.c b/src/link/unicast/serial.c index 40cdbf349..eebbff12a 100644 --- a/src/link/unicast/serial.c +++ b/src/link/unicast/serial.c @@ -23,7 +23,7 @@ #include "zenoh-pico/system/link/serial.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #define SPP_MAXIMUM_PAYLOAD 128 diff --git a/src/link/unicast/tcp.c b/src/link/unicast/tcp.c index c6af264d2..b7b78fa43 100644 --- a/src/link/unicast/tcp.c +++ b/src/link/unicast/tcp.c @@ -23,7 +23,7 @@ #include "zenoh-pico/system/link/tcp.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 char *__z_parse_port_segment_tcp(char *address) { char *ret = NULL; diff --git a/src/link/unicast/udp.c b/src/link/unicast/udp.c index 63ae5de04..c87441709 100644 --- a/src/link/unicast/udp.c +++ b/src/link/unicast/udp.c @@ -23,7 +23,7 @@ #include "zenoh-pico/system/link/udp.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 char *__z_parse_port_segment_udp_unicast(char *address) { char *ret = NULL; diff --git a/src/link/unicast/ws.c b/src/link/unicast/ws.c index cd7edd673..426e5fa96 100644 --- a/src/link/unicast/ws.c +++ b/src/link/unicast/ws.c @@ -24,7 +24,7 @@ #include "zenoh-pico/system/link/ws.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 char *__z_parse_port_segment_ws(char *address) { char *ret = NULL; diff --git a/src/net/session.c b/src/net/session.c index 2f2b0c93e..24d66dea6 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -33,7 +33,7 @@ int8_t __z_open_inner(_z_session_t *zn, char *locator, z_whatami_t mode) { int8_t ret = _Z_RES_OK; _z_id_t local_zid = _z_id_empty(); -#if Z_UNICAST_TRANSPORT == 1 || Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 || Z_FEATURE_MULTICAST_TRANSPORT == 1 ret = _z_session_generate_zid(&local_zid, Z_ZID_LENGTH); if (ret == _Z_RES_OK) { ret = _z_new_transport(&zn->_tp, &local_zid, locator, mode); @@ -154,14 +154,14 @@ _z_config_t *_z_info(const _z_session_t *zn) { _z_bytes_t local_zid = _z_bytes_wrap(zn->_local_zid.id, _z_id_len(zn->_local_zid)); _zp_config_insert(ps, Z_INFO_PID_KEY, _z_string_from_bytes(&local_zid)); -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { _z_id_t remote_zid = zn->_tp._transport._unicast._remote_zid; _z_bytes_t remote_zidbytes = _z_bytes_wrap(remote_zid.id, _z_id_len(remote_zid)); _zp_config_insert(ps, Z_INFO_ROUTER_PID_KEY, _z_string_from_bytes(&remote_zidbytes)); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { _z_transport_peer_entry_list_t *xs = zn->_tp._transport._multicast._peers; while (xs != NULL) { @@ -172,7 +172,7 @@ _z_config_t *_z_info(const _z_session_t *zn) { xs = _z_transport_peer_entry_list_tail(xs); } } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { __asm__("nop"); } @@ -187,7 +187,7 @@ int8_t _zp_send_keep_alive(_z_session_t *zn) { return _z_send_keep_alive(&zn->_t int8_t _zp_send_join(_z_session_t *zn) { return _z_send_join(&zn->_tp); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 int8_t _zp_start_read_task(_z_session_t *zn) { int8_t ret = _Z_RES_OK; @@ -195,7 +195,7 @@ int8_t _zp_start_read_task(_z_session_t *zn) { if (task != NULL) { (void)memset(task, 0, sizeof(_z_task_t)); -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { zn->_tp._transport._unicast._read_task = task; zn->_tp._transport._unicast._read_task_running = true; @@ -205,8 +205,8 @@ int8_t _zp_start_read_task(_z_session_t *zn) { z_free(task); } } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { zn->_tp._transport._multicast._read_task = task; zn->_tp._transport._multicast._read_task_running = true; @@ -216,7 +216,7 @@ int8_t _zp_start_read_task(_z_session_t *zn) { z_free(task); } } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; z_free(task); @@ -229,16 +229,16 @@ int8_t _zp_start_read_task(_z_session_t *zn) { int8_t _zp_stop_read_task(_z_session_t *zn) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { zn->_tp._transport._unicast._read_task_running = false; } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { zn->_tp._transport._multicast._read_task_running = false; } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } @@ -253,7 +253,7 @@ int8_t _zp_start_lease_task(_z_session_t *zn) { if (task != NULL) { (void)memset(task, 0, sizeof(_z_task_t)); -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { zn->_tp._transport._unicast._lease_task = task; zn->_tp._transport._unicast._lease_task_running = true; @@ -263,8 +263,8 @@ int8_t _zp_start_lease_task(_z_session_t *zn) { z_free(task); } } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { zn->_tp._transport._multicast._lease_task = task; zn->_tp._transport._multicast._lease_task_running = true; @@ -274,7 +274,7 @@ int8_t _zp_start_lease_task(_z_session_t *zn) { z_free(task); } } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; z_free(task); @@ -287,20 +287,20 @@ int8_t _zp_start_lease_task(_z_session_t *zn) { int8_t _zp_stop_lease_task(_z_session_t *zn) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { zn->_tp._transport._unicast._lease_task_running = false; } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { zn->_tp._transport._multicast._lease_task_running = false; } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } return ret; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 diff --git a/src/session/query.c b/src/session/query.c index 52caa9beb..ec976c7e3 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -102,15 +102,15 @@ _z_pending_query_t *__unsafe__z_get_pending_query_by_id(_z_session_t *zn, const } _z_pending_query_t *_z_get_pending_query_by_id(_z_session_t *zn, const _z_zint_t id) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pql = __unsafe__z_get_pending_query_by_id(zn, id); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return pql; } @@ -120,9 +120,9 @@ int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) _Z_DEBUG(">>> Allocating query for (%ju:%s,%s)\n", (uintmax_t)pen_qry->_key._id, pen_qry->_key._suffix, pen_qry->_parameters); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pql = __unsafe__z_get_pending_query_by_id(zn, pen_qry->_id); if (pql == NULL) { // Register query only if a pending one with the same ID does not exist @@ -131,9 +131,9 @@ int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) ret = _Z_ERR_ENTITY_DECLARATION_FAILED; } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -143,9 +143,9 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons const _z_timestamp_t timestamp) { int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pen_qry = __unsafe__z_get_pending_query_by_id(zn, id); if ((ret == _Z_RES_OK) && (pen_qry == NULL)) { @@ -215,9 +215,9 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Trigger the user callback if ((ret == _Z_RES_OK) && (pen_qry->_consolidation != Z_CONSOLIDATION_MODE_LATEST)) { @@ -234,9 +234,9 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons int8_t _z_trigger_query_reply_final(_z_session_t *zn, _z_zint_t id) { int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Final reply received for unknown query id _z_pending_query_t *pen_qry = __unsafe__z_get_pending_query_by_id(zn, id); @@ -260,33 +260,33 @@ int8_t _z_trigger_query_reply_final(_z_session_t *zn, _z_zint_t id) { zn->_pending_queries = _z_pending_query_list_drop_filter(zn->_pending_queries, _z_pending_query_eq, pen_qry); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } void _z_unregister_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 zn->_pending_queries = _z_pending_query_list_drop_filter(zn->_pending_queries, _z_pending_query_eq, pen_qry); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_pending_queries(_z_session_t *zn) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_list_free(&zn->_pending_queries); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/queryable.c b/src/session/queryable.c index d18c5705e..7431712b4 100644 --- a/src/session/queryable.c +++ b/src/session/queryable.c @@ -89,30 +89,30 @@ _z_questionable_sptr_list_t *__unsafe_z_get_questionable_by_key(_z_session_t *zn } _z_questionable_sptr_t *_z_get_questionable_by_id(_z_session_t *zn, const _z_zint_t id) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_questionable_sptr_t *qle = __unsafe_z_get_questionable_by_id(zn, id); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return qle; } _z_questionable_sptr_list_t *_z_get_questionable_by_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, keyexpr); _z_questionable_sptr_list_t *qles = __unsafe_z_get_questionable_by_key(zn, key); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return qles; } @@ -121,9 +121,9 @@ _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionab _Z_DEBUG(">>> Allocating queryable for (%ju:%s)\n", (uintmax_t)q->_key._id, q->_key._suffix); _z_questionable_sptr_t *ret = NULL; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 ret = (_z_questionable_sptr_t *)z_malloc(sizeof(_z_questionable_sptr_t)); if (ret != NULL) { @@ -131,9 +131,9 @@ _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionab zn->_local_questionable = _z_questionable_sptr_list_push(zn->_local_questionable, ret); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -141,17 +141,17 @@ _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionab int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, const _z_keyexpr_t q_key, uint32_t qid) { int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &q_key); if (key._suffix != NULL) { _z_questionable_sptr_list_t *qles = __unsafe_z_get_questionable_by_key(zn, key); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Build the query z_query_t q; @@ -190,9 +190,9 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons } _z_msg_clear(&z_msg); } else { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 ret = _Z_ERR_KEYEXPR_UNKNOWN; } @@ -201,26 +201,26 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons } void _z_unregister_questionable(_z_session_t *zn, _z_questionable_sptr_t *qle) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 zn->_local_questionable = _z_questionable_sptr_list_drop_filter(zn->_local_questionable, _z_questionable_sptr_eq, qle); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_questionables(_z_session_t *zn) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_questionable_sptr_list_free(&zn->_local_questionable); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/resource.c b/src/session/resource.c index 30c29702e..8a36ef951 100644 --- a/src/session/resource.c +++ b/src/session/resource.c @@ -174,15 +174,15 @@ _z_keyexpr_t __unsafe_z_get_expanded_key_from_key(_z_session_t *zn, const _z_key } _z_resource_t *_z_get_resource_by_id(_z_session_t *zn, uint16_t mapping, _z_zint_t rid) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t *res = __unsafe_z_get_resource_by_id(zn, mapping, rid); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return res; } @@ -191,28 +191,28 @@ _z_resource_t *_z_get_resource_by_key(_z_session_t *zn, const _z_keyexpr_t *keye if (keyexpr->_suffix == NULL) { return _z_get_resource_by_id(zn, _z_keyexpr_mapping_id(keyexpr), keyexpr->_id); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t *res = __unsafe_z_get_resource_by_key(zn, keyexpr); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return res; } _z_keyexpr_t _z_get_expanded_key_from_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t res = __unsafe_z_get_expanded_key_from_key(zn, keyexpr); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return res; } @@ -224,9 +224,9 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui uint16_t mapping = register_to_mapping; uint16_t parent_mapping = _z_keyexpr_mapping_id(&key); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 if (key._id != Z_RESOURCE_ID_NONE) { if (parent_mapping == mapping) { @@ -255,9 +255,9 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -265,9 +265,9 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping) { _Bool is_local = mapping == _Z_KEYEXPR_MAPPING_LOCAL; _Z_DEBUG("unregistering: id %d, mapping: %d\n", id, mapping); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_list_t **parent_mut = is_local ? &zn->_local_resources : &zn->_remote_resources; while (id != 0) { _z_resource_list_t *parent = *parent_mut; @@ -289,9 +289,9 @@ void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping) { parent = *parent_mut; } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } _Bool _z_unregister_resource_for_peer_filter(const _z_resource_t *candidate, const _z_resource_t *ctx) { @@ -299,27 +299,27 @@ _Bool _z_unregister_resource_for_peer_filter(const _z_resource_t *candidate, con return _z_keyexpr_mapping_id(&candidate->_key) == mapping; } void _z_unregister_resources_for_peer(_z_session_t *zn, uint16_t mapping) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t ctx = {._id = mapping, ._refcount = 0, ._key = {0}}; zn->_remote_resources = _z_resource_list_drop_filter(zn->_remote_resources, _z_unregister_resource_for_peer_filter, &ctx); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_resources(_z_session_t *zn) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_list_free(&zn->_local_resources); _z_resource_list_free(&zn->_remote_resources); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/scout.c b/src/session/scout.c index 7a45a3ecc..e9191da07 100644 --- a/src/session/scout.c +++ b/src/session/scout.c @@ -20,8 +20,8 @@ #include "zenoh-pico/protocol/core.h" #include "zenoh-pico/utils/logging.h" -#if Z_SCOUTING_UDP == 1 && Z_LINK_UDP_UNICAST == 0 -#error "Scouting UDP requires UDP unicast links to be enabled (Z_LINK_UDP_UNICAST = 1 in config.h)" +#if Z_FEATURE_SCOUTING_UDP == 1 && Z_FEATURE_LINK_UDP_UNICAST == 0 +#error "Scouting UDP requires UDP unicast links to be enabled (Z_FEATURE_LINK_UDP_UNICAST = 1 in config.h)" #endif _z_hello_list_t *__z_scout_loop(const _z_wbuf_t *wbf, const char *locator, unsigned long period, _Bool exit_on_first) { @@ -32,7 +32,7 @@ _z_hello_list_t *__z_scout_loop(const _z_wbuf_t *wbf, const char *locator, unsig _z_endpoint_t ep; err = _z_endpoint_from_str(&ep, locator); -#if Z_SCOUTING_UDP == 1 +#if Z_FEATURE_SCOUTING_UDP == 1 if ((err == _Z_RES_OK) && (_z_str_eq(ep._locator._protocol, UDP_SCHEMA) == true)) { _z_endpoint_clear(&ep); } else @@ -140,13 +140,13 @@ _z_hello_list_t *_z_scout_inner(const z_what_t what, _z_id_t zid, const char *lo _z_scouting_message_encode(&wbf, &scout); // Scout on multicast -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 ret = __z_scout_loop(&wbf, locator, timeout, exit_on_first); #else (void)(locator); (void)(timeout); (void)(exit_on_first); -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_wbuf_clear(&wbf); diff --git a/src/session/subscription.c b/src/session/subscription.c index fd057aac3..e3e0833f3 100644 --- a/src/session/subscription.c +++ b/src/session/subscription.c @@ -96,29 +96,29 @@ _z_subscription_sptr_list_t *__unsafe_z_get_subscriptions_by_key(_z_session_t *z } _z_subscription_sptr_t *_z_get_subscription_by_id(_z_session_t *zn, uint8_t is_local, const _z_zint_t id) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_t *sub = __unsafe_z_get_subscription_by_id(zn, is_local, id); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return sub; } _z_subscription_sptr_list_t *_z_get_subscriptions_by_key(_z_session_t *zn, uint8_t is_local, const _z_keyexpr_t *key) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, is_local, *key); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return subs; } @@ -127,9 +127,9 @@ _z_subscription_sptr_t *_z_register_subscription(_z_session_t *zn, uint8_t is_lo _Z_DEBUG(">>> Allocating sub decl for (%ju:%s)\n", (uintmax_t)s->_key._id, s->_key._suffix); _z_subscription_sptr_t *ret = NULL; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, is_local, s->_key); if (subs == NULL) { // A subscription for this name does not yet exists @@ -144,9 +144,9 @@ _z_subscription_sptr_t *_z_register_subscription(_z_session_t *zn, uint8_t is_lo } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -155,9 +155,9 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co const _z_encoding_t encoding, const _z_zint_t kind, const _z_timestamp_t timestamp) { int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _Z_DEBUG("Resolving %d - %s on mapping 0x%x\n", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &keyexpr); @@ -165,9 +165,9 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co if (key._suffix != NULL) { _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, _Z_RESOURCE_IS_LOCAL, key); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Build the sample _z_sample_t s; @@ -187,9 +187,9 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co _z_keyexpr_clear(&key); _z_subscription_sptr_list_free(&subs); } else { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 ret = _Z_ERR_KEYEXPR_UNKNOWN; } @@ -197,9 +197,9 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co } void _z_unregister_subscription(_z_session_t *zn, uint8_t is_local, _z_subscription_sptr_t *sub) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 if (is_local == _Z_RESOURCE_IS_LOCAL) { zn->_local_subscriptions = @@ -209,20 +209,20 @@ void _z_unregister_subscription(_z_session_t *zn, uint8_t is_local, _z_subscript _z_subscription_sptr_list_drop_filter(zn->_remote_subscriptions, _z_subscription_sptr_eq, sub); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_subscriptions(_z_session_t *zn) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_free(&zn->_local_subscriptions); _z_subscription_sptr_list_free(&zn->_remote_subscriptions); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/tx.c b/src/session/tx.c index ae3697b42..409f5d402 100644 --- a/src/session/tx.c +++ b/src/session/tx.c @@ -21,16 +21,16 @@ int8_t _z_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reli int8_t ret = _Z_RES_OK; _Z_DEBUG(">> send network message\n"); -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _z_unicast_send_n_msg(zn, z_msg, reliability, cong_ctrl); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _z_multicast_send_n_msg(zn, z_msg, reliability, cong_ctrl); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } diff --git a/src/session/utils.c b/src/session/utils.c index 215c2717f..494cb7a5d 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -66,21 +66,21 @@ int8_t _z_session_init(_z_session_t *zn, _z_id_t *zid) { zn->_local_questionable = NULL; zn->_pending_queries = NULL; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 ret = _z_mutex_init(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 if (ret == _Z_RES_OK) { zn->_local_zid = *zid; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { zn->_tp._transport._unicast._session = zn; } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zn->_tp._type == _Z_TRANSPORT_MULTICAST_TYPE) { zn->_tp._transport._multicast._session = zn; } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { // Do nothing. Required to be here because of the #if directive } @@ -103,9 +103,9 @@ void _z_session_clear(_z_session_t *zn) { _z_flush_questionables(zn); _z_flush_pending_queries(zn); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_free(&zn->_mutex_inner); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_session_free(_z_session_t **zn) { diff --git a/src/system/arduino/esp32/network.cpp b/src/system/arduino/esp32/network.cpp index c85ea7d07..c02557fac 100644 --- a/src/system/arduino/esp32/network.cpp +++ b/src/system/arduino/esp32/network.cpp @@ -32,7 +32,7 @@ extern "C" { #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -143,7 +143,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -165,7 +165,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { freeaddrinfo(ep->_iptcp); } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -238,7 +238,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, _z_sys_net_endpoint_t *lep, uint32_t tout, const char *iface) { int8_t ret = _Z_RES_OK; @@ -544,7 +544,7 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 /*------------------ Bluetooth sockets ------------------*/ int8_t _z_open_bt(_z_sys_net_socket_t *sock, const char *gname, uint8_t mode, uint8_t profile, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -641,7 +641,7 @@ size_t _z_send_bt(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t len } #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 /*------------------ Serial sockets ------------------*/ int8_t _z_open_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin, uint32_t rxpin, uint32_t baudrate) { int8_t ret = _Z_RES_OK; diff --git a/src/system/arduino/esp32/system.c b/src/system/arduino/esp32/system.c index 1d823c14c..a9eab813c 100644 --- a/src/system/arduino/esp32/system.c +++ b/src/system/arduino/esp32/system.c @@ -44,7 +44,7 @@ void *z_realloc(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MA void z_free(void *ptr) { heap_caps_free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // This wrapper is only used for ESP32. // In FreeRTOS, tasks created using xTaskCreate must end with vTaskDelete. // A task function should __not__ simply return. @@ -112,7 +112,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { return usleep(time); } diff --git a/src/system/arduino/opencr/network.cpp b/src/system/arduino/opencr/network.cpp index 1912d7cfb..bdbb9939a 100644 --- a/src/system/arduino/opencr/network.cpp +++ b/src/system/arduino/opencr/network.cpp @@ -26,7 +26,7 @@ extern "C" { #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { @@ -118,7 +118,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { @@ -147,7 +147,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { delete ep->_iptcp._addr; } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -229,7 +229,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, _z_sys_net_endpoint_t *lep, uint32_t tout, const char *iface) { int8_t ret = _Z_RES_OK; @@ -340,11 +340,11 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on OpenCR port of Zenoh-Pico" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #error "Serial not supported yet on OpenCR port of Zenoh-Pico" #endif } diff --git a/src/system/arduino/opencr/system.c b/src/system/arduino/opencr/system.c index 946392bb3..9ad314b5c 100644 --- a/src/system/arduino/opencr/system.c +++ b/src/system/arduino/opencr/system.c @@ -59,8 +59,8 @@ void z_free(void *ptr) { return free(ptr); } -#if Z_MULTI_THREAD == 1 -#error "Multi-threading not supported yet on OpenCR port. Disable it by defining Z_MULTI_THREAD=0" +#if Z_FEATURE_MULTI_THREAD == 1 +#error "Multi-threading not supported yet on OpenCR port. Disable it by defining Z_FEATURE_MULTI_THREAD=0" /*------------------ Task ------------------*/ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { return -1; } @@ -94,7 +94,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return -1; } int8_t _z_condvar_signal(_z_condvar_t *cv) { return -1; } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return -1; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { diff --git a/src/system/emscripten/network.c b/src/system/emscripten/network.c index 56a67714a..8b2f14caf 100644 --- a/src/system/emscripten/network.c +++ b/src/system/emscripten/network.c @@ -28,7 +28,7 @@ #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_WS == 1 +#if Z_FEATURE_LINK_WS == 1 #define WS_LINK_SLEEP 1 @@ -158,18 +158,18 @@ size_t _z_send_ws(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t len #endif -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 #error "TCP not supported yet on Emscripten port of Zenoh-Pico" #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 #error "UDP not supported yet on Emscripten port of Zenoh-Pico" #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on Emscripten port of Zenoh-Pico" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #error "Serial not supported yet on Emscripten port of Zenoh-Pico" #endif diff --git a/src/system/emscripten/system.c b/src/system/emscripten/system.c index 89242bd72..0654898b3 100644 --- a/src/system/emscripten/system.c +++ b/src/system/emscripten/system.c @@ -42,7 +42,7 @@ void *z_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void z_free(void *ptr) { free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ int8_t _z_task_init(_z_task_t *task, pthread_attr_t *attr, void *(*fun)(void *), void *arg) { return pthread_create(task, attr, fun, arg); @@ -77,7 +77,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { diff --git a/src/system/espidf/network.c b/src/system/espidf/network.c index 55b3e7036..9a49bf157 100644 --- a/src/system/espidf/network.c +++ b/src/system/espidf/network.c @@ -28,7 +28,7 @@ #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -139,7 +139,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -161,7 +161,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { freeaddrinfo(ep->_iptcp); } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -234,7 +234,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, _z_sys_net_endpoint_t *lep, uint32_t tout, const char *iface) { int8_t ret = _Z_RES_OK; @@ -540,7 +540,7 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, } #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 /*------------------ Serial sockets ------------------*/ int8_t _z_open_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin, uint32_t rxpin, uint32_t baudrate) { int8_t ret = _Z_RES_OK; @@ -736,6 +736,6 @@ size_t _z_send_serial(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on ESP-IDF port of Zenoh-Pico" #endif diff --git a/src/system/espidf/system.c b/src/system/espidf/system.c index a3a4dd472..8a655cf0d 100644 --- a/src/system/espidf/system.c +++ b/src/system/espidf/system.c @@ -45,7 +45,7 @@ void *z_realloc(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MA void z_free(void *ptr) { heap_caps_free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // This wrapper is only used for ESP32. // In FreeRTOS, tasks created using xTaskCreate must end with vTaskDelete. // A task function should __not__ simply return. @@ -113,7 +113,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { return usleep(time); } diff --git a/src/system/mbed/network.cpp b/src/system/mbed/network.cpp index 6653fceea..744b92df0 100644 --- a/src/system/mbed/network.cpp +++ b/src/system/mbed/network.cpp @@ -31,7 +31,7 @@ extern "C" { #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -115,7 +115,7 @@ size_t _z_read_exact_tcp(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t le size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t len) { return sock._tcp->send(ptr, len); } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -134,7 +134,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { delete ep->_iptcp; } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; (void)sock; @@ -205,7 +205,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, _z_sys_net_endpoint_t *lep, uint32_t tout, const char *iface) { int8_t ret = _Z_RES_OK; @@ -317,7 +317,7 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, } #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 int8_t _z_open_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin, uint32_t rxpin, uint32_t baudrate) { int8_t ret = _Z_RES_OK; @@ -479,7 +479,7 @@ size_t _z_send_serial(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on MBED port of Zenoh-Pico" #endif diff --git a/src/system/mbed/system.cpp b/src/system/mbed/system.cpp index 68dc20b01..2adeec297 100644 --- a/src/system/mbed/system.cpp +++ b/src/system/mbed/system.cpp @@ -39,7 +39,7 @@ void *z_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void z_free(void *ptr) { free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { *task = new Thread(); @@ -106,7 +106,7 @@ int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { ((ConditionVariable *)*cv)->wait(); return 0; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { diff --git a/src/system/unix/network.c b/src/system/unix/network.c index 917e9a4be..b7e899e23 100644 --- a/src/system/unix/network.c +++ b/src/system/unix/network.c @@ -31,7 +31,7 @@ #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { @@ -158,7 +158,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -180,7 +180,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { freeaddrinfo(ep->_iptcp); } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -253,7 +253,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 unsigned int __get_ip_from_iface(const char *iface, int sa_family, struct sockaddr **lsockaddr) { unsigned int addrlen = 0U; @@ -584,10 +584,10 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on Unix port of Zenoh-Pico" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #error "Serial not supported yet on Unix port of Zenoh-Pico" #endif diff --git a/src/system/unix/system.c b/src/system/unix/system.c index e5dca90e9..875bc5f2b 100644 --- a/src/system/unix/system.c +++ b/src/system/unix/system.c @@ -98,7 +98,7 @@ void *z_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void z_free(void *ptr) { free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { return pthread_create(task, attr, fun, arg); @@ -133,7 +133,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { return usleep(time); } diff --git a/src/system/windows/network.c b/src/system/windows/network.c index 6ce0eb5ab..76d37027c 100644 --- a/src/system/windows/network.c +++ b/src/system/windows/network.c @@ -25,7 +25,7 @@ WSADATA wsaData; -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { @@ -161,7 +161,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -190,7 +190,7 @@ void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -272,7 +272,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 unsigned int __get_ip_from_iface(const char *iface, int sa_family, SOCKADDR **lsockaddr) { unsigned int addrlen = 0U; @@ -603,10 +603,10 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on Windows port of Zenoh-Pico" #endif -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 #error "Serial not supported yet on Windows port of Zenoh-Pico" #endif diff --git a/src/system/windows/system.c b/src/system/windows/system.c index b813d6627..581b42291 100644 --- a/src/system/windows/system.c +++ b/src/system/windows/system.c @@ -58,7 +58,7 @@ void *z_realloc(void *ptr, size_t size) { return realloc(ptr, size); } void z_free(void *ptr) { free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { (void)(attr); @@ -146,7 +146,7 @@ int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { SleepConditionVariableSRW(cv, m, INFINITE, 0); return ret; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { return z_sleep_ms((time / 1000) + (time % 1000 == 0 ? 0 : 1)); } diff --git a/src/system/zephyr/network.c b/src/system/zephyr/network.c index 49978b49c..e07381914 100644 --- a/src/system/zephyr/network.c +++ b/src/system/zephyr/network.c @@ -34,7 +34,7 @@ #include "zenoh-pico/utils/logging.h" #include "zenoh-pico/utils/pointers.h" -#if Z_LINK_TCP == 1 +#if Z_FEATURE_LINK_TCP == 1 /*------------------ TCP sockets ------------------*/ int8_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -147,7 +147,7 @@ size_t _z_send_tcp(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t le } #endif -#if Z_LINK_UDP_UNICAST == 1 || Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 /*------------------ UDP sockets ------------------*/ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) { int8_t ret = _Z_RES_OK; @@ -169,7 +169,7 @@ int8_t _z_create_endpoint_udp(_z_sys_net_endpoint_t *ep, const char *s_address, void _z_free_endpoint_udp(_z_sys_net_endpoint_t *ep) { freeaddrinfo(ep->_iptcp); } #endif -#if Z_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_UDP_UNICAST == 1 int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, uint32_t tout) { int8_t ret = _Z_RES_OK; @@ -243,7 +243,7 @@ size_t _z_send_udp_unicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, s } #endif -#if Z_LINK_UDP_MULTICAST == 1 +#if Z_FEATURE_LINK_UDP_MULTICAST == 1 int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, _z_sys_net_endpoint_t *lep, uint32_t tout, const char *iface) { int8_t ret = _Z_RES_OK; @@ -550,9 +550,9 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, _z_sys_net_endpoint_t rep) { return sendto(sock._fd, ptr, len, 0, rep._iptcp->ai_addr, rep._iptcp->ai_addrlen); } -#endif // Z_LINK_UDP_MULTICAST == 1 +#endif // Z_FEATURE_LINK_UDP_MULTICAST == 1 -#if Z_LINK_SERIAL == 1 +#if Z_FEATURE_LINK_SERIAL == 1 int8_t _z_open_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin, uint32_t rxpin, uint32_t baudrate) { int8_t ret = _Z_RES_OK; (void)(sock); @@ -725,6 +725,6 @@ size_t _z_send_serial(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t } #endif -#if Z_LINK_BLUETOOTH == 1 +#if Z_FEATURE_LINK_BLUETOOTH == 1 #error "Bluetooth not supported yet on Zephyr port of Zenoh-Pico" #endif diff --git a/src/system/zephyr/system.c b/src/system/zephyr/system.c index 2670ae9cb..28ce1d303 100644 --- a/src/system/zephyr/system.c +++ b/src/system/zephyr/system.c @@ -55,7 +55,7 @@ void *z_realloc(void *ptr, size_t size) { void z_free(void *ptr) { k_free(ptr); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 #define Z_THREADS_NUM 4 @@ -112,7 +112,7 @@ int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ int z_sleep_us(size_t time) { diff --git a/src/transport/common/join.c b/src/transport/common/join.c index b896dac2e..5c9d6819b 100644 --- a/src/transport/common/join.c +++ b/src/transport/common/join.c @@ -17,12 +17,12 @@ int8_t _z_send_join(_z_transport_t *zt) { int8_t ret = _Z_RES_OK; -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 // Join task only applies to multicast transports if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _zp_multicast_send_join(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { (void)zt; ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; diff --git a/src/transport/common/lease.c b/src/transport/common/lease.c index dcf2d908d..bf32a5884 100644 --- a/src/transport/common/lease.c +++ b/src/transport/common/lease.c @@ -18,16 +18,16 @@ int8_t _z_send_keep_alive(_z_transport_t *zt) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _zp_unicast_send_keep_alive(&zt->_transport._unicast); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _zp_multicast_send_keep_alive(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } @@ -39,16 +39,16 @@ void *_zp_lease_task(void *zt_arg) { void *ret = NULL; _z_transport_t *zt = (_z_transport_t *)zt_arg; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _zp_unicast_lease_task(&zt->_transport._unicast); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _zp_multicast_lease_task(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = NULL; } diff --git a/src/transport/common/read.c b/src/transport/common/read.c index bf0f20381..e1bcdcee8 100644 --- a/src/transport/common/read.c +++ b/src/transport/common/read.c @@ -19,16 +19,16 @@ int8_t _z_read(_z_transport_t *zt) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _zp_unicast_read(&zt->_transport._unicast); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _zp_multicast_read(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } @@ -40,16 +40,16 @@ void *_zp_read_task(void *zt_arg) { void *ret = NULL; _z_transport_t *zt = (_z_transport_t *)zt_arg; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _zp_unicast_read_task(&zt->_transport._unicast); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _zp_multicast_read_task(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = NULL; } diff --git a/src/transport/common/tx.c b/src/transport/common/tx.c index f3625250e..811cf7a2d 100644 --- a/src/transport/common/tx.c +++ b/src/transport/common/tx.c @@ -54,16 +54,16 @@ void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, _Bool is_streamed) { int8_t _z_send_t_msg(_z_transport_t *zt, const _z_transport_message_t *t_msg) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _z_unicast_send_t_msg(&zt->_transport._unicast, t_msg); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _z_multicast_send_t_msg(&zt->_transport._multicast, t_msg); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } @@ -71,7 +71,7 @@ int8_t _z_send_t_msg(_z_transport_t *zt, const _z_transport_message_t *t_msg) { return ret; } -#if Z_UNICAST_TRANSPORT == 1 || Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 || Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_link_send_t_msg(const _z_link_t *zl, const _z_transport_message_t *t_msg) { int8_t ret = _Z_RES_OK; @@ -103,7 +103,7 @@ int8_t _z_link_send_t_msg(const _z_link_t *zl, const _z_transport_message_t *t_m return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 || Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 || Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t __unsafe_z_serialize_zenoh_fragment(_z_wbuf_t *dst, _z_wbuf_t *src, z_reliability_t reliability, size_t sn) { int8_t ret = _Z_RES_OK; diff --git a/src/transport/manager.c b/src/transport/manager.c index f365a399e..c7e868ed1 100644 --- a/src/transport/manager.c +++ b/src/transport/manager.c @@ -25,7 +25,7 @@ int8_t _z_new_transport_client(_z_transport_t *zt, char *locator, _z_id_t *local ret = _z_open_link(&zl, locator); if (ret == _Z_RES_OK) { -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (_Z_LINK_IS_MULTICAST(zl._capabilities) == false) { _z_transport_unicast_establish_param_t tp_param; ret = _z_transport_unicast_open_client(&tp_param, &zl, local_zid); @@ -35,8 +35,8 @@ int8_t _z_new_transport_client(_z_transport_t *zt, char *locator, _z_id_t *local _z_link_clear(&zl); } } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (_Z_LINK_IS_MULTICAST(zl._capabilities) == true) { _z_transport_multicast_establish_param_t tp_param; ret = _z_transport_multicast_open_client(&tp_param, &zl, local_zid); @@ -46,7 +46,7 @@ int8_t _z_new_transport_client(_z_transport_t *zt, char *locator, _z_id_t *local _z_link_clear(&zl); } } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { _z_link_clear(&zl); ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; @@ -64,7 +64,7 @@ int8_t _z_new_transport_peer(_z_transport_t *zt, char *locator, _z_id_t *local_z ret = _z_listen_link(&zl, locator); if (ret == _Z_RES_OK) { -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (_Z_LINK_IS_MULTICAST(zl._capabilities) == false) { _z_transport_unicast_establish_param_t tp_param; ret = _z_transport_unicast_open_peer(&tp_param, &zl, local_zid); @@ -74,8 +74,8 @@ int8_t _z_new_transport_peer(_z_transport_t *zt, char *locator, _z_id_t *local_z _z_link_clear(&zl); } } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (_Z_LINK_IS_MULTICAST(zl._capabilities) == true) { _z_transport_multicast_establish_param_t tp_param; ret = _z_transport_multicast_open_peer(&tp_param, &zl, local_zid); @@ -85,7 +85,7 @@ int8_t _z_new_transport_peer(_z_transport_t *zt, char *locator, _z_id_t *local_z _z_link_clear(&zl); } } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { _z_link_clear(&zl); ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; diff --git a/src/transport/multicast/link/rx.c b/src/transport/multicast/link/rx.c index b5d50e030..cb585503c 100644 --- a/src/transport/multicast/link/rx.c +++ b/src/transport/multicast/link/rx.c @@ -27,7 +27,7 @@ #include "zenoh-pico/transport/utils.h" #include "zenoh-pico/utils/logging.h" -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_transport_peer_entry_t *_z_find_peer_entry(_z_transport_peer_entry_list_t *l, _z_bytes_t *remote_addr) { _z_transport_peer_entry_t *ret = NULL; @@ -52,10 +52,10 @@ int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_me _Z_DEBUG(">> recv session msg\n"); int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock _z_mutex_lock(&ztm->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 size_t to_read = 0; do { @@ -96,9 +96,9 @@ int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_me ret = _z_transport_message_decode(t_msg, &ztm->_zbuf); } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztm->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -110,10 +110,10 @@ int8_t _z_multicast_recv_t_msg(_z_transport_multicast_t *ztm, _z_transport_messa int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr) { int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Acquire and keep the lock _z_mutex_lock(&ztm->_mutex_peer); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Mark the session that we have received data from this peer _z_transport_peer_entry_t *entry = _z_find_peer_entry(ztm->_peers, addr); @@ -254,7 +254,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t _z_conduit_sn_list_copy(&entry->_sn_rx_sns, &t_msg->_body._join._next_sn); _z_conduit_sn_list_decrement(entry->_sn_res, &entry->_sn_rx_sns); -#if Z_DYNAMIC_MEMORY_ALLOCATION == 1 +#if Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION == 1 entry->_dbuf_reliable = _z_wbuf_make(0, true); entry->_dbuf_best_effort = _z_wbuf_make(0, true); #else @@ -313,11 +313,11 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztm->_mutex_peer); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 diff --git a/src/transport/multicast/link/task/join.c b/src/transport/multicast/link/task/join.c index 345ab689c..45ce08aaa 100644 --- a/src/transport/multicast/link/task/join.c +++ b/src/transport/multicast/link/task/join.c @@ -17,7 +17,7 @@ #include "zenoh-pico/session/utils.h" #include "zenoh-pico/transport/link/tx.h" -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm) { _z_conduit_sn_list_t next_sn; @@ -31,4 +31,4 @@ int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm) { return _z_multicast_send_t_msg(ztm, &jsm); } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 diff --git a/src/transport/multicast/link/task/lease.c b/src/transport/multicast/link/task/lease.c index c653d2dea..91a594c4b 100644 --- a/src/transport/multicast/link/task/lease.c +++ b/src/transport/multicast/link/task/lease.c @@ -22,7 +22,7 @@ #include "zenoh-pico/transport/link/tx.h" #include "zenoh-pico/utils/logging.h" -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 _z_zint_t _z_get_minimum_lease(_z_transport_peer_entry_list_t *peers, _z_zint_t local_lease) { _z_zint_t ret = local_lease; @@ -68,7 +68,7 @@ int8_t _zp_multicast_send_keep_alive(_z_transport_multicast_t *ztm) { } void *_zp_multicast_lease_task(void *ztm_arg) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_transport_multicast_t *ztm = (_z_transport_multicast_t *)ztm_arg; ztm->_transmitted = false; @@ -158,9 +158,9 @@ void *_zp_multicast_lease_task(void *ztm_arg) { _z_mutex_unlock(&ztm->_mutex_peer); } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return 0; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 diff --git a/src/transport/multicast/link/task/read.c b/src/transport/multicast/link/task/read.c index 2c4278426..606f2a8c1 100644 --- a/src/transport/multicast/link/task/read.c +++ b/src/transport/multicast/link/task/read.c @@ -22,7 +22,7 @@ #include "zenoh-pico/transport/link/rx.h" #include "zenoh-pico/utils/logging.h" -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _zp_multicast_read(_z_transport_multicast_t *ztm) { int8_t ret = _Z_RES_OK; @@ -39,7 +39,7 @@ int8_t _zp_multicast_read(_z_transport_multicast_t *ztm) { } void *_zp_multicast_read_task(void *ztm_arg) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_transport_multicast_t *ztm = (_z_transport_multicast_t *)ztm_arg; // Acquire and keep the lock @@ -113,9 +113,9 @@ void *_zp_multicast_read_task(void *ztm_arg) { } _z_mutex_unlock(&ztm->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return NULL; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 diff --git a/src/transport/multicast/link/tx.c b/src/transport/multicast/link/tx.c index 991f878f3..81197bf12 100644 --- a/src/transport/multicast/link/tx.c +++ b/src/transport/multicast/link/tx.c @@ -20,7 +20,7 @@ #include "zenoh-pico/transport/utils.h" #include "zenoh-pico/utils/logging.h" -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 /** * This function is unsafe because it operates in potentially concurrent data. @@ -43,10 +43,10 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport int8_t ret = _Z_RES_OK; _Z_DEBUG(">> send session message\n"); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock _z_mutex_lock(&ztm->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Prepare the buffer eventually reserving space for the message length __unsafe_z_prepare_wbuf(&ztm->_wbuf, _Z_LINK_IS_STREAMED(ztm->_link._capabilities)); @@ -63,9 +63,9 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztm->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -80,18 +80,18 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m // Acquire the lock and drop the message if needed _Bool drop = false; if (cong_ctrl == Z_CONGESTION_CONTROL_BLOCK) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&ztm->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } else { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 int8_t locked = _z_mutex_trylock(&ztm->_mutex_tx); if (locked != (int8_t)0) { _Z_INFO("Dropping zenoh message because of congestion control\n"); // We failed to acquire the lock, drop the message drop = true; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } if (drop == false) { @@ -145,12 +145,12 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztm->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 diff --git a/src/transport/transport.c b/src/transport/transport.c index af71c2016..0019be34e 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -26,7 +26,7 @@ #include "zenoh-pico/transport/utils.h" #include "zenoh-pico/utils/logging.h" -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_unicast_send_close(_z_transport_unicast_t *ztu, uint8_t reason, _Bool link_only) { int8_t ret = _Z_RES_OK; @@ -37,9 +37,9 @@ int8_t _z_unicast_send_close(_z_transport_unicast_t *ztu, uint8_t reason, _Bool return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_multicast_send_close(_z_transport_multicast_t *ztm, uint8_t reason, _Bool link_only) { int8_t ret = _Z_RES_OK; @@ -50,21 +50,21 @@ int8_t _z_multicast_send_close(_z_transport_multicast_t *ztm, uint8_t reason, _B return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_send_close(_z_transport_t *zt, uint8_t reason, _Bool link_only) { int8_t ret = _Z_RES_OK; -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { ret = _z_unicast_send_close(&zt->_transport._unicast, reason, link_only); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { ret = _z_multicast_send_close(&zt->_transport._multicast, reason, link_only); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; } @@ -72,13 +72,13 @@ int8_t _z_send_close(_z_transport_t *zt, uint8_t reason, _Bool link_only) { return ret; } -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unicast_establish_param_t *param) { int8_t ret = _Z_RES_OK; zt->_type = _Z_TRANSPORT_UNICAST_TYPE; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Initialize the mutexes ret = _z_mutex_init(&zt->_transport._unicast._mutex_tx); if (ret == _Z_RES_OK) { @@ -87,7 +87,7 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic _z_mutex_free(&zt->_transport._unicast._mutex_tx); } } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Initialize the read and write buffers if (ret == _Z_RES_OK) { @@ -95,7 +95,7 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic _Bool expandable = _Z_LINK_IS_STREAMED(zl->_capabilities); size_t dbuf_size = 0; -#if Z_DYNAMIC_MEMORY_ALLOCATION == 0 +#if Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION == 0 expandable = false; dbuf_size = Z_FRAG_MAX_SIZE; #endif @@ -109,7 +109,7 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic // Clean up the buffers if one of them failed to be allocated if ((_z_wbuf_capacity(&zt->_transport._unicast._wbuf) != mtu) || (_z_zbuf_capacity(&zt->_transport._unicast._zbuf) != Z_BATCH_UNICAST_SIZE) || -#if Z_DYNAMIC_MEMORY_ALLOCATION == 0 +#if Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION == 0 (_z_wbuf_capacity(&zt->_transport._unicast._dbuf_reliable) != dbuf_size) || (_z_wbuf_capacity(&zt->_transport._unicast._dbuf_best_effort) != dbuf_size)) { #else @@ -118,10 +118,10 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic #endif ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_free(&zt->_transport._unicast._mutex_tx); _z_mutex_free(&zt->_transport._unicast._mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_wbuf_clear(&zt->_transport._unicast._wbuf); _z_zbuf_clear(&zt->_transport._unicast._zbuf); @@ -143,13 +143,13 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic zt->_transport._unicast._sn_rx_reliable = initial_sn_rx; zt->_transport._unicast._sn_rx_best_effort = initial_sn_rx; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Tasks zt->_transport._unicast._read_task_running = false; zt->_transport._unicast._read_task = NULL; zt->_transport._unicast._lease_task_running = false; zt->_transport._unicast._lease_task = NULL; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Notifiers zt->_transport._unicast._received = 0; @@ -169,15 +169,15 @@ int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unic return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_multicast_establish_param_t *param) { int8_t ret = _Z_RES_OK; zt->_type = _Z_TRANSPORT_MULTICAST_TYPE; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Initialize the mutexes ret = _z_mutex_init(&zt->_transport._multicast._mutex_tx); if (ret == _Z_RES_OK) { @@ -192,7 +192,7 @@ int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_mu _z_mutex_free(&zt->_transport._multicast._mutex_tx); } } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Initialize the read and write buffers if (ret == _Z_RES_OK) { @@ -205,11 +205,11 @@ int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_mu (_z_zbuf_capacity(&zt->_transport._multicast._zbuf) != Z_BATCH_MULTICAST_SIZE)) { ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_free(&zt->_transport._multicast._mutex_tx); _z_mutex_free(&zt->_transport._multicast._mutex_rx); _z_mutex_free(&zt->_transport._multicast._mutex_peer); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 _z_wbuf_clear(&zt->_transport._multicast._wbuf); _z_zbuf_clear(&zt->_transport._multicast._zbuf); @@ -227,13 +227,13 @@ int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_mu // Initialize peer list zt->_transport._multicast._peers = _z_transport_peer_entry_list_new(); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Tasks zt->_transport._multicast._read_task_running = false; zt->_transport._multicast._read_task = NULL; zt->_transport._multicast._lease_task_running = false; zt->_transport._multicast._lease_task = NULL; -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 zt->_transport._multicast._lease = Z_TRANSPORT_LEASE; @@ -246,9 +246,9 @@ int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_mu return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_transport_unicast_open_client(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) { int8_t ret = _Z_RES_OK; @@ -343,9 +343,9 @@ int8_t _z_transport_unicast_open_client(_z_transport_unicast_establish_param_t * return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_transport_multicast_open_client(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) { (void)(param); @@ -357,9 +357,9 @@ int8_t _z_transport_multicast_open_client(_z_transport_multicast_establish_param return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_transport_unicast_open_peer(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) { (void)(param); @@ -371,9 +371,9 @@ int8_t _z_transport_unicast_open_peer(_z_transport_unicast_establish_param_t *pa return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_transport_multicast_open_peer(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) { int8_t ret = _Z_RES_OK; @@ -402,25 +402,25 @@ int8_t _z_transport_multicast_open_peer(_z_transport_multicast_establish_param_t return ret; } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_transport_unicast_close(_z_transport_unicast_t *ztu, uint8_t reason) { return _z_unicast_send_close(ztu, reason, false); } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_transport_multicast_close(_z_transport_multicast_t *ztm, uint8_t reason) { return _z_multicast_send_close(ztm, reason, false); } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 int8_t _z_transport_close(_z_transport_t *zt, uint8_t reason) { return _z_send_close(zt, reason, false); } -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 void _z_transport_unicast_clear(_z_transport_unicast_t *ztu) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Clean up tasks if (ztu->_read_task != NULL) { _z_task_join(ztu->_read_task); @@ -434,7 +434,7 @@ void _z_transport_unicast_clear(_z_transport_unicast_t *ztu) { // Clean up the mutexes _z_mutex_free(&ztu->_mutex_tx); _z_mutex_free(&ztu->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Clean up the buffers _z_wbuf_clear(&ztu->_wbuf); @@ -446,11 +446,11 @@ void _z_transport_unicast_clear(_z_transport_unicast_t *ztu) { ztu->_remote_zid = _z_id_empty(); _z_link_clear(&ztu->_link); } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 void _z_transport_multicast_clear(_z_transport_multicast_t *ztm) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Clean up tasks if (ztm->_read_task != NULL) { _z_task_join(ztm->_read_task); @@ -465,7 +465,7 @@ void _z_transport_multicast_clear(_z_transport_multicast_t *ztm) { _z_mutex_free(&ztm->_mutex_tx); _z_mutex_free(&ztm->_mutex_rx); _z_mutex_free(&ztm->_mutex_peer); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Clean up the buffers _z_wbuf_clear(&ztm->_wbuf); @@ -475,19 +475,19 @@ void _z_transport_multicast_clear(_z_transport_multicast_t *ztm) { _z_transport_peer_entry_list_free(&ztm->_peers); _z_link_clear(&ztm->_link); } -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 void _z_transport_clear(_z_transport_t *zt) { -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_UNICAST_TYPE) { _z_transport_unicast_clear(&zt->_transport._unicast); } else -#endif // Z_UNICAST_TRANSPORT == 1 -#if Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_MULTICAST_TRANSPORT == 1 if (zt->_type == _Z_TRANSPORT_MULTICAST_TYPE) { _z_transport_multicast_clear(&zt->_transport._multicast); } else -#endif // Z_MULTICAST_TRANSPORT == 1 +#endif // Z_FEATURE_MULTICAST_TRANSPORT == 1 { __asm__("nop"); } diff --git a/src/transport/unicast/link/rx.c b/src/transport/unicast/link/rx.c index 6604e71ea..dfc580e4d 100644 --- a/src/transport/unicast/link/rx.c +++ b/src/transport/unicast/link/rx.c @@ -25,15 +25,15 @@ #include "zenoh-pico/transport/utils.h" #include "zenoh-pico/utils/logging.h" -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg) { _Z_DEBUG(">> recv session msg\n"); int8_t ret = _Z_RES_OK; -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock _z_mutex_lock(&ztu->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 size_t to_read = 0; do { @@ -79,9 +79,9 @@ int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_messag } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztu->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -197,4 +197,4 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans return _Z_RES_OK; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 diff --git a/src/transport/unicast/link/task/lease.c b/src/transport/unicast/link/task/lease.c index 5d9e0a2f2..02ff178db 100644 --- a/src/transport/unicast/link/task/lease.c +++ b/src/transport/unicast/link/task/lease.c @@ -17,7 +17,7 @@ #include "zenoh-pico/transport/link/tx.h" #include "zenoh-pico/utils/logging.h" -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _zp_unicast_send_keep_alive(_z_transport_unicast_t *ztu) { int8_t ret = _Z_RES_OK; @@ -29,7 +29,7 @@ int8_t _zp_unicast_send_keep_alive(_z_transport_unicast_t *ztu) { } void *_zp_unicast_lease_task(void *ztu_arg) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_transport_unicast_t *ztu = (_z_transport_unicast_t *)ztu_arg; ztu->_received = false; @@ -83,9 +83,9 @@ void *_zp_unicast_lease_task(void *ztu_arg) { next_lease = next_lease - interval; next_keep_alive = next_keep_alive - interval; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return 0; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 diff --git a/src/transport/unicast/link/task/read.c b/src/transport/unicast/link/task/read.c index 31bc35609..bf27b1c70 100644 --- a/src/transport/unicast/link/task/read.c +++ b/src/transport/unicast/link/task/read.c @@ -21,7 +21,7 @@ #include "zenoh-pico/transport/link/rx.h" #include "zenoh-pico/utils/logging.h" -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _zp_unicast_read(_z_transport_unicast_t *ztu) { int8_t ret = _Z_RES_OK; @@ -37,7 +37,7 @@ int8_t _zp_unicast_read(_z_transport_unicast_t *ztu) { } void *_zp_unicast_read_task(void *ztu_arg) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_transport_unicast_t *ztu = (_z_transport_unicast_t *)ztu_arg; // Acquire and keep the lock @@ -107,9 +107,9 @@ void *_zp_unicast_read_task(void *ztu_arg) { } _z_mutex_unlock(&ztu->_mutex_rx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return NULL; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 diff --git a/src/transport/unicast/link/tx.c b/src/transport/unicast/link/tx.c index 8f825b7e4..eb43c769d 100644 --- a/src/transport/unicast/link/tx.c +++ b/src/transport/unicast/link/tx.c @@ -23,7 +23,7 @@ #include "zenoh-pico/transport/utils.h" #include "zenoh-pico/utils/logging.h" -#if Z_UNICAST_TRANSPORT == 1 +#if Z_FEATURE_UNICAST_TRANSPORT == 1 /** * This function is unsafe because it operates in potentially concurrent data. @@ -46,10 +46,10 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes int8_t ret = _Z_RES_OK; _Z_DEBUG(">> send session message\n"); -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock _z_mutex_lock(&ztu->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 // Prepare the buffer eventually reserving space for the message length __unsafe_z_prepare_wbuf(&ztu->_wbuf, _Z_LINK_IS_STREAMED(ztu->_link._capabilities)); @@ -66,9 +66,9 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztu->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } @@ -83,18 +83,18 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg // Acquire the lock and drop the message if needed _Bool drop = false; if (cong_ctrl == Z_CONGESTION_CONTROL_BLOCK) { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&ztu->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } else { -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 int8_t locked = _z_mutex_trylock(&ztu->_mutex_tx); if (locked != (int8_t)0) { _Z_INFO("Dropping zenoh message because of congestion control\n"); // We failed to acquire the lock, drop the message drop = true; } -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } if (drop == false) { @@ -154,12 +154,12 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg } } -#if Z_MULTI_THREAD == 1 +#if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_unlock(&ztu->_mutex_tx); -#endif // Z_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 } return ret; } -#endif // Z_UNICAST_TRANSPORT == 1 +#endif // Z_FEATURE_UNICAST_TRANSPORT == 1 From 28818dfee6574b64320b3ee507a9d47cd6b0fe7a Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 9 Oct 2023 10:32:35 +0200 Subject: [PATCH 6/6] build: update config files with new token names --- .github/workflows/arduino_esp32.yaml | 2 +- .github/workflows/emscripten.yaml | 2 +- .github/workflows/mbed.yaml | 2 +- .github/workflows/zephyr.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/arduino_esp32.yaml b/.github/workflows/arduino_esp32.yaml index 197ce7776..0e1865973 100644 --- a/.github/workflows/arduino_esp32.yaml +++ b/.github/workflows/arduino_esp32.yaml @@ -51,7 +51,7 @@ jobs: mkdir -p $ARDUINO_BASE cd $ARDUINO_BASE - platformio init -b esp32thing_plus --project-option="build_flags=-DZ_LINK_BLUETOOTH=1 -DZENOH_DEBUG=3" + platformio init -b esp32thing_plus --project-option="build_flags=-DZ_FEATURE_LINK_BLUETOOTH=1 -DZENOH_DEBUG=3" cd $ARDUINO_BASE/lib ln -s $ZENOH_PICO_BASE diff --git a/.github/workflows/emscripten.yaml b/.github/workflows/emscripten.yaml index b995749d9..7080b5579 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.yaml @@ -34,7 +34,7 @@ jobs: - name: Compile debug run: | mkdir build - emcmake cmake -E env CFLAGS="-DZ_LINK_WS=1 -DZ_LINK_TCP=0 -DZ_LINK_UDP_MULTICAST=0 -DZ_LINK_UDP_UNICAST=0 -DZ_SCOUTING_UDP=0" cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=11 -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DZENOH_DEBUG=3 -H. -Bbuild + emcmake cmake -E env CFLAGS="-DZ_FEATURE_LINK_WS=1 -DZ_FEATURE_LINK_TCP=0 -DZ_FEATURE_LINK_UDP_MULTICAST=0 -DZ_FEATURE_LINK_UDP_UNICAST=0 -DZ_FEATURE_SCOUTING_UDP=0" cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=11 -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DZENOH_DEBUG=3 -H. -Bbuild make -C build diff --git a/.github/workflows/mbed.yaml b/.github/workflows/mbed.yaml index 03386d06e..5bfbf4d94 100644 --- a/.github/workflows/mbed.yaml +++ b/.github/workflows/mbed.yaml @@ -51,7 +51,7 @@ jobs: mkdir -p $MBED_BASE cd $MBED_BASE - pio init -b nucleo_f767zi --project-option="framework=mbed" --project-option="build_flags=-DZ_LINK_SERIAL=1 -DZENOH_DEBUG=3" + pio init -b nucleo_f767zi --project-option="framework=mbed" --project-option="build_flags=-DZ_FEATURE_LINK_SERIAL=1 -DZENOH_DEBUG=3" cd $MBED_BASE/lib ln -s $ZENOH_PICO_BASE diff --git a/.github/workflows/zephyr.yaml b/.github/workflows/zephyr.yaml index 7ec080212..c7df7ecaa 100644 --- a/.github/workflows/zephyr.yaml +++ b/.github/workflows/zephyr.yaml @@ -51,7 +51,7 @@ jobs: mkdir -p $ZEPHYR_BASE cd $ZEPHYR_BASE - pio init -b nucleo_f767zi --project-option="framework=zephyr" --project-option="build_flags=-DZ_LINK_SERIAL=1 -DZENOH_DEBUG=3" + pio init -b nucleo_f767zi --project-option="framework=zephyr" --project-option="build_flags=-DZ_FEATURE_LINK_SERIAL=1 -DZENOH_DEBUG=3" cd $ZEPHYR_BASE/lib ln -s $ZENOH_PICO_BASE