diff --git a/CMakeLists.txt b/CMakeLists.txt index 7920bdc68..ba8f552b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ set(Z_FEATURE_PUBLICATION 1 CACHE STRING "Toggle publication feature") set(Z_FEATURE_SUBSCRIPTION 1 CACHE STRING "Toggle subscription feature") set(Z_FEATURE_QUERY 1 CACHE STRING "Toggle query feature") set(Z_FEATURE_QUERYABLE 1 CACHE STRING "Toggle queryable feature") -set(Z_FEATURE_LIVELINESS 1 CACHE STRING "Toggle liveliness feature") +set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature") set(Z_FEATURE_INTEREST 1 CACHE STRING "Toggle interests") set(Z_FEATURE_FRAGMENTATION 1 CACHE STRING "Toggle fragmentation") set(Z_FEATURE_ENCODING_VALUES 1 CACHE STRING "Toggle encoding values") @@ -239,6 +239,12 @@ set(Z_FEATURE_PUBLISHER_SESSION_CHECK 1 CACHE STRING "Toggle publisher session c set(Z_FEATURE_BATCHING 1 CACHE STRING "Toggle batching") set(Z_FEATURE_RX_CACHE 0 CACHE STRING "Toggle RX_CACHE") +# Add a warning message if someone tries to enable Z_FEATURE_LIVELINESS directly +if(Z_FEATURE_LIVELINESS AND NOT Z_FEATURE_UNSTABLE_API) + message(WARNING "Z_FEATURE_LIVELINESS can only be enabled when Z_FEATURE_UNSTABLE_API is also enabled. Disabling Z_FEATURE_LIVELINESS.") + set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature" FORCE) +endif() + add_compile_definitions("Z_BUILD_DEBUG=$") message(STATUS "Building with feature confing:\n\ * UNSTABLE_API: ${Z_FEATURE_UNSTABLE_API}\n\ diff --git a/docs/api.rst b/docs/api.rst index 7271209eb..1a3893a0b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1289,7 +1289,7 @@ See details at :ref:`owned_types_concept` Functions --------- -.. autocfunction:: liveliness.h::z_liveliness_token_options_t_default +.. autocfunction:: liveliness.h::z_liveliness_token_options_default .. autocfunction:: liveliness.h::z_liveliness_declare_token .. autocfunction:: liveliness.h::z_liveliness_undeclare_token .. autocfunction:: liveliness.h::z_liveliness_subscriber_options_default diff --git a/include/zenoh-pico/api/liveliness.h b/include/zenoh-pico/api/liveliness.h index 43e3012fc..d3751bc4f 100644 --- a/include/zenoh-pico/api/liveliness.h +++ b/include/zenoh-pico/api/liveliness.h @@ -48,7 +48,7 @@ typedef struct z_liveliness_token_options_t { /** * Constructs default value for :c:type:`z_liveliness_token_options_t`. */ -z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t *options); +z_result_t z_liveliness_token_options_default(z_liveliness_token_options_t *options); /** * Constructs and declares a liveliness token on the network. diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index b28f3ec6c..3da9ab8f0 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -2063,9 +2063,9 @@ const z_loaned_keyexpr_t *z_subscriber_keyexpr(const z_loaned_subscriber_t *subs #ifdef Z_FEATURE_UNSTABLE_API #if Z_FEATURE_BATCHING == 1 /** - * Activate the batching mechanism. - * Any message that would have been sent on the network by a subsequent api call (e.g z_put, z_get) - * will be instead stored until the batch is full or batching is stopped with :c:func:`zp_batch_stop`. + * Activate the batching mechanism, any message that would have been sent on the network by a subsequent api call (e.g + * z_put, z_get) will be instead stored until the batch is full, flushed with :c:func:`zp_batch_flush` or batching is + * stopped with :c:func:`zp_batch_stop`. * * Parameters: * zs: Pointer to a :c:type:`z_loaned_session_t` that will start batching messages. @@ -2076,7 +2076,18 @@ const z_loaned_keyexpr_t *z_subscriber_keyexpr(const z_loaned_subscriber_t *subs z_result_t zp_batch_start(const z_loaned_session_t *zs); /** - * Deactivate the batching mechanism and flush the remaining messages. + * Send the currently batched messages on the network. + * + * Parameters: + * zs: Pointer to a :c:type:`z_loaned_session_t` that will send its batched messages. + * + * Return: + * ``0`` if batch successfully sent, ``negative value`` otherwise. + */ +z_result_t zp_batch_flush(const z_loaned_session_t *zs); + +/** + * Deactivate the batching mechanism and send the currently batched on the network. * * Parameters: * zs: Pointer to a :c:type:`z_loaned_session_t` that will stop batching messages. diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h index 4e4ae9f99..840dff4ee 100644 --- a/include/zenoh-pico/config.h +++ b/include/zenoh-pico/config.h @@ -27,7 +27,7 @@ #define Z_FEATURE_SUBSCRIPTION 1 #define Z_FEATURE_QUERY 1 #define Z_FEATURE_QUERYABLE 1 -#define Z_FEATURE_LIVELINESS 1 +#define Z_FEATURE_LIVELINESS 0 #define Z_FEATURE_RAWETH_TRANSPORT 0 #define Z_FEATURE_INTEREST 1 #define Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION 0 @@ -44,9 +44,9 @@ #define Z_FEATURE_ENCODING_VALUES 1 #define Z_FEATURE_TCP_NODELAY 1 #define Z_FEATURE_LOCAL_SUBSCRIBER 0 -#define Z_FEATURE_PUBLISHER_SESSION_CHECK 0 +#define Z_FEATURE_PUBLISHER_SESSION_CHECK 1 #define Z_FEATURE_BATCHING 1 -#define Z_FEATURE_RX_CACHE 1 +#define Z_FEATURE_RX_CACHE 0 // End of CMake generation /*------------------ Runtime configuration properties ------------------*/ diff --git a/include/zenoh-pico/net/primitives.h b/include/zenoh-pico/net/primitives.h index 53db370e1..b53a8f4e4 100644 --- a/include/zenoh-pico/net/primitives.h +++ b/include/zenoh-pico/net/primitives.h @@ -29,10 +29,6 @@ extern "C" { #endif -#ifdef __cplusplus -extern "C" { -#endif - /*------------------ Discovery ------------------*/ /** diff --git a/src/api/api.c b/src/api/api.c index 40f3e5ed3..c4b827209 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -1432,6 +1432,15 @@ z_result_t zp_batch_start(const z_loaned_session_t *zs) { return _z_transport_start_batching(&session->_tp) ? _Z_RES_OK : _Z_ERR_GENERIC; } +z_result_t zp_batch_flush(const z_loaned_session_t *zs) { + _z_session_t *session = _Z_RC_IN_VAL(zs); + if (_Z_RC_IS_NULL(zs)) { + return _Z_ERR_SESSION_CLOSED; + } + // Send current batch + return _z_send_n_batch(session, Z_CONGESTION_CONTROL_DEFAULT); +} + z_result_t zp_batch_stop(const z_loaned_session_t *zs) { _z_session_t *session = _Z_RC_IN_VAL(zs); if (_Z_RC_IS_NULL(zs)) { diff --git a/src/transport/multicast/rx.c b/src/transport/multicast/rx.c index 1ab13f161..dc64460e4 100644 --- a/src/transport/multicast/rx.c +++ b/src/transport/multicast/rx.c @@ -252,8 +252,6 @@ z_result_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _Z_INFO("Failed to decode defragmented message"); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } - // Fragmented messages must be cleared. Non-fragmented messages are released with their transport. - _z_msg_clear(&zm); // Free the decoding buffer _z_zbuf_clear(&zbf); *dbuf_state = _Z_DBUF_STATE_NULL; diff --git a/src/transport/unicast/rx.c b/src/transport/unicast/rx.c index 628f2815d..d90b59f38 100644 --- a/src/transport/unicast/rx.c +++ b/src/transport/unicast/rx.c @@ -204,8 +204,6 @@ z_result_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_t _Z_INFO("Failed to decode defragmented message"); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } - // Fragmented messages must be cleared. Non-fragmented messages are released with their transport. - _z_msg_clear(&zm); // Free the decoding buffer _z_zbuf_clear(&zbf); *dbuf_state = _Z_DBUF_STATE_NULL; diff --git a/src/transport/unicast/transport.c b/src/transport/unicast/transport.c index 9ae20a38c..64a1d6540 100644 --- a/src/transport/unicast/transport.c +++ b/src/transport/unicast/transport.c @@ -217,6 +217,8 @@ static z_result_t _z_unicast_handshake_client(_z_transport_unicast_establish_par return _Z_RES_OK; } +// TODO: Activate if we add peer unicast support +#if 0 static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid, enum z_whatami_t whatami) { // Read t message from link @@ -293,6 +295,16 @@ static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_p // Handshake finished return _Z_RES_OK; } +#else +static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, + const _z_id_t *local_zid, enum z_whatami_t whatami) { + _ZP_UNUSED(param); + _ZP_UNUSED(zl); + _ZP_UNUSED(local_zid); + _ZP_UNUSED(whatami); + return _Z_ERR_TRANSPORT_OPEN_FAILED; +} +#endif z_result_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) {