-
Notifications
You must be signed in to change notification settings - Fork 21
lib: bluetooth: ble_adv: change error codes to nrf_error #436
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
base: main
Are you sure you want to change the base?
lib: bluetooth: ble_adv: change error codes to nrf_error #436
Conversation
You can find the documentation preview for this PR here. |
c94cb69
to
6fc813d
Compare
|
||
if (err) { | ||
LOG_ERR("Failed to start advertising, err %d", err); | ||
if (nrf_err != nrf_success) { |
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.
Should this be if (nrf_err != NRF_SUCCESS) {
?
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.
Yes, corrected.
6fc813d
to
c2fa6b6
Compare
|
||
if (err) { | ||
LOG_ERR("Failed to initialize advertising, err %d", err); | ||
if (nrf_err != NRF_SUCCESS) { |
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.
Do we need to be this explicit? I think it's easier to read if (nrf_err)
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.
I think we should for good practice, as we don't have full control over the nrf_error values (although in practice it is very unlikely that NRF_SUCCESS will change). It also makes a clear distinction between errnos and nrf_errors.
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.
I think we can safely stick to the simpler:
if (nrf_err) {
}
|
||
if (err) { | ||
LOG_ERR("Failed to initialize advertising, err %d", err); | ||
if (nrf_err != NRF_SUCCESS) { |
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.
I think we can safely stick to the simpler:
if (nrf_err) {
}
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.
Why are you changing this file?
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.
Should not be part of it...
lib/bluetooth/ble_adv/ble_adv_data.c
Outdated
/* Check parameter consistency */ | ||
if (ble_adv_data->srv_list.service == NULL) { | ||
return -EFAULT; | ||
return NRF_ERROR_INVALID_PARAM; |
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.
Use NRF_ERROR_NULL
lib/bluetooth/ble_adv/ble_adv_data.c
Outdated
if (service_data->len > 0) { | ||
if (service_data->data == NULL) { | ||
return -EINVAL; | ||
return NRF_ERROR_INVALID_PARAM; |
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.
Use NRF_ERROR_NULL
when a check against NULL
fails
lib/bluetooth/ble_adv/ble_adv.c
Outdated
{ | ||
#if CONFIG_BLE_ADV_FAST_ADVERTISING | ||
int err; | ||
uint32_t err; |
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.
We should decide whether we want to store nrf_error
values into nrf_err
or whether it can be called generically err
where there is only one error.
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.
Yes, I was thinking about that as well. For now I've only updated in the samples where it collides.
lib/bluetooth/ble_adv/ble_adv.c
Outdated
const struct ble_adv_data *sr_data) | ||
{ | ||
int err; | ||
uint32_t err; |
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 here
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 here" does not make sense, what are you referring to?
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.
Nevermind :) left over comment, it was probably to say we needed to decide whether it was going to be err
or nrf_err
.
7902739
to
031b124
Compare
Change error codes to nrf_errors. Signed-off-by: Eivind Jølsgard <[email protected]>
031b124
to
89653ba
Compare
Change error codes to nrf_errors.
This is the first PR for updating the error codes for BLE libraries. Starting with the ble_adv library.
Moving forward all non-BLE libraries and components will return errnos, while BLE related code as BLE services, libraries and the SoftDevice will return nrf_errors.