From 29f8074fcb844cf9668a5bf071e9cffa47299c99 Mon Sep 17 00:00:00 2001 From: JF Date: Thu, 29 Oct 2020 16:06:01 +0100 Subject: Refactoring of BLE service discovery : it is now implemented into the classes of the services. --- src/components/ble/AlertNotificationClient.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/components/ble/AlertNotificationClient.h') diff --git a/src/components/ble/AlertNotificationClient.h b/src/components/ble/AlertNotificationClient.h index ebd5d56f..bc0df51e 100644 --- a/src/components/ble/AlertNotificationClient.h +++ b/src/components/ble/AlertNotificationClient.h @@ -3,16 +3,12 @@ #include #include #include +#include "BleClient.h" namespace Pinetime { namespace Controllers { - int NewAlertSubcribeCallback(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, - void *arg); - - class AlertNotificationClient { + class AlertNotificationClient : public BleClient { public: explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager ¬ificationManager); @@ -24,14 +20,9 @@ namespace Pinetime { int OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error, uint16_t characteristicValueHandle, const ble_gatt_dsc *descriptor); void OnNotification(ble_gap_event *event); - bool IsDiscovered() const; - uint16_t StartHandle() const; - uint16_t EndHandle() const; void Reset(); + void Discover(uint16_t connectionHandle, std::function lambda) override; - static constexpr const ble_uuid16_t &Uuid() { return ansServiceUuid; } - - uint16_t NewAlerthandle() const; private: static constexpr uint16_t ansServiceId{0x1811}; static constexpr uint16_t supportedNewAlertCategoryId = 0x2a47; @@ -77,6 +68,9 @@ namespace Pinetime { bool isDiscovered = false; Pinetime::System::SystemTask &systemTask; Pinetime::Controllers::NotificationManager ¬ificationManager; + std::function onServiceDiscovered; + bool isCharacteristicDiscovered = false; + bool isDescriptorFound = false; }; } } \ No newline at end of file -- cgit v1.2.3-70-g09d2