nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.35k stars 710 forks source link

BLE Observer and Client in the same time #258

Open tendriu opened 6 years ago

tendriu commented 6 years ago

Is it possible to maintain a connection with the service (central role) and receive advertising packets at the same time?

Regards, Andrew

nkolban commented 6 years ago

Its a good question. The BLE C++ classes found in this repository basically act as wrappers for the underlying ESP-IDF implementation of BLE which is implemented on top of Bluedroid which ideally implements the BLE specification. As such we have a whole multitude of layers, levels and abstractions.

BLE C++ -> ESP-IDF -> Bluedroid -> BLE Specification

In thinking about your question, we would ideally work bottom up. The question would thus become ... "Is it a valid thing to ask that a BLE Central (client) can be connected to more than server at the same time?". If yes, then we should be able to listen for new advertising packets while, at the same time, have a connection to a partner. However it all starts with asking at the BLE specification level ... "Is this allowed?"

chegewara commented 6 years ago

Short answer, yes, it is possible. Easiest way to check it is to run Sample example (client or server, whatever you need) and add scan function at the same time.