Skip to content

Commit 96ce437

Browse files
sashacmcDenisBiryukov91milyinfuzzypixelzjean-roland
authored
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 <[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]>
1 parent 2c7929f commit 96ce437

File tree

21 files changed

+200
-39
lines changed

21 files changed

+200
-39
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ on:
2626
type: string
2727
description: Release number
2828
required: false
29+
branch:
30+
type: string
31+
description: Release branch
32+
required: false
2933
jobs:
3034
tag:
3135
name: Branch, Bump & tag
@@ -44,6 +48,7 @@ jobs:
4448
# However, we still need some placeholder version to test that the
4549
# version can be reliably bumped.
4650
version: ${{ inputs.version || '0.0.0' }}
51+
branch: ${{ inputs.branch }}
4752
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
4853

4954
- name: Checkout this repository

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ set(ZENOH_PICO_MINOR ${PROJECT_VERSION_MINOR})
2727
set(ZENOH_PICO_PATCH ${PROJECT_VERSION_PATCH})
2828
set(ZENOH_PICO_TWEAK ${PROJECT_VERSION_TWEAK})
2929

30+
configure_file(
31+
${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico.h.in
32+
${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico.h
33+
@ONLY
34+
)
35+
3036
set(project_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
3137
if(NOT DEFINED PROJECT_VERSION_TWEAK)
3238
set(project_version "${project_version}")

include/zenoh-pico/protocol/definitions/network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ typedef _z_qos_t _z_n_qos_t;
7878
static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control,
7979
z_priority_t priority) {
8080
_z_n_qos_t ret;
81-
_Bool nodrop = (congestion_control != Z_CONGESTION_CONTROL_DROP);
81+
_Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1;
8282
ret._val = (uint8_t)((express << 4) | (nodrop << 3) | priority);
8383
return ret;
8484
}

include/zenoh-pico/protocol/definitions/transport.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,12 @@ _z_transport_message_t _z_t_msg_make_open_syn(_z_zint_t lease, _z_zint_t initial
505505
_z_transport_message_t _z_t_msg_make_open_ack(_z_zint_t lease, _z_zint_t initial_sn);
506506
_z_transport_message_t _z_t_msg_make_close(uint8_t reason, _Bool link_only);
507507
_z_transport_message_t _z_t_msg_make_keep_alive(void);
508-
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable);
509-
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable);
510-
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last);
511-
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t messages, _Bool is_reliable, _Bool is_last);
508+
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages,
509+
z_reliability_t reliability);
510+
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability);
511+
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last);
512+
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t messages, z_reliability_t reliability,
513+
_Bool is_last);
512514

513515
/*------------------ Copy ------------------*/
514516
void _z_t_msg_copy(_z_transport_message_t *clone, _z_transport_message_t *msg);

src/protocol/definitions/transport.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ _z_transport_message_t _z_t_msg_make_keep_alive(void) {
209209
return msg;
210210
}
211211

212-
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable) {
212+
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages,
213+
z_reliability_t reliability) {
213214
_z_transport_message_t msg;
214215
msg._header = _Z_MID_T_FRAME;
215216

216217
msg._body._frame._sn = sn;
217-
if (is_reliable == true) {
218+
if (reliability == Z_RELIABILITY_RELIABLE) {
218219
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R);
219220
}
220221

@@ -224,12 +225,12 @@ _z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_
224225
}
225226

226227
/*------------------ Frame Message ------------------*/
227-
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable) {
228+
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability) {
228229
_z_transport_message_t msg;
229230
msg._header = _Z_MID_T_FRAME;
230231

231232
msg._body._frame._sn = sn;
232-
if (is_reliable == true) {
233+
if (reliability == Z_RELIABILITY_RELIABLE) {
233234
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R);
234235
}
235236

@@ -239,16 +240,17 @@ _z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliabl
239240
}
240241

