-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup commands.txt
90 lines (73 loc) · 2.78 KB
/
Setup commands.txt
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
84
85
86
87
88
89
90
Setup incoming on localhost
cd /home/rob/Documents/simple-gateway
source .venv/bin/activate
Setup incoming data app:
gunicorn -w 4 -k uvicorn.workers.UvicornWorker grafana_duckdb_api:app --bind 0.0.0.0:8000
In Grafana;
http://localhost:8000/query?device_id=47&latitude=35.6617&unit=cpm
or http://localhost:8000/query?device_id=49&latitude=35.6617&unit=cpm&device_id=47
Test a curl:
curl -X POST http://grafana.safecast.jp:8000/measurements?api_key=q1LKu7RQyxunnDW -H "Content-Type: application/json" -d '{"when_captured": "2024-11-02T15:38:00","longitude":"139.7449","latitude":"35.6617","device_urn":"49","device":"49","value":"60","unit":"cpm","height":"111"}'
curl -X POST "http://grafana.safecast.jp:8000/measurements?api_key=q1LKu7RQyxunnDW" \
-H "Content-Type: application/json" \
-d '{
"bat_voltage": "3.7",
"dev_temp": "25",
"device": "2830364905",
"device_sn": "65000",
"device_urn": "urn:dev:12345",
"env_temp": "30",
"lnd_7128ec": "60",
"lnd_7318c": "",
"lnd_7318u": "20",
"loc_country": "US",
"loc_lat": "37.7749",
"loc_lon": "-122.4194",
"loc_name": "San Francisco",
"pms_pm02_5": "12.5",
"device_class": "geigiecast-zen",
"when_captured": "2024-11-02T15:38:00"
}'
Minimum:
curl -X POST "http://grafana.safecast.jp:8000/measurements?api_key=q1LKu7RQyxunnDW" \
-H "Content-Type: application/json" \
-d '{
"device": "2830364905"
}'
curl -X GET "http://localhost:8000/query?device_sn=SN12345"
If duckdb DB is changed there can ge a lock on the uniqueness of the table to remove use:
CREATE TABLE measurements_temp AS SELECT * FROM measurements;
DROP TABLE measurements;
CREATE TABLE measurements AS
SELECT * FROM measurements_temp;
DROP TABLE measurements_temp;
curl -X POST "http://grafana.safecast.jp:8000/measurements?api_key=q1LKu7RQyxunnDW" \
-H "Content-Type: application/json" \
-d '{
"bat_voltage": "3.7",
"dev_temp": "25",
"device": "2830364905",
"device_sn": "65000",
"device_urn": "urn:dev:12345",
"env_temp": "30",
"lnd_7128ec": "60",
"lnd_7318c": "",
"lnd_7318u": "20",
"loc_country": "US",
"loc_lat": "37.7749",
"loc_lon": "-122.4194",
"loc_name": "San Francisco",
"pms_pm02_5": "12.5",
"device_class": "geigiecast-zen",
"when_captured": "2024-11-02T15:56:00"
}'
Locally testing
curl -X POST "http://localhost:8000/measurements?api_key=q1LKu7RQyxunnDW" \
-H "Content-Type: application/json" \
-d '{
"device_id": "65001",
"value": "20",
"latitude": "37.7749",
"longitude": "-122.4194",
"captured_at": "2024-11-02T15:47:00"
}'