software:firmware
MakAir Firmware
telemetry.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <stdint.h>
10 
11 #include "../includes/alarm_controller.h"
12 #include "../includes/config.h"
13 #include "../includes/cycle.h"
14 #ifndef SIMULATOR
15 #include "../includes/end_of_line_test.h"
16 #endif
17 
19 #define PROTOCOL_VERSION 2u
20 
22 void initTelemetry(void);
23 
25 void sendBootMessage(void);
26 
28 void sendStoppedMessage(uint8_t peakCommand,
29  uint8_t plateauCommand,
30  uint8_t peepCommand,
31  uint8_t cpmCommand,
32  uint8_t expiratoryTerm,
33  bool triggerEnabled,
34  uint8_t triggerOffset,
35  bool alarmSnoozed,
36  uint8_t cpuLoad,
37  VentilationModes ventilationMode,
38  uint8_t inspiratoryTriggerFlow,
39  uint8_t expiratoryTriggerFlow,
40  uint16_t tiMinValue,
41  uint16_t tiMaxValue,
42  uint8_t lowInspiratoryMinuteVolumeAlarmThreshold,
43  uint8_t highInspiratoryMinuteVolumeAlarmThreshold,
44  uint8_t lowExpiratoryMinuteVolumeAlarmThreshold,
45  uint8_t highExpiratoryMinuteVolumeAlarmThreshold,
46  uint8_t lowRespiratoryRateAlarmThreshold,
47  uint8_t highRespiratoryRateAlarmThreshold,
48  uint16_t targetTidalVolumeValue,
49  uint16_t lowTidalVolumeAlarmThresholdValue,
50  uint16_t highTidalVolumeAlarmThresholdValue,
51  uint16_t plateauDurationValue,
52  uint16_t leakAlarmThresholdValue,
53  uint8_t targetInspiratoryFlow,
54  uint16_t inspiratoryDurationCommandValue,
55  uint16_t batteryLevelValue,
56  uint8_t currentAlarmCodes[ALARMS_SIZE],
57  uint16_t localeValue,
58  uint8_t patientHeight,
59  uint8_t patientGender,
60  uint16_t peakPressureAlarmThresholdValue);
61 
63 void sendDataSnapshot(uint16_t centileValue,
64  int16_t pressureValue,
65  CyclePhases phase,
66  uint8_t blowerValvePosition,
67  uint8_t patientValvePosition,
68  uint8_t blowerRpm,
69  uint8_t batteryLevel,
70  int16_t inspiratoryFlowValue,
71  int16_t expiratoryFlowValue);
72 
74 // cppcheck-suppress misra-c2012-2.7
75 void sendMachineStateSnapshot(uint32_t cycleValue,
76  uint8_t peakCommand,
77  uint8_t plateauCommand,
78  uint8_t peepCommand,
79  uint8_t cpmCommand,
80  uint16_t previousPeakPressureValue,
81  uint16_t previousPlateauPressureValue,
82  uint16_t previousPeepPressureValue,
83  uint8_t currentAlarmCodes[ALARMS_SIZE],
84  uint16_t volumeValue,
85  uint8_t expiratoryTerm,
86  bool triggerEnabled,
87  uint8_t triggerOffset,
88  uint8_t previouscpmValue,
89  bool alarmSnoozed,
90  uint8_t cpuLoad,
91  VentilationModes ventilationMode,
92  uint8_t inspiratoryTriggerFlow,
93  uint8_t expiratoryTriggerFlow,
94  uint16_t tiMinValue,
95  uint16_t tiMaxValue,
96  uint8_t lowInspiratoryMinuteVolumeAlarmThreshold,
97  uint8_t highInspiratoryMinuteVolumeAlarmThreshold,
98  uint8_t lowExpiratoryMinuteVolumeAlarmThreshold,
99  uint8_t highExpiratoryMinuteVolumeAlarmThreshold,
100  uint8_t lowRespiratoryRateAlarmThreshold,
101  uint8_t highRespiratoryRateAlarmThreshold,
102  uint16_t targetTidalVolumeValue,
103  uint16_t lowTidalVolumeAlarmThresholdValue,
104  uint16_t highTidalVolumeAlarmThresholdValue,
105  uint16_t plateauDurationValue,
106  uint16_t leakAlarmThresholdValue,
107  uint8_t targetInspiratoryFlow,
108  uint16_t inspiratoryDurationCommandValue,
109  uint16_t previousInspiratoryDurationValue,
110  uint16_t batteryLevelValue,
111  uint16_t localeValue,
112  uint8_t patientHeight,
113  uint8_t patientGender,
114  uint16_t peakPressureAlarmThresholdValue);
115 
117 void sendAlarmTrap(uint16_t centileValue,
118  int16_t pressureValue,
119  CyclePhases phase,
120  uint32_t cycleValue,
121  uint8_t alarmCode,
122  AlarmPriority alarmPriority,
123  bool triggered,
124  uint32_t expectedValue,
125  uint32_t measuredValue,
126  uint32_t cyclesSinceTriggerValue);
127 
129 void sendControlAck(uint8_t setting, uint16_t value);
130 
133 
134 // /// Send a "calibration" fatal error
135 void sendCalibrationFatalError(int16_t pressureOffsetValue,
136  int16_t minPressureValue,
137  int16_t maxPressureValue,
138  int16_t flowAtStartingValue,
139  int16_t flowWithBlowerOnValue);
140 
142 void sendBatteryDeeplyDischargedFatalError(uint16_t batteryLevelValue);
143 
145 void sendMassFlowMeterFatalError(void);
146 
147 // /// Send a "inconsistent pressure" fatal error
149 
150 #ifndef SIMULATOR // Disable the following function when in simulator
152 void sendEolTestSnapshot(TestStep step, TestState state, char message[]);
153 
154 #endif
155 
162 uint8_t mmH2OtoCmH2O(uint16_t pressure);
AlarmPriority
Priority levels of an alarm.
Definition: alarm.h:18
#define ALARMS_SIZE
VentilationModes
Supported ventilation modes.
Definition: cycle.h:22
CyclePhases
Defines the 2 main phases of the respiratory cycle.
Definition: cycle.h:14
int32_t maxPressureValue
int32_t pressureValue
int32_t minPressureValue
void sendMassFlowMeterFatalError(void)
Send a "mass flow meter" fatal error.
Definition: telemetry.cpp:1321
void sendCalibrationFatalError(int16_t pressureOffsetValue, int16_t minPressureValue, int16_t maxPressureValue, int16_t flowAtStartingValue, int16_t flowWithBlowerOnValue)
Definition: telemetry.cpp:1193
void sendWatchdogRestartFatalError(void)
Send a "watchdog restart" fatal error.
Definition: telemetry.cpp:1155
void sendControlAck(uint8_t setting, uint16_t value)
Send a "control ack" message.
Definition: telemetry.cpp:1109
void sendInconsistentPressureFatalError(uint16_t pressureValue)
Definition: telemetry.cpp:1359
void sendBatteryDeeplyDischargedFatalError(uint16_t batteryLevelValue)
Send a "battery deeply discharged" fatal error.
Definition: telemetry.cpp:1275
uint8_t mmH2OtoCmH2O(uint16_t pressure)
Convert and round a pressure in mmH2O to a pressure in cmH2O.
Definition: telemetry.cpp:1459
void initTelemetry(void)
Prepare Serial6 to send telemetry data.
Definition: telemetry.cpp:109
void sendAlarmTrap(uint16_t centileValue, int16_t pressureValue, CyclePhases phase, uint32_t cycleValue, uint8_t alarmCode, AlarmPriority alarmPriority, bool triggered, uint32_t expectedValue, uint32_t measuredValue, uint32_t cyclesSinceTriggerValue)
Send a "alarm trap" message.
Definition: telemetry.cpp:969
void sendStoppedMessage(uint8_t peakCommand, uint8_t plateauCommand, uint8_t peepCommand, uint8_t cpmCommand, uint8_t expiratoryTerm, bool triggerEnabled, uint8_t triggerOffset, bool alarmSnoozed, uint8_t cpuLoad, VentilationModes ventilationMode, uint8_t inspiratoryTriggerFlow, uint8_t expiratoryTriggerFlow, uint16_t tiMinValue, uint16_t tiMaxValue, uint8_t lowInspiratoryMinuteVolumeAlarmThreshold, uint8_t highInspiratoryMinuteVolumeAlarmThreshold, uint8_t lowExpiratoryMinuteVolumeAlarmThreshold, uint8_t highExpiratoryMinuteVolumeAlarmThreshold, uint8_t lowRespiratoryRateAlarmThreshold, uint8_t highRespiratoryRateAlarmThreshold, uint16_t targetTidalVolumeValue, uint16_t lowTidalVolumeAlarmThresholdValue, uint16_t highTidalVolumeAlarmThresholdValue, uint16_t plateauDurationValue, uint16_t leakAlarmThresholdValue, uint8_t targetInspiratoryFlow, uint16_t inspiratoryDurationCommandValue, uint16_t batteryLevelValue, uint8_t currentAlarmCodes[ALARMS_SIZE], uint16_t localeValue, uint8_t patientHeight, uint8_t patientGender, uint16_t peakPressureAlarmThresholdValue)
Send a "stopped" message.
Definition: telemetry.cpp:164
void sendBootMessage(void)
Send a "boot" message.
Definition: telemetry.cpp:114
void sendDataSnapshot(uint16_t centileValue, int16_t pressureValue, CyclePhases phase, uint8_t blowerValvePosition, uint8_t patientValvePosition, uint8_t blowerRpm, uint8_t batteryLevel, int16_t inspiratoryFlowValue, int16_t expiratoryFlowValue)
Send a "data snapshot" message.
Definition: telemetry.cpp:481
void sendMachineStateSnapshot(uint32_t cycleValue, uint8_t peakCommand, uint8_t plateauCommand, uint8_t peepCommand, uint8_t cpmCommand, uint16_t previousPeakPressureValue, uint16_t previousPlateauPressureValue, uint16_t previousPeepPressureValue, uint8_t currentAlarmCodes[ALARMS_SIZE], uint16_t volumeValue, uint8_t expiratoryTerm, bool triggerEnabled, uint8_t triggerOffset, uint8_t previouscpmValue, bool alarmSnoozed, uint8_t cpuLoad, VentilationModes ventilationMode, uint8_t inspiratoryTriggerFlow, uint8_t expiratoryTriggerFlow, uint16_t tiMinValue, uint16_t tiMaxValue, uint8_t lowInspiratoryMinuteVolumeAlarmThreshold, uint8_t highInspiratoryMinuteVolumeAlarmThreshold, uint8_t lowExpiratoryMinuteVolumeAlarmThreshold, uint8_t highExpiratoryMinuteVolumeAlarmThreshold, uint8_t lowRespiratoryRateAlarmThreshold, uint8_t highRespiratoryRateAlarmThreshold, uint16_t targetTidalVolumeValue, uint16_t lowTidalVolumeAlarmThresholdValue, uint16_t highTidalVolumeAlarmThresholdValue, uint16_t plateauDurationValue, uint16_t leakAlarmThresholdValue, uint8_t targetInspiratoryFlow, uint16_t inspiratoryDurationCommandValue, uint16_t previousInspiratoryDurationValue, uint16_t batteryLevelValue, uint16_t localeValue, uint8_t patientHeight, uint8_t patientGender, uint16_t peakPressureAlarmThresholdValue)
Send a "machine state snapshot" message.
Definition: telemetry.cpp:592