241242
/*------------------ Fragment Message ------------------*/
242-
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last) {
243-
return _z_t_msg_make_fragment(sn, _z_slice_empty(), is_reliable, is_last);
243+
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last) {
244+
return _z_t_msg_make_fragment(sn, _z_slice_empty(), reliability, is_last);
244245
}
245-
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t payload, _Bool is_reliable, _Bool is_last) {
246+
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_slice_t payload, z_reliability_t reliability,
247+
_Bool is_last) {
246248
_z_transport_message_t msg;
247249
msg._header = _Z_MID_T_FRAGMENT;
248250
if (is_last == false) {
249251
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_M);
250252
}
251-
if (is_reliable == true) {
253+
if (reliability == Z_RELIABILITY_RELIABLE) {
252254
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_R);
253255
}
254256

src/system/windows/network.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ int8_t _z_open_tcp(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_t rep, u
6464

6565
sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol);
6666
if (sock->_sock._fd != INVALID_SOCKET) {
67-
z_time_t tv;
68-
tv.time = tout / (uint32_t)1000;
69-
tv.millitm = tout % (uint32_t)1000;
67+
DWORD tv = tout;
7068
if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) {
7169
ret = _Z_ERR_GENERIC;
7270
}
@@ -200,9 +198,7 @@ int8_t _z_open_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoint_
200198

