NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

Are there examples of how to run tasks on the Nimble stack core?

Open jackjansen opened this issue 2 years ago • 3 comments
trafficstars

In the usage tips document it is stated that it is best to use the library from a task that runs on the Nimble stack core in stead of the normal core.

An example of how to do this would be good. But actually a pointer to code that does this would also be helpful already...

jackjansen avatar Apr 29 '23 19:04 jackjansen

There are examples in the esp-nimble-cpp repo that do this, for instance https://github.com/h2zero/esp-nimble-cpp/blob/master/examples/basic/BLE_scan/main/main.cpp

h2zero avatar May 14 '23 19:05 h2zero

Ah, thanks, that's a very useful repo! A few remarks:

  • I have the feeling that the BLE_scan example you're referring to has a bug: it seems like pBLE->start() isn't called (or maybe I'm overlooking it)
  • NimBLE_Client seems like a better example (it does quite a bit more in the task, and also shows one way of communicating between the tasks, using a shared variable)
  • Maybe add a reference to this repo in the documentation?

jackjansen avatar May 15 '23 20:05 jackjansen

That example is in the master branch which has some API changes, the blocking scan call no longer uses start() instead the getResults() call replaces it.

Yes the Client example is probably better but for simplicity I used the scan example.

There is a reference in the README, perhaps it should be made more apparent though.

h2zero avatar May 15 '23 21:05 h2zero