apache / apache/mynewt-nimble

Callback triggered multiple times for same request

Open
#382 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
893
Forks
512
Avg merge
13d 31m
Merged PRs (30d)
7

Description

Hello,

I have an issue with nimble on RIOT. My testing environment is the following:
- nrf52dk
- latest RIOT master https://github.com/RIOT-OS/RIOT/commit/c0d907addc26450cae4de645711ecfac0fa85e1e (but problem is there for several weeks already)
- RIOT example application 'nimble_gatt'
- Nordics nrF Connect App (but also with my own one)

If I read the read- and writeable characteristic, then its callback is called twice, the readonly characteristic only once. But if i write to the rw characteristic and read it again, the callback is called once from there on.
In another application a callback is called 6 times on a read operation, which leads to empty messages if I don't handle every single callback, but that's problematic because it's a ringbuffer and I get the message exactly one time.

@haukepetersen experienced the same issue on his board with the nimble_gatt example.

Is that behaviour intended? I thought as a callback it should be only called once, when the characteristic is read from or wrote to, or am I wrong?

Below is my terminal output:
```
2019-03-23 17:23:19,013 - INFO # main(): This is RIOT! (Version: 2019.04-devel-597-gc0d90)
2019-03-23 17:23:19,015 - INFO # NimBLE GATT Server Example

2019-03-23 17:24:30,496 - INFO # service 'rw demo' callback triggered
2019-03-23 17:24:30,499 - INFO # access to characteristic 'rw demo (write)'
2019-03-23 17:24:30,501 - INFO # read from characteristic
2019-03-23 17:24:30,508 - INFO # current value of rm_demo_write_data: 'This characteristic is read- and writeable!'
2019-03-23 17:24:30,509 - INFO #
2019-03-23 17:24:30,642 - INFO # service 'rw demo' callback triggered
2019-03-23 17:24:30,646 - INFO # access to characteristic 'rw demo (write)'
2019-03-23 17:24:30,648 - INFO # read from characteristic
2019-03-23 17:24:30,655 - INFO # current value of rm_demo_write_data: 'This characteristic is read- and writeable!'
2019-03-23 17:24:30,655 - INFO #

2019-03-23 17:24:34,395 - INFO # service 'rw demo' callback triggered
2019-03-23 17:24:34,399 - INFO # access to characteristic 'rw demo (read-only)'
2019-03-23 17:24:34,401 - INFO # new random number: 8
2019-03-23 17:24:34,402 - INFO #

2019-03-23 17:24:45,657 - INFO # service 'rw demo' callback triggered
2019-03-23 17:24:45,660 - INFO # access to characteristic 'rw demo (write)'
2019-03-23 17:24:45,662 - INFO # write to characteristic
2019-03-23 17:24:45,669 - INFO # old value of rm_demo_write_data: 'This characteristic is read- and writeable!'
2019-03-23 17:24:45,673 - INFO # new value of rm_demo_write_data: 'test'
2019-03-23 17:24:45,674 - INFO #

2019-03-23 17:24:48,192 - INFO # service 'rw demo' callback triggered
2019-03-23 17:24:48,195 - INFO # access to characteristic 'rw demo (write)'
2019-03-23 17:24:48,198 - INFO # read from characteristic
2019-03-23 17:24:48,201 - INFO # current value of rm_demo_write_data: 'test'
2019-03-23 17:24:48,202 - INFO #
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the report with the RIOT nimble_gatt example on an nrf52dk and compare read-only with read/write characteristic access. Trace the NimBLE GATT callback path behind the terminal output to determine why one request can trigger multiple callbacks. Done means the behavior is explained and, if unintended, corrected without duplicate callbacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.