Host software for the MAXREFDES220 Heart Rate Monitor Smart Sensor. Hosted on the MAX32630FTHR.

Dependencies:   max32630fthr USBDevice

Fork of MAXREFDES220_HEART_RATE_MONITOR by Maxim Integrated

Finger Heart Rate Monitor and SpO2 Monitor

The MAXREFDES220 Smart Sensor FeatherWing board is a integrated solution for providing finger-based heart rate measurements and SpO2 (blood oxygen saturation). This evaluation board interfaces to the host computer using the I2C interface. Heart rate outpu is available in beats per minute (BPM) and SpO2 is reported in percentages.; the PPG (photoplethysmography) raw data is also available. The board has an MAX30101 chip which is a low power heart rate monitor with adjustable sample rates and adjustable LED currents. The low cost MAX32664 microcontroller is pre-flashed with C code for finger-based pulse rate and SpO2 monitoring. Bootloader software is included to allow for future algorithms or updates to the algorithm from Maxim Integrated.

Ordering information will be available soon.

Note: SpO2 values are not calibrated. Calibration should be performed using the final end product.

Warning

The MAXREFDES220 source code listed is dated and only compatible with the 1.2.8a.msbl. The latest sample host source code is available on the MAX32664 website.

MAXREFDES220 FeatherWing Pinout Connections

/media/uploads/phonemacro/maxrefdes220_pinouts_heart_rate_monitor.jpg

