Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove qos designated initializers #354

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ static inline z_qos_t z_qos_default(void) { return _Z_N_QOS_DEFAULT; }
* z_encoding_t encoding: The encoding of the value of this data sample.
* z_sample_kind_t kind: The kind of this data sample (PUT or DELETE).
* z_timestamp_t timestamp: The timestamp of this data sample.
* z_qos_t qos: Quality of service settings used to deliver this sample.
*/
typedef _z_sample_t z_sample_t;

Expand Down
17 changes: 4 additions & 13 deletions include/zenoh-pico/protocol/definitions/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,10 @@

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) {
_Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1;
_z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)};
return ret;
}
static inline z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) {
return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */);
}
static inline z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) {
return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP;
}
static inline _Bool _z_n_qos_get_express(_z_n_qos_t n_qos) { return (_Bool)(n_qos._val & 0x10 /* 0b10000 */); }
_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority);
z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos);
z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos);
_Bool _z_n_qos_get_express(_z_n_qos_t n_qos);
#define _z_n_qos_make(express, nodrop, priority) \
_z_n_qos_create((_Bool)express, nodrop ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP, \
(z_priority_t)priority)
Expand Down
9 changes: 9 additions & 0 deletions src/protocol/definitions/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,12 @@ void _z_msg_fix_mapping(_z_zenoh_message_t *msg, uint16_t mapping) {
break;
}
}
_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) {
_Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1;
_z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)};
return ret;
}
z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); }
z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) {
return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP;
}
Loading