From 96ce437e0595d9aab9a7ba35d5047dd2c56cb1ee Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 1 Aug 2024 12:20:36 +0200 Subject: [PATCH] Merge main into dev/1.0.0 (#567) * add support for qos settings in sample * - silence cpp compiler regading compound literals and type conversions, - add missing dots in docs * fix _z_qos_t definition and doc * fix z_qos_t definition and doc * - replace binary literals (non-core C) with hexadecimal ones - replace _z_n_qos_unmake with _z_n_qos_unmake_public in subscription.c * make _z_n_qos_unmake static inline to prevent linking errors * fix format * reduce qos size to 1 byte; use getters to extract individual qos settings * fix _z_n_qos_make to no longer use compund literals to avoid warnings from zenoh-cpp * fix z_qos_default() signature * Add Flipper platform (#351) * Add Flipper platform * Fix warnings and other platform builds * move z_n_qos_t related functions into .c (to hide designated initializers from c++) * z_sample_t docs update to include qos * move qos functions back to header and remove usage of designated initializers * format * fix: Bump sphinx doc build dep to `7.2.6` (#361) * replac zp_ prefix for platform functions that are also available in zenoh-c * fix format * replace zp_ prefix with z_ for zp_random_u64 * put back previously removed zp_ functions as deprecated * added missing new line at the end of the file * typo fix * move deprecated platform header to a separate folder * Add config endpoint in raweth locator (#364) * feat: add ethtype to reth endpoint config * feat: type renaming * fix: remove unused macro call * feat: remove static raweth config * feat: use defines for separators * feat: add mapping function * fix: add default raweth mapping * feat: add debug traces on raweth config parsing * fix: ethtype validity test * fix: strtok parsing calls * chore: clang-format * fix: include first mapping entry in lookup * fix: appease the tyran codacy * Fix bug reading from ws (#370) * Expose timeout option in z_get_options_t (#375) * Expose timeout option in z_get_options_t * Add default get timeout * Align examples and remove reading from stdin (#359) * Remove reading from stdin, align example implementations * Update examples tests * Adjust z_sub_thr output * Fix z_get single query examples * Replace pthread uses with z_mutex and z_condvar * Add multi-thread feature condition to z_get examples * Update error message for features absence * Update z_get expected output in modularity test * Update sample count for freertos single-thread examples * fix: remove unused variable warning (#379) * Changing references to zenoh:master to zenoh:main. (#381) * correct unsigned atomic in refcount.h (#382) * Fix refcount cast (#384) * Fix esp32 CI (#386) * fix: const discard warning * build: fix platformio dependency check * Serial timeout (#383) * correct unsigned atomic in refcount.h * made espidf freertos compatible with timeout on read --------- Co-authored-by: Luca Cominardi * Run clang-format (#388) * Fix misra violations (#390) * chore: run clang format * fix: misra issues * ci: Allow building zenoh from arbitrary branch in build-check workflow (#389) * ci: Allow building Zenoh from arbitrary branch in build-check workflow * Update other jobs --------- Co-authored-by: OlivierHecart * support for integration as a west module in zephyr (#395) Integrate zenoh as a west module and enable adding zenoh as a library using kconfig. This will allows easier integration with zephyr by including in the west manifest (west.yml), i.e.: @@ -2,7 +2,13 @@ manifest: remotes: - name: upstream url-base: https://github.com/zephyrproject-rtos + - name: zenoh + url-base: https://github.com/eclipse-zenoh projects: + - name: zenoh-pico + revision: main + path: external/zenoh-pico + remote: zenoh - name: canopennode revision: dec12fa3f0d790cafa8414a4c2930ea71ab72ffd path: modules/lib/canopennode and then enabling the publication example with: CONFIG_ZENOH_PICO=y CONFIG_ZENOH_PICO_LINK_SERIAL=y CONFIG_ZENOH_PICO_PUBLICATION=y application can then be built with west: west build -b reel_board zephyr/samples/publication Signed-off-by: Anas Nashif * fix: concurrency issue on task_running init value (#401) * feat: Automate Release (#402) * feat: Store project version in `version.txt` * fix: Add `CMakeFiles` to `.gitignore` * feat: Automate Release * fix: Remove enforce-linking-issues workflow * fix: Remove unecessary SSH passphrase/privatekey inputs * fix: Force push release branch * fix: Make build-macos need pre-build * fix: Typo in pre-build.bash path * fix: Typo in examples build path * Fix windows socket timeout value (#411) * fix: replace windows sockopt timeout value type * fix: void functions returning value * fix: use z_reliability enum type to set flag (#413) * ci: change raweth workflow (#416) * Enable releasing from any branch (#421) * Align version with zenoh-c (#438) As per https://github.com/eclipse-zenoh/zenoh-c/pull/466, align how we configure zenoh CMake based projects version. * feat: add malloc value guards for freertos (#527) * fix: add mutex free value guard (#551) * Add missed merge changes --------- Signed-off-by: Anas Nashif Co-authored-by: Denis Biryukov Co-authored-by: Michael Ilyin Co-authored-by: Mahmoud Mazouz Co-authored-by: Jean-Roland Gosse Co-authored-by: OlivierHecart Co-authored-by: oteffahi <70609372+oteffahi@users.noreply.github.com> Co-authored-by: Geoff Martin Co-authored-by: Lieven Co-authored-by: Luca Cominardi Co-authored-by: OlivierHecart Co-authored-by: Anas Nashif Co-authored-by: Diogo Matsubara --- .github/workflows/release.yml | 5 ++ CMakeLists.txt | 6 ++ .../zenoh-pico/protocol/definitions/network.h | 2 +- .../protocol/definitions/transport.h | 10 +-- src/protocol/definitions/transport.c | 18 ++--- src/system/windows/network.c | 16 ++--- src/system/zephyr/system.c | 7 +- src/transport/multicast/lease.c | 5 +- src/transport/multicast/read.c | 5 +- src/transport/raweth/read.c | 3 +- src/transport/unicast/read.c | 5 +- tests/fragment.py | 2 +- tests/z_client_test.c | 7 ++ tests/z_peer_multicast_test.c | 7 ++ tests/z_perf_tx.c | 5 ++ tests/z_session_test.c | 5 ++ tests/z_test_fragment_rx.c | 5 +- tests/z_test_fragment_tx.c | 8 ++- zephyr/CMakeLists.txt | 45 ++++++++++++ zephyr/Kconfig.zenoh | 69 +++++++++++++++++++ zephyr/module.yml | 4 +- 21 files changed, 200 insertions(+), 39 deletions(-) create mode 100644 zephyr/CMakeLists.txt create mode 100644 zephyr/Kconfig.zenoh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7599b0ba4..01fb354b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,10 @@ on: type: string description: Release number required: false + branch: + type: string + description: Release branch + required: false jobs: tag: name: Branch, Bump & tag @@ -44,6 +48,7 @@ jobs: # However, we still need some placeholder version to test that the # version can be reliably bumped. version: ${{ inputs.version || '0.0.0' }} + branch: ${{ inputs.branch }} github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }} - name: Checkout this repository diff --git a/CMakeLists.txt b/CMakeLists.txt index 408ce5d07..21c321878 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,12 @@ set(ZENOH_PICO_MINOR ${PROJECT_VERSION_MINOR}) set(ZENOH_PICO_PATCH ${PROJECT_VERSION_PATCH}) set(ZENOH_PICO_TWEAK ${PROJECT_VERSION_TWEAK}) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico.h + @ONLY +) + set(project_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") if(NOT DEFINED PROJECT_VERSION_TWEAK) set(project_version "${project_version}") diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index 004897594..023959cce 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -78,7 +78,7 @@ typedef _z_qos_t _z_n_qos_t; static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) { _z_n_qos_t ret; - _Bool nodrop = (congestion_control != Z_CONGESTION_CONTROL_DROP); + _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; ret._val = (uint8_t)((express << 4) | (nodrop << 3) | priority); return ret; } diff --git a/include/zenoh-pico/protocol/definitions/transport.h b/include/zenoh-pico/protocol/definitions/transport.h index 30c064585..74f4de973 100644 --- a/include/zenoh-pico/protocol/definitions/transport.h +++ b/include/zenoh-pico/protocol/definitions/transport.h @@ -505,10 +505,12 @@ _z_transport_message_t _z_t_msg_make_open_syn(_z_zint_t lease, _z_zint_t initial _z_transport_message_t _z_t_msg_make_open_ack(_z_zint_t lease, _z_zint_t initial_sn); _z_transport_message_t _z_t_msg_make_close(uint8_t reason, _Bool link_only); _z_transport_message_t _z_t_msg_make_keep_alive(void); -_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable); -_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable); -_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last); -_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t messages, _Bool is_reliable, _Bool is_last); +_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, + z_reliability_t reliability); +_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability); +_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last); +_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t messages, z_reliability_t reliability, + _Bool is_last); /*------------------ Copy ------------------*/ void _z_t_msg_copy(_z_transport_message_t *clone, _z_transport_message_t *msg); diff --git a/src/protocol/definitions/transport.c b/src/protocol/definitions/transport.c index 39bbee9d1..28b670f5d 100644 --- a/src/protocol/definitions/transport.c +++ b/src/protocol/definitions/transport.c @@ -209,12 +209,13 @@ _z_transport_message_t _z_t_msg_make_keep_alive(void) { return msg; } -_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable) { +_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, + z_reliability_t reliability) { _z_transport_message_t msg; msg._header = _Z_MID_T_FRAME; msg._body._frame._sn = sn; - if (is_reliable == true) { + if (reliability == Z_RELIABILITY_RELIABLE) { _Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R); } @@ -224,12 +225,12 @@ _z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_ } /*------------------ Frame Message ------------------*/ -_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable) { +_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability) { _z_transport_message_t msg; msg._header = _Z_MID_T_FRAME; msg._body._frame._sn = sn; - if (is_reliable == true) { + if (reliability == Z_RELIABILITY_RELIABLE) { _Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R); } @@ -239,16 +240,17 @@ _z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliabl } /*------------------ Fragment Message ------------------*/ -_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last) { - return _z_t_msg_make_fragment(sn, _z_slice_empty(), is_reliable, is_last); +_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last) { + return _z_t_msg_make_fragment(sn, _z_slice_empty(), reliability, is_last); } -_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t payload, _Bool is_reliable, _Bool is_last) { +_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t payload, z_reliability_t reliability, + _Bool is_last) { _z_transport_message_t msg; msg._header = _Z_MID_T_FRAGMENT; if (is_last == false) { _Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_M); } - if (is_reliable == true) { + if (reliability == Z_RELIABILITY_RELIABLE) { _Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_R); } diff --git a/src/system/windows/network.c b/src/system/windows/network.c index 821a2883f..77dd68720 100644 --- a/src/system/windows/network.c +++ b/src/system/windows/network.c @@ -64,9 +64,7 @@ int8_t _z_open_tcp(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, u sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol); if (sock->_sock._fd != INVALID_SOCKET) { - z_time_t tv; - tv.time = tout / (uint32_t)1000; - tv.millitm = tout % (uint32_t)1000; + DWORD tv = tout; if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) { ret = _Z_ERR_GENERIC; } @@ -200,9 +198,7 @@ int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_ sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol); if (sock->_sock._fd != INVALID_SOCKET) { - z_time_t tv; - tv.time = tout / (uint32_t)1000; - tv.millitm = tout % (uint32_t)1000; + DWORD tv = tout; if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) { ret = _Z_ERR_GENERIC; } @@ -326,9 +322,7 @@ int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoin if (addrlen != 0U) { sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol); if (sock->_sock._fd != INVALID_SOCKET) { - z_time_t tv; - tv.time = tout / (uint32_t)1000; - tv.millitm = tout % (uint32_t)1000; + DWORD tv = tout; if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) { ret = _Z_ERR_GENERIC; @@ -430,9 +424,7 @@ int8_t _z_listen_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpo if (addrlen != 0U) { sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol); if (sock->_sock._fd != INVALID_SOCKET) { - z_time_t tv; - tv.time = tout / (uint32_t)1000; - tv.millitm = tout % (uint32_t)1000; + DWORD tv = tout; if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) { ret = _Z_ERR_GENERIC; diff --git a/src/system/zephyr/system.c b/src/system/zephyr/system.c index 132644fce..a40328a28 100644 --- a/src/system/zephyr/system.c +++ b/src/system/zephyr/system.c @@ -96,7 +96,12 @@ void _z_task_free(_z_task_t **task) { /*------------------ Mutex ------------------*/ int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, 0); } -int8_t _z_mutex_drop(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t _z_mutex_drop(_z_mutex_t *m) { + if (m == NULL) { + return 0; + } + return pthread_mutex_destroy(m); +} int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } diff --git a/src/transport/multicast/lease.c b/src/transport/multicast/lease.c index 7661d0e87..3a62de042 100644 --- a/src/transport/multicast/lease.c +++ b/src/transport/multicast/lease.c @@ -189,13 +189,14 @@ void *_zp_multicast_lease_task(void *ztm_arg) { int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr_t *attr, _z_task_t *task) { // Init memory (void)memset(task, 0, sizeof(_z_task_t)); - // Init task + ztm->_lease_task_running = true; // Init before z_task_init for concurrency issue + // Init task if (_z_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) { + ztm->_lease_task_running = false; return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task ztm->_lease_task = task; - ztm->_lease_task_running = true; return _Z_RES_OK; } diff --git a/src/transport/multicast/read.c b/src/transport/multicast/read.c index 8c8784373..bc9c76f2c 100644 --- a/src/transport/multicast/read.c +++ b/src/transport/multicast/read.c @@ -130,13 +130,14 @@ void *_zp_multicast_read_task(void *ztm_arg) { int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) { // Init memory (void)memset(task, 0, sizeof(_z_task_t)); - // Init task + zt->_transport._multicast._read_task_running = true; // Init before z_task_init for concurrency issue + // Init task if (_z_task_init(task, attr, _zp_multicast_read_task, &zt->_transport._multicast) != _Z_RES_OK) { + zt->_transport._multicast._read_task_running = false; return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task zt->_transport._multicast._read_task = task; - zt->_transport._multicast._read_task_running = true; return _Z_RES_OK; } diff --git a/src/transport/raweth/read.c b/src/transport/raweth/read.c index 13c100621..5e85dc4a4 100644 --- a/src/transport/raweth/read.c +++ b/src/transport/raweth/read.c @@ -90,13 +90,14 @@ void *_zp_raweth_read_task(void *ztm_arg) { int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) { // Init memory (void)memset(task, 0, sizeof(_z_task_t)); + zt->_transport._unicast._lease_task_running = true; // Init before z_task_init for concurrency issue // Init task if (_z_task_init(task, attr, _zp_raweth_read_task, &zt->_transport._raweth) != _Z_RES_OK) { + zt->_transport._unicast._lease_task_running = false; return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task zt->_transport._raweth._read_task = task; - zt->_transport._raweth._read_task_running = true; return _Z_RES_OK; } diff --git a/src/transport/unicast/read.c b/src/transport/unicast/read.c index 8b1227aba..fbea2f6d8 100644 --- a/src/transport/unicast/read.c +++ b/src/transport/unicast/read.c @@ -123,13 +123,14 @@ void *_zp_unicast_read_task(void *ztu_arg) { int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) { // Init memory (void)memset(task, 0, sizeof(_z_task_t)); - // Init task + zt->_transport._unicast._read_task_running = true; // Init before z_task_init for concurrency issue + // Init task if (_z_task_init(task, attr, _zp_unicast_read_task, &zt->_transport._unicast) != _Z_RES_OK) { + zt->_transport._unicast._read_task_running = false; return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task zt->_transport._unicast._read_task = task; - zt->_transport._unicast._read_task_running = true; return _Z_RES_OK; } diff --git a/tests/fragment.py b/tests/fragment.py index d29295f0f..7b2a6f8d5 100644 --- a/tests/fragment.py +++ b/tests/fragment.py @@ -14,7 +14,7 @@ def check_output(tx_status, tx_output, rx_status, rx_output): # Expected rx output & status z_rx_expected_status = 0 z_rx_expected_output = ( - "[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1") + "[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1, qos {priority: 4, cong_ctrl: 0}") # Check the exit status of tx if tx_status == z_tx_expected_status: diff --git a/tests/z_client_test.c b/tests/z_client_test.c index ac3b631f4..0317c24fa 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -387,6 +387,13 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); + // Stop read and lease tasks for zenoh-pico + zp_stop_read_task(z_loan_mut(s1)); + zp_stop_lease_task(z_loan_mut(s1)); + + zp_stop_read_task(z_loan_mut(s2)); + zp_stop_lease_task(z_loan_mut(s2)); + // Close both sessions printf("Closing session 1\n"); z_close(z_move(s1)); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 2a6d98e45..5afebbbcb 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -178,6 +178,13 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); + // Stop read and lease tasks for zenoh-pico + zp_stop_read_task(z_loan_mut(s1)); + zp_stop_lease_task(z_loan_mut(s1)); + + zp_stop_read_task(z_loan_mut(s2)); + zp_stop_lease_task(z_loan_mut(s2)); + // Close both sessions printf("Closing session 1\n"); z_close(z_move(s1)); diff --git a/tests/z_perf_tx.c b/tests/z_perf_tx.c index 906ec2aa1..4c8c7cd0a 100644 --- a/tests/z_perf_tx.c +++ b/tests/z_perf_tx.c @@ -106,6 +106,11 @@ int main(int argc, char **argv) { z_bytes_from_buf(&payload, value, 1, NULL, NULL); z_publisher_put(z_loan(pub), z_move(payload), NULL); + + // Stop read and lease tasks for zenoh-pico + zp_stop_read_task(z_loan_mut(s)); + zp_stop_lease_task(z_loan_mut(s)); + // Clean up z_undeclare_publisher(z_move(pub)); z_close(z_move(s)); diff --git a/tests/z_session_test.c b/tests/z_session_test.c index a78f89a3f..4b662d0a0 100644 --- a/tests/z_session_test.c +++ b/tests/z_session_test.c @@ -17,6 +17,7 @@ #include #include "zenoh-pico.h" +#include "zenoh-pico/api/macros.h" #undef NDEBUG #include @@ -43,6 +44,10 @@ int main(void) { // Commented out wait for 1 second. Stopping should work without it. // z_sleep_ms(1000); + // Stop read and lease tasks for zenoh-pico + zp_stop_read_task(z_loan_mut(s)); + zp_stop_lease_task(z_loan_mut(s)); + // Immediately close the session z_close(&s); } diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 8edaa5a96..a122fb704 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -33,8 +33,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { break; } } - printf("[rx]: Received packet on %s, len: %d, validity: %d\n", z_string_data(z_loan(keystr)), (int)data_len, - is_valid); + printf("[rx]: Received packet on %s, len: %d, validity: %d, qos {priority: %d, cong_ctrl: %d}\n", + z_string_data(z_loan(keystr)), (int)data_len, is_valid, z_qos_get_priority(sample->qos), + z_qos_get_congestion_control(sample->qos)); z_drop(z_move(value)); } diff --git a/tests/z_test_fragment_tx.c b/tests/z_test_fragment_tx.c index 07ed301b0..bf12b18dc 100644 --- a/tests/z_test_fragment_tx.c +++ b/tests/z_test_fragment_tx.c @@ -76,13 +76,19 @@ int main(int argc, char **argv) { // Put data z_view_keyexpr_t ke; z_view_keyexpr_from_str(&ke, keyexpr); + + z_put_options_t options; + z_put_options_default(&options); + options.priority = Z_PRIORITY_DATA_HIGH; + options.congestion_control = Z_CONGESTION_CONTROL_BLOCK; + for (int i = 0; i < 5; i++) { // Create payload z_owned_bytes_t payload; z_bytes_from_buf(&payload, value, size, NULL, NULL); printf("[tx]: Sending packet on %s, len: %d\n", keyexpr, (int)size); - if (z_put(z_loan(s), z_loan(ke), z_move(payload), NULL) < 0) { + if (z_put(z_loan(s), z_loan(ke), z_move(payload), &options) < 0) { printf("Oh no! Put has failed...\n"); return -1; } diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt new file mode 100644 index 000000000..3559a1c90 --- /dev/null +++ b/zephyr/CMakeLists.txt @@ -0,0 +1,45 @@ +if(CONFIG_ZENOH_PICO) + +zephyr_compile_definitions(ZENOH_ZEPHYR) +zephyr_include_directories(../include) +zephyr_library() + +function(configure_zenoh_feature config) + string(REPLACE CONFIG_ZENOH_PICO Z_FEATURE feature ${config}) + if(${config}) + zephyr_compile_definitions(${feature}=1) + else() + zephyr_compile_definitions(${feature}=0) + endif() +endfunction() + + +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_SERIAL) +configure_zenoh_feature(CONFIG_ZENOH_PICO_MULTI_THREAD) +configure_zenoh_feature(CONFIG_ZENOH_PICO_PUBLICATION) +configure_zenoh_feature(CONFIG_ZENOH_PICO_SUBSCRIPTION) +configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERY) +configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERYABLE) +configure_zenoh_feature(CONFIG_ZENOH_PICO_RAWETH_TRANSPORT) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_TCP) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_UNICAST) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_MULTICAST) +configure_zenoh_feature(CONFIG_ZENOH_PICO_SCOUTING_UDP) +configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_WS) + + +file(GLOB_RECURSE Sources + "../src/api/*.c" + "../src/collections/*.c" + "../src/link/*.c" + "../src/net/*.c" + "../src/protocol/*.c" + "../src/session/*.c" + "../src/transport/*.c" + "../src/utils/*.c" +) + +file (GLOB Sources_Zephyr "../src/system/zephyr/*.c") +list(APPEND Sources ${Sources_Zephyr}) +zephyr_library_sources(${Sources}) +endif() diff --git a/zephyr/Kconfig.zenoh b/zephyr/Kconfig.zenoh new file mode 100644 index 000000000..fce27a370 --- /dev/null +++ b/zephyr/Kconfig.zenoh @@ -0,0 +1,69 @@ +config ZENOH_PICO + bool "Zenoh PICO library" + help + Enable Zenoh pico support + +if ZENOH_PICO + +config ZENOH_PICO_LINK_SERIAL + bool "Serial Link" + help + Use serial link + +config ZENOH_PICO_MULTI_THREAD + bool "Multithreading support" + help + Multithreading support + +config ZENOH_PICO_PUBLICATION + bool "Publication Support" + help + Publication support + +config ZENOH_PICO_SUBSCRIPTION + bool "Subscription Support" + help + Subscription Support + +config ZENOH_PICO_QUERY + bool "Query Support" + help + Query Support + +config ZENOH_PICO_QUERYABLE + bool "Queryable Support" + help + Queryable Support + +config ZENOH_PICO_RAWETH_TRANSPORT + bool "Raw Ethernet Support" + help + Raw Ethernet Support + +config ZENOH_PICO_LINK_TCP + bool "TCP Link" + help + TCP Link + +config ZENOH_PICO_LINK_UDP_UNICAST + bool "UDP Unicast" + help + UDP Unicast + +config ZENOH_PICO_LINK_UDP_MULTICAST + bool "UDP Multicast" + help + UDP Multicast + +config ZENOH_PICO_SCOUTING_UDP + bool "Scouting UDP" + help + Scouting UDP + +config ZENOH_PICO_LINK_WS + bool "WS Link" + help + WS Link + +endif + diff --git a/zephyr/module.yml b/zephyr/module.yml index 31f5d4f30..507856e5e 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -1,4 +1,4 @@ name: zenoh-pico build: - cmake-ext: True - kconfig-ext: True + cmake: zephyr/ + kconfig: zephyr/Kconfig.zenoh