diff options
author | JF002 <JF002@users.noreply.github.com> | 2021-04-26 21:10:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 21:10:11 +0200 |
commit | 4706c99db4c1e05f9dd90f152f2dea08d8f22ab2 (patch) | |
tree | cf2bea6d67e8d91a7d6222b8e0b55a0075575003 /src/components/ble/ImmediateAlertService.cpp | |
parent | e56ebb8bd621cc8838e86fa032d680a6e7a35ffc (diff) | |
parent | 69898545193a82f7d72c9f47c9d9de36167b157b (diff) |
Merge pull request #293 from Avamander/patch-5
Reformatted all the files according to clang-format style
Diffstat (limited to 'src/components/ble/ImmediateAlertService.cpp')
-rw-r--r-- | src/components/ble/ImmediateAlertService.cpp | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/src/components/ble/ImmediateAlertService.cpp b/src/components/ble/ImmediateAlertService.cpp index 0f6bf6cf..fd6430af 100644 --- a/src/components/ble/ImmediateAlertService.cpp +++ b/src/components/ble/ImmediateAlertService.cpp @@ -9,49 +9,42 @@ constexpr ble_uuid16_t ImmediateAlertService::immediateAlertServiceUuid; constexpr ble_uuid16_t ImmediateAlertService::alertLevelUuid; namespace { - int AlertLevelCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { - auto *immediateAlertService = static_cast<ImmediateAlertService *>(arg); + int AlertLevelCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { + auto* immediateAlertService = static_cast<ImmediateAlertService*>(arg); return immediateAlertService->OnAlertLevelChanged(conn_handle, attr_handle, ctxt); } const char* ToString(ImmediateAlertService::Levels level) { switch (level) { - case ImmediateAlertService::Levels::NoAlert: return "Alert : None"; - case ImmediateAlertService::Levels::HighAlert: return "Alert : High"; - case ImmediateAlertService::Levels::MildAlert: return "Alert : Mild"; - default: return ""; + case ImmediateAlertService::Levels::NoAlert: + return "Alert : None"; + case ImmediateAlertService::Levels::HighAlert: + return "Alert : High"; + case ImmediateAlertService::Levels::MildAlert: + return "Alert : Mild"; + default: + return ""; } } } -ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask &systemTask, - Pinetime::Controllers::NotificationManager ¬ificationManager) : - systemTask{systemTask}, - notificationManager{notificationManager}, - characteristicDefinition{ - { - .uuid = (ble_uuid_t *) &alertLevelUuid, - .access_cb = AlertLevelCallback, - .arg = this, - .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, - .val_handle = &alertLevelHandle - }, - { - 0 - } - }, - serviceDefinition{ - { - /* Device Information Service */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = (ble_uuid_t *) &immediateAlertServiceUuid, - .characteristics = characteristicDefinition - }, - { - 0 - }, - }{ - +ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask& systemTask, + Pinetime::Controllers::NotificationManager& notificationManager) + : systemTask {systemTask}, + notificationManager {notificationManager}, + characteristicDefinition {{.uuid = (ble_uuid_t*) &alertLevelUuid, + .access_cb = AlertLevelCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, + .val_handle = &alertLevelHandle}, + {0}}, + serviceDefinition { + {/* Device Information Service */ + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = (ble_uuid_t*) &immediateAlertServiceUuid, + .characteristics = characteristicDefinition}, + {0}, + } { } void ImmediateAlertService::Init() { @@ -63,9 +56,9 @@ void ImmediateAlertService::Init() { ASSERT(res == 0); } -int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context) { - if(attributeHandle == alertLevelHandle) { - if(context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { +int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { + if (attributeHandle == alertLevelHandle) { + if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { auto alertLevel = static_cast<Levels>(context->om->om_data[0]); auto* alertString = ToString(alertLevel); |