Committer:
Shaun Kelsey
Date:
Thu May 24 14:54:28 2018 -0700
Revision:
5:e458409e913f
Parent:
0:da5f5b56060a
Child:
8:0f55f59ca341
Bootloader feature additions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Shaun Kelsey 0:da5f5b56060a 1 /***************************************************************************
Shaun Kelsey 0:da5f5b56060a 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
Shaun Kelsey 0:da5f5b56060a 3 *
Shaun Kelsey 0:da5f5b56060a 4 * Permission is hereby granted, free of charge, to any person obtaining a
Shaun Kelsey 0:da5f5b56060a 5 * copy of this software and associated documentation files (the "Software"),
Shaun Kelsey 0:da5f5b56060a 6 * to deal in the Software without restriction, including without limitation
Shaun Kelsey 0:da5f5b56060a 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Shaun Kelsey 0:da5f5b56060a 8 * and/or sell copies of the Software, and to permit persons to whom the
Shaun Kelsey 0:da5f5b56060a 9 * Software is furnished to do so, subject to the following conditions:
Shaun Kelsey 0:da5f5b56060a 10 *
Shaun Kelsey 0:da5f5b56060a 11 * The above copyright notice and this permission notice shall be included
Shaun Kelsey 0:da5f5b56060a 12 * in all copies or substantial portions of the Software.
Shaun Kelsey 0:da5f5b56060a 13 *
Shaun Kelsey 0:da5f5b56060a 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Shaun Kelsey 0:da5f5b56060a 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Shaun Kelsey 0:da5f5b56060a 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Shaun Kelsey 0:da5f5b56060a 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Shaun Kelsey 0:da5f5b56060a 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Shaun Kelsey 0:da5f5b56060a 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Shaun Kelsey 0:da5f5b56060a 20 * OTHER DEALINGS IN THE SOFTWARE.
Shaun Kelsey 0:da5f5b56060a 21 *
Shaun Kelsey 0:da5f5b56060a 22 * Except as contained in this notice, the name of Maxim Integrated
Shaun Kelsey 0:da5f5b56060a 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Shaun Kelsey 0:da5f5b56060a 24 * Products, Inc. Branding Policy.
Shaun Kelsey 0:da5f5b56060a 25 *
Shaun Kelsey 0:da5f5b56060a 26 * The mere transfer of this software does not imply any licenses
Shaun Kelsey 0:da5f5b56060a 27 * of trade secrets, proprietary technology, copyrights, patents,
Shaun Kelsey 0:da5f5b56060a 28 * trademarks, maskwork rights, or any other form of intellectual
Shaun Kelsey 0:da5f5b56060a 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
Shaun Kelsey 0:da5f5b56060a 30 * ownership rights.
Shaun Kelsey 0:da5f5b56060a 31 ****************************************************************************
Shaun Kelsey 0:da5f5b56060a 32 */
Shaun Kelsey 0:da5f5b56060a 33
Shaun Kelsey 0:da5f5b56060a 34 #include <ctype.h>
Shaun Kelsey 0:da5f5b56060a 35 #include <string.h>
Shaun Kelsey 0:da5f5b56060a 36 #include "DSInterface.h"
Shaun Kelsey 0:da5f5b56060a 37 #include "../version.h"
Shaun Kelsey 0:da5f5b56060a 38 #include "Peripherals.h"
Shaun Kelsey 0:da5f5b56060a 39 #include "assert.h"
Shaun Kelsey 5:e458409e913f 40 #include "utils.h"
Shaun Kelsey 5:e458409e913f 41
Shaun Kelsey 5:e458409e913f 42 #ifdef ENABLE_BLE
Shaun Kelsey 5:e458409e913f 43 #include "BLE_ICARUS.h"
Shaun Kelsey 5:e458409e913f 44 #endif
Shaun Kelsey 0:da5f5b56060a 45
Shaun Kelsey 0:da5f5b56060a 46 static const char *glbl_cmds[] = {
Shaun Kelsey 0:da5f5b56060a 47 "stop",
Shaun Kelsey 0:da5f5b56060a 48 "get_device_info",
Shaun Kelsey 0:da5f5b56060a 49 "silent_mode 0",
Shaun Kelsey 0:da5f5b56060a 50 "silent_mode 1",
Shaun Kelsey 0:da5f5b56060a 51 "pause 0",
Shaun Kelsey 0:da5f5b56060a 52 "pause 1",
Shaun Kelsey 0:da5f5b56060a 53 "enable console",
Shaun Kelsey 0:da5f5b56060a 54 "disable console",
Shaun Kelsey 0:da5f5b56060a 55 };
Shaun Kelsey 0:da5f5b56060a 56
Shaun Kelsey 0:da5f5b56060a 57 typedef enum {
Shaun Kelsey 0:da5f5b56060a 58 stop=0,
Shaun Kelsey 0:da5f5b56060a 59 get_device_info,
Shaun Kelsey 0:da5f5b56060a 60 silent0_mode,
Shaun Kelsey 0:da5f5b56060a 61 silent1_mode,
Shaun Kelsey 0:da5f5b56060a 62 pause0_mode,
Shaun Kelsey 0:da5f5b56060a 63 pause1_mode,
Shaun Kelsey 0:da5f5b56060a 64 enable_console,
Shaun Kelsey 0:da5f5b56060a 65 disable_console,
Shaun Kelsey 0:da5f5b56060a 66 NUM_CMDS,
Shaun Kelsey 0:da5f5b56060a 67 } glbl_cmd_state;
Shaun Kelsey 0:da5f5b56060a 68
Shaun Kelsey 0:da5f5b56060a 69
Shaun Kelsey 0:da5f5b56060a 70 DSInterface::DSInterface(USBSerial* USB)
Shaun Kelsey 0:da5f5b56060a 71 {
Shaun Kelsey 0:da5f5b56060a 72 cmd_idx = 0;
Shaun Kelsey 0:da5f5b56060a 73 silent_mode = false;
Shaun Kelsey 0:da5f5b56060a 74 pause_mode = false;
Shaun Kelsey 0:da5f5b56060a 75
Shaun Kelsey 0:da5f5b56060a 76 memset(sensor_list, 0, DS_MAX_NUM_SENSORCOMMS * sizeof(SensorComm*));
Shaun Kelsey 0:da5f5b56060a 77 num_sensors = 0;
Shaun Kelsey 0:da5f5b56060a 78
Shaun Kelsey 0:da5f5b56060a 79 m_USB = USB;
Shaun Kelsey 0:da5f5b56060a 80
Shaun Kelsey 0:da5f5b56060a 81 data_report_mode = 0;
Shaun Kelsey 5:e458409e913f 82 console_interface_exists = true;
Shaun Kelsey 0:da5f5b56060a 83 }
Shaun Kelsey 0:da5f5b56060a 84
Shaun Kelsey 0:da5f5b56060a 85 DSInterface::~DSInterface()
Shaun Kelsey 0:da5f5b56060a 86 {
Shaun Kelsey 0:da5f5b56060a 87 }
Shaun Kelsey 0:da5f5b56060a 88
Shaun Kelsey 0:da5f5b56060a 89 void DSInterface::add_sensor_comm(SensorComm *s)
Shaun Kelsey 0:da5f5b56060a 90 {
Shaun Kelsey 0:da5f5b56060a 91 assert_msg(num_sensors < DS_MAX_NUM_SENSORCOMMS, "Too many sensors added to DSInterface. Increase DS_MAX_NUM_SENSORCOMMS.");
Shaun Kelsey 0:da5f5b56060a 92 sensor_list[num_sensors++] = s;
Shaun Kelsey 0:da5f5b56060a 93 }
Shaun Kelsey 0:da5f5b56060a 94
Shaun Kelsey 0:da5f5b56060a 95 void DSInterface::enable_console_interface()
Shaun Kelsey 0:da5f5b56060a 96 {
Shaun Kelsey 0:da5f5b56060a 97 console_interface_exists = true;
Shaun Kelsey 0:da5f5b56060a 98 }
Shaun Kelsey 0:da5f5b56060a 99
Shaun Kelsey 0:da5f5b56060a 100 void DSInterface::build_command(char ch)
Shaun Kelsey 0:da5f5b56060a 101 {
Shaun Kelsey 0:da5f5b56060a 102 if (!this->silent_mode) /* BUG: POTENTIAL BUG, what uart port to echo, not only console */
Shaun Kelsey 0:da5f5b56060a 103 m_USB->printf("%c", ch);
Shaun Kelsey 0:da5f5b56060a 104
Shaun Kelsey 0:da5f5b56060a 105 if (ch == 0x00) {
Shaun Kelsey 0:da5f5b56060a 106 pr_err("Ignored char 0x00");
Shaun Kelsey 0:da5f5b56060a 107 return;
Shaun Kelsey 0:da5f5b56060a 108 }
Shaun Kelsey 0:da5f5b56060a 109
Shaun Kelsey 0:da5f5b56060a 110 if ((ch == '\n') || (ch == '\r')) {
Shaun Kelsey 5:e458409e913f 111 if (cmd_idx < (int)CONSOLE_STR_BUF_SZ)
Shaun Kelsey 0:da5f5b56060a 112 cmd_str[cmd_idx++] = '\0';
Shaun Kelsey 0:da5f5b56060a 113 m_USB->printf("\r\n");
Shaun Kelsey 0:da5f5b56060a 114 parse_command();
Shaun Kelsey 0:da5f5b56060a 115
Shaun Kelsey 0:da5f5b56060a 116 //Clear cmd_str
Shaun Kelsey 0:da5f5b56060a 117 while (cmd_idx > 0) /* BUG: POTENTIAL BUG for multiple port access */
Shaun Kelsey 0:da5f5b56060a 118 cmd_str[--cmd_idx] = '\0';
Shaun Kelsey 0:da5f5b56060a 119
Shaun Kelsey 0:da5f5b56060a 120 } else if ((ch == 0x08 || ch == 0x7F) && cmd_idx > 0) {
Shaun Kelsey 0:da5f5b56060a 121 //Backspace character
Shaun Kelsey 0:da5f5b56060a 122 if (cmd_idx > 0)
Shaun Kelsey 0:da5f5b56060a 123 cmd_str[--cmd_idx] = '\0';
Shaun Kelsey 0:da5f5b56060a 124 } else {
Shaun Kelsey 0:da5f5b56060a 125 /* BUG: POTENTIAL BUG for multiple port access */
Shaun Kelsey 5:e458409e913f 126 if (cmd_idx < (int)CONSOLE_STR_BUF_SZ)
Shaun Kelsey 0:da5f5b56060a 127 cmd_str[cmd_idx++] = ch;
Shaun Kelsey 0:da5f5b56060a 128 }
Shaun Kelsey 0:da5f5b56060a 129
Shaun Kelsey 0:da5f5b56060a 130 }
Shaun Kelsey 0:da5f5b56060a 131
Shaun Kelsey 0:da5f5b56060a 132 void DSInterface::parse_command()
Shaun Kelsey 0:da5f5b56060a 133 {
Shaun Kelsey 0:da5f5b56060a 134 int i;
Shaun Kelsey 0:da5f5b56060a 135 glbl_cmd_state cmd;
Shaun Kelsey 0:da5f5b56060a 136 char charbuf[512];
Shaun Kelsey 0:da5f5b56060a 137 int data_len = 0;
Shaun Kelsey 0:da5f5b56060a 138 int ret;
Shaun Kelsey 5:e458409e913f 139 bool parsed_cmd = true;
Shaun Kelsey 0:da5f5b56060a 140
Shaun Kelsey 0:da5f5b56060a 141 //If top level command, then handle it
Shaun Kelsey 0:da5f5b56060a 142 for (i = 0; i < NUM_CMDS; i++) {
Shaun Kelsey 5:e458409e913f 143 if (starts_with(&cmd_str[0], glbl_cmds[i])) {
Shaun Kelsey 0:da5f5b56060a 144 cmd = (glbl_cmd_state)i;
Shaun Kelsey 0:da5f5b56060a 145
Shaun Kelsey 0:da5f5b56060a 146 switch (cmd) {
Shaun Kelsey 0:da5f5b56060a 147 case (stop): {
Shaun Kelsey 0:da5f5b56060a 148 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 149 sensor_list[i]->stop();
Shaun Kelsey 0:da5f5b56060a 150 }
Shaun Kelsey 5:e458409e913f 151 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 152 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 153 } break;
Shaun Kelsey 0:da5f5b56060a 154 case (get_device_info): {
Shaun Kelsey 0:da5f5b56060a 155 data_len = snprintf(charbuf, sizeof(charbuf),
Shaun Kelsey 5:e458409e913f 156 "\r\n%s platform=%s firmware_ver=%s sensors=", cmd_str, platform_name, firmware_version);
Shaun Kelsey 0:da5f5b56060a 157
Shaun Kelsey 0:da5f5b56060a 158 //Add list of sensors
Shaun Kelsey 0:da5f5b56060a 159 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 160 if (sensor_list[i]->is_visible()) {
Shaun Kelsey 0:da5f5b56060a 161 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len,
Shaun Kelsey 0:da5f5b56060a 162 "%s", sensor_list[i]->get_type());
Shaun Kelsey 0:da5f5b56060a 163 if (i < (num_sensors - 1))
Shaun Kelsey 0:da5f5b56060a 164 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len, ",");
Shaun Kelsey 0:da5f5b56060a 165 }
Shaun Kelsey 0:da5f5b56060a 166 }
Shaun Kelsey 0:da5f5b56060a 167
Shaun Kelsey 0:da5f5b56060a 168
Shaun Kelsey 0:da5f5b56060a 169 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 170 SensorComm *s = sensor_list[i];
Shaun Kelsey 0:da5f5b56060a 171 if (!s->is_visible())
Shaun Kelsey 0:da5f5b56060a 172 continue;
Shaun Kelsey 0:da5f5b56060a 173
Shaun Kelsey 0:da5f5b56060a 174 //Add part name
Shaun Kelsey 0:da5f5b56060a 175 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len,
Shaun Kelsey 0:da5f5b56060a 176 " part_name_%s=%s", s->get_type(), s->get_part_name());
Shaun Kelsey 0:da5f5b56060a 177
Shaun Kelsey 0:da5f5b56060a 178 uint8_t part_id, part_rev;
Shaun Kelsey 0:da5f5b56060a 179 ret = s->get_part_info(&part_id, &part_rev);
Shaun Kelsey 0:da5f5b56060a 180
Shaun Kelsey 0:da5f5b56060a 181 if (ret == 0) {
Shaun Kelsey 0:da5f5b56060a 182 //Add part id
Shaun Kelsey 0:da5f5b56060a 183 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len,
Shaun Kelsey 0:da5f5b56060a 184 " part_id_%s=%d", s->get_type(), part_id);
Shaun Kelsey 0:da5f5b56060a 185
Shaun Kelsey 0:da5f5b56060a 186 //Add rev id
Shaun Kelsey 0:da5f5b56060a 187 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len,
Shaun Kelsey 0:da5f5b56060a 188 " part_rev_%s=%d", s->get_type(), part_rev);
Shaun Kelsey 0:da5f5b56060a 189 }
Shaun Kelsey 0:da5f5b56060a 190 }
Shaun Kelsey 0:da5f5b56060a 191
Shaun Kelsey 0:da5f5b56060a 192
Shaun Kelsey 5:e458409e913f 193 data_len += snprintf(charbuf + data_len, sizeof(charbuf) - data_len, " err=0\r\n");
Shaun Kelsey 0:da5f5b56060a 194
Shaun Kelsey 0:da5f5b56060a 195 } break;
Shaun Kelsey 0:da5f5b56060a 196 case (silent0_mode): {
Shaun Kelsey 0:da5f5b56060a 197 silent_mode = false;
Shaun Kelsey 5:e458409e913f 198 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 199 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 200 } break;
Shaun Kelsey 0:da5f5b56060a 201 case (silent1_mode): {
Shaun Kelsey 0:da5f5b56060a 202 silent_mode = true;
Shaun Kelsey 5:e458409e913f 203 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 204 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 205 } break;
Shaun Kelsey 0:da5f5b56060a 206 case (pause0_mode): {
Shaun Kelsey 0:da5f5b56060a 207 pause_mode = false;
Shaun Kelsey 5:e458409e913f 208 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 209 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 210 } break;
Shaun Kelsey 0:da5f5b56060a 211 case (pause1_mode): {
Shaun Kelsey 0:da5f5b56060a 212 pause_mode = true;
Shaun Kelsey 5:e458409e913f 213 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 214 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 215 } break;
Shaun Kelsey 0:da5f5b56060a 216 case (enable_console): {
Shaun Kelsey 0:da5f5b56060a 217 console_interface_exists = true;
Shaun Kelsey 5:e458409e913f 218 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 219 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 220 } break;
Shaun Kelsey 0:da5f5b56060a 221 case (disable_console): {
Shaun Kelsey 0:da5f5b56060a 222 console_interface_exists = false;
Shaun Kelsey 5:e458409e913f 223 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 224 "\r\n%s err=0\r\n", cmd_str);
Shaun Kelsey 0:da5f5b56060a 225 } break;
Shaun Kelsey 0:da5f5b56060a 226 default:
Shaun Kelsey 5:e458409e913f 227 parsed_cmd = false;
Shaun Kelsey 0:da5f5b56060a 228 break;
Shaun Kelsey 0:da5f5b56060a 229 }
Shaun Kelsey 0:da5f5b56060a 230
Shaun Kelsey 5:e458409e913f 231 if (parsed_cmd) {
Shaun Kelsey 5:e458409e913f 232 m_USB->printf(charbuf);
Shaun Kelsey 5:e458409e913f 233 #if ENABLE_BLE
Shaun Kelsey 5:e458409e913f 234 if (BLE_Icarus_Interface_Exists()) {
Shaun Kelsey 5:e458409e913f 235 BLE_Icarus_AddtoQueue((uint8_t *)charbuf, (int32_t)sizeof(charbuf), data_len);
Shaun Kelsey 5:e458409e913f 236 }
Shaun Kelsey 5:e458409e913f 237 #endif
Shaun Kelsey 5:e458409e913f 238 }
Shaun Kelsey 5:e458409e913f 239
Shaun Kelsey 0:da5f5b56060a 240 return;
Shaun Kelsey 0:da5f5b56060a 241 }
Shaun Kelsey 0:da5f5b56060a 242 }
Shaun Kelsey 0:da5f5b56060a 243
Shaun Kelsey 0:da5f5b56060a 244 //Loop through each sensor in sensorList
Shaun Kelsey 0:da5f5b56060a 245 //If sensor.get_type() is contained in cmd_str, pass cmd_str to that sensor's parser
Shaun Kelsey 0:da5f5b56060a 246 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 247 if (strstr(&cmd_str[0], sensor_list[i]->get_type())) {
Shaun Kelsey 0:da5f5b56060a 248 if (sensor_list[i]->parse_command(cmd_str))
Shaun Kelsey 0:da5f5b56060a 249 return;
Shaun Kelsey 0:da5f5b56060a 250 break;
Shaun Kelsey 0:da5f5b56060a 251 }
Shaun Kelsey 0:da5f5b56060a 252 }
Shaun Kelsey 0:da5f5b56060a 253
Shaun Kelsey 0:da5f5b56060a 254 //If we still haven't found a way to parse the command,
Shaun Kelsey 0:da5f5b56060a 255 //send it to every sensor until one handles it
Shaun Kelsey 0:da5f5b56060a 256 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 257 if (sensor_list[i]->parse_command(cmd_str))
Shaun Kelsey 0:da5f5b56060a 258 return;
Shaun Kelsey 0:da5f5b56060a 259 }
Shaun Kelsey 0:da5f5b56060a 260
Shaun Kelsey 0:da5f5b56060a 261
Shaun Kelsey 0:da5f5b56060a 262 //No one could handle the command, print cmd not recognized string
Shaun Kelsey 5:e458409e913f 263 data_len += snprintf(charbuf, sizeof(charbuf) - 1,
Shaun Kelsey 5:e458409e913f 264 "\r\n%s err=-255\r\n", cmd_str);
Shaun Kelsey 5:e458409e913f 265 m_USB->printf(charbuf);
Shaun Kelsey 5:e458409e913f 266 #if ENABLE_BLE
Shaun Kelsey 5:e458409e913f 267 if (BLE_Icarus_Interface_Exists()) {
Shaun Kelsey 5:e458409e913f 268 BLE_Icarus_AddtoQueue((uint8_t *)charbuf, (int32_t)sizeof(charbuf), data_len);
Shaun Kelsey 5:e458409e913f 269 }
Shaun Kelsey 5:e458409e913f 270 #endif
Shaun Kelsey 0:da5f5b56060a 271 }
Shaun Kelsey 0:da5f5b56060a 272
Shaun Kelsey 0:da5f5b56060a 273 void DSInterface::data_report_execute()
Shaun Kelsey 0:da5f5b56060a 274 {
Shaun Kelsey 0:da5f5b56060a 275 char buffer[256];
Shaun Kelsey 0:da5f5b56060a 276 int data_len = 0;
Shaun Kelsey 0:da5f5b56060a 277
Shaun Kelsey 0:da5f5b56060a 278 buffer[0] = '\0';
Shaun Kelsey 0:da5f5b56060a 279
Shaun Kelsey 0:da5f5b56060a 280 for (int i = 0; i < num_sensors; i++) {
Shaun Kelsey 0:da5f5b56060a 281 //if ((*it)->is_enabled()) {
Shaun Kelsey 0:da5f5b56060a 282 data_len = sensor_list[i]->data_report_execute(buffer, sizeof(buffer));
Shaun Kelsey 0:da5f5b56060a 283 if (!this->pause_mode && (data_len > 0)) {
Shaun Kelsey 5:e458409e913f 284 #ifdef ENABLE_BLE
Shaun Kelsey 5:e458409e913f 285 if (BLE_Icarus_Interface_Exists()) {
Shaun Kelsey 5:e458409e913f 286 BLE_Icarus_AddtoQueue((uint8_t *)buffer, (int32_t)sizeof(buffer), data_len);
Shaun Kelsey 5:e458409e913f 287 }
Shaun Kelsey 5:e458409e913f 288 #endif
Shaun Kelsey 5:e458409e913f 289 if (console_interface_exists){
Shaun Kelsey 0:da5f5b56060a 290 #ifdef ASCII_COMM
Shaun Kelsey 0:da5f5b56060a 291 m_USB->printf(buffer);
Shaun Kelsey 0:da5f5b56060a 292 #else
Shaun Kelsey 0:da5f5b56060a 293 m_USB->writeBlock((uint8_t*)buffer, data_len);
Shaun Kelsey 0:da5f5b56060a 294 #endif
Shaun Kelsey 0:da5f5b56060a 295 }
Shaun Kelsey 0:da5f5b56060a 296 data_len = 0;
Shaun Kelsey 0:da5f5b56060a 297 }
Shaun Kelsey 0:da5f5b56060a 298 //We only support streaming from one device at a time, so break here
Shaun Kelsey 0:da5f5b56060a 299 // break;
Shaun Kelsey 0:da5f5b56060a 300 //}
Shaun Kelsey 0:da5f5b56060a 301 }
Shaun Kelsey 0:da5f5b56060a 302 }
Shaun Kelsey 0:da5f5b56060a 303
Shaun Kelsey 0:da5f5b56060a 304 void DSInterface::set_fw_version(const char* version)
Shaun Kelsey 0:da5f5b56060a 305 {
Shaun Kelsey 0:da5f5b56060a 306 if (version && *version)
Shaun Kelsey 0:da5f5b56060a 307 firmware_version = version;
Shaun Kelsey 0:da5f5b56060a 308 }
Shaun Kelsey 0:da5f5b56060a 309
Shaun Kelsey 0:da5f5b56060a 310 void DSInterface::set_fw_platform(const char* platform)
Shaun Kelsey 0:da5f5b56060a 311 {
Shaun Kelsey 0:da5f5b56060a 312 if (platform && *platform)
Shaun Kelsey 0:da5f5b56060a 313 platform_name = platform;
Shaun Kelsey 0:da5f5b56060a 314 }