-
Notifications
You must be signed in to change notification settings - Fork 399
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
Added periodic adv feature updates in ble 5.3 #1537
Conversation
RoshanESP
commented
Jun 28, 2023
- Added periodic adv enhancements(adi support) in Bluetooth spec 5.3
- Current APIs don't have a way to add the parameters for periodic adv commands. So, modified the APIs wherever necessary.
@sjanc can you PTAL? |
There was a problem hiding this 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?
nimble/host/include/host/ble_gap.h
Outdated
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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
nimble/host/include/host/ble_gap.h
Outdated
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; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
nimble/host/include/host/ble_gap.h
Outdated
struct ble_gap_periodic_adv_sync_report_params { | ||
#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH) | ||
/** If filter duplicates */ | ||
unsigned int filter_duplicates:1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
nimble/host/include/host/ble_gap.h
Outdated
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
nimble/host/include/host/ble_gap.h
Outdated
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
nimble/host/src/ble_gap.c
Outdated
@@ -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) { |
There was a problem hiding this comment.
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 ->)
nimble/host/src/ble_gap.c
Outdated
|
||
/* BLE_HCI_OCF_LE_SET_DEFAULT_SYNC_TRANSFER_PARAMS command api */ | ||
int | ||
periodic_adv_set_default_sync_params(uint16_t conn_handle, |
There was a problem hiding this comment.
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...
nimble/host/src/ble_gap.c
Outdated
|
||
cmd.conn_handle = htole16(conn_handle); | ||
cmd.sync_cte_type = 0x00; | ||
cmd.mode = params->reports_disabled ? 0x01 : 0x02; |
There was a problem hiding this comment.
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?
nimble/host/src/ble_gap.c
Outdated
cmd.mode = params->reports_disabled ? 0x01 : 0x02; | ||
|
||
#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH) | ||
if (params->filter_duplicates) |
There was a problem hiding this comment.
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)
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 |
a621764
to
ba41c24
Compare
Hi @sjanc , Made the suggested changes. PTAL |
2b90aa7
to
561838e
Compare
There was a problem hiding this 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
nimble/host/include/host/ble_gap.h
Outdated
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
nimble/host/src/ble_gap.c
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
561838e
to
4c5cc4e
Compare
4c5cc4e
to
a5b0c09
Compare