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

Why is the value of a characteristic automatically changed but notify is not automatically called? #71

Closed
ChocolateLoverRaj opened this issue Jan 21, 2024 · 1 comment · Fixed by #75

Comments

@ChocolateLoverRaj
Copy link
Contributor

I connected to an ESP32-C3 BLE server and there is a read, write, and notify characteristic. I enabled notifications on the first device and then changed the value with the second device. The first device did not get a notification. When I read the value with the first device manually, I saw the updated value. When I added notify() to the code on write, notifications worked as expected.

  • Is this expected behavior?
  • If yes, why are notifications not automatic? Seems inconsistent / confusing.
@taks
Copy link
Owner

taks commented Jan 26, 2024

The current behavior is expected.
Notify is not automatically invoked so that users can use it when they want to.

However, I did not realize that it is a hard to call notify when writing from the outside.
So, I added notify funciton to OnWriteArgs so that you can easily notify as follows.

characteristic
  .lock()
  .on_write(|args| {
    args.notify();
  });

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 a pull request may close this issue.

2 participants