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

Multiple notifications for the same characteristic #36

Open
JasonBSteele opened this issue Jul 12, 2020 · 8 comments
Open

Multiple notifications for the same characteristic #36

JasonBSteele opened this issue Jul 12, 2020 · 8 comments

Comments

@JasonBSteele
Copy link

Hi,

I am using a Nano BLE Sense device to listen for sounds, and then infer what they are. If the sound is other than background noise it sends a Notify to the central.

There is only one characteristic and when I first set it up it was working fine with a single message being out put when the Notify was sent. However after reconnecting, and the resubscribing for notifications I found that two messages were being sent. I now have five messages being sent.

I'm guessing the subscriptions aren't being cleared down when reconnecting. I tried reconnecting without resubscribing but then I didn't receive any notifications.

@dbaba
Copy link
Collaborator

dbaba commented Jul 13, 2020

Thank you for the report.
Let me check the notification behavior when a device is reconnected.

@dbaba
Copy link
Collaborator

dbaba commented Jul 15, 2020

Mmm, I couldn't reproduce the duplicate notification.

I used TI's Sensor Tag to test with the example flow included in this node (menu => Import => Examples => node-red-contrib-generic-ble => 01-read-write). I modified the notification period from 5 to 0 in the flow and deployed it.

What I did is

  1. Connect to a peripheral by sending "topic": "connect"
  2. Start Temperature Measurement
  3. Subscribe Notify by sending "payload": {"notify":true,"period":0} (0 means notification lasting until disconnected)
  4. Disconnect the peripheral by (I tried both)
    1. Removing a battery
    2. Sending "topic":"disconnect"
  5. Re-connect to the peripheral by sending "topic": "connect"
  6. Start Temperature Measurement
  7. Subscribe Notify by sending "payload": {"notify":true,"period":0}

Then the result showed a single message per event. I thought I'd had been able to reproduce with these steps but no luck so far.

The device I tested is not same as yours so the way to reproduce it is different from yours.
But if you find something helpful to reproduce the issue, can you please give me any suggestion?

@JasonBSteele
Copy link
Author

JasonBSteele commented Jul 15, 2020 via email

@JasonBSteele
Copy link
Author

I have just completed some testing on this and found the following:

  1. I was getting 6 notification messages for each Notify
  2. Just Disconnect, Connect => I didn't get any
  3. Disconnect, Connect, Subscribe ( {"notify":true, "period":0 } ) => I got 6 notifications.
  4. Arduino power Off, On, Connect, Subscribe => I still got 6 notifications.
  5. Redeploy Node Red Flow, Connect, Subscribe => I still got 6 notifications.
  6. RPi power Off, On, Connect, Subscribe => I got 1 Notify
  7. Disconnect, Connect, Subscribe => I still got 1 Notify
  8. Subscribe => I still got 1 Notify
  9. Caused a disconnect by using Microwave Oven to interfere with signal, Connect, Subscribe => I still got 1 Notify

So not as simple as # of Subscribes == # of messages, and the issue appears to be on the RPi side somehow getting into a state where it has remembered subscriptions and is not clearing them down. I'll keep an eye on it and let you know if I can see a pattern if it happens again.

@aries84ct
Copy link

Hello, I have the same problem, did you solve it? Thanks for your help

@JasonBSteele
Copy link
Author

Sorry, a while ago now and I can't remember whether I just manged to workaround it or just accept it. I no longer have it running so unable to replicate it.

@aries84ct
Copy link

Ok, thanks anyway

@dhruvjhalani95
Copy link

Hi! I am still facing this issue of multiple notifications. Were any of you able to solve this @JasonBSteele @dbaba @aries84ct

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

4 participants