Skip to content

Commit 90a3fb3

Browse files
committed
Add dynamic set profile
1 parent edff7f0 commit 90a3fb3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/MainClasses/ANTPLUS_AntPlusRouter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ uint8_t AntPlusRouter::getMaxChannels() {
9090
return _maxChannels;
9191
}
9292

93+
uint8_t AntPlusRouter::addProfileToNextChannel(BaseProfile* profile) {
94+
for (uint8_t i = 0; i < _maxChannels; i++) {
95+
if (!_profiles[i]) {
96+
setProfile(i, profile);
97+
return i;
98+
}
99+
}
100+
return 255; //TODO change this to a define
101+
}
102+
93103
void AntPlusRouter::loop() {
94104
_ant->loop();
95105
}

src/MainClasses/ANTPLUS_AntPlusRouter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class AntPlusRouter {
2828
* Associates a profile with a channel
2929
*/
3030
void setProfile(uint8_t channel, BaseProfile* profile);
31+
/**
32+
* Associates a profile with the next lowest available channel
33+
* returns associated channel, if all channels full then it
34+
* returns TODO
35+
*/
36+
uint8_t addProfileToNextChannel(BaseProfile* profile);
3137
/**
3238
* Stops a provile at the given channel
3339
* Unassigns channel

0 commit comments

Comments
 (0)