Skip to content

Commit d3ccd72

Browse files
committed
Add method to remove profile by pointer
1 parent 5e998da commit d3ccd72

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/MainClasses/ANTPLUS_AntPlusRouter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ void AntPlusRouter::setProfile(uint8_t channel, BaseProfile* profile) {
6868
profile->setRouter(this);
6969
}
7070

71+
void AntPlusRouter::removeProfile(BaseProfile *profile) {
72+
for (uint8_t i = 0; i < ANTPLUS_MAX_CHANNELS_POSSIBLE; i++) {
73+
if (_profiles[i] == profile) {
74+
removeProfileByChannel(i);
75+
}
76+
}
77+
}
78+
7179
void AntPlusRouter::removeProfileByChannel(uint8_t channel) {
7280
if (channel >= ANTPLUS_MAX_CHANNELS_POSSIBLE) {
7381
return;

src/MainClasses/ANTPLUS_AntPlusRouter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class AntPlusRouter {
3434
* returns ANTPLUS_NO_MORE_CHANNELS
3535
*/
3636
uint8_t addProfileToNextChannel(BaseProfile* profile);
37+
/**
38+
* Stops a profile if the given profile is present
39+
* Unassigns channel
40+
* Removes the profile from index
41+
*/
42+
void removeProfile(BaseProfile *profile);
3743
/**
3844
* Stops a profile at the given channel
3945
* Unassigns channel

0 commit comments

Comments
 (0)