Skip to content

Commit

Permalink
Merge main into dev/1.0.0 (#567)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 eclipse-zenoh/zenoh-c#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 <[email protected]>
Co-authored-by: Denis Biryukov <[email protected]>
Co-authored-by: Michael Ilyin <[email protected]>
Co-authored-by: Mahmoud Mazouz <[email protected]>
Co-authored-by: Jean-Roland Gosse <[email protected]>
Co-authored-by: OlivierHecart <[email protected]>
Co-authored-by: oteffahi <[email protected]>
Co-authored-by: Geoff Martin <[email protected]>
Co-authored-by: Lieven <[email protected]>
Co-authored-by: Luca Cominardi <[email protected]>
Co-authored-by: OlivierHecart <[email protected]>
Co-authored-by: Anas Nashif <[email protected]>
Co-authored-by: Diogo Matsubara <[email protected]>
  • Loading branch information
13 people authored Aug 1, 2024
1 parent 2c7929f commit 96ce437
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/protocol/definitions/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions include/zenoh-pico/protocol/definitions/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 10 additions & 8 deletions src/protocol/definitions/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
16 changes: 4 additions & 12 deletions src/system/windows/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/system/zephyr/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
5 changes: 3 additions & 2 deletions src/transport/multicast/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/transport/multicast/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transport/raweth/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/transport/unicast/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tests/z_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 7 additions & 0 deletions tests/z_peer_multicast_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions tests/z_perf_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions tests/z_session_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string.h>

#include "zenoh-pico.h"
#include "zenoh-pico/api/macros.h"

#undef NDEBUG
#include <assert.h>
Expand All @@ -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);
}
5 changes: 3 additions & 2 deletions tests/z_test_fragment_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
8 changes: 7 additions & 1 deletion tests/z_test_fragment_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
45 changes: 45 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 96ce437

Please sign in to comment.