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

notify callback #5

Open
gremlin-it opened this issue Aug 13, 2021 · 5 comments
Open

notify callback #5

gremlin-it opened this issue Aug 13, 2021 · 5 comments

Comments

@gremlin-it
Copy link

Hi

I'm not able to implement a notify callback.
the second parameter of the function blz_char_notify_start is the callback "blz_notify_handler_t cb", it's a function that return void and accept four parameters :
const uint8_t* data
size_t len
blz_char* ch
void* user

but, if inside this callback i need to access some characteristic fields is impossible cause all definition is in the blzlib_internal.h.
I'll need to check the uuid cause I'll attach the same callback to more than one chararacteristic but ch->uuid can't be resolved.

moreover also if I attach the callback to only one characteristic nothing happen ...

    characteristic = blz_get_char_from_uuid(service, "00000003-0000-1000-8000-00805f9b3062");
    blz_char_notify_start(characteristic, indicate_cb, NULL);

    for (i=0; i < 10; ++i) {
        blz_loop_one(blz, 1000);
    }

    blz_char_notify_stop(characteristic);

this code could work ?
thanks

@br101
Copy link
Collaborator

br101 commented Aug 13, 2021

Hi! Yes this code should work, actually I have something very similar in my code.

To the fact that the characteristic is defined in internal, I would like to keep it like this in order to hide the implementation. Couldn't you have the characteristics pointers global and check against them? Or you could pass the characteristics pointer as the user pointer and check that?

@gremlin-it
Copy link
Author

about the code: now seem to work also for me ... really i don't know why it didn't work for half a day ...

about the opaque structure: I agree with you to keep the implementation hide, so maybe could be simple and useful to provide some getter funcion such as "char* blx_char_uuid(blz_char* ch, char *uuid)" or something like

@br101
Copy link
Collaborator

br101 commented Aug 13, 2021

yes that could be useful. in the mean time i think it should be OK to check the pointers themselves...

@gremlin-it
Copy link
Author

Found it !!!

the notify callback work if the characteristic have the "Notify" attribute but nothing happen with the "Indicate" attribute!

@br101
Copy link
Collaborator

br101 commented Aug 13, 2021

okay, can I close this issue then? Welcome to add the UUID check method via pull request.

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

No branches or pull requests

2 participants