updates
This commit is contained in:
parent
c3b6952017
commit
8acb6bfaf1
43
Install.sh
43
Install.sh
@ -1,13 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Install Python3 and pip
|
|
||||||
|
|
||||||
|
# Install and enable SSH
|
||||||
|
install_ssh() {
|
||||||
|
echo "Installing SSH..."
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y openssh-server
|
||||||
|
sudo systemctl start ssh
|
||||||
|
sudo systemctl enable ssh
|
||||||
|
echo "SSH installed and enabled."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install and enable ProFTPD
|
||||||
|
install_ftp() {
|
||||||
|
echo "Installing ProFTPD..."
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y proftpd
|
||||||
|
sudo systemctl start proftpd
|
||||||
|
sudo systemctl enable proftpd
|
||||||
|
echo "ProFTPD installed and enabled."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Install Python3 and modules
|
||||||
|
install_python(){
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y python3 python3-pip python3-flask python3-schedule python3-plotly python3-pandas
|
sudo apt install -y python3 python3-pip python3-flask python3-schedule python3-plotly python3-pandas
|
||||||
|
|
||||||
# Install required Python modules
|
|
||||||
pip3 install bluepy --break-system-packages
|
pip3 install bluepy --break-system-packages
|
||||||
|
}
|
||||||
# Create env.py file
|
# Create env.py file and add values
|
||||||
|
env_py() {
|
||||||
echo -n "Enter database file name (default: data.db): "
|
echo -n "Enter database file name (default: data.db): "
|
||||||
read db_file
|
read db_file
|
||||||
db_file=${db_file:-data.db}
|
db_file=${db_file:-data.db}
|
||||||
@ -49,8 +72,18 @@ temp_max=${temp_max:-30}
|
|||||||
echo -e "MAX_TEMP= $temp_max" >> Program/env.py
|
echo -e "MAX_TEMP= $temp_max" >> Program/env.py
|
||||||
|
|
||||||
echo -e "SENSORS = {'d6:c6:c7:39:a2:e8': 'DEMO3', 'd6:1c:bf:b7:76:62': 'DEMO1', 'd7:ef:13:27:15:29': 'DEMO2'}" >> Program/env.py
|
echo -e "SENSORS = {'d6:c6:c7:39:a2:e8': 'DEMO3', 'd6:1c:bf:b7:76:62': 'DEMO1', 'd7:ef:13:27:15:29': 'DEMO2'}" >> Program/env.py
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Execute main.py
|
# Execute main.py
|
||||||
|
exec(){
|
||||||
cd Program
|
cd Program
|
||||||
python3 main.py
|
python3 main.py
|
||||||
|
}
|
||||||
|
|
||||||
|
install_ssh
|
||||||
|
install_ssh
|
||||||
|
install_python
|
||||||
|
env_py
|
||||||
|
exec
|
||||||
|
|||||||
@ -58,17 +58,14 @@ def dashboard():
|
|||||||
def history():
|
def history():
|
||||||
data = fetch_all_sensor()
|
data = fetch_all_sensor()
|
||||||
disp_data = []
|
disp_data = []
|
||||||
|
sensors_name = []
|
||||||
for mac, name in data:
|
for mac, name in data:
|
||||||
disp_data += [fetch_data_by_sensor(name)]
|
disp_data += [fetch_data_by_sensor(name)]
|
||||||
|
sensors_name.append[name]
|
||||||
|
|
||||||
|
|
||||||
""" S1 = fetch_data_by_sensor("DEMO1")
|
|
||||||
S2 = fetch_data_by_sensor("DEMO2")
|
|
||||||
S3 = fetch_data_by_sensor("DEMO3") """
|
|
||||||
|
|
||||||
|
return render_template('history.html', S1=disp_data[0], S2=disp_data[1], S3=disp_data[2], sensor=sensors_name)
|
||||||
return render_template('history.html', S1=disp_data[0], S2=disp_data[1], S3=disp_data[2])
|
|
||||||
|
|
||||||
@app.route('/adm', methods=['GET'])
|
@app.route('/adm', methods=['GET'])
|
||||||
def admin():
|
def admin():
|
||||||
|
|||||||
@ -13,13 +13,14 @@ def BltDataScrap():
|
|||||||
#print("Begin device scan")
|
#print("Begin device scan")
|
||||||
devices = scanner.scan(timeout=3.0)
|
devices = scanner.scan(timeout=3.0)
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if device.addr in SENSORS :
|
if device.addr in sensor_dict :
|
||||||
#print(
|
#print(
|
||||||
#f"Device found {device.addr} ({device.addrType}), "
|
#f"Device found {device.addr} ({device.addrType}), "
|
||||||
#f"RSSI={device.rssi} dB"
|
#f"RSSI={device.rssi} dB"
|
||||||
#)
|
#)
|
||||||
for adtype, description, value in device.getScanData():
|
for adtype, description, value in device.getScanData():
|
||||||
if adtype == 22:
|
if adtype == 22:
|
||||||
|
#print(value)
|
||||||
temp = int(value[24:28], 16) / 100
|
temp = int(value[24:28], 16) / 100
|
||||||
HR = int(value[28:32], 16) / 100
|
HR = int(value[28:32], 16) / 100
|
||||||
Bat = int(value[20:22], 16)
|
Bat = int(value[20:22], 16)
|
||||||
|
|||||||
@ -60,7 +60,7 @@ tr:hover {
|
|||||||
<a href="/adm" class="btn">Admin</a>
|
<a href="/adm" class="btn">Admin</a>
|
||||||
</div>
|
</div>
|
||||||
<h1>Database Contents</h1>
|
<h1>Database Contents</h1>
|
||||||
<h2>Sensor 1</h2>
|
<h2>{{ sensor[0] }}</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
@ -81,7 +81,7 @@ tr:hover {
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<h2>Sensor 2</h2>
|
<h2>{{ sensor[1] }}</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
@ -102,7 +102,7 @@ tr:hover {
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<h2>Sensor 3</h2>
|
<h2>{{ sensor[2] }}</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
Plotly.newPlot('graph_hr', HR_graphData.data, HR_graphData.layout);
|
Plotly.newPlot('graph_hr', HR_graphData.data, HR_graphData.layout);
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Refresh the page every 10 seconds
|
// Refresh the page every 20 seconds
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
location.reload();
|
location.reload();
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user