-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathble_spo2_monitor.sh
executable file
·83 lines (73 loc) · 1.94 KB
/
ble_spo2_monitor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
SPO2_LOW=89
SPO2_HIGH=99
HCI=hci0
HCI_ID=$(rfkill list | grep $HCI | cut -d: -f1)
# Enable HCI usage
rfkill unblock $HCI_ID
# Check if virtual environment is available to use
if [ -x ble_spo2/bin/activate ]; then
source ble_spo2/bin/activate
fi
# Check for MAC
if [ -z "$O2_BLE_MAC" ]; then
if [ -r ./my_o2.sh ]; then
source ./my_o2.sh
fi
if [ -z "$O2_BLE_MAC" ]; then
echo "Do export your SpO2 sensor MAC e.g. using"
echo "export O2_BLE_MAC=DA:1C:F9:12:34:56"
exit
fi
fi
# Check for language to use
if [ -z "$LANG" ]; then
LANG=$(locale | grep LANG=)
LANG=${LANG##*=}
fi
export SPEAK="espeak -v en"
export LANG_START=Start_monitoring
export LANG_STOP=Stop_monitoring
export LANG_HIGH=high_oxygen
export LANG_LOW=low_oxygen
export LANG_INACT=sensor_idle
export LANG_OFF=sensor_off
# Texts for different languages
case $LANG in
en*) ;;
de*)
SPEAK="espeak -v de"
export LANG_START=Überwachung_starten
export LANG_STOP=Überwachung_stop
export LANG_HIGH=viel_Sauerschtoff
export LANG_LOW=wenig_Sauerschtoff
export LANG_INACT=Sensor_nicht_aktiv
export LANG_OFF=Sensor_aus
;;
es*)
SPEAK="espeak -v es"
export LANG_START=comenzar_a_monitorear
export LANG_STOP=parada_de_monitorear
export LANG_HIGH=mucho_oxigeno
export LANG_LOW=poco_oxigeno
export LANG_INACT=sensor_inactivo
export LANG_OFF=sensor_apagado
;;
*)
echo "LANGUAGE $LA not supported (using english)"
;;
esac
# Let monitoring run in infinite loop
# to restart imediately if python throws an exception.
$SPEAK $LANG_START
CSV=./spo2_$(date +%d.%m.%y_%H:%M:%S).csv
./ble_spo2.py -L $CSV \
--o2_max $SPO2_HIGH --o2_high_action "$SPEAK $LANG_HIGH" \
--o2_min $SPO2_LOW --o2_low_action "$SPEAK $LANG_LOW" \
--sensor_idle_action "$SPEAK $LANG_INACT" \
--sensor_off_action "$SPEAK $LANG_OFF" \
$O2_BLE_MAC
echo "Exit $?"
$SPEAK $LANG_STOP
./plot_csv.sh $CSV
#EOF