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

peer_addr = null when doing directed advertising #501

Closed
ViktorRindom opened this issue Jan 31, 2023 · 9 comments · Fixed by #507
Closed

peer_addr = null when doing directed advertising #501

ViktorRindom opened this issue Jan 31, 2023 · 9 comments · Fixed by #507
Labels
bug Something isn't working

Comments

@ViktorRindom
Copy link

When I do "BLE_GAP_CONN_MODE_UND" everything works but when I change to "BLE_GAP_CONN_MODE_DIR" I always get the error "Unable to advertise - Duration too long". I have found out that this is a result of the rc value of 3 (BLE_HS_EINVAL). This error code is used in a lot of places and I started replacing the values with my own unique error codes and found out that my error was peer_addr being null in the file ble_gap.c in the function ble_gap_adv_validate. But i cant fix this since the file NimBLEAdvertising.cpp puts null in the call ble_gap_adv_start.

TLDR: NimBLEAdvertising.cpp sets peer_addr to null and ble_gap.c returns an error if peer_addr is null

@ViktorRindom
Copy link
Author

the line with null:

rc = ble_gap_adv_start(NimBLEDevice::m_own_addr_type, NULL, duration,

the line with null check:
if (peer_addr == NULL) {

@h2zero
Copy link
Owner

h2zero commented Feb 4, 2023

Thanks for bringing this up, a new parameter should be added to advertising start in this case that takes the address.

@h2zero h2zero added the bug Something isn't working label Feb 4, 2023
@ViktorRindom
Copy link
Author

Is it possible to do directed advertise to a list and not a single peer_addr?

@h2zero
Copy link
Owner

h2zero commented Feb 4, 2023

Only a single address can be directly advertised to.

@ViktorRindom
Copy link
Author

It would also be nice if all errors did not use rc code 3

@ViktorRindom
Copy link
Author

@h2zero will you write here when the bug is fixed?
So we can close this issue and so I can update to the fix?

@h2zero
Copy link
Owner

h2zero commented Feb 20, 2023

@ViktorRindom please check #507 and let me know if this works for you.

@ViktorRindom
Copy link
Author

ViktorRindom commented Feb 22, 2023

@h2zero Im using Platformio how do I use the pull request version of the library?

@h2zero
Copy link
Owner

h2zero commented Feb 22, 2023

You can just use the branch name: lib_deps = https://github.com/h2zero/NimBLE-Arduino.git#bugfix-directed-adv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants