-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
samples: bluetooth: Fix bt_le_scan_stop() error checking in central_multilink sample #84369
base: main
Are you sure you want to change the base?
Conversation
Hello @ramana-g-123, and thank you very much for your first pull request to the Zephyr project! |
@ramana-g-123 thanks for the pull request! The change itself looks great, however please fix the commit message to be compliant with Zephyr requirements:
|
@@ -75,7 +75,7 @@ static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type, | |||
return; | |||
} | |||
|
|||
if (bt_le_scan_stop()) { | |||
if (bt_le_scan_stop() == 0) { | |||
printk("Scanning successfully stopped\n"); |
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.
Hmm isn't the check correct but printed error message is wrong?
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.
If bt_le_scan_stop
returns 0 it means that it was stopped :) Looks right to me
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.
Looking at the more general flow of the function, I believe the purpose is to proceed to the bt_conn_le_create()
step when scanning was stopped, so we shouldn't return from the function in a success case. So it does seem like @sjanc is right, i.e. the log message is wrong. Since the function has an err
variable, I'd also take advantage of it in the same go:
err = bt_le_scan_stop();
if (err != 0) {
printk("Failed to stop scanning (err %d)\n", err);
return;
}
@ramana-g-123 can you update the PR accordingly? Thanks.
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.
Agree with @sjanc and @jhedberg, on failure to stop scanning the control should not proceed further to setup a connection. Hence, it is the message that is incorrect.
@ramana-g-123 Thank you for noticing the issue.
@@ -75,7 +75,7 @@ static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type, | |||
return; | |||
} | |||
|
|||
if (bt_le_scan_stop()) { | |||
if (bt_le_scan_stop() == 0) { | |||
printk("Scanning successfully stopped\n"); |
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.
Looking at the more general flow of the function, I believe the purpose is to proceed to the bt_conn_le_create()
step when scanning was stopped, so we shouldn't return from the function in a success case. So it does seem like @sjanc is right, i.e. the log message is wrong. Since the function has an err
variable, I'd also take advantage of it in the same go:
err = bt_le_scan_stop();
if (err != 0) {
printk("Failed to stop scanning (err %d)\n", err);
return;
}
@ramana-g-123 can you update the PR accordingly? Thanks.
@@ -75,7 +75,7 @@ static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type, | |||
return; | |||
} | |||
|
|||
if (bt_le_scan_stop()) { | |||
if (bt_le_scan_stop() == 0) { | |||
printk("Scanning successfully stopped\n"); |
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.
Agree with @sjanc and @jhedberg, on failure to stop scanning the control should not proceed further to setup a connection. Hence, it is the message that is incorrect.
@ramana-g-123 Thank you for noticing the issue.
Code looks good now... @ramana-g-123 please follow above suggestion to have single commit in this PR. |
@ramana-g-123 you still need a commit message body. You can find more info here: https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-message-guidelines |
@ramana-g-123 and also note this failure: |
@ramana-g-123 the commit message still isn't compliant, causing the Compliance check to fail: "Commit message body line exceeds max length (160>75)". Once that's fixed I think we can merge it. |
@ramana-g-123 you don't need to close/re-open pull requests like this. Just a force-push is enough. |
Outputs error code to console if bt_le_scan_stop() fails Signed-off-by: Ramana Gudipudi <[email protected]>
Hey @jhedberg , sorry for the previous commit I was unable to run compliance_checks.py with the following issue even after installing all the packages needed using requirements.txt
|
@ramana-g-123 did you install the |
Fixes #84187
The logic in central_multilink example outputs "Scanning successfully stopped" when the stop call has failed as the bt_le_scan_stop() call returns 0 when successful and error when unsuccessful