13 #include "../includes/telemetry.h"
18 #include "LL/stm32yyxx_ll_utils.h"
21 #include "../includes/main_controller.h"
28 #define FIRST_BYTE (uint8_t)0xFF
106 return (
static_cast<uint64_t
>(millis()) * 1000u) + (micros() % 1000u);
115 uint8_t value128 = 128u;
120 crc32.update(
"B:", 2);
125 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
133 crc32.update(
"\t", 1);
139 crc32.update(systick, 8);
143 crc32.update(
"\t", 1);
146 crc32.update(
static_cast<uint8_t
>(
MODE));
150 crc32.update(
"\t", 1);
153 crc32.update(value128);
156 crc32.update(
"\n", 1);
165 uint8_t plateauCommand,
168 uint8_t expiratoryTerm,
170 uint8_t triggerOffset,
174 uint8_t inspiratoryTriggerFlow,
175 uint8_t expiratoryTriggerFlow,
178 uint8_t lowInspiratoryMinuteVolumeAlarmThreshold,
179 uint8_t highInspiratoryMinuteVolumeAlarmThreshold,
180 uint8_t lowExpiratoryMinuteVolumeAlarmThreshold,
181 uint8_t highExpiratoryMinuteVolumeAlarmThreshold,
182 uint8_t lowRespiratoryRateAlarmThreshold,
183 uint8_t highRespiratoryRateAlarmThreshold,
184 uint16_t targetTidalVolumeValue,
185 uint16_t lowTidalVolumeAlarmThresholdValue,
186 uint16_t highTidalVolumeAlarmThresholdValue,
187 uint16_t plateauDurationValue,
188 uint16_t leakAlarmThresholdValue,
189 uint8_t targetInspiratoryFlow,
190 uint16_t inspiratoryDurationCommandValue,
191 uint16_t batteryLevelValue,
193 uint16_t localeValue,
194 uint8_t patientHeight,
195 uint8_t patientGender,
196 uint16_t peakPressureAlarmThresholdValue) {
197 uint8_t currentAlarmSize = 0;
199 if (currentAlarmCodes[
i] != 0u) {
206 uint8_t ventilationModeValue;
207 switch (ventilationMode) {
209 ventilationModeValue = 1u;
212 ventilationModeValue = 2u;
215 ventilationModeValue = 3u;
218 ventilationModeValue = 4u;
221 ventilationModeValue = 5u;
224 ventilationModeValue = 0u;
231 crc32.update(
"O:", 2);
236 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
243 crc32.update(
"\t", 1);
248 crc32.update(systick, 8);
251 crc32.update(
"\t", 1);
254 crc32.update(peakCommand);
257 crc32.update(
"\t", 1);
260 crc32.update(plateauCommand);
263 crc32.update(
"\t", 1);
266 crc32.update(peepCommand);
269 crc32.update(
"\t", 1);
272 crc32.update(cpmCommand);
275 crc32.update(
"\t", 1);
278 crc32.update(expiratoryTerm);
281 crc32.update(
"\t", 1);
284 crc32.update(triggerEnabled);
287 crc32.update(
"\t", 1);
290 crc32.update(triggerOffset);
293 crc32.update(
"\t", 1);
296 crc32.update(alarmSnoozed);
299 crc32.update(
"\t", 1);
302 crc32.update(cpuLoad);
305 crc32.update(
"\t", 1);
307 Serial6.write(ventilationModeValue);
308 crc32.update(ventilationModeValue);
311 crc32.update(
"\t", 1);
313 Serial6.write(inspiratoryTriggerFlow);
314 crc32.update(inspiratoryTriggerFlow);
317 crc32.update(
"\t", 1);
319 Serial6.write(expiratoryTriggerFlow);
320 crc32.update(expiratoryTriggerFlow);
323 crc32.update(
"\t", 1);
328 crc32.update(tiMin, 2);
331 crc32.update(
"\t", 1);
336 crc32.update(tiMax, 2);
339 crc32.update(
"\t", 1);
341 Serial6.write(lowInspiratoryMinuteVolumeAlarmThreshold);
342 crc32.update(lowInspiratoryMinuteVolumeAlarmThreshold);
345 crc32.update(
"\t", 1);
347 Serial6.write(highInspiratoryMinuteVolumeAlarmThreshold);
348 crc32.update(highInspiratoryMinuteVolumeAlarmThreshold);
351 crc32.update(
"\t", 1);
353 Serial6.write(lowExpiratoryMinuteVolumeAlarmThreshold);
354 crc32.update(lowExpiratoryMinuteVolumeAlarmThreshold);
357 crc32.update(
"\t", 1);
359 Serial6.write(highExpiratoryMinuteVolumeAlarmThreshold);
360 crc32.update(highExpiratoryMinuteVolumeAlarmThreshold);
363 crc32.update(
"\t", 1);
365 Serial6.write(lowRespiratoryRateAlarmThreshold);
366 crc32.update(lowRespiratoryRateAlarmThreshold);
369 crc32.update(
"\t", 1);
371 Serial6.write(highRespiratoryRateAlarmThreshold);
372 crc32.update(highRespiratoryRateAlarmThreshold);
375 crc32.update(
"\t", 1);
377 byte targetTidalVolume[2];
378 toBytes16(targetTidalVolume, targetTidalVolumeValue);
379 Serial6.write(targetTidalVolume, 2);
380 crc32.update(targetTidalVolume, 2);
383 crc32.update(
"\t", 1);
385 byte lowTidalVolumeAlarmThreshold[2];
386 toBytes16(lowTidalVolumeAlarmThreshold, lowTidalVolumeAlarmThresholdValue);
387 Serial6.write(lowTidalVolumeAlarmThreshold, 2);
388 crc32.update(lowTidalVolumeAlarmThreshold, 2);
391 crc32.update(
"\t", 1);
393 byte highTidalVolumeAlarmThreshold[2];
394 toBytes16(highTidalVolumeAlarmThreshold, highTidalVolumeAlarmThresholdValue);
395 Serial6.write(highTidalVolumeAlarmThreshold, 2);
396 crc32.update(highTidalVolumeAlarmThreshold, 2);
399 crc32.update(
"\t", 1);
401 byte plateauDuration[2];
402 toBytes16(plateauDuration, plateauDurationValue);
403 Serial6.write(plateauDuration, 2);
404 crc32.update(plateauDuration, 2);
407 crc32.update(
"\t", 1);
409 byte leakAlarmThreshold[2];
410 toBytes16(leakAlarmThreshold, leakAlarmThresholdValue);
411 Serial6.write(leakAlarmThreshold, 2);
412 crc32.update(leakAlarmThreshold, 2);
415 crc32.update(
"\t", 1);
417 Serial6.write(targetInspiratoryFlow);
418 crc32.update(targetInspiratoryFlow);
421 crc32.update(
"\t", 1);
423 byte inspiratoryDurationCommand[2];
424 toBytes16(inspiratoryDurationCommand, inspiratoryDurationCommandValue);
425 Serial6.write(inspiratoryDurationCommand, 2);
426 crc32.update(inspiratoryDurationCommand, 2);
429 crc32.update(
"\t", 1);
431 byte batteryLevel[2];
432 toBytes16(batteryLevel, batteryLevelValue);
433 Serial6.write(batteryLevel, 2);
434 crc32.update(batteryLevel, 2);
437 crc32.update(
"\t", 1);
439 Serial6.write(currentAlarmSize);
440 crc32.update(currentAlarmSize);
441 Serial6.write(currentAlarmCodes, currentAlarmSize);
442 crc32.update(currentAlarmCodes, currentAlarmSize);
445 crc32.update(
"\t", 1);
450 crc32.update(locale, 2);
453 crc32.update(
"\t", 1);
456 crc32.update(patientHeight);
459 crc32.update(
"\t", 1);
462 crc32.update(patientGender);
465 crc32.update(
"\t", 1);
467 byte peakPressureAlarmThreshold[2];
468 toBytes16(peakPressureAlarmThreshold, peakPressureAlarmThresholdValue);
469 Serial6.write(peakPressureAlarmThreshold, 2);
470 crc32.update(peakPressureAlarmThreshold, 2);
473 crc32.update(
"\n", 1);
484 uint8_t blowerValvePosition,
485 uint8_t patientValvePosition,
487 uint8_t batteryLevel,
488 int16_t inspiratoryFlowValue,
489 int16_t expiratoryFlowValue) {
502 crc32.update(
"D:", 2);
507 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
514 crc32.update(
"\t", 1);
519 crc32.update(systick, 8);
522 crc32.update(
"\t", 1);
527 crc32.update(centile, 2);
530 crc32.update(
"\t", 1);
535 crc32.update(pressure, 2);
538 crc32.update(
"\t", 1);
541 crc32.update(phaseValue);
544 crc32.update(
"\t", 1);
546 Serial6.write(blowerValvePosition);
547 crc32.update(blowerValvePosition);
550 crc32.update(
"\t", 1);
552 Serial6.write(patientValvePosition);
553 crc32.update(patientValvePosition);
556 crc32.update(
"\t", 1);
559 crc32.update(blowerRpm);
562 crc32.update(
"\t", 1);
565 crc32.update(batteryLevel);
568 crc32.update(
"\t", 1);
570 byte inspiratoryFlow[2];
571 toBytes16(inspiratoryFlow, inspiratoryFlowValue);
572 Serial6.write(inspiratoryFlow, 2);
573 crc32.update(inspiratoryFlow, 2);
576 crc32.update(
"\t", 1);
578 byte expiratoryFlow[2];
579 toBytes16(expiratoryFlow, expiratoryFlowValue);
580 Serial6.write(expiratoryFlow, 2);
581 crc32.update(expiratoryFlow, 2);
584 crc32.update(
"\n", 1);
594 uint8_t plateauCommand,
597 uint16_t previousPeakPressureValue,
598 uint16_t previousPlateauPressureValue,
599 uint16_t previousPeepPressureValue,
601 uint16_t volumeValue,
602 uint8_t expiratoryTerm,
604 uint8_t triggerOffset,
605 uint8_t previouscpmValue,
609 uint8_t inspiratoryTriggerFlow,
610 uint8_t expiratoryTriggerFlow,
613 uint8_t lowInspiratoryMinuteVolumeAlarmThreshold,
614 uint8_t highInspiratoryMinuteVolumeAlarmThreshold,
615 uint8_t lowExpiratoryMinuteVolumeAlarmThreshold,
616 uint8_t highExpiratoryMinuteVolumeAlarmThreshold,
617 uint8_t lowRespiratoryRateAlarmThreshold,
618 uint8_t highRespiratoryRateAlarmThreshold,
619 uint16_t targetTidalVolumeValue,
620 uint16_t lowTidalVolumeAlarmThresholdValue,
621 uint16_t highTidalVolumeAlarmThresholdValue,
622 uint16_t plateauDurationValue,
623 uint16_t leakAlarmThresholdValue,
624 uint8_t targetInspiratoryFlow,
625 uint16_t inspiratoryDurationCommandValue,
626 uint16_t previousInspiratoryDurationValue,
627 uint16_t batteryLevelValue,
628 uint16_t localeValue,
629 uint8_t patientHeight,
630 uint8_t patientGender,
631 uint16_t peakPressureAlarmThresholdValue) {
632 uint8_t currentAlarmSize = 0;
634 if (currentAlarmCodes[
i] != 0u) {
641 uint8_t ventilationModeValue;
642 switch (ventilationMode) {
644 ventilationModeValue = 1u;
647 ventilationModeValue = 2u;
650 ventilationModeValue = 3u;
653 ventilationModeValue = 4u;
656 ventilationModeValue = 5u;
659 ventilationModeValue = 0u;
665 crc32.update(
"S:", 2);
670 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
677 crc32.update(
"\t", 1);
682 crc32.update(systick, 8);
685 crc32.update(
"\t", 1);
690 crc32.update(cycle, 4);
693 crc32.update(
"\t", 1);
696 crc32.update(peakCommand);
699 crc32.update(
"\t", 1);
702 crc32.update(plateauCommand);
705 crc32.update(
"\t", 1);
708 crc32.update(peepCommand);
711 crc32.update(
"\t", 1);
714 crc32.update(cpmCommand);
717 crc32.update(
"\t", 1);
719 byte previousPeakPressure[2];
720 toBytes16(previousPeakPressure, previousPeakPressureValue);
721 Serial6.write(previousPeakPressure, 2);
722 crc32.update(previousPeakPressure, 2);
725 crc32.update(
"\t", 1);
727 byte previousPlateauPressure[2];
728 toBytes16(previousPlateauPressure, previousPlateauPressureValue);
729 Serial6.write(previousPlateauPressure, 2);
730 crc32.update(previousPlateauPressure, 2);
733 crc32.update(
"\t", 1);
735 byte previousPeepPressure[2];
736 toBytes16(previousPeepPressure, previousPeepPressureValue);
737 Serial6.write(previousPeepPressure, 2);
738 crc32.update(previousPeepPressure, 2);
741 crc32.update(
"\t", 1);
743 Serial6.write(currentAlarmSize);
744 crc32.update(currentAlarmSize);
745 Serial6.write(currentAlarmCodes, currentAlarmSize);
746 crc32.update(currentAlarmCodes, currentAlarmSize);
749 crc32.update(
"\t", 1);
754 crc32.update(volume, 2);
757 crc32.update(
"\t", 1);
760 crc32.update(expiratoryTerm);
763 crc32.update(
"\t", 1);
766 crc32.update(triggerEnabled);
769 crc32.update(
"\t", 1);
772 crc32.update(triggerOffset);
775 crc32.update(
"\t", 1);
777 Serial6.write(previouscpmValue);
778 crc32.update(previouscpmValue);
781 crc32.update(
"\t", 1);
784 crc32.update(alarmSnoozed);
787 crc32.update(
"\t", 1);
790 crc32.update(cpuLoad);
793 crc32.update(
"\t", 1);
795 Serial6.write(ventilationModeValue);
796 crc32.update(ventilationModeValue);
799 crc32.update(
"\t", 1);
801 Serial6.write(inspiratoryTriggerFlow);
802 crc32.update(inspiratoryTriggerFlow);
805 crc32.update(
"\t", 1);
807 Serial6.write(expiratoryTriggerFlow);
808 crc32.update(expiratoryTriggerFlow);
811 crc32.update(
"\t", 1);
816 crc32.update(tiMin, 2);
819 crc32.update(
"\t", 1);
824 crc32.update(tiMax, 2);
827 crc32.update(
"\t", 1);
829 Serial6.write(lowInspiratoryMinuteVolumeAlarmThreshold);
830 crc32.update(lowInspiratoryMinuteVolumeAlarmThreshold);
833 crc32.update(
"\t", 1);
835 Serial6.write(highInspiratoryMinuteVolumeAlarmThreshold);
836 crc32.update(highInspiratoryMinuteVolumeAlarmThreshold);
839 crc32.update(
"\t", 1);
841 Serial6.write(lowExpiratoryMinuteVolumeAlarmThreshold);
842 crc32.update(lowExpiratoryMinuteVolumeAlarmThreshold);
845 crc32.update(
"\t", 1);
847 Serial6.write(highExpiratoryMinuteVolumeAlarmThreshold);
848 crc32.update(highExpiratoryMinuteVolumeAlarmThreshold);
851 crc32.update(
"\t", 1);
853 Serial6.write(lowRespiratoryRateAlarmThreshold);
854 crc32.update(lowRespiratoryRateAlarmThreshold);
857 crc32.update(
"\t", 1);
859 Serial6.write(highRespiratoryRateAlarmThreshold);
860 crc32.update(highRespiratoryRateAlarmThreshold);
863 crc32.update(
"\t", 1);
865 byte targetTidalVolume[2];
866 toBytes16(targetTidalVolume, targetTidalVolumeValue);
867 Serial6.write(targetTidalVolume, 2);
868 crc32.update(targetTidalVolume, 2);
871 crc32.update(
"\t", 1);
873 byte lowTidalVolumeAlarmThreshold[2];
874 toBytes16(lowTidalVolumeAlarmThreshold, lowTidalVolumeAlarmThresholdValue);
875 Serial6.write(lowTidalVolumeAlarmThreshold, 2);
876 crc32.update(lowTidalVolumeAlarmThreshold, 2);
879 crc32.update(
"\t", 1);
881 byte highTidalVolumeAlarmThreshold[2];
882 toBytes16(highTidalVolumeAlarmThreshold, highTidalVolumeAlarmThresholdValue);
883 Serial6.write(highTidalVolumeAlarmThreshold, 2);
884 crc32.update(highTidalVolumeAlarmThreshold, 2);
887 crc32.update(
"\t", 1);
889 byte plateauDuration[2];
890 toBytes16(plateauDuration, plateauDurationValue);
891 Serial6.write(plateauDuration, 2);
892 crc32.update(plateauDuration, 2);
895 crc32.update(
"\t", 1);
897 byte leakAlarmThreshold[2];
898 toBytes16(leakAlarmThreshold, leakAlarmThresholdValue);
899 Serial6.write(leakAlarmThreshold, 2);
900 crc32.update(leakAlarmThreshold, 2);
903 crc32.update(
"\t", 1);
905 Serial6.write(targetInspiratoryFlow);
906 crc32.update(targetInspiratoryFlow);
909 crc32.update(
"\t", 1);
911 byte inspiratoryDurationCommand[2];
912 toBytes16(inspiratoryDurationCommand, inspiratoryDurationCommandValue);
913 Serial6.write(inspiratoryDurationCommand, 2);
914 crc32.update(inspiratoryDurationCommand, 2);
917 crc32.update(
"\t", 1);
919 byte previousInspiratoryDuration[2];
920 toBytes16(previousInspiratoryDuration, previousInspiratoryDurationValue);
921 Serial6.write(previousInspiratoryDuration, 2);
922 crc32.update(previousInspiratoryDuration, 2);
925 crc32.update(
"\t", 1);
927 byte batteryLevel[2];
928 toBytes16(batteryLevel, batteryLevelValue);
929 Serial6.write(batteryLevel, 2);
930 crc32.update(batteryLevel, 2);
933 crc32.update(
"\t", 1);
938 crc32.update(locale, 2);
941 crc32.update(
"\t", 1);
944 crc32.update(patientHeight);
947 crc32.update(
"\t", 1);
950 crc32.update(patientGender);
953 crc32.update(
"\t", 1);
955 byte peakPressureAlarmThreshold[2];
956 toBytes16(peakPressureAlarmThreshold, peakPressureAlarmThresholdValue);
957 Serial6.write(peakPressureAlarmThreshold, 2);
958 crc32.update(peakPressureAlarmThreshold, 2);
961 crc32.update(
"\n", 1);
976 uint32_t expectedValue,
977 uint32_t measuredValue,
978 uint32_t cyclesSinceTriggerValue) {
988 uint8_t triggeredValue;
990 triggeredValue = 240u;
992 triggeredValue = 15u;
995 uint8_t alarmPriorityValue;
997 alarmPriorityValue = 4u;
999 alarmPriorityValue = 2u;
1001 alarmPriorityValue = 1u;
1003 alarmPriorityValue = 0u;
1009 crc32.update(
"T:", 2);
1014 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1021 crc32.update(
"\t", 1);
1026 crc32.update(systick, 8);
1029 crc32.update(
"\t", 1);
1034 crc32.update(centile, 2);
1037 crc32.update(
"\t", 1);
1042 crc32.update(pressure, 2);
1045 crc32.update(
"\t", 1);
1048 crc32.update(phaseValue);
1051 crc32.update(
"\t", 1);
1056 crc32.update(cycle, 4);
1059 crc32.update(
"\t", 1);
1062 crc32.update(alarmCode);
1065 crc32.update(
"\t", 1);
1067 Serial6.write(alarmPriorityValue);
1068 crc32.update(alarmPriorityValue);
1071 crc32.update(
"\t", 1);
1073 Serial6.write(triggeredValue);
1074 crc32.update(triggeredValue);
1077 crc32.update(
"\t", 1);
1082 crc32.update(expected, 4);
1085 crc32.update(
"\t", 1);
1090 crc32.update(measured, 4);
1093 crc32.update(
"\t", 1);
1095 byte cyclesSinceTrigger[4];
1096 toBytes32(cyclesSinceTrigger, cyclesSinceTriggerValue);
1097 Serial6.write(cyclesSinceTrigger, 4);
1098 crc32.update(cyclesSinceTrigger, 4);
1101 crc32.update(
"\n", 1);
1113 crc32.update(
"A:", 2);
1118 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1125 crc32.update(
"\t", 1);
1130 crc32.update(systick, 8);
1133 crc32.update(
"\t", 1);
1136 crc32.update(setting);
1139 crc32.update(
"\t", 1);
1144 crc32.update(value, 2);
1147 crc32.update(
"\n", 1);
1159 crc32.update(
"E:", 2);
1164 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1171 crc32.update(
"\t", 1);
1176 crc32.update(systick, 8);
1179 crc32.update(
"\t", 1);
1182 crc32.update((uint8_t)1);
1185 crc32.update(
"\n", 1);
1196 int16_t flowAtStartingValue,
1197 int16_t flowWithBlowerOnValue) {
1201 crc32.update(
"E:", 2);
1206 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1213 crc32.update(
"\t", 1);
1218 crc32.update(systick, 8);
1221 crc32.update(
"\t", 1);
1224 crc32.update((uint8_t)2);
1227 crc32.update(
"\t", 1);
1229 byte pressureOffset[2];
1230 toBytes16(pressureOffset, pressureOffsetValue);
1231 Serial6.write(pressureOffset, 2);
1232 crc32.update(pressureOffset, 2);
1235 crc32.update(
"\t", 1);
1237 byte minPressure[2];
1239 Serial6.write(minPressure, 2);
1240 crc32.update(minPressure, 2);
1243 crc32.update(
"\t", 1);
1245 byte maxPressure[2];
1247 Serial6.write(maxPressure, 2);
1248 crc32.update(maxPressure, 2);
1251 crc32.update(
"\t", 1);
1253 byte flowAtStarting[2];
1254 toBytes16(flowAtStarting, flowAtStartingValue);
1255 Serial6.write(flowAtStarting, 2);
1256 crc32.update(flowAtStarting, 2);
1259 crc32.update(
"\t", 1);
1261 byte flowWithBlowerOn[2];
1262 toBytes16(flowWithBlowerOn, flowWithBlowerOnValue);
1263 Serial6.write(flowWithBlowerOn, 2);
1264 crc32.update(flowWithBlowerOn, 2);
1267 crc32.update(
"\n", 1);
1279 crc32.update(
"E:", 2);
1284 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1291 crc32.update(
"\t", 1);
1296 crc32.update(systick, 8);
1299 crc32.update(
"\t", 1);
1302 crc32.update((uint8_t)3);
1305 crc32.update(
"\t", 1);
1307 byte batteryLevel[2];
1308 toBytes16(batteryLevel, batteryLevelValue);
1309 Serial6.write(batteryLevel, 2);
1310 crc32.update(batteryLevel, 2);
1313 crc32.update(
"\n", 1);
1325 crc32.update(
"E:", 2);
1330 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1337 crc32.update(
"\t", 1);
1342 crc32.update(systick, 8);
1345 crc32.update(
"\t", 1);
1348 crc32.update((uint8_t)4);
1351 crc32.update(
"\n", 1);
1363 crc32.update(
"E:", 2);
1368 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1375 crc32.update(
"\t", 1);
1380 crc32.update(systick, 8);
1383 crc32.update(
"\t", 1);
1386 crc32.update((uint8_t)5);
1389 crc32.update(
"\t", 1);
1394 crc32.update(pressure, 2);
1397 crc32.update(
"\n", 1);
1410 crc32.update(
"L:", 2);
1415 crc32.update(
static_cast<uint8_t
>(strlen(
VERSION)));
1422 crc32.update(
"\t", 1);
1427 crc32.update(systick, 8);
1430 crc32.update(
"\t", 1);
1436 crc32.update(
"\t", 1);
1439 crc32.update(state);
1442 crc32.update(
"\t", 1);
1444 Serial6.write(
static_cast<uint8_t
>(strlen(message)));
1445 crc32.update(
static_cast<uint8_t
>(strlen(message)));
1447 crc32.update(message, strlen(message));
1450 crc32.update(
"\n", 1);
1461 uint16_t lastDigit = pressure % 10u;
1463 if (lastDigit < 5u) {
1464 result = (pressure / 10u);
1466 result = (pressure / 10u) + 1u;
AlarmPriority
Priority levels of an alarm.
#define MODE
Defines the current mode.
VentilationModes
Supported ventilation modes.
CyclePhases
Defines the 2 main phases of the respiratory cycle.
@ EXHALATION
Exhalation and pause.
@ INHALATION
Inspiration and inspiration holding.
#define VERSION
Current version of the software.
HardwareSerial Serial6(PIN_TELEMETRY_SERIAL_RX, PIN_TELEMETRY_SERIAL_TX)
void sendMassFlowMeterFatalError(void)
Send a "mass flow meter" fatal error.
void sendCalibrationFatalError(int16_t pressureOffsetValue, int16_t minPressureValue, int16_t maxPressureValue, int16_t flowAtStartingValue, int16_t flowWithBlowerOnValue)
void sendWatchdogRestartFatalError(void)
Send a "watchdog restart" fatal error.
static const uint8_t header[HEADER_SIZE]
static const uint8_t footer[FOOTER_SIZE]
void sendInconsistentPressureFatalError(uint16_t pressureValue)
void sendControlAck(uint8_t setting, uint16_t valueValue)
Send a "control ack" message.
uint64_t computeSystick(void)
Compute current systick.
void sendBootMessage()
Send a "boot" message.
void toBytes16(byte bytes[], uint16_t data)
Convert a u16 so that it can be sent through serial.
void sendBatteryDeeplyDischargedFatalError(uint16_t batteryLevelValue)
Send a "battery deeply discharged" fatal error.
void sendEolTestSnapshot(TestStep step, TestState state, char message[])
Send an "end-of-line test" snapshot.
uint8_t mmH2OtoCmH2O(uint16_t pressure)
Convert and round a pressure in mmH2O to a pressure in cmH2O.
void initTelemetry(void)
Prepare Serial6 to send telemetry data.
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.
void computeDeviceId(void)
Compute device ID.
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.
void toBytes32(byte bytes[], uint32_t data)
Convert a u32 so that it can be sent through serial.
static byte deviceId[12]
Internals.
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.
void toBytes64(byte bytes[], uint64_t data)
Convert a u64 so that it can be sent through serial.
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.
#define PROTOCOL_VERSION
Current version of the telemetry protocol.