-
Notifications
You must be signed in to change notification settings - Fork 3k
Ble extended advertising fixes #8998
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
Changes from all commits
d9d4a21
0543442
c83dccf
d372f16
58c7c38
5735456
22a117a
df443c2
df95a1f
698447b
1c71713
0d398bc
a36b04f
20e0cd1
57b79d9
4e5240b
e7f81fe
c13dcf3
bdabada
a483696
674ff28
3f00595
db6b09a
6f94339
642b2df
97df8f5
c998287
a545da7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -670,6 +670,76 @@ ble_error_t Gap::set_extended_advertising_parameters( | |
bool scan_request_notification | ||
) | ||
{ | ||
uint8_t adv_type; | ||
|
||
if (event_properties.use_legacy_pdu) { | ||
if (event_properties.directed == false) { | ||
if (event_properties.high_duty_cycle) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (event_properties.connectable && event_properties.scannable == false) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (event_properties.connectable && event_properties.scannable) { | ||
adv_type = DM_ADV_CONN_UNDIRECT; | ||
} else if (event_properties.scannable) { | ||
adv_type = DM_ADV_SCAN_UNDIRECT; | ||
} else { | ||
adv_type = DM_ADV_NONCONN_UNDIRECT; | ||
} | ||
} else { | ||
if (event_properties.scannable) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (event_properties.connectable == false) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (event_properties.high_duty_cycle) { | ||
adv_type = DM_ADV_CONN_DIRECT; | ||
} else { | ||
adv_type = DM_ADV_CONN_DIRECT_LO_DUTY; | ||
} | ||
} | ||
} else { | ||
if (event_properties.directed == false) { | ||
if (event_properties.high_duty_cycle) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (event_properties.connectable && event_properties.scannable) { | ||
adv_type = DM_ADV_CONN_UNDIRECT; | ||
} else if (event_properties.scannable) { | ||
adv_type = DM_ADV_SCAN_UNDIRECT; | ||
} else if (event_properties.connectable) { | ||
adv_type = DM_EXT_ADV_CONN_UNDIRECT; | ||
} else { | ||
adv_type = DM_ADV_NONCONN_UNDIRECT; | ||
} | ||
} else { | ||
// note: not sure how to act with the high duty cycle in scannable | ||
// and non connectable mode. These cases looks correct from a Bluetooth | ||
// standpoint | ||
|
||
if (event_properties.connectable && event_properties.scannable) { | ||
return BLE_ERROR_INVALID_PARAM; | ||
} else if (event_properties.connectable) { | ||
if (event_properties.high_duty_cycle) { | ||
adv_type = DM_ADV_CONN_DIRECT; | ||
} else { | ||
adv_type = DM_ADV_CONN_DIRECT_LO_DUTY; | ||
} | ||
} else if (event_properties.scannable) { | ||
adv_type = DM_EXT_ADV_SCAN_DIRECT; | ||
} else { | ||
adv_type = DM_EXT_ADV_NONCONN_DIRECT; | ||
} | ||
} | ||
} | ||
|
||
DmAdvSetInterval( | ||
advertising_handle, | ||
primary_advertising_interval_min, | ||
|
@@ -709,7 +779,7 @@ ble_error_t Gap::set_extended_advertising_parameters( | |
|
||
DmAdvConfig( | ||
advertising_handle, | ||
event_properties.value(), // TODO: use the raw value here ??? | ||
adv_type, | ||
peer_address_type.value(), | ||
const_cast<uint8_t *>(peer_address.data()) | ||
); | ||
|
@@ -853,7 +923,7 @@ uint16_t Gap::get_maximum_advertising_data_length() | |
|
||
uint8_t Gap::get_max_number_of_advertising_sets() | ||
{ | ||
return HciGetNumSupAdvSets(); | ||
return std::min(HciGetNumSupAdvSets(), (uint8_t) DM_NUM_ADV_SETS); | ||
} | ||
|
||
ble_error_t Gap::remove_advertising_set(advertising_handle_t advertising_handle) | ||
|
@@ -911,12 +981,11 @@ ble_error_t Gap::extended_scan_enable( | |
if (enable) { | ||
uint32_t duration_ms = duration * 10; | ||
|
||
DmScanModeExt(); | ||
DmScanStart( | ||
scanning_phys.value(), | ||
DM_DISC_MODE_NONE, | ||
extended_scan_type, | ||
filter_duplicates.value(), // TODO: cordio API incomplete ??? | ||
filter_duplicates.value(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any more TODOs to update? 😜 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why I removed it, the comment still stands 😆 . These TODO's and FIXME are important in our implementations and internal files when we work with APIs that do not implement all Bluetooth requirements or when we deliver subsets of BT features. |
||
duration_ms > 0xFFFF ? 0xFFFF : duration_ms, | ||
period | ||
); | ||
|
@@ -936,23 +1005,25 @@ ble_error_t Gap::periodic_advertising_create_sync( | |
uint16_t sync_timeout | ||
) | ||
{ | ||
if (use_periodic_advertiser_list) { | ||
DmDevSetExtFilterPolicy( | ||
DM_ADV_HANDLE_DEFAULT, | ||
DM_FILT_POLICY_MODE_SYNC, | ||
HCI_FILT_PER_ADV_LIST | ||
); | ||
} | ||
DmDevSetExtFilterPolicy( | ||
DM_ADV_HANDLE_DEFAULT, | ||
DM_FILT_POLICY_MODE_SYNC, | ||
use_periodic_advertiser_list ? HCI_FILT_PER_ADV_LIST : HCI_FILT_NONE | ||
); | ||
|
||
DmSyncStart( | ||
dmSyncId_t sync_id = DmSyncStart( | ||
advertising_sid, | ||
peer_address_type.value(), | ||
peer_address.data(), | ||
allowed_skip, | ||
sync_timeout | ||
); | ||
|
||
return BLE_ERROR_INVALID_PARAM; | ||
if (sync_id == DM_SYNC_ID_NONE) { | ||
return BLE_ERROR_INTERNAL_STACK_FAILURE; | ||
} else { | ||
return BLE_ERROR_NONE; | ||
} | ||
} | ||
|
||
ble_error_t Gap::cancel_periodic_advertising_create_sync() | ||
|
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.
Odd. Why not replace/update the constructor instead?
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.
As you can see, that constructor is not part of the documentation because it is not meant to be used by user code. We cannot use
friend
in this case becausefriend
cannot be inherited and we don't know the vendor file that will use it. There is no reason for us to keep non usable constructor if it is not part of the public API.To give a bit more context, the periodic interval returned in an advertising event can be equal to 0 if there is no periodic interval or a value comprised between [0x0006 : 0xFFFF]. The type
periodic_interval_t
is not able to represent the absence of value as it normalizes values passed in input.