From: Prathibha Madugonde <prathibha.madugonde@oss.qualcomm.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, quic_mohamull@quicinc.com,
quic_hbandi@quicinc.com, quic_anubhavg@quicinc.com
Subject: [PATCH BlueZ v1] shared/rap: Fix Mode 0 step serialization
Date: Thu, 18 Jun 2026 13:25:29 +0530 [thread overview]
Message-ID: <20260618075529.98419-1-prathm@qti.qualcomm.com> (raw)
From: Prathibha Madugonde <prathibha.madugonde@oss.qualcomm.com>
Replace raw struct byte dump with field-by-field serialization
that conditionally includes init_measured_freq_offset only for
the Initiator role, matching the RAS wire format (5 bytes for
Initiator, 3 bytes for Reflector)
---
src/shared/rap.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/shared/rap.c b/src/shared/rap.c
index 390fd3080..ecf7df5a7 100644
--- a/src/shared/rap.c
+++ b/src/shared/rap.c
@@ -1307,15 +1307,40 @@ static void process_cs_mode_zero(struct bt_rap *rap,
const struct cs_step_data *step,
uint8_t idx, uint8_t mode_byte)
{
- const uint8_t *payload;
- uint8_t plen;
+ const struct cs_mode_zero_data *m0 =
+ &step->step_mode_data.mode_zero_data;
+ struct cstracker *resptracker = rap->resptracker;
+ enum cs_role cs_role = resptracker->role;
+ struct iovec temp_iov = { 0 };
+
+ temp_iov.iov_base = malloc(8);
+ if (!temp_iov.iov_base) {
+ DBG(rap, "Mode0 ERROR: malloc failed!");
+ return;
+ }
+ temp_iov.iov_len = 0;
+
+ if (!util_iov_push_u8(&temp_iov, m0->packet_quality) ||
+ !util_iov_push_u8(&temp_iov, m0->packet_rssi_dbm) ||
+ !util_iov_push_u8(&temp_iov, m0->packet_ant))
+ goto done;
+
+ if (cs_role == CS_ROLE_INITIATOR) {
+ if (!util_iov_push_le16(&temp_iov,
+ m0->init_measured_freq_offset))
+ goto done;
+ }
- /* Mode 0: use raw structure bytes */
- payload = (const uint8_t *)&step->step_mode_data;
- plen = step->step_data_length;
- cs_pd_ras_append_subevent_bytes(proc, payload, plen);
- DBG(rap, "step[%u]: mode=0x%02x Mode0 payload_len=%u sent",
- idx, mode_byte, (unsigned int)plen);
+ cs_pd_ras_append_subevent_bytes(proc, temp_iov.iov_base,
+ temp_iov.iov_len);
+
+done:
+ free(temp_iov.iov_base);
+
+ DBG(rap, "step[%u]: mode=0x%02x Mode0 serialized payload_len=%zu "
+ "role=%s",
+ idx, mode_byte, temp_iov.iov_len,
+ cs_role == CS_ROLE_INITIATOR ? "INIT" : "REFL");
}
static void process_cs_mode_one(struct bt_rap *rap,
--
2.34.1
next reply other threads:[~2026-06-18 7:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 7:55 Prathibha Madugonde [this message]
2026-06-18 11:48 ` [BlueZ,v1] shared/rap: Fix Mode 0 step serialization bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260618075529.98419-1-prathm@qti.qualcomm.com \
--to=prathibha.madugonde@oss.qualcomm.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=quic_anubhavg@quicinc.com \
--cc=quic_hbandi@quicinc.com \
--cc=quic_mohamull@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox