Skip to content

Commit 4f38e68

Browse files
committed
Merge branch 'develop'
2 parents d49b125 + e77f291 commit 4f38e68

File tree

60 files changed

+1115
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1115
-395
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Arduino library for communicating with ANT radios, with support for nrf51 device
1515

1616
## Roadmap
1717

18-
* v1.5 callback system implemented (partially implemented in current release)
18+
* v1.0 callback system implemented (partially implemented in current release)
19+
* v1.1 unit test done on all messages, serial driver and callback system
1920
* ~~v1.6 SPI support~~ (Arduino has no support for being a SPI slave, maybe mbed)
2021
* v2.0 compile switch to handle running natively on an nRF52 dev board
2122

examples/Callbacks/Callbacks.ino

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void handleBroadcastMessage(BroadcastData& bd, uintptr_t data);
1919
void handleAntError(uint8_t code, uintptr_t data);
2020
void handleStartUpMessage(StartUpMessage& sum, uintptr_t data);
2121
void handleChannelEventResponse(ChannelEventResponse& cer, uintptr_t data);
22+
bool itsAlive(StartUpMessage& sm, uintptr_t data);
2223

2324
void setup()
2425
{
@@ -29,6 +30,7 @@ void setup()
2930
ChannelPeriod cp;
3031
ChannelRfFrequency crf;
3132
OpenChannel oc;
33+
StartUpMessage sm;
3234

3335
Serial1.begin(BAUD_RATE);
3436
ant.onBroadcastData(handleBroadcastMessage);
@@ -37,24 +39,39 @@ void setup()
3739
ant.onChannelEventResponse(handleChannelEventResponse);
3840
ant.onOtherResponse(handleMessageWithNoCallback);
3941
ant.begin(Serial1);
40-
ant.send(rs);
41-
// Delay after resetting the radio to give the user time to connect on serial
42-
delay(10000);
42+
4343
Serial.begin(9600);
44+
delay(10000);
45+
// Delay to give the user time to connect on serial
46+
4447
Serial.println("Running");
4548

49+
ant.send(rs);
50+
ant.waitFor(sm, 2000, itsAlive); // wait 2s for device to start
51+
4652
snk = SetNetworkKey();
4753
snk.setNetwork(0);
4854
snk.setKey((uint8_t*)NETWORK_KEY);
4955
ant.send(snk);
50-
ant.loop();
56+
if(ant.waitForStatus(snk.getMsgId(), 1000)) {
57+
Serial.println("No Response for setting network key");
58+
} else {
59+
ChannelEventResponse cer = ChannelEventResponse();
60+
ant.getResponse().getChannelEventResponseMsg(cer);
61+
handleChannelEventResponse(cer, 0);
62+
}
5163

5264
ac = AssignChannel();
5365
ac.setChannel(0);
5466
ac.setChannelType(CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE); //can't wildcard this
5567
ac.setChannelNetwork(0);
56-
ant.send(ac);
57-
ant.loop();
68+
if (ant.sendAndWait(ac, 2000)) {
69+
Serial.println("No Response for assigning channel");
70+
} else {
71+
ChannelEventResponse cer = ChannelEventResponse();
72+
ant.getResponse().getChannelEventResponseMsg(cer);
73+
handleChannelEventResponse(cer, 0);
74+
}
5875

5976
ci = ChannelId();
6077
ci.setChannel(0);
@@ -145,3 +162,8 @@ void handleChannelEventResponse(ChannelEventResponse& cer, uintptr_t data) {
145162
break;
146163
}
147164
}
165+
166+
bool itsAlive(StartUpMessage& sm, uintptr_t data) {
167+
Serial.println("Radio Reset!");
168+
return true;
169+
}

examples/OpenChannel/OpenChannel.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void setup()
3535
ant.send(rs);
3636
// Delay after resetting the radio to give the user time to connect on serial
3737
delay(10000);
38-
Serial.begin(9600);
38+
Serial.begin(BAUD_RATE);
3939
Serial.println("Running");
4040

4141
snk = SetNetworkKey();

src/ANT_defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
#define CHECKSUM_FAILURE 1
239239
#define PACKET_EXCEEDS_BYTE_ARRAY_LENGTH 2
240240
#define UNEXPECTED_START_BYTE 3
241+
#define ANT_WAIT_TIMEOUT 255
241242

