diff --git a/src/components/ble/AppleNotificationCenterClient.cpp b/src/components/ble/AppleNotificationCenterClient.cpp index 81c3b5922f..6f166b030e 100644 --- a/src/components/ble/AppleNotificationCenterClient.cpp +++ b/src/components/ble/AppleNotificationCenterClient.cpp @@ -82,7 +82,8 @@ int AppleNotificationCenterClient::OnCharacteristicsDiscoveryEvent(uint16_t conn // DebugNotification("ANCS Characteristic discovery complete"); if (isCharacteristicDiscovered) { ble_gattc_disc_all_dscs(connectionHandle, notificationSourceHandle, ancsEndHandle, OnANCSDescriptorDiscoveryEventCallback, this); - } if (isDataCharacteristicDiscovered) { + } + if (isDataCharacteristicDiscovered) { // DebugNotification("ANCS Characteristic discovery complete: Data Source"); ble_gattc_disc_all_dscs(connectionHandle, dataSourceHandle, ancsEndHandle, OnANCSDescriptorDiscoveryEventCallback, this); } @@ -134,7 +135,7 @@ int AppleNotificationCenterClient::OnDescriptorDiscoveryEventCallback(uint16_t c NRF_LOG_INFO("ANCS Descriptor discovered : %d", descriptor->handle); // DebugNotification("ANCS Descriptor discovered"); controlPointDescriptorHandle = descriptor->handle; - isControlDescriptorFound = true; + isControlDescriptorFound = true; } } else if (characteristicValueHandle == dataSourceHandle && ble_uuid_cmp(&dataSourceChar.u, &descriptor->uuid.u)) { if (dataSourceDescriptorHandle == 0) { @@ -159,7 +160,9 @@ int AppleNotificationCenterClient::OnDescriptorDiscoveryEventCallback(uint16_t c return 0; } -int AppleNotificationCenterClient::OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* /*attribute*/) { +int AppleNotificationCenterClient::OnNewAlertSubcribe(uint16_t connectionHandle, + const ble_gatt_error* error, + ble_gatt_attr* /*attribute*/) { if (error->status == 0) { NRF_LOG_INFO("ANCS New alert subscribe OK"); DebugNotification("ANCS New alert subscribe OK"); @@ -173,7 +176,9 @@ int AppleNotificationCenterClient::OnNewAlertSubcribe(uint16_t connectionHandle, return 0; } -int AppleNotificationCenterClient::OnControlPointWrite(uint16_t /*connectionHandle*/, const ble_gatt_error* error, ble_gatt_attr* /*attribute*/) { +int AppleNotificationCenterClient::OnControlPointWrite(uint16_t /*connectionHandle*/, + const ble_gatt_error* error, + ble_gatt_attr* /*attribute*/) { if (error->status == 0) { NRF_LOG_INFO("ANCS Control Point write OK"); // DebugNotification("ANCS Control Point write OK"); @@ -255,7 +260,7 @@ void AppleNotificationCenterClient::OnNotification(ble_gap_event* event) { snprintf(uuidStr, sizeof(uuidStr), "iOS Notif.:%08lx\nEvID: %d\nCat: %d\nFlags: %d", notificationUuid, eventId, category, eventFlags); notif.message = std::array {}; std::strncpy(notif.message.data(), uuidStr, notif.message.size() - 1); - notif.message[10] = '\0'; // Seperate Title and Message + notif.message[10] = '\0'; // Seperate Title and Message notif.message[notif.message.size() - 1] = '\0'; // Ensure null-termination notif.size = std::min(std::strlen(uuidStr), notif.message.size()); notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; @@ -365,13 +370,13 @@ void AppleNotificationCenterClient::OnNotification(ble_gap_event* event) { notif.message = std::array {}; std::strncpy(notif.message.data(), notifStr.c_str(), notif.message.size() - 1); - if (incomingCall) + if (incomingCall) notif.message[13] = '\0'; // Seperate Title and Message else if (!decodedSubTitle.empty()) - notif.message[titleSize+subTitleSize] = '\0'; // Seperate Title and Message + notif.message[titleSize + subTitleSize] = '\0'; // Seperate Title and Message else - notif.message[titleSize-1] = '\0'; // Seperate Title and Message - + notif.message[titleSize - 1] = '\0'; // Seperate Title and Message + notif.message[notif.message.size() - 1] = '\0'; // Ensure null-termination notif.size = std::min(std::strlen(notifStr.c_str()), notif.message.size()); if (incomingCall) { diff --git a/src/components/ble/AppleNotificationCenterClient.h b/src/components/ble/AppleNotificationCenterClient.h index 084ed25cc6..76e1a51a19 100644 --- a/src/components/ble/AppleNotificationCenterClient.h +++ b/src/components/ble/AppleNotificationCenterClient.h @@ -22,12 +22,15 @@ namespace Pinetime { class AppleNotificationCenterClient : public BleClient { public: explicit AppleNotificationCenterClient(Pinetime::System::SystemTask& systemTask, - Pinetime::Controllers::NotificationManager& notificationManager); + Pinetime::Controllers::NotificationManager& notificationManager); 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); int OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* attribute); - int OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error* error, uint16_t characteristicValueHandle, const ble_gatt_dsc* descriptor); + int OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, + const ble_gatt_error* error, + uint16_t characteristicValueHandle, + const ble_gatt_dsc* descriptor); int OnControlPointWrite(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* attribute); void OnNotification(ble_gap_event* event); void Reset(); @@ -42,27 +45,23 @@ namespace Pinetime { static constexpr uint8_t maxMessageSize {120}; // 7905F431-B5CE-4E99-A40F-4B1E122D00D0 - static constexpr ble_uuid128_t ancsUuid { + static constexpr ble_uuid128_t ancsUuid { .u {.type = BLE_UUID_TYPE_128}, - .value = {0xd0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79} - }; + .value = {0xd0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79}}; private: // 9FBF120D-6301-42D9-8C58-25E699A21DBD - const ble_uuid128_t notificationSourceChar { - .u {.type = BLE_UUID_TYPE_128}, - .value = {0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C, 0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F} - }; + const ble_uuid128_t notificationSourceChar { + .u {.type = BLE_UUID_TYPE_128}, + .value = {0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C, 0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F}}; // 69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9 const ble_uuid128_t controlPointChar { .u {.type = BLE_UUID_TYPE_128}, - .value = {0xD9, 0xD9, 0xAA, 0xFD, 0xBD, 0x9B, 0x21, 0x98,0xA8, 0x49,0xE1, 0x45, 0xF3, 0xD8, 0xD1, 0x69 } - }; + .value = {0xD9, 0xD9, 0xAA, 0xFD, 0xBD, 0x9B, 0x21, 0x98, 0xA8, 0x49, 0xE1, 0x45, 0xF3, 0xD8, 0xD1, 0x69}}; // 22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB const ble_uuid128_t dataSourceChar { .u {.type = BLE_UUID_TYPE_128}, - .value = {0xFB, 0x7B, 0x7C, 0xCE, 0x6A, 0xB3, 0x44, 0xBE, 0xB5, 0x4B, 0xD6, 0x24, 0xE9, 0xC6, 0xEA, 0x22 } - }; + .value = {0xFB, 0x7B, 0x7C, 0xCE, 0x6A, 0xB3, 0x44, 0xBE, 0xB5, 0x4B, 0xD6, 0x24, 0xE9, 0xC6, 0xEA, 0x22}}; const ble_uuid16_t gattServiceUuid = {BLE_UUID_TYPE_16, 0x1801}; const ble_uuid16_t serviceChangedCharUuid = {BLE_UUID_TYPE_16, 0x2A05}; @@ -82,11 +81,7 @@ namespace Pinetime { Entertainment = 11 }; - enum class EventIds : uint8_t { - Added = 0, - Modified = 1, - Removed = 2 - }; + enum class EventIds : uint8_t { Added = 0, Modified = 1, Removed = 2 }; enum class EventFlags : uint8_t { Silent = (1 << 0), diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 23edddac37..f32c37827b 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -14,7 +14,7 @@ extern lv_font_t jetbrains_mono_bold_20; Notifications::Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::AppleNotificationCenterClient& ancsClient, + Pinetime::Controllers::AppleNotificationCenterClient& ancsClient, Pinetime::Controllers::MotorController& motorController, System::SystemTask& systemTask, Modes mode) diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index a7e00661fa..18ab8e5a34 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -24,7 +24,7 @@ namespace Pinetime { explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::AppleNotificationCenterClient& ancsClient, + Pinetime::Controllers::AppleNotificationCenterClient& ancsClient, Pinetime::Controllers::MotorController& motorController, System::SystemTask& systemTask, Modes mode);