Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
965e69a
Started working on ANCS
cyberneel Dec 19, 2024
646c209
Started working on he client, which is the correct half that needs to…
cyberneel Dec 20, 2024
315f69b
Formatting
cyberneel Dec 21, 2024
fcdecbb
Added RTT logging
cyberneel Dec 21, 2024
b9cc3c3
Added debugging through watch notifications
cyberneel Dec 24, 2024
72df4fc
Removed encryption of battery and added required pairing on connect G…
cyberneel Dec 29, 2024
0a26a59
ANCS Partially works
cyberneel Dec 29, 2024
3cc4ece
Started working on using Control Point and Data Source:
cyberneel Dec 30, 2024
dfa13a9
More debugging
cyberneel Dec 31, 2024
8916920
Got Datsource to somewhat work and notifications now show title.
cyberneel Dec 31, 2024
7f0e066
Fixed check to only let new notifications pass (maybe)
cyberneel Dec 31, 2024
fce4a60
Proper Notification works.
cyberneel Jan 1, 2025
9fbc594
Fixed the event flag detection. Only shows a notification when it's new.
cyberneel Jan 2, 2025
1bed731
Fixed first letter in Subtitle being cut off
cyberneel Jan 2, 2025
670c379
Improve message display
liamcharger Jan 2, 2025
5bf8406
Updated notification, Title and Subtitle are in the orange test and m…
cyberneel Jan 2, 2025
288d167
Implemented Incoming Calls to ANCS
cyberneel Jan 3, 2025
f370d63
Turned off non important debugs
cyberneel Jan 3, 2025
0ba425a
Formatted Code
cyberneel Jan 3, 2025
2fe3a6b
Remove RTT settings
liamcharger Jan 3, 2025
1e4989f
Removed more debug notifications
cyberneel Jan 4, 2025
8ab8296
Added check for special characters and show unknown symbol.
cyberneel Jan 5, 2025
bb48b5f
removed all debug notifications
cyberneel Jan 5, 2025
c2b392b
Ignore silent notifications
cyberneel Jan 5, 2025
f888483
Make trunacated messages end in "..." to indicate that message has mo…
cyberneel Jan 5, 2025
65ead6e
Fix typos and remove unnecessary commented code
liamcharger Jan 16, 2025
b8da191
Merge branch 'main' into ancs
liamcharger Jan 16, 2025
c73f016
Merge pull request #26 from InfiniTimeOrg/main
tituscmd Jan 21, 2025
de63dce
Merge branch 'main' into ancs
liamcharger Feb 4, 2025
ec4b3a7
Merge branch 'InfiniTimeOrg:main' into main
tituscmd Apr 10, 2025
d653c17
Merge branch 'InfiniTimeOrg:main' into main
tituscmd May 13, 2025
5e7a77f
Merge branch 'main' into ancs
liamcharger May 14, 2025
3669665
Made codebase changes based on PR Comments
cyberneel May 19, 2025
92673eb
Merge branch 'main' into ancs
cyberneel May 19, 2025
fede286
Merge branch 'InfiniTimeOrg:main' into main
tituscmd May 20, 2025
5e35637
Merge branch 'InfiniTimeOrg:main' into main
tituscmd Jun 10, 2025
ce15d50
Merge branch 'InfiniTimeOrg:main' into ancs
cyberneel Jul 12, 2025
f47c921
Added security initiate back for ancs to work.
cyberneel Jul 12, 2025
8cb0ec4
Updated checks to prevent duplicate notification triggers, NEEDS test…
cyberneel Jul 12, 2025
1937e7e
Check for silent before ringing notification
cyberneel Jul 13, 2025
1d17899
Fix typo in ping check
cyberneel Jul 13, 2025
3450956
ignore notifications not in list
cyberneel Jul 14, 2025
9c919d3
Added a session uuid cache to try to help with duplicate pings
cyberneel Jul 14, 2025
e549e89
clear session uids on reset
cyberneel Jul 14, 2025
a693cff
removed extra array
cyberneel Jul 18, 2025
94b88a0
Merge branch 'InfiniTimeOrg:main' into main
tituscmd Aug 10, 2025
211e85e
Merge branch 'ancs' of https://github.com/cyberneel/InfiniTime into a…
tituscmd Sep 27, 2025
6c89b79
add new helper method
tituscmd Sep 27, 2025
d745049
add another condition for connecting
tituscmd Sep 27, 2025
34a6850
add in header as well
tituscmd Sep 27, 2025
1599edb
Merge branch 'ancs' into ancs-fix-crashes
tituscmd Nov 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/components/ble/AppleNotificationCenterClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool AppleNotificationCenterClient::OnDiscoveryEvent(uint16_t connectionHandle,
ble_gattc_disc_all_chrs(connectionHandle, ancsStartHandle, ancsEndHandle, OnANCSCharacteristicDiscoveredCallback, this);
} else {
NRF_LOG_INFO("ANCS not found");
onServiceDiscovered(connectionHandle);
MaybeFinishDiscovery(connectionHandle);
}
return true;
}
Expand All @@ -69,7 +69,7 @@ int AppleNotificationCenterClient::OnCharacteristicsDiscoveryEvent(uint16_t conn
const ble_gatt_chr* characteristic) {
if (error->status != 0 && error->status != BLE_HS_EDONE) {
NRF_LOG_INFO("ANCS Characteristic discovery ERROR");
onServiceDiscovered(connectionHandle);
MaybeFinishDiscovery(connectionHandle);
return 0;
}

Expand All @@ -82,7 +82,7 @@ int AppleNotificationCenterClient::OnCharacteristicsDiscoveryEvent(uint16_t conn
ble_gattc_disc_all_dscs(connectionHandle, dataSourceHandle, ancsEndHandle, OnANCSDescriptorDiscoveryEventCallback, this);
}
if (isCharacteristicDiscovered == isControlCharacteristicDiscovered && isCharacteristicDiscovered == isDataCharacteristicDiscovered) {
onServiceDiscovered(connectionHandle);
MaybeFinishDiscovery(connectionHandle);
}
} else if (characteristic != nullptr) {
if (ble_uuid_cmp(&notificationSourceChar.u, &characteristic->uuid.u) == 0) {
Expand Down Expand Up @@ -138,7 +138,7 @@ int AppleNotificationCenterClient::OnDescriptorDiscoveryEventCallback(uint16_t c
NRF_LOG_INFO(errorStr);
}
if (isDescriptorFound == isDataDescriptorFound)
onServiceDiscovered(connectionHandle);
MaybeFinishDiscovery(connectionHandle);
}
return 0;
}
Expand All @@ -148,11 +148,16 @@ int AppleNotificationCenterClient::OnNewAlertSubcribe(uint16_t connectionHandle,
ble_gatt_attr* /*attribute*/) {
if (error->status == 0) {
NRF_LOG_INFO("ANCS New alert subscribe OK");

// Mark subscriptions complete only after both CCCDs are known
if (notificationSourceDescriptorHandle != 0 && dataSourceDescriptorHandle != 0) {
subscriptionsDone = true;
}
} else {
NRF_LOG_INFO("ANCS New alert subscribe ERROR");
}
if (isDescriptorFound == isControlDescriptorFound && isDescriptorFound == isDataDescriptorFound)
onServiceDiscovered(connectionHandle);
MaybeFinishDiscovery(connectionHandle);

return 0;
}
Expand All @@ -170,6 +175,13 @@ int AppleNotificationCenterClient::OnControlPointWrite(uint16_t /*connectionHand
return 0;
}

void AppleNotificationCenterClient::MaybeFinishDiscovery(uint16_t connectionHandle) {
if (isCharacteristicDiscovered && isControlCharacteristicDiscovered && isDataCharacteristicDiscovered && isDescriptorFound &&
isControlDescriptorFound && isDataDescriptorFound && subscriptionsDone) {
onServiceDiscovered(connectionHandle);
}
}

void AppleNotificationCenterClient::OnNotification(ble_gap_event* event) {
if (event->notify_rx.attr_handle == notificationSourceHandle || event->notify_rx.attr_handle == notificationSourceDescriptorHandle) {
NRF_LOG_INFO("ANCS Notification received");
Expand Down Expand Up @@ -442,6 +454,7 @@ void AppleNotificationCenterClient::Reset() {
isControlDescriptorFound = false;
isDataCharacteristicDiscovered = false;
isDataDescriptorFound = false;
subscriptionsDone = false;

notifications.clear();
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/ble/AppleNotificationCenterClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Pinetime {
uint16_t characteristicValueHandle,
const ble_gatt_dsc* descriptor);
int OnControlPointWrite(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* attribute);
void MaybeFinishDiscovery(uint16_t connectionHandle);
void OnNotification(ble_gap_event* event);
void Reset();
void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override;
Expand Down Expand Up @@ -107,6 +108,7 @@ namespace Pinetime {

std::string DecodeUtf8String(os_mbuf* om, uint16_t size, uint16_t offset);

bool subscriptionsDone = false;
uint16_t ancsStartHandle {0};
uint16_t ancsEndHandle {0};
uint16_t notificationSourceHandle {0};
Expand Down