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

Return BLE_HS_EDONE in characteristic discovery #106

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

geovie
Copy link
Contributor

@geovie geovie commented Feb 29, 2024

If the characteristic is not the last one in a service next_char_cb will be called again with the next characteristic which in the current implementation would override the end handle and would again send the state signal.

The double state signal then leads to get_descriptors returning an empty array, can be tested with this sample code:

let characteristic = service
        .get_characteristic(characteristic_uuid)
        .await
        .unwrap();

    let uuids: Vec<_> = characteristic
        .get_descriptors()
        .await
        .unwrap()
        .map(|d| d.uuid().to_string())
        .collect();
    log::info!("subscribe to {:?}", uuids);

I haven't found any documentation about what the callback is supposed to return but I found out that returning HS_DONE would not call the callback again. Also Nimble-Arduino also does this so it seems to be correct: https://github.com/wakwak-koba/NimBLE-Arduino/blob/aec7e4294dc2ede1434b68cf8381a307f2c08c68/src/NimBLERemoteCharacteristic.cpp#L216C14-L216C26

@taks
Copy link
Owner

taks commented Mar 1, 2024

Thanks.

@taks taks merged commit e25fbd3 into taks:develop Mar 1, 2024
7 checks passed
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.

2 participants