Bluetooth: ISO: Change ISO recv flags to bitfield

Change the receive flags in the struct bt_iso_recv_info
to a bitfield instead of a single value. This will allow
us to extend the flags with more options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-03-30 13:06:02 +02:00 committed by Carles Cufí
parent 0b8b1ae997
commit ffedee6e39
4 changed files with 11 additions and 10 deletions

View file

@ -180,17 +180,17 @@ struct bt_iso_chan_path {
uint8_t cc[0];
};
/** ISO packet status flags */
/** ISO packet status flag bits */
enum {
/** The ISO packet is valid. */
BT_ISO_FLAGS_VALID,
BT_ISO_FLAGS_VALID = BIT(0),
/** @brief The ISO packet may possibly contain errors.
*
* May be caused by a failed CRC check or if missing a part of the SDU.
*/
BT_ISO_FLAGS_ERROR,
BT_ISO_FLAGS_ERROR = BIT(1),
/** The ISO packet was lost. */
BT_ISO_FLAGS_LOST
BT_ISO_FLAGS_LOST = BIT(2)
};
/** @brief ISO Meta Data structure for received ISO packets. */
@ -203,7 +203,7 @@ struct bt_iso_recv_info {
/** ISO packet sequence number of the first fragment in the SDU */
uint16_t sn;
/** ISO packet flags (BT_ISO_FLAGS_*) */
/** ISO packet flags bitfield (BT_ISO_FLAGS_*) */
uint8_t flags;
};

View file

@ -181,7 +181,7 @@ static void iso_recv(struct bt_iso_chan *chan,
/* NOTE: The packets received may be on different BISes */
if (info->flags == BT_ISO_FLAGS_VALID) {
if (info->flags & BT_ISO_FLAGS_VALID) {
stats_current_sync.iso_recv_count++;
stats_overall.iso_recv_count++;
stats_latest_arr[stats_latest_arr_pos++] = true;

View file

@ -216,7 +216,7 @@ static void iso_recv(struct bt_iso_chan *chan,
/* NOTE: The packets received may be on different CISes */
if (info->flags == BT_ISO_FLAGS_VALID) {
if (info->flags & BT_ISO_FLAGS_VALID) {
stats_current_conn.iso_recv_count++;
stats_overall.iso_recv_count++;
stats_latest_arr[stats_latest_arr_pos++] = true;

View file

@ -642,12 +642,13 @@ void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
pkt_seq_no = sys_le16_to_cpu(hdr->sn);
iso_info(buf)->sn = pkt_seq_no;
iso_info(buf)->flags = 0;
if (flags == BT_ISO_DATA_VALID) {
iso_info(buf)->flags = BT_ISO_FLAGS_VALID;
iso_info(buf)->flags |= BT_ISO_FLAGS_VALID;
} else if (flags == BT_ISO_DATA_INVALID) {
iso_info(buf)->flags = BT_ISO_FLAGS_ERROR;
iso_info(buf)->flags |= BT_ISO_FLAGS_ERROR;
} else if (flags == BT_ISO_DATA_NOP) {
iso_info(buf)->flags = BT_ISO_FLAGS_LOST;
iso_info(buf)->flags |= BT_ISO_FLAGS_LOST;
} else {
BT_WARN("Invalid ISO packet status flag: %u", flags);
iso_info(buf)->flags = 0;