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

Added periodic adv feature updates in ble 5.3 #1537

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

RoshanESP
Copy link
Contributor

  1. Added periodic adv enhancements(adi support) in Bluetooth spec 5.3
  2. Current APIs don't have a way to add the parameters for periodic adv commands. So, modified the APIs wherever necessary.

@RoshanESP
Copy link
Contributor Author

@sjanc can you PTAL?

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.

maybe instead of new MYNEWT_VAL(BLE_PERIODIC_ADV_ENH) simply depend some code on selected BLE version?

int ble_gap_periodic_adv_start(uint8_t instance);
int
ble_gap_periodic_adv_start(uint8_t instance,
const struct ble_gap_periodic_adv_enable_params *params);
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: since function is called adv_start I'd name params structure same (is ble_gap_periodic_adv_start_params)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

struct ble_gap_periodic_adv_enable_params {
#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
/** If include adi in aux_sync_ind PDU */
unsigned int include_adi:1;
Copy link
Contributor

Choose a reason for hiding this comment

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

there should be spaces around ":" ie. include_adi : 1;
(to keep this consistent with codebase)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

struct ble_gap_periodic_adv_sync_report_params {
#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
/** If filter duplicates */
unsigned int filter_duplicates:1;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

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.

struct ble_gap_periodic_adv_set_data_params {
#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
/** If include adi in aux_sync_ind PDU */
unsigned int update_did:1;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

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.

int ble_gap_periodic_adv_sync_reporting(uint16_t sync_handle, bool enable);
int ble_gap_periodic_adv_sync_reporting(uint16_t sync_handle,
bool enable,
const struct ble_gap_periodic_adv_sync_report_params *params);
Copy link
Contributor

Choose a reason for hiding this comment

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

same, lest keep params names consistent with function name ie. ble_gap_periodic_adv_sync_reporting_params

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.

static uint8_t buf[sizeof(struct ble_hci_le_set_periodic_adv_data_cp)];
struct ble_hci_le_set_periodic_adv_data_cp *cmd = (void *) buf;
uint16_t opcode;
memset(buf, 0, sizeof(buf));
Copy link
Contributor

Choose a reason for hiding this comment

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

empty line between variables declarations and code

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.

@@ -3838,7 +3877,16 @@ ble_gap_periodic_adv_set_data(uint8_t instance, struct os_mbuf *data)
goto done;
}

#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
if (params && params -> update_did) {
Copy link
Contributor

Choose a reason for hiding this comment

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

"params->update_did" (no spaces around ->)


/* BLE_HCI_OCF_LE_SET_DEFAULT_SYNC_TRANSFER_PARAMS command api */
int
periodic_adv_set_default_sync_params(uint16_t conn_handle,
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't look correct, default sync params shouldn't need connection handle, right?

also ble_hci_le_periodic_adv_sync_transfer_params_cp is not matching BLE_HCI_OCF_LE_SET_DEFAULT_SYNC_TRANSFER_PARAMS opcode...


cmd.conn_handle = htole16(conn_handle);
cmd.sync_cte_type = 0x00;
cmd.mode = params->reports_disabled ? 0x01 : 0x02;
Copy link
Contributor

Choose a reason for hiding this comment

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

and how to disable this? maybe null params could be used for this?

cmd.mode = params->reports_disabled ? 0x01 : 0x02;

#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
if (params->filter_duplicates)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be set only if params->reports_disabled is not set (ie when reports are not disabled)

@sjanc
Copy link
Contributor

sjanc commented Sep 18, 2023

oh, and while I'm fine with breaking public API here (unfortunate but...) with additions of parameter structure, all samples in repo needs to be updated in same commit to avoid CI breaking

@RoshanESP RoshanESP force-pushed the feature/periodic_adv_enhancement branch 3 times, most recently from a621764 to ba41c24 Compare September 20, 2023 03:27
@RoshanESP
Copy link
Contributor Author

Hi @sjanc , Made the suggested changes. PTAL

@RoshanESP RoshanESP force-pushed the feature/periodic_adv_enhancement branch 2 times, most recently from 2b90aa7 to 561838e Compare September 26, 2023 05:36
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.

bttester application also requires update (it was missing in CI check due to misconfiguration of CI target, seehttps://github.com//pull/1629/ )

and some params can be const, otherwise looks OK

int ble_gap_periodic_adv_set_data(uint8_t instance, struct os_mbuf *data);
int ble_gap_periodic_adv_set_data(uint8_t instance,
struct os_mbuf *data,
struct ble_gap_periodic_adv_set_data_params *params);
Copy link
Contributor

Choose a reason for hiding this comment

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

could be const

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.

ble_gap_periodic_adv_set_data(uint8_t instance, struct os_mbuf *data)
ble_gap_periodic_adv_set_data(uint8_t instance,
struct os_mbuf *data,
struct ble_gap_periodic_adv_set_data_params *params)
Copy link
Contributor

Choose a reason for hiding this comment

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

const

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.

@RoshanESP RoshanESP force-pushed the feature/periodic_adv_enhancement branch from 561838e to 4c5cc4e Compare October 18, 2023 10:28
@RoshanESP RoshanESP force-pushed the feature/periodic_adv_enhancement branch from 4c5cc4e to a5b0c09 Compare October 21, 2023 16:27
@sjanc sjanc merged commit fb3ccfd into apache:master Oct 24, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants