diff options
| author | JF <jf@codingfield.com> | 2020-10-29 15:06:01 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-10-29 15:06:01 (GMT) |
| commit | 29f8074fcb844cf9668a5bf071e9cffa47299c99 (patch) | |
| tree | 9b410aee92af82099619c56a4d25c9c6b7c99e68 /src/components/ble/CurrentTimeClient.h | |
| parent | f90f2254f55086589d1d378d35a54085e2620cb6 (diff) | |
Refactoring of BLE service discovery : it is now implemented into the classes of the services.
Diffstat (limited to 'src/components/ble/CurrentTimeClient.h')
| -rw-r--r-- | src/components/ble/CurrentTimeClient.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/components/ble/CurrentTimeClient.h b/src/components/ble/CurrentTimeClient.h index fcc124c..9313939 100644 --- a/src/components/ble/CurrentTimeClient.h +++ b/src/components/ble/CurrentTimeClient.h @@ -3,12 +3,13 @@ #include <array> #include "components/datetime/DateTimeController.h" +#include "BleClient.h" #include <host/ble_gap.h> namespace Pinetime { namespace Controllers { - class CurrentTimeClient { + class CurrentTimeClient : public BleClient { public: explicit CurrentTimeClient(DateTime& dateTimeController); void Init(); @@ -17,14 +18,11 @@ namespace Pinetime { int OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error *error, const ble_gatt_chr *characteristic); int OnCurrentTimeReadResult(uint16_t conn_handle, const ble_gatt_error *error, const ble_gatt_attr *attribute); - bool IsDiscovered() const; - bool IsCharacteristicDiscovered() const; - uint16_t StartHandle() const; - uint16_t EndHandle() const; - uint16_t CurrentTimeHandle() const; static constexpr const ble_uuid16_t* Uuid() { return &CurrentTimeClient::ctsServiceUuid; } static constexpr const ble_uuid16_t* CurrentTimeCharacteristicUuid() { return &CurrentTimeClient::currentTimeCharacteristicUuid; } - private: + void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override; + + private: typedef struct __attribute__((packed)) { uint16_t year; uint8_t month; @@ -55,7 +53,7 @@ namespace Pinetime { bool isCharacteristicDiscovered = false; uint16_t currentTimeHandle; - + std::function<void(uint16_t)> onServiceDiscovered; }; } }
\ No newline at end of file |
