Skip to content

Commit

Permalink
Firmware v1.6 (#16)
Browse files Browse the repository at this point in the history
* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update

* firmware update
  • Loading branch information
psmsmets committed Dec 29, 2021
1 parent f26019c commit 704cc6c
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 161 deletions.
42 changes: 21 additions & 21 deletions multi_ear_services/ctrl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import os
import socket
import hashlib
import requests
from flask import Flask, Response, jsonify, request, render_template
from flask_cors import CORS
from influxdb_client import InfluxDBClient
from pandas import Timestamp

# relative imports
try:
Expand Down Expand Up @@ -63,7 +63,6 @@ def create_app(test_config=None):
version=version,
services=utils.services,
hostapd=dict(hostapd.items('DEFAULT')),
utcnow=Timestamp.utcnow,
)

# inject template globals
Expand All @@ -84,17 +83,14 @@ def index():

@app.route("/_tab/<tab>", methods=['GET'])
def load_tab(tab="home"):

if not is_internal_referer():
return "Invalid request", 400

try:
html = render_template(f"tabs/{tab}.html.jinja")
except FileNotFoundError:
return f"Tab {tab} not found", 404
except Exception as e:
return f"Server Error: {e}", 500

resp = {
"succes": True,
"tab": tab,
Expand All @@ -104,61 +100,65 @@ def load_tab(tab="home"):

@app.route("/_systemd_status", methods=['GET'])
def systemd_status():

if not is_rpi:
return "I'm not Raspberry Pi", 418

service = request.args.get('service') or '*'
if service == '*':
resp = utils.systemd_status_all()
else:
resp = utils.systemd_status(service)

return jsonify(resp), 200

@app.route("/_append_wpa_supplicant", methods=['POST'])
def append_wpa_supplicant():

if not is_internal_referer():
return "Invalid request", 403

if not is_rpi:
return "I'm not Raspberry Pi", 418

secret = request.args.get('secret')
if secret != wifi_secret:
return "Secret invalid", 403

ssid = request.args.get('ssid')
passphrase = request.args.get('passphrase')
if not (ssid and passphrase):
return "Invalid ssid and/or passphrase arguments", 400

resp = utils.wlan_ssid_passphrase(ssid, passphrase)

return jsonify(resp), 200

@app.route("/_autohotspot", methods=['POST'])
def autohotspot():

if not is_internal_referer():
return "Invalid request", 403

if not is_rpi:
return "I'm not Raspberry Pi", 418

secret = request.args.get('secret')
if secret != wifi_secret:
return "Secret invalid", 403

resp = utils.wlan_autohotspot()

return jsonify(resp), 200


@app.route("/api/dataselect/health", methods=['GET'])
def api_dataselect_health():
return repr(db_client.health()), 200
if not is_rpi:
return "I'm not Raspberry Pi", 418
r = requests.get("http://localhost:8086/health")
return r.text, r.status_code

@app.route("/api/dataselect/timing", methods=['GET'])
def api_dataselect_gnss():
if not is_rpi:
return "I'm not Raspberry Pi", 418
r = requests.get(
url="http://localhost:8086/query?pretty=true",
params=dict(
db="multi_ear",
q=("SELECT * FROM \"multi_ear\" "
"WHERE \"clock\"='GNSS' "
"ORDER BY time DESC "
"LIMIT 1"),
)
)
return r.text, r.status_code

@app.route("/api/dataselect/query", methods=['GET', 'POST'])
def api_dataselect_query():
Expand Down
Binary file modified multi_ear_services/ctrl/static/datasheet/GNS41x.pdf
Binary file not shown.
16 changes: 12 additions & 4 deletions multi_ear_services/ctrl/static/js/multi-ear.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ Highcharts.setOptions({
})


Date.prototype.addSecs = function(s) {

this.setTime(this.getTime() + (s * 1000));
return this;

}


function sleep(ms) {

return new Promise(resolve => setTimeout(resolve, ms));
Expand Down Expand Up @@ -286,8 +294,8 @@ function fetchSensorData(end) {
fetchButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...'
fetchButton.disabled = true

if (end === undefined) {
end = new Date().toISOString().substring(0, 19)
if (end === undefined | end === '') {
end = (new Date()).addSecs(-5).toISOString().substring(0, 19)
var sendorDataEnd = document.getElementById('sensorDataEnd')
sensorDataEnd.value = end
}
Expand Down Expand Up @@ -550,8 +558,6 @@ function stopCharts(tab) {

function loadPCB () {

resizePCB()

var pcbItems = [].slice.call(document.querySelectorAll('.pcb > svg > *'))

var pcbPopovers = pcbItems.map(function (item) {
Expand Down Expand Up @@ -579,6 +585,8 @@ function loadPCB () {
return popover
})

resizePCB()

}


Expand Down
17 changes: 15 additions & 2 deletions multi_ear_services/ctrl/templates/tabs/dashboard.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<h4 class="my-3 pt-4">Live sensor data</h4>

<canvas class="my-3" id="sensorDataWS"></canvas>
<canvas class="my-3 img-fluid" id="sensorDataWS"></canvas>
<small>here comes a live timeseries graph via websockets</small>

<hr class="my-4 my-md-5">
Expand Down Expand Up @@ -94,7 +94,7 @@
<div class="col-md-6 col-xl-4">
<div class="input-group mb-3">
<span class="input-group-text">End time (UTC)</span>
<input type="text" class="form-control" placeholder="YYYY-MM-DDTHH:mm:ss" id="sensorDataEnd" aria-label="End time" value="{{utcnow().strftime('%Y-%m-%dT%H:%M:%S')}}">
<input type="text" class="form-control" placeholder="YYYY-MM-DDTHH:mm:ss" id="sensorDataEnd" aria-label="End time" value="">
</div>
</div>
<div class="col-md-6 col-xl-4">
Expand Down Expand Up @@ -123,6 +123,16 @@
data-title="Barometric Pressure"
data-units="hPa">
</div>
<div id="chart-dp"
class="py-3"
data-source="multi_ear"
data-series="DLVR"
data-scalar="0.01*250/6553"
data-offset="0,0"
data-title="Differential Pressure"
data-units="Pa">
</div>
<!--
<div id="chart-dp"
class="py-3"
data-source="multi_ear"
Expand All @@ -132,6 +142,8 @@
data-title="Differential Pressure"
data-units="Pa">
</div>
-->
<!--
<div id="chart-spl"
class="py-3"
data-source="multi_ear"
Expand All @@ -141,6 +153,7 @@
data-title="Sound Pressure Level"
data-units="dbV">
</div>
-->
<div id="chart-acc-z"
class="py-3"
data-source="multi_ear"
Expand Down
35 changes: 18 additions & 17 deletions multi_ear_services/ctrl/templates/tabs/pcb.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
x="19%" y="05%" width="21%" height="21%" />
<rect class="btn" id="PCB-DLVR" data-bs-content="DLVR-L01D"
x="45%" y="02%" width="28%" height="15%" />
<rect class="btn" id="PCB-FLASH" data-bs-content="LIS3D"
x="47%" y="21%" width="08%" height="05%" />
<rect class="btn" id="PCB-LIS3DH" data-bs-content="LIS3DH"
x="46%" y="20%" width="09%" height="06%" />
<rect class="btn" id="PCB-LSM303C" data-bs-content="LSM303C"
x="47%" y="30%" width="06%" height="04%" />
<rect class="btn" id="PCB-ICS" data-bs-content="ICS-40300"
x="77%" y="04%" width="08%" height="06%" />
<rect class="btn" id="PCB-GNS413-ANT" data-bs-content="GNS413 antenna"
Expand Down Expand Up @@ -193,44 +195,43 @@
</dl>

<h4 class="my-3 pt-3 border-top">Inertial measurement units</h4>
<!--
<dl class="row pcb" id="LSM303">
<dt class="col-sm-3 text-sm-end">Type</dt>
<dd class="col-sm-9">LSM303</dd>

<dl class="row pcb" id="LIS3DH">
<dt class="col-sm-3 text-sm-end">Type</dt>
<dd class="col-sm-9">LIS3DH</dd>
<dt class="col-sm-3 text-sm-end">Manufacturer</dt>
<dd class="col-sm-9">ST Microelectronics</dd>
<dt class="col-sm-3 text-sm-end">Description</dt>
<dd class="col-sm-9">three-axis linear accelerometer and 3-axis magnetometer</dd>
<dd class="col-sm-9">three-axis linear accelerometer</dd>
<dt class="col-sm-3 text-sm-end">Datasheet</dt>
<dd class="col-sm-9">
<a href="{{ url_for('static', filename='datasheet/LSM303.pdf') }}">LSM303 Datasheet (PDF)</a>
<a href="{{ url_for('static', filename='datasheet/LIS3DH.pdf') }}">LIS3DH Datasheet (PDF)</a>
</dd>
<dt class="col-sm-3 text-sm-end">Range</dt>
<dd class="col-sm-9">&#177;2 to &#177;16 G</dd>
<dd class="col-sm-9">&#177;2 to &#177;16 <i>g</i></dd>
<dt class="col-sm-3 text-sm-end">Resolution</dt>
<dd class="col-sm-9">16 bit</dd>
<dt class="col-sm-3 text-sm-end">Accuracy</dt>
<dd class="col-sm-9">..</dd>
<dd class="col-sm-9">&#177;40 m<i>g</i> (zero-<i>g</i> level)</dd>
</dl>
-->

<dl class="row pcb" id="LIS3DH">
<dl class="row pcb" id="LSM303C">
<dt class="col-sm-3 text-sm-end">Type</dt>
<dd class="col-sm-9">LIS3DH</dd>
<dd class="col-sm-9">LSM303C <i>(only present on the green pcb)</i></dd>
<dt class="col-sm-3 text-sm-end">Manufacturer</dt>
<dd class="col-sm-9">ST Microelectronics</dd>
<dt class="col-sm-3 text-sm-end">Description</dt>
<dd class="col-sm-9">three-axis linear accelerometer</dd>
<dd class="col-sm-9">three-axis linear accelerometer and 3-axis magnetometer</dd>
<dt class="col-sm-3 text-sm-end">Datasheet</dt>
<dd class="col-sm-9">
<a href="{{ url_for('static', filename='datasheet/LIS3DH.pdf') }}">LIS3DH Datasheet (PDF)</a>
<a href="{{ url_for('static', filename='datasheet/LSM303C.pdf') }}">LSM303C Datasheet (PDF)</a>
</dd>
<dt class="col-sm-3 text-sm-end">Range</dt>
<dd class="col-sm-9">&#177;2 to &#177;16 G</dd>
<dd class="col-sm-9">&#177;2 to &#177;8 <i>g</i></dd>
<dt class="col-sm-3 text-sm-end">Resolution</dt>
<dd class="col-sm-9">16 bit</dd>
<dt class="col-sm-3 text-sm-end">Accuracy</dt>
<dd class="col-sm-9">&#177;40 mG (zero-G)</dd>
<dd class="col-sm-9">&#177;40 m<i>g</i> (zero-<i>g</i> level)</dd>
</dl>

</div>
Expand Down
Loading

0 comments on commit 704cc6c

Please sign in to comment.