201199
sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol);
202200
if (sock->_sock._fd != INVALID_SOCKET) {
203-
z_time_t tv;
204-
tv.time = tout / (uint32_t)1000;
205-
tv.millitm = tout % (uint32_t)1000;
201+
DWORD tv = tout;
206202
if ((ret == _Z_RES_OK) && (setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) {
207203
ret = _Z_ERR_GENERIC;
208204
}
@@ -326,9 +322,7 @@ int8_t _z_open_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpoin
326322
if (addrlen != 0U) {
327323
sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol);
328324
if (sock->_sock._fd != INVALID_SOCKET) {
329-
z_time_t tv;
330-
tv.time = tout / (uint32_t)1000;
331-
tv.millitm = tout % (uint32_t)1000;
325+
DWORD tv = tout;
332326
if ((ret == _Z_RES_OK) &&
333327
(setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) {
334328
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
430424
if (addrlen != 0U) {
431425
sock->_sock._fd = socket(rep._ep._iptcp->ai_family, rep._ep._iptcp->ai_socktype, rep._ep._iptcp->ai_protocol);
432426
if (sock->_sock._fd != INVALID_SOCKET) {
433-
z_time_t tv;
434-
tv.time = tout / (uint32_t)1000;
435-
tv.millitm = tout % (uint32_t)1000;
427+
DWORD tv = tout;
436428
if ((ret == _Z_RES_OK) &&
437429
(setsockopt(sock->_sock._fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)) < 0)) {
438430
ret = _Z_ERR_GENERIC;

src/system/zephyr/system.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ void _z_task_free(_z_task_t **task) {
9696
/*------------------ Mutex ------------------*/
9797
int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, 0); }
9898

99-
int8_t _z_mutex_drop(_z_mutex_t *m) { return pthread_mutex_destroy(m); }
99+
int8_t _z_mutex_drop(_z_mutex_t *m) {
100+
if (m == NULL) {
101+
return 0;
102+
}
103+
return pthread_mutex_destroy(m);
104+
}
100105

101106
int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); }
102107

src/transport/multicast/lease.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ void *_zp_multicast_lease_task(void *ztm_arg) {
189189
int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr_t *attr, _z_task_t *task) {
190190
// Init memory
191191
(void)memset(task, 0, sizeof(_z_task_t));
192-
// Init task
192+
ztm->_lease_task_running = true; // Init before z_task_init for concurrency issue
193+
// Init task
193194
if (_z_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) {
195+
ztm->_lease_task_running = false;
194196
return _Z_ERR_SYSTEM_TASK_FAILED;
195197
}
196198
// Attach task
197199
ztm->_lease_task = task;
198-
ztm->_lease_task_running = true;
199200
return _Z_RES_OK;
200201
}
201202

src/transport/multicast/read.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ void *_zp_multicast_read_task(void *ztm_arg) {
130130
int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) {
131131
// Init memory
132132
(void)memset(task, 0, sizeof(_z_task_t));
133-
// Init task
133+
zt->_transport._multicast._read_task_running = true; // Init before z_task_init for concurrency issue
134+
// Init task
134135
if (_z_task_init(task, attr, _zp_multicast_read_task, &zt->_transport._multicast) != _Z_RES_OK) {
136+
zt->_transport._multicast._read_task_running = false;
135137
return _Z_ERR_SYSTEM_TASK_FAILED;
136138
}
137139
// Attach task
138140
zt->_transport._multicast._read_task = task;
139-
zt->_transport._multicast._read_task_running = true;
140141
return _Z_RES_OK;
141142
}
142143

src/transport/raweth/read.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ void *_zp_raweth_read_task(void *ztm_arg) {
9090
int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) {
9191
// Init memory
9292
(void)memset(task, 0, sizeof(_z_task_t));
93+
zt->_transport._unicast._lease_task_running = true; // Init before z_task_init for concurrency issue
9394
// Init task
9495
if (_z_task_init(task, attr, _zp_raweth_read_task, &zt->_transport._raweth) != _Z_RES_OK) {
96+
zt->_transport._unicast._lease_task_running = false;
9597
return _Z_ERR_SYSTEM_TASK_FAILED;
9698
}
9799
// Attach task
98100
zt->_transport._raweth._read_task = task;
99-
zt->_transport._raweth._read_task_running = true;
100101
return _Z_RES_OK;
101102
}
102103

src/transport/unicast/read.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ void *_zp_unicast_read_task(void *ztu_arg) {
123123
int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, _z_task_t *task) {
124124
// Init memory
125125
(void)memset(task, 0, sizeof(_z_task_t));
126-
// Init task
126+
zt->_transport._unicast._read_task_running = true; // Init before z_task_init for concurrency issue
127+
// Init task
127128
if (_z_task_init(task, attr, _zp_unicast_read_task, &zt->_transport._unicast) != _Z_RES_OK) {
129+
zt->_transport._unicast._read_task_running = false;
128130
return _Z_ERR_SYSTEM_TASK_FAILED;
129131
}
130132
// Attach task
131133
zt->_transport._unicast._read_task = task;
132-
zt->_transport._unicast._read_task_running = true;
133134
return _Z_RES_OK;
134135
}
135136

tests/fragment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def check_output(tx_status, tx_output, rx_status, rx_output):
1414
# Expected rx output & status
1515
z_rx_expected_status = 0
1616
z_rx_expected_output = (
17-
"[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1")
17+
"[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1, qos {priority: 4, cong_ctrl: 0}")
1818

1919
# Check the exit status of tx
2020
if tx_status == z_tx_expected_status:

tests/z_client_test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ int main(int argc, char **argv) {
387387

388388
z_sleep_s(SLEEP);
389389

390+
// Stop read and lease tasks for zenoh-pico
391+
zp_stop_read_task(z_loan_mut(s1));
392+
zp_stop_lease_task(z_loan_mut(s1));
393+
394+
zp_stop_read_task(z_loan_mut(s2));
395+
zp_stop_lease_task(z_loan_mut(s2));
396+
390397
// Close both sessions
391398
printf("Closing session 1\n");
392399
z_close(z_move(s1));

tests/z_peer_multicast_test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ int main(int argc, char **argv) {
178178

179179
z_sleep_s(SLEEP);
180180

181+
// Stop read and lease tasks for zenoh-pico
182+
zp_stop_read_task(z_loan_mut(s1));
183+
zp_stop_lease_task(z_loan_mut(s1));
184+
185+
zp_stop_read_task(z_loan_mut(s2));
186+
zp_stop_lease_task(z_loan_mut(s2));
187+
181188
// Close both sessions
182189
printf("Closing session 1\n");
183190
z_close(z_move(s1));

tests/z_perf_tx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ int main(int argc, char **argv) {
106106
z_bytes_from_buf(&payload, value, 1, NULL, NULL);
107107

108108
z_publisher_put(z_loan(pub), z_move(payload), NULL);
109+
110+
// Stop read and lease tasks for zenoh-pico
111+
zp_stop_read_task(z_loan_mut(s));
112+
zp_stop_lease_task(z_loan_mut(s));
113+
109114
// Clean up
110115
z_undeclare_publisher(z_move(pub));
111116
z_close(z_move(s));

tests/z_session_test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string.h>
1818

1919
#include "zenoh-pico.h"
20+
#include "zenoh-pico/api/macros.h"
2021

2122
#undef NDEBUG
2223
#include <assert.h>
@@ -43,6 +44,10 @@ int main(void) {
4344
// Commented out wait for 1 second. Stopping should work without it.
4445
// z_sleep_ms(1000);
4546

47+
// Stop read and lease tasks for zenoh-pico
48+
zp_stop_read_task(z_loan_mut(s));
49+
zp_stop_lease_task(z_loan_mut(s));
50+
4651
// Immediately close the session
4752
z_close(&s);
4853
}

tests/z_test_fragment_rx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
3333
break;
3434
}
3535
}
36-
printf("[rx]: Received packet on %s, len: %d, validity: %d\n", z_string_data(z_loan(keystr)), (int)data_len,
37-
is_valid);
36+
printf("[rx]: Received packet on %s, len: %d, validity: %d, qos {priority: %d, cong_ctrl: %d}\n",
37+
z_string_data(z_loan(keystr)), (int)data_len, is_valid, z_qos_get_priority(sample->qos),
38+
z_qos_get_congestion_control(sample->qos));
3839
z_drop(z_move(value));
3940
}
4041

tests/z_test_fragment_tx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@ int main(int argc, char **argv) {
7676
// Put data
7777
z_view_keyexpr_t ke;
7878
z_view_keyexpr_from_str(&ke, keyexpr);
79+
80+
z_put_options_t options;
81+
z_put_options_default(&options);
82+
options.priority = Z_PRIORITY_DATA_HIGH;
83+
options.congestion_control = Z_CONGESTION_CONTROL_BLOCK;
84+
7985
for (int i = 0; i < 5; i++) {
8086
// Create payload
8187
z_owned_bytes_t payload;
8288
z_bytes_from_buf(&payload, value, size, NULL, NULL);
8389

8490
printf("[tx]: Sending packet on %s, len: %d\n", keyexpr, (int)size);
85-
if (z_put(z_loan(s), z_loan(ke), z_move(payload), NULL) < 0) {
91+
if (z_put(z_loan(s), z_loan(ke), z_move(payload), &options) < 0) {
8692
printf("Oh no! Put has failed...\n");
8793
return -1;
8894
}

zephyr/CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
if(CONFIG_ZENOH_PICO)
2+
3+
zephyr_compile_definitions(ZENOH_ZEPHYR)
4+
zephyr_include_directories(../include)
5+
zephyr_library()
6+
7+
function(configure_zenoh_feature config)
8+
string(REPLACE CONFIG_ZENOH_PICO Z_FEATURE feature ${config})
9+
if(${config})
10+
zephyr_compile_definitions(${feature}=1)
11+
else()
12+
zephyr_compile_definitions(${feature}=0)
13+
endif()
14+
endfunction()
15+
16+
17+
configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_SERIAL)
18+
configure_zenoh_feature(CONFIG_ZENOH_PICO_MULTI_THREAD)
19+
configure_zenoh_feature(CONFIG_ZENOH_PICO_PUBLICATION)
20+
configure_zenoh_feature(CONFIG_ZENOH_PICO_SUBSCRIPTION)
21+
configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERY)
22+
configure_zenoh_feature(CONFIG_ZENOH_PICO_QUERYABLE)
23+
configure_zenoh_feature(CONFIG_ZENOH_PICO_RAWETH_TRANSPORT)
24+
configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_TCP)
25+
configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_UNICAST)
26+
configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_UDP_MULTICAST)
27+
configure_zenoh_feature(CONFIG_ZENOH_PICO_SCOUTING_UDP)
28+
configure_zenoh_feature(CONFIG_ZENOH_PICO_LINK_WS)
29+
30+
31+
file(GLOB_RECURSE Sources
32+
"../src/api/*.c"
33+
"../src/collections/*.c"
34+
"../src/link/*.c"
35+
"../src/net/*.c"
36+
"../src/protocol/*.c"
37+
"../src/session/*.c"
38+
"../src/transport/*.c"
39+
"../src/utils/*.c"
40+
)
41+
42+
file (GLOB Sources_Zephyr "../src/system/zephyr/*.c")
43+
list(APPEND Sources ${Sources_Zephyr})
44+
zephyr_library_sources(${Sources})
45+
endif()

0 commit comments

Comments
 (0)