1
0
Fork 0
InfiniTime/src/components/ble/ServiceDiscovery.cpp
Reinhold Gschweicher ac7b2da611 Update includes to to be relative to src directory
Don't use relative imports like `../foo.h` as those depend on the
relative position of both files. Rather than that use imports relative
to the `src` directory, which explicitly is part of the include
directories.
2021-11-15 22:02:49 +01:00

32 lines
No EOL
1,009 B
C++

#include "components/ble/ServiceDiscovery.h"
#include <libraries/log/nrf_log.h>
#include "components/ble/BleClient.h"
using namespace Pinetime::Controllers;
ServiceDiscovery::ServiceDiscovery(std::array<BleClient*, 2>&& clients) : clients {clients} {
}
void ServiceDiscovery::StartDiscovery(uint16_t connectionHandle) {
NRF_LOG_INFO("[Discovery] Starting discovery");
clientIterator = clients.begin();
DiscoverNextService(connectionHandle);
}
void ServiceDiscovery::OnServiceDiscovered(uint16_t connectionHandle) {
clientIterator++;
if (clientIterator != clients.end()) {
DiscoverNextService(connectionHandle);
} else {
NRF_LOG_INFO("End of service discovery");
}
}
void ServiceDiscovery::DiscoverNextService(uint16_t connectionHandle) {
NRF_LOG_INFO("[Discovery] Discover next service");
auto discoverNextService = [this](uint16_t connectionHandle) {
this->OnServiceDiscovered(connectionHandle);
};
(*clientIterator)->Discover(connectionHandle, discoverNextService);
}