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/host/include/host/ble_gap: expose ble_gap_adv_active_instance #1065

Merged
merged 1 commit into from
Nov 2, 2021

Conversation

fjmolinas
Copy link
Contributor

This PR exposes ble_gap_adv_active_instance, it's sometimes useful to check if there is an active advertisement on an instance before stopping it or changing some parameter.

@fjmolinas fjmolinas force-pushed the pr_ext_adv_is_active_instance branch from 41885f8 to 7d88fe8 Compare October 29, 2021 08:43
@@ -1294,14 +1294,12 @@ ble_gap_master_in_progress(void)
#endif
}

#if NIMBLE_BLE_ADVERTISE || NIMBLE_BLE_CONNECT
static int
int
ble_gap_adv_active_instance(uint8_t instance)
{
/* Assume read is atomic; mutex not necessary. */
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already ble_gap_adv_active() for legacy API.

So I'd add new API ble_gap_ext_adv_active() (under EXT_ADV ifdef) that would wrap this (and check if instance is valid)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had done that initially, but the function is used in legacy api code, just with instance=0 and so travis complained. I could wrap the static qualifier based on EXT_ADV ifdef. Would that be ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant add new function ble_gap_ext_adv_active(uint8_t instance) that will internally use ble_gap_adv_active_instance()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed, is it what you had in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe another return code is more appropriate when the instance is invalid?

Copy link
Contributor

Choose a reason for hiding this comment

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

other functions typically use BLE_HS_EINVAL for such cases, lets keep it consistent (note no minus)

other than that looks OK to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

squashed directly

@fjmolinas fjmolinas force-pushed the pr_ext_adv_is_active_instance branch 2 times, most recently from e3102a4 to 6bdec5f Compare October 29, 2021 13:58
int ble_gap_ext_adv_active(uint8_t instance)
{
if (instance >= BLE_ADV_INSTANCES) {
return -BLE_HS_EINVAL;
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 be return BLE_HS_EINVAL (no minus)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must be dyslexic, you had said it before and I somehow read note the minus., sorry for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed as you said, it might be confusing to have 1 be a valid output and 3 an error though.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is actually a good point, so lets just return 0 if instance is invalid... (sorry for jumping back and forth on this)

@fjmolinas fjmolinas force-pushed the pr_ext_adv_is_active_instance branch from 6bdec5f to 5152b78 Compare October 29, 2021 15:08
@fjmolinas
Copy link
Contributor Author

Is this one ok now @sjanc?

@sjanc sjanc self-requested a review November 2, 2021 12:27
@fjmolinas fjmolinas force-pushed the pr_ext_adv_is_active_instance branch from 5152b78 to 0c59457 Compare November 2, 2021 12:37
@fjmolinas fjmolinas force-pushed the pr_ext_adv_is_active_instance branch from 0c59457 to 02c8b6c Compare November 2, 2021 12:38
@sjanc sjanc merged commit 9716331 into apache:master Nov 2, 2021
@fjmolinas
Copy link
Contributor Author

Thank you for the review! @sjanc

@fjmolinas fjmolinas deleted the pr_ext_adv_is_active_instance branch November 2, 2021 15:27
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.

None yet

2 participants