diff options
| author | JF <jf@codingfield.com> | 2020-04-25 13:52:00 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-04-25 13:52:00 (GMT) |
| commit | 032fad094c6411ad3ff4321ad61ceed95d7dc4ff (patch) | |
| tree | 53a9341ba2e93491e025ab54299ccd7241c504c6 /src/Components/Ble/AlertNotificationClient.h | |
| parent | 5fcb90a14951ec70a8ec41a656f6f58358b9986b (diff) | |
NimbleController : CTS & ANS are now working together (even if the code is not as good as I would like).
Diffstat (limited to 'src/Components/Ble/AlertNotificationClient.h')
| -rw-r--r-- | src/Components/Ble/AlertNotificationClient.h | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/src/Components/Ble/AlertNotificationClient.h b/src/Components/Ble/AlertNotificationClient.h index 595dbe3..7a085b7 100644 --- a/src/Components/Ble/AlertNotificationClient.h +++ b/src/Components/Ble/AlertNotificationClient.h @@ -1,4 +1,5 @@ #pragma once + #include <cstdint> #include <array> #include <host/ble_gap.h> @@ -6,29 +7,17 @@ namespace Pinetime { namespace Controllers { - int AlertNotificationDiscoveryEventCallback(uint16_t conn_handle, const struct ble_gatt_error *error, - const struct ble_gatt_svc *service, void *arg); - int AlertNotificationCharacteristicsDiscoveryEventCallback(uint16_t conn_handle, - const struct ble_gatt_error *error, - const struct ble_gatt_chr *chr, void *arg); int NewAlertSubcribeCallback(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, - void *arg); - - int AlertNotificationDescriptorDiscoveryEventCallback(uint16_t conn_handle, - const struct ble_gatt_error *error, - uint16_t chr_val_handle, - const struct ble_gatt_dsc *dsc, - void *arg); + const struct ble_gatt_error *error, + struct ble_gatt_attr *attr, + void *arg); class AlertNotificationClient { public: - explicit AlertNotificationClient(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager); + explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask, + Pinetime::Controllers::NotificationManager ¬ificationManager); void Init(); - - void StartDiscovery(uint16_t connectionHandle); bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service); int OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_chr *characteristic); @@ -36,39 +25,47 @@ 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; + + static constexpr const ble_uuid16_t &Uuid() { return ansServiceUuid; } + + uint16_t NewAlerthandle() const; private: - static constexpr uint16_t ansServiceId {0x1811}; + static constexpr uint16_t ansServiceId{0x1811}; static constexpr uint16_t supportedNewAlertCategoryId = 0x2a47; static constexpr uint16_t supportedUnreadAlertCategoryId = 0x2a48; static constexpr uint16_t newAlertId = 0x2a46; static constexpr uint16_t unreadAlertStatusId = 0x2a45; static constexpr uint16_t controlPointId = 0x2a44; - static constexpr ble_uuid16_t ansServiceUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t ansServiceUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = ansServiceId }; - static constexpr ble_uuid16_t supportedNewAlertCategoryUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t supportedNewAlertCategoryUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = supportedNewAlertCategoryId }; - static constexpr ble_uuid16_t supportedUnreadAlertCategoryUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t supportedUnreadAlertCategoryUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = supportedUnreadAlertCategoryId }; - static constexpr ble_uuid16_t newAlertUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t newAlertUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = newAlertId }; - static constexpr ble_uuid16_t unreadAlertStatusUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t unreadAlertStatusUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = unreadAlertStatusId }; - static constexpr ble_uuid16_t controlPointUuid { - .u { .type = BLE_UUID_TYPE_16 }, + static constexpr ble_uuid16_t controlPointUuid{ + .u {.type = BLE_UUID_TYPE_16}, .value = controlPointId }; + uint16_t ansStartHandle; uint16_t ansEndHandle; uint16_t supportedNewAlertCategoryHandle; uint16_t supportedUnreadAlertCategoryHandle; @@ -77,12 +74,9 @@ namespace Pinetime { uint16_t newAlertDefHandle; uint16_t unreadAlertStatusHandle; uint16_t controlPointHandle; - bool discoveryDone = false; - Pinetime::System::SystemTask& systemTask; - Pinetime::Controllers::NotificationManager& notificationManager; - + bool isDiscovered = false; + Pinetime::System::SystemTask &systemTask; + Pinetime::Controllers::NotificationManager ¬ificationManager; }; - - } }
\ No newline at end of file |
