Skip to content

Commit e60b9de

Browse files
committed
fix lil bugs & logs
1 parent ae29027 commit e60b9de

File tree

6 files changed

+124
-7
lines changed

6 files changed

+124
-7
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<mxfile host="app.diagrams.net" modified="2023-07-10T21:47:44.302Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" etag="-YLaqlcZPeSAo_H65HH6" version="21.6.1" type="device">
2+
<diagram name="Page-1" id="2YBvvXClWsGukQMizWep">
3+
<mxGraphModel dx="629" dy="353" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="aM9ryv3xv72pqoxQDRHE-1" value="Phone" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;dropTarget=0;collapsible=0;recursiveResize=0;outlineConnect=0;portConstraint=eastwest;newEdgeStyle={&quot;edgeStyle&quot;:&quot;elbowEdgeStyle&quot;,&quot;elbow&quot;:&quot;vertical&quot;,&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
8+
<mxGeometry x="40" y="30" width="100" height="320" as="geometry" />
9+
</mxCell>
10+
<mxCell id="aM9ryv3xv72pqoxQDRHE-2" value="" style="html=1;points=[];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;edgeStyle&quot;:&quot;elbowEdgeStyle&quot;,&quot;elbow&quot;:&quot;vertical&quot;,&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="aM9ryv3xv72pqoxQDRHE-1" vertex="1">
11+
<mxGeometry x="45" y="70" width="10" height="190" as="geometry" />
12+
</mxCell>
13+
<mxCell id="aM9ryv3xv72pqoxQDRHE-5" value="TTGO" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;dropTarget=0;collapsible=0;recursiveResize=0;outlineConnect=0;portConstraint=eastwest;newEdgeStyle={&quot;edgeStyle&quot;:&quot;elbowEdgeStyle&quot;,&quot;elbow&quot;:&quot;vertical&quot;,&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
14+
<mxGeometry x="375" y="40" width="100" height="300" as="geometry" />
15+
</mxCell>
16+
<mxCell id="aM9ryv3xv72pqoxQDRHE-6" value="" style="html=1;points=[];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;edgeStyle&quot;:&quot;elbowEdgeStyle&quot;,&quot;elbow&quot;:&quot;vertical&quot;,&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="aM9ryv3xv72pqoxQDRHE-5" vertex="1">
17+
<mxGeometry x="45" y="80" width="10" height="170" as="geometry" />
18+
</mxCell>
19+
<mxCell id="9y3XMGGlQb83UzjVloVq-15" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="aM9ryv3xv72pqoxQDRHE-5" source="aM9ryv3xv72pqoxQDRHE-6" target="aM9ryv3xv72pqoxQDRHE-6">
20+
<mxGeometry width="50" height="50" relative="1" as="geometry">
21+
<mxPoint x="65" y="210" as="sourcePoint" />
22+
<mxPoint x="15" y="190" as="targetPoint" />
23+
<Array as="points">
24+
<mxPoint x="25" y="170" />
25+
<mxPoint x="5" y="170" />
26+
<mxPoint x="5" y="190" />
27+
</Array>
28+
</mxGeometry>
29+
</mxCell>
30+
<mxCell id="aM9ryv3xv72pqoxQDRHE-7" value="Connecting" style="html=1;verticalAlign=bottom;endArrow=classic;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;startArrow=classic;startFill=1;endFill=1;" parent="1" source="aM9ryv3xv72pqoxQDRHE-2" target="aM9ryv3xv72pqoxQDRHE-6" edge="1">
31+
<mxGeometry relative="1" as="geometry">
32+
<mxPoint x="195" y="130" as="sourcePoint" />
33+
<Array as="points">
34+
<mxPoint x="180" y="120" />
35+
</Array>
36+
</mxGeometry>
37+
</mxCell>
38+
<mxCell id="aM9ryv3xv72pqoxQDRHE-8" value="Exit" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;startArrow=open;startFill=0;endFill=0;" parent="1" source="aM9ryv3xv72pqoxQDRHE-6" target="aM9ryv3xv72pqoxQDRHE-2" edge="1">
39+
<mxGeometry relative="1" as="geometry">
40+
<mxPoint x="195" y="205" as="targetPoint" />
41+
<Array as="points">
42+
<mxPoint x="190" y="280" />
43+
</Array>
44+
</mxGeometry>
45+
</mxCell>
46+
<mxCell id="aM9ryv3xv72pqoxQDRHE-9" value="" style="html=1;verticalAlign=bottom;endArrow=none;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;endFill=0;startArrow=classic;startFill=1;" parent="1" source="aM9ryv3xv72pqoxQDRHE-6" target="aM9ryv3xv72pqoxQDRHE-2" edge="1">
47+
<mxGeometry relative="1" as="geometry">
48+
<mxPoint x="175" y="160" as="sourcePoint" />
49+
<Array as="points">
50+
<mxPoint x="190" y="160" />
51+
</Array>
52+
</mxGeometry>
53+
</mxCell>
54+
<mxCell id="9y3XMGGlQb83UzjVloVq-3" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="1">
55+
<mxGeometry width="50" height="50" relative="1" as="geometry">
56+
<mxPoint x="120" y="100" as="sourcePoint" />
57+
<mxPoint x="400" y="100" as="targetPoint" />
58+
</mxGeometry>
59+
</mxCell>
60+
<mxCell id="9y3XMGGlQb83UzjVloVq-4" value="Scanning" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="9y3XMGGlQb83UzjVloVq-3">
61+
<mxGeometry x="0.1389" relative="1" as="geometry">
62+
<mxPoint x="-20" y="-10" as="offset" />
63+
</mxGeometry>
64+
</mxCell>
65+
<mxCell id="9y3XMGGlQb83UzjVloVq-5" value="Trigger Send Data" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
66+
<mxGeometry x="200" y="130" width="120" height="30" as="geometry" />
67+
</mxCell>
68+
<mxCell id="9y3XMGGlQb83UzjVloVq-6" value="" style="html=1;verticalAlign=bottom;endArrow=none;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;endFill=0;startArrow=classic;startFill=1;" edge="1" parent="1">
69+
<mxGeometry relative="1" as="geometry">
70+
<mxPoint x="420" y="200" as="sourcePoint" />
71+
<Array as="points">
72+
<mxPoint x="190" y="200" />
73+
</Array>
74+
<mxPoint x="95" y="200" as="targetPoint" />
75+
</mxGeometry>
76+
</mxCell>
77+
<mxCell id="9y3XMGGlQb83UzjVloVq-7" value="Trigger Receive Data" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
78+
<mxGeometry x="200" y="175" width="120" height="30" as="geometry" />
79+
</mxCell>
80+
<mxCell id="9y3XMGGlQb83UzjVloVq-9" value="Read Received Data (characteristic)" style="html=1;verticalAlign=bottom;endArrow=none;edgeStyle=elbowEdgeStyle;elbow=vertical;curved=0;rounded=0;startArrow=classic;startFill=1;endFill=0;" edge="1" parent="1">
81+
<mxGeometry relative="1" as="geometry">
82+
<mxPoint x="97.5" y="250.21951219512198" as="sourcePoint" />
83+
<Array as="points" />
84+
<mxPoint x="422.5" y="250" as="targetPoint" />
85+
</mxGeometry>
86+
</mxCell>
87+
<mxCell id="9y3XMGGlQb83UzjVloVq-11" value="Writes to a characteristic and performs Uplink to TTN" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
88+
<mxGeometry x="440" y="130" width="200" height="30" as="geometry" />
89+
</mxCell>
90+
<mxCell id="9y3XMGGlQb83UzjVloVq-13" value="Performs Uplink to TTN, then Downlink from TTN to TTGO and writes received value to proper characteristic" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
91+
<mxGeometry x="440" y="205" width="230" height="30" as="geometry" />
92+
</mxCell>
93+
<mxCell id="9y3XMGGlQb83UzjVloVq-22" value="W" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
94+
<mxGeometry x="375" y="200" width="45" height="40" as="geometry" />
95+
</mxCell>
96+
<mxCell id="9y3XMGGlQb83UzjVloVq-28" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
97+
<mxGeometry width="50" height="50" relative="1" as="geometry">
98+
<mxPoint x="420" y="130" as="sourcePoint" />
99+
<mxPoint x="420" y="150" as="targetPoint" />
100+
<Array as="points">
101+
<mxPoint x="400" y="130" />
102+
<mxPoint x="380" y="130" />
103+
<mxPoint x="380" y="150" />
104+
</Array>
105+
</mxGeometry>
106+
</mxCell>
107+
<mxCell id="9y3XMGGlQb83UzjVloVq-29" value="W" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
108+
<mxGeometry x="375" y="120" width="45" height="40" as="geometry" />
109+
</mxCell>
110+
</root>
111+
</mxGraphModel>
112+
</diagram>
113+
</mxfile>

Docs/SeaSpot.postman_collection.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@
204204
"method": "GET",
205205
"header": [],
206206
"url": {
207-
"raw": "localhost:9200/device/_doc/eui-70b3d57ed005bfb0",
207+
"raw": "localhost:9200/devices/_doc/eui-70b3d57ed005bfb0",
208208
"host": [
209209
"localhost"
210210
],
211211
"port": "9200",
212212
"path": [
213-
"device",
213+
"devices",
214214
"_doc",
215215
"eui-70b3d57ed005bfb0"
216216
]

Docs/WeabApp_structure.png

201 KB
Loading

WebApp/data/data-elastic.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ function elasticDB(config){
7272
*/
7373
async function addMessage(messageObj){
7474
console.log("Adding message -> ", JSON.stringify(messageObj))
75-
7675
return elasticFetx.createDoc(ourIndexes.messages, messageObj).then(obj => {
77-
console.log("Msg source:", obj._source)
7876
return {id: obj._id}
7977
})
8078
}
@@ -188,6 +186,7 @@ function elasticDB(config){
188186
if(obj.found==false) throw new NotFound(errorMsgs.deviceNotFound(id))
189187

190188
const device = new Device(obj._id, obj._source)
189+
device.deviceObj.setCharacteristic = new DeviceObj("", "").setCharacteristic //get the setCharacteristic method
191190
const wasSet = device.deviceObj.setCharacteristic(characteristic, value)
192191
if(wasSet) await elasticFetx.updateDoc(ourIndexes.devices, device.id, device.deviceObj)
193192
}

WebApp/web/api/bodies/extractUpLinkInfo.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export function extractUplinkInfo(body) {
1616
if(locations!=undefined){
1717
const loc = locations['frm-payload'] //using locaitons.user will get the hardcoded location (done in the TTN)
1818
if(loc){
19-
console.log("Location source =", loc.source)
19+
console.log("Location source =\n", loc.source)
2020
location = new Location(loc.latitude, loc.longitude)
2121
} else console.log("Warning: No GPS location provided")
2222
}
2323

2424
const payload = body.uplink_message.frm_payload
2525
const decodedPayload = base64ToHex(payload)
2626
const fPort = body.uplink_message.f_port
27-
const characID = getCharacteristicID(fPort)
27+
const characID = getCharacteristicID(fPort, true)
2828

2929
// characteristic can be read from the f_port, so no ExtratCharar
3030

WebApp/web/api/web-api.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ export default function webApi(config) {
6868
* @param {express.Response} rsp
6969
*/
7070
async function upLinkWebHook(req, rsp) {
71-
console.log(`BODY = ${JSON.stringify(req.body)}\n`)
71+
console.log(`\nBODY = ${JSON.stringify(req.body)}\n`)
7272
console.log(`HEADERS = ${JSON.stringify(req.headers)}\n`)
7373
if(req.headers["x-downlink-apikey"]!=ourApplicationApiKey)
7474
throw new codes.Unauthorized(errorMessages.noPermissions(req.headers['user-agent']))
7575

7676
const upLinkMessage = extractUplinkInfo(req.body)
7777
console.log("upLinkWebHook message =", JSON.stringify(upLinkMessage))
7878

79+
if(upLinkMessage.msg.characteristic==undefined){
80+
console.log("\nUnknown characteritic (fport) provided, ignoring message\n")
81+
return
82+
}
83+
7984
services.addMessage(upLinkMessage)
8085

8186
console.log('Add the uplinked message, will schedule downlink')

0 commit comments

Comments
 (0)