Skip to content

Commit ae79087

Browse files
committed
Merge branch 'develop'
2 parents 0a1fbce + f8640e2 commit ae79087

File tree

138 files changed

+3261
-612
lines changed

Some content is hidden

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

138 files changed

+3261
-612
lines changed

.circleci/config.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Python CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-python/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
11+
- image: circleci/python:2.7
12+
13+
# Specify service dependencies here if necessary
14+
# CircleCI maintains a library of pre-built images
15+
# documented at https://circleci.com/docs/2.0/circleci-images/
16+
# - image: circleci/postgres:9.4
17+
18+
working_directory: ~/repo
19+
20+
steps:
21+
- checkout
22+
23+
- run:
24+
name: install dependencies
25+
command: |
26+
sudo pip install -U platformio
27+
28+
# other common Python testing frameworks include pytest and nose
29+
# https://pytest.org
30+
# https://nose.readthedocs.io
31+
- run:
32+
name: run tests
33+
command: |
34+
pio test -e native
35+
36+
- store_artifacts:
37+
path: test-reports
38+
destination: test-reports
39+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ src/main.cpp
88
.DS_Store
99
.tags*
1010
tags
11+
.pio

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ cache:
3434
- "~/.platformio"
3535

3636
env:
37+
- PLATFORMIO_CI_SRC=examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino
3738
- PLATFORMIO_CI_SRC=examples/EnvironmentDisplay/EnvironmentDisplay.ino
3839
- PLATFORMIO_CI_SRC=examples/HeartRateDisplay/HeartRateDisplay.ino
39-
- PLATFORMIO_CI_SRC=examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino
40+
- PLATFORMIO_CI_SRC=examples/HeartRateMonitor/HeartRateMonitor.ino
41+
- PLATFORMIO_CI_SRC=examples/LEVDisplay/LEVDisplay.ino
4042

4143
install:
4244
- pip install -U platformio

COPYING

