Skip to content

Commit cd8b1f0

Browse files
committed
Request capabilites on boot
1 parent 7c3ae42 commit cd8b1f0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/ANTPLUS_Defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#define ANTPLUS_MAX_CHANNELS_POSSIBLE 15
66
#define ANTPLUS_NETWORKKEY_INDEX 0
77
#define ANTPLUS_DRIVER_RESET_TIMEOUT 2000
8+
#define ANTPLUS_DRIVER_REQUEST_TIMEOUT 1000
89

910
// Errors
1011
#define ANTPLUS_RESET_RADIO_FAILED 1
12+
#define ANTPLUS_MAX_CHANNEL_CHECK_FAILED 2
1113

1214
// State
1315
#define ANTPLUS_DRIVER_STATE_UNKNOWN 0

src/MainClasses/ANTPLUS_AntPlusRouter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <ANTPLUS_PrivateDefines.h>
44

55
AntPlusRouter::AntPlusRouter() {
6-
// TODO
6+
77
}
88

99
AntPlusRouter::AntPlusRouter(BaseAntWithCallbacks* driver) {
@@ -16,6 +16,9 @@ AntPlusRouter::AntPlusRouter(BaseAntWithCallbacks* driver, const uint8_t* key) {
1616
}
1717

1818
uint8_t AntPlusRouter::setDriver(BaseAntWithCallbacks* driver) {
19+
// Synchronous locking nature needed to gurantee all configs were recieved
20+
RequestMessage rm = RequestMessage();
21+
Capabilities cap = Capabilities();
1922
_ant = driver;
2023
// register callbacks
2124
_ant->onPacketError(onPacketErrorCallback, (uintptr_t)this);
@@ -37,7 +40,11 @@ uint8_t AntPlusRouter::setDriver(BaseAntWithCallbacks* driver) {
3740
return ANTPLUS_RESET_RADIO_FAILED;
3841
}
3942
pushNetworkKey();
40-
// get max channels
43+
rm.setRequestedMessage(CAPABILITIES);
44+
_ant->send(rm);
45+
if (_ant->waitFor(cap, ANTPLUS_DRIVER_REQUEST_TIMEOUT)) {
46+
return ANTPLUS_MAX_CHANNEL_CHECK_FAILED;
47+
}
4148
return 0;
4249
}
4350

0 commit comments

Comments
 (0)