242243
/**
243244
* Framework Defines
@@ -246,6 +247,7 @@
246247
#define MESSAGE_SIZE 0x08
247248
#define INVALID_REQUEST 0xFF
248249
#define BITS_IN_BYTE 0x08
250+
#define BITS_IN_SHORT 0x10
249251

250252
/**
251253
* SoftDevice API available, build native ant

src/ANT_private_defines.h

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,43 @@
1414
/**
1515
* Message Length Defines
1616
*/
17-
#define ACKNOWLEDGED_DATA_LENGTH 0x09
18-
#define ADVANCED_BURST_DATA_LENGTH 0x09
19-
#define ASSIGN_CHANNEL_LENGTH 0x03
20-
#define BROADCAST_DATA_LENGTH 0x09
21-
#define BURST_DATA_TRANSFER_LENGTH 0x09
22-
#define BURST_TRANSFER_DATA_LENGTH 0x09
23-
#define CHANNEL_ID_LENGTH 0x05
24-
#define CHANNEL_PERIOD_LENGTH 0x03
25-
#define CHANNEL_RF_FREQUENCY_LENGTH 0x02
26-
#define CHANNEL_SEARCH_SHARING_LENGTH 0x02
27-
#define CLOSE_CHANNEL_LENGTH 0x01
28-
#define CONFIG_ENCRYPTION_ID_LIST_LENGTH 0x03
29-
#define CONFIG_ID_LIST_LENGTH 0x03
30-
#define CW_INIT_LENGTH 0x01
31-
#define LIB_CONFIG_LENGTH 0x02
32-
#define OPEN_CHANNEL_LENGTH 0x01
33-
#define OPEN_RX_SCAN_MODE_LENGTH 0x01
34-
#define REQUEST_MESSAGE_LENGTH 0x02
35-
#define RESET_SYSTEM_LENGTH 0x01
36-
#define SEARCH_TIMEOUT_LENGTH 0x02
37-
#define SEARCH_WAVEFORM_LENGTH 0x03
38-
#define SET_NETWORK_KEY_LENGTH 0x09
39-
#define TRANSMIT_POWER_LENGTH 0x02
40-
#define UNASSIGN_CHANNEL_LENGTH 0x01
17+
#define ACKNOWLEDGED_DATA_LENGTH 0x09
18+
#define ADD_CHANNEL_ID_TO_LIST_LENGTH 0x06
19+
#define ADD_ENCRYPTION_ID_TO_LIST_LENGTH 0x06
20+
#define ADVANCED_BURST_DATA_LENGTH 0x09
21+
#define ASSIGN_CHANNEL_LENGTH 0x03
22+
#define BROADCAST_DATA_LENGTH 0x09
23+
#define BURST_DATA_TRANSFER_LENGTH 0x09
24+
#define BURST_TRANSFER_DATA_LENGTH 0x09
25+
#define CHANNEL_ID_LENGTH 0x05
26+
#define CHANNEL_PERIOD_LENGTH 0x03
27+
#define CHANNEL_RF_FREQUENCY_LENGTH 0x02
28+
#define CHANNEL_SEARCH_PRIORITY_LENGTH 0x02
29+
#define CHANNEL_SEARCH_SHARING_LENGTH 0x02
30+
#define CLOSE_CHANNEL_LENGTH 0x01
31+
#define CONFIG_ENCRYPTION_ID_LIST_LENGTH 0x03
32+
#define CONFIG_ID_LIST_LENGTH 0x03
33+
#define CONFIGURE_ADVANCED_BURST_LENGTH 0x0C
34+
#define CONFIGURE_EVENT_FILTER_LENTGH 0x03
35+
#define CONFIGURE_SELECTIVE_DATA_UPDATES_LENGTH 0x02
36+
#define CW_INIT_LENGTH 0x01
37+
#define ENABLE_EXT_RX_MESSAGES_LENGTH 0x02
38+
#define ENABLE_SINGLE_CHANNEL_ENCRYPTION_LENGTH 0x04
39+
#define FREQUENCY_AGILITY_LENGTH 0x04
40+
#define LIB_CONFIG_LENGTH 0x02
41+
#define LOW_PRIORITY_SEARCH_TIMEOUT_LENGTH 0x02
42+
#define OPEN_CHANNEL_LENGTH 0x01
43+
#define OPEN_RX_SCAN_MODE_LENGTH 0x01
44+
#define PROXIMITY_SEARCH_LENGTH 0x02
45+
#define REQUEST_MESSAGE_LENGTH 0x02
46+
#define RESET_SYSTEM_LENGTH 0x01
47+
#define SEARCH_TIMEOUT_LENGTH 0x02
48+
#define SEARCH_WAVEFORM_LENGTH 0x03
49+
#define SERIAL_NUMBER_SET_CHANNEL_ID_LENGTH 0x03
50+
#define SET_CHANNEL_TRANSMIT_POWER_LENGTH 0x02
51+
#define SET_NETWORK_KEY_LENGTH 0x09
52+
#define TRANSMIT_POWER_LENGTH 0x02
53+
#define UNASSIGN_CHANNEL_LENGTH 0x01
4154

4255
/**
4356
* Channel Status BitField Defines
@@ -52,4 +65,17 @@
5265
*/
5366
#define CONFIG_ID_LIST_LIST_MAX_SIZE 0x04
5467

68+
/**
69+
* Advanced burst defines
70+
*/
71+
#define ADVANCED_BURST_DATA_CHANNEL_MASK 0x1F
72+
#define ADVANCED_BURST_DATA_SEQUENCENUMBER_SHIFT 5
73+
74+
/**
75+
* Configure Selective Data Updates defines
76+
*/
77+
#define CONFIGURE_SELECTIVE_DATA_UPDATES_SDU_DISABLE 0xFF
78+
#define CONFIGURE_SELECTIVE_DATA_UPDATES_SDU_NUMBER_MASK 0x1F
79+
#define CONFIGURE_SELECTIVE_DATA_UPDATES_FILTER_BIT_MASK 0x80
80+
5581
#endif // ANT_PRIVATE_DEFINES_h

0 commit comments

Comments
 (0)