100755100644
File mode changed.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ An Implementation of the Ant+ Network on top of [ant-arduino](https://github.com
44
## Status
55

66
[![Build Status](https://travis-ci.org/cujomalainey/antplus-arduino.svg?branch=master)](https://travis-ci.org/cujomalainey/antplus-arduino)
7+
[![Test Status](https://img.shields.io/circleci/build/github/cujomalainey/antplus-arduino?label=test)](https://circleci.com/gh/cujomalainey/antplus-arduino)
78
[![BCH compliance](https://bettercodehub.com/edge/badge/cujomalainey/antplus-arduino?branch=master)](https://bettercodehub.com/)
89

910
## News
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/***********************************
2+
* AntPlus DeviceSearch example
3+
*
4+
* The example demonstrates the device
5+
* search functionality of the router.
6+
*
7+
* Author Curtis Malainey
8+
************************************/
9+
#include <Arduino.h>
10+
#include "ANT.h"
11+
#include "ANTPLUS.h"
12+
13+
#define BAUD_RATE 9600
14+
// 30s
15+
#define SEARCH_RUNTIME 30*1000
16+
17+
const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com
18+
uint32_t timeLastSwitch = 0;
19+
bool isSearching = false;
20+
21+
AntWithCallbacks ant = AntWithCallbacks();
22+
AntPlusRouter router = AntPlusRouter();
23+
24+
void searchCallback(uint16_t deviceNumber, uint8_t deviceType, uint8_t transmissionType, uint8_t rssi);
25+
void flipSearch();
26+
27+
void setup() {
28+
Serial.begin(BAUD_RATE);
29+
Serial.println("Running");
30+
Serial1.begin(BAUD_RATE);
31+
ant.setSerial(Serial1);
32+
// Delay after initial setup to wait for user to connect on serial
33+
34+
router.setDriver(&ant); // never touch ant again
35+
router.setAntPlusNetworkKey(NETWORK_KEY);
36+
flipSearch();
37+
}
38+
39+
void loop() {
40+
router.loop();
41+
42+
if (millis() - timeLastSwitch > SEARCH_RUNTIME) {
43+
timeLastSwitch = millis();
44+
flipSearch();
45+
}
46+
}
47+
48+
void flipSearch() {
49+
Serial.println("===========================");
50+
if (isSearching) {
51+
// starting a search will stop all profiles and will need to be
52+
// restarted after the search is stopped
53+
router.startRxSearch(searchCallback);
54+
} else {
55+
router.stopRxSearch();
56+
}
57+
isSearching = !isSearching;
58+
}
59+
60+
void searchCallback(uint16_t deviceNumber, uint8_t deviceType, uint8_t transmissionType, uint8_t rssi) {
61+
Serial.print("Device Number: ");
62+
Serial.print(deviceNumber);
63+
Serial.print(" Device Type: ");
64+
switch (deviceType) {
65+
case ANTPLUS_HEARTRATE_DEVICETYPE:
66+
Serial.println("Heart Rate");
67+
break;
68+
default:
69+
Serial.println("Unknown");
70+
break;
71+
}
72+
Serial.print(" Transmission Type: ");
73+
Serial.print(transmissionType);
74+
Serial.print(" RSSI: ");
75+
Serial.println(rssi);
76+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/***********************************
2+
* AntPlus HRMonitor example
3+
*
4+
* Implements a HR Monitor sensor with
5+
* mocked data to it and then reports
6+
* all events through the serial port
7+
*
8+
* This is a minimum viable example
9+
* all additional datapages are optional
10+
* and are enabled through flags passed
11+
* into the profile
12+
*
13+
* It is highly recommended you read the documenation at
14+
* https://github.com/cujomalainey/antplus-arduino/wiki/HeartRate-Monitor-Profile
15+
*
16+
* Author Curtis Malainey
17+
************************************/
18+
#include <Arduino.h>
19+
#include "ANT.h"
20+
#include "ANTPLUS.h"
21+
22+
#define BAUD_RATE 9600
23+
#define CHANNEL_0 0
24+
25+
const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com
26+
27+
uint32_t flags = 0;
28+
AntWithCallbacks ant;
29+
AntPlusRouter router;
30+
ProfileHeartRateMonitor hr(123, 0, flags);
31+
32+
// void batteryStatusDataPageHandler(HeartRateBatteryStatusMsg& msg, uintptr_t data);
33+
// void capabilitiesDataPageHandler(HeartRateCapabilitiesMsg& msg, uintptr_t data);
34+
// void cumulativeOperatingTimeDataPageHandler(HeartRateCumulativeOperatingTimeMsg& msg, uintptr_t data);
35+
void defaultDataPageHandler(HeartRateDefaultMsg& msg, uintptr_t data);
36+
void manufacturerInformationDataPageHandler(HeartRateManufacturerInformationMsg& msg, uintptr_t data);
37+
// void previousHeartBeatDataPageHandler(HeartRatePreviousHeartBeatMsg& msg, uintptr_t data);
38+
void productInformationDataPageHandler(HeartRateProductInformationMsg& msg, uintptr_t data);
39+
// void swimIntervalSummary(HeartRateSwimIntervalSummaryMsg& msg, uintptr_t data);
40+
41+
void populateBaseHeartRate(HeartRateBaseMainDataPageMsg& msg);
42+
43+
void setup() {
44+
Serial1.begin(BAUD_RATE);
45+
ant.setSerial(Serial1);
46+
delay(15000);
47+
Serial.begin(BAUD_RATE);
48+
Serial.println("Running");
49+
50+
router.setDriver(&ant); // never touch ant again
51+
router.setAntPlusNetworkKey(NETWORK_KEY);
52+
router.setProfile(CHANNEL_0, &hr);
53+
// Delay after initial setup to wait for user to connect on serial
54+
55+
// hr.createHeartRateBatteryStatusMsg(batteryStatusDataPageHandler);
56+
// hr.createHeartRateCapabilitiesMsg(capabilitiesDataPageHandler);
57+
// hr.createHeartRateCumulativeOperatingTimeMsg(cumulativeOperatingTimeDataPageHandler);
58+
hr.createHeartRateDefaultMsg(defaultDataPageHandler);
59+
hr.createHeartRateManufacturerInformationMsg(manufacturerInformationDataPageHandler);
60+
// hr.createHeartRatePreviousHeartBeatMsg(previousHeartBeatDataPageHandler);
61+
hr.createHeartRateProductInformationMsg(productInformationDataPageHandler);
62+
// hr.createHeartRateSwimIntervalSummaryMsg(swimIntervalSummary);
63+
Serial.println("===========================");
64+
hr.begin();
65+
}
66+
67+
void loop() {
68+
// Call this very frequently
69+
router.loop();
70+
}
71+
72+
void printDpMsg(int dp, const char* s) {
73+
Serial.print("Sending DataPage: ");
74+
Serial.print(dp);
75+
Serial.print(" - ");
76+
Serial.println(s);
77+
}
78+
79+
/* Optional */
80+
// void batteryStatusDataPageHandler(HeartRateBatteryStatusMsg& msg, uintptr_t data) {
81+
// printDpMsg(7, "Battery Status");
82+
// populateBaseHeartRate(msg);
83+
// }
84+
85+
/* Optional */
86+
// void capabilitiesDataPageHandler(HeartRateCapabilitiesMsg& msg, uintptr_t data) {
87+
// printDpMsg(6, "Capabilities");
88+
// populateBaseHeartRate(msg);
89+
// }
90+
91+
/* Optional */
92+
// void cumulativeOperatingTimeDataPageHandler(HeartRateCumulativeOperatingTimeMsg& msg, uintptr_t data) {
93+
// printDpMsg(1, "Cumulative Operating Time");
94+
// populateBaseHeartRate(msg);
95+
// }
96+
97+
void defaultDataPageHandler(HeartRateDefaultMsg& msg, uintptr_t data) {
98+
// All fields are reserved
99+
printDpMsg(0, "Default");
100+
populateBaseHeartRate(msg);
101+
}
102+
103+
void manufacturerInformationDataPageHandler(HeartRateManufacturerInformationMsg& msg, uintptr_t data) {
104+
printDpMsg(2, "Manufacturer Information");
105+
populateBaseHeartRate(msg);
106+
msg.setManufacturerIdLsb(78);
107+
msg.setSerialNumber(0xabcd);
108+
}
109+
110+
/* Optional */
111+
// void previousHeartBeatDataPageHandler(HeartRatePreviousHeartBeatMsg& msg, uintptr_t data) {
112+
// printDpMsg(4, "Previous Heart Beat");
113+
// populateBaseHeartRate(msg);
114+
// }
115+
116+
void productInformationDataPageHandler(HeartRateProductInformationMsg& msg, uintptr_t data) {
117+
printDpMsg(3, "Product Information");
118+
populateBaseHeartRate(msg);
119+
msg.setHardwareVersion(1);
120+
msg.setSoftwareVersion(2);
121+
msg.setModelNumber(3);
122+
}
123+
124+
/* Optional */
125+
// void swimIntervalSummary(HeartRateSwimIntervalSummaryMsg& msg, uintptr_t data) {
126+
// printDpMsg(5, "Swim Interval");
127+
// populateBaseHeartRate(msg);
128+
// }
129+
130+
void populateBaseHeartRate(HeartRateBaseMainDataPageMsg& msg) {
131+
static uint8_t toggle = 0;
132+
static uint8_t hr = 0;
133+
static uint16_t eventTime = 0;
134+
static uint8_t count = 0;
135+
msg.setPageChangeToggle(toggle++ < 4);
136+
msg.setComputedHeartRate(20*sin(hr++) + 120);
137+
msg.setHeartBeatEventTime(eventTime);
138+
msg.setHeartBeatCount(count++);
139+
140+
if (toggle >= 8) {
141+
toggle = 0;
142+
}
143+
eventTime += 120;
144+
}

0 commit comments

Comments
 (0)