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

nimble/audio: Modify BASS control point write access. #1833

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

szymon-czapracki
Copy link
Contributor

Modify BASS control point write access in a way that it would use proper mbuf for holding incoming data.

Fix handler check from simple bool comparison to ensuring that it's not NULL.

@github-actions github-actions bot added host size/S Small PR labels Aug 8, 2024

uint8_t opcode = ctxt->om->om_data[0];
os_mbuf_copydata(ctxt->om, 0, mbuf_len, data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we want to put those data on the stack?

Copy link
Contributor Author

@szymon-czapracki szymon-czapracki Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous implementation produced some problems regarding passing data into specific handlers, as not all of the data was present - after discussing this with @sjanc we've decided that a good solution would be to use os_mbuf for passing the data that write access function handles.

Edit: The incorrect amount of data was a result of chained mbufs.

Copy link
Contributor

@MariuszSkamra MariuszSkamra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please improve the commit message, I'm not sure I understand what this change supposed to fix.

But I see what it breaks unfortunately. The data you pass to the handler include the opcode (as you pass &data[0], not &data[1]), while the handles assume the 0 parameter won't be opcode

Comment on lines 621 to 623
uint16_t mbuf_len = OS_MBUF_PKTLEN(ctxt->om);
uint8_t opcode;
uint8_t data[MYNEWT_VAL(BLE_SVC_AUDIO_BASS_METADATA_MAX_SZ)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow the coding style - code is not aligned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@szymon-czapracki szymon-czapracki force-pushed the bass_ctrlp_write_access branch 6 times, most recently from 3f3e343 to c9d531e Compare August 22, 2024 13:23
@@ -633,7 +636,12 @@ ble_svc_audio_bass_ctrl_point_write_access(struct ble_gatt_access_ctxt *ctxt, ui
return BLE_ATT_ERR_WRITE_REQ_REJECTED;
}

return handler->handler_cb(&ctxt->om->om_data[1], ctxt->om->om_len - 1, conn_handle);
om = os_mbuf_pullup(ctxt->om, mbuf_len);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard om, use ctx->om

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @rymanluk LGTY?

Modify BASS control point write access in a way that
it would use flattened mbuf to pass data to handler.
Previous solution was prone to errors due to chained mbufs.

Fix handler check from simple bool comparison to ensuring
that it's not NULL.

Add opcode variable to hold proper operation id in write access.
This is helpful during debugging operations.
Copy link
Contributor

@sjanc sjanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in long term we should consider passing mbuf directly to handler so that pullup is not needed

Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rymanluk rymanluk merged commit cda8b20 into apache:master Sep 2, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants