esp32-snippets icon indicating copy to clipboard operation
esp32-snippets copied to clipboard

pCharacteristic->notify() notifications are sent when value doesn't change

Open Make-It-Racing opened this issue 3 years ago • 4 comments

Hi! I am communicating with a phone and once I execute the following code (only once): pCharacteristic->setValue(value); pCharacteristic->notify(); notifications never stop coming in , although there is no change in data or anything... Is there any way to prevent this or maybe stop notifying ?

Make-It-Racing avatar Apr 20 '22 06:04 Make-It-Racing

Stop sending notifications. Its your responsibility to set new value and to send notification whenever you want.

chegewara avatar Apr 20 '22 10:04 chegewara

I send the notification only once, the problem is ios keep sending it over and over again even though a new value was not set. Now I finally understand why this happened, so will share in case it can be useful to anyone: inside my onNotify function I had BLE read call. iOS doesn't provide a way to distinguish whether the characteristic has updated due to a notification or due to a read value So it was resending the notification every time I made the read call, this created a loop because every time I got a notification I did a read call....

Make-It-Racing avatar Apr 20 '22 12:04 Make-It-Racing

Again, its problem either with your esp32 or iOS app. When you are sending notify you are also sending a value, not just notifying the value changed.

chegewara avatar Apr 20 '22 12:04 chegewara

I am just trying to say the making a ble read call will make IOS send a notification every time a read call is made Android will send a notification only when the value was changed but IOS will also send a notification every time the value is read.

Make-It-Racing avatar Apr 20 '22 12:04 Make-It-Racing