commit eca3e08291e20217f898683188d4a0dc6ae86ce3 Author: Cole Deck Date: Tue Mar 21 15:01:08 2023 -0500 first commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..66b1e25 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM waggle/plugin-base:1.1.1-ml +COPY requirements.txt /app/ +RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt +COPY . /app/ +WORKDIR /app +ENTRYPOINT ["python3", "/app/main.py"] \ No newline at end of file diff --git a/ecr-meta/ecr-icon.jpg b/ecr-meta/ecr-icon.jpg new file mode 100644 index 0000000..e69de29 diff --git a/ecr-meta/ecr-science-description.md b/ecr-meta/ecr-science-description.md new file mode 100644 index 0000000..e69de29 diff --git a/ecr-meta/ecr-science-image.jpg b/ecr-meta/ecr-science-image.jpg new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..5c2686b --- /dev/null +++ b/main.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +from waggle.plugin import Plugin +import time + +sensortypes = ["microphone", "camera", "humidity"] +showData = True + +def publishData(data, sensorID, sensorType, dataTimestamp): + with Plugin() as plugin: + if showData is True: + print("publishing network.bridge.sensor." + sensorType + "with metadata:", {"sensorID": sensorID, "sensorType": sensorType}, "and timestamp:", dataTimestamp, "and data:", data) + else: + print("publishing network.bridge.sensor." + sensorType + "with metadata", {"sensorID": sensorID, "sensorType": sensorType}) + + plugin.publish("network.bridge.sensor." + sensorType, data, meta={"sensorID": sensorID, "sensorType": sensorType}, timestamp=dataTimestamp) + time.sleep(1) + +if __name__ == "__main__": + # testing + publishData(1, "0", sensortypes[0], time.time_ns()) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..821be3e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pywaggle[all] \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..92aa61b --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export PYWAGGLE_LOG_DIR=test-run +python main.py \ No newline at end of file diff --git a/sage.yaml b/sage.yaml new file mode 100644 index 0000000..2de5a6b --- /dev/null +++ b/sage.yaml @@ -0,0 +1,13 @@ +name: "network-sensor-bridge" +description: "Bridge plugin to connect networked (optionally meshed sensors)" +keywords: "network, mesh, bridge" +authors: "Your Name , A Coworker " +collaborators: "Cole Deck " +funding: "" +license: "" +homepage: "" +source: + architectures: + - "linux/amd64" + - "linux/arm64" + - "linux/arm/v7" \ No newline at end of file diff --git a/test-run/data.ndjson b/test-run/data.ndjson new file mode 100644 index 0000000..39e2f0b --- /dev/null +++ b/test-run/data.ndjson @@ -0,0 +1,5 @@ +{"meta":{"sensorID":"0","sensorType":"microphone"},"name":"network.bridge.sensor.microphone","timestamp":"2023-03-21T14:46:25.762401149","value":1} +{"meta":{"sensorID":"0","sensorType":"microphone"},"name":"network.bridge.sensor.microphone","timestamp":"2023-03-21T14:49:11.913989882","value":1} +{"meta":{"sensorID":"0","sensorType":"microphone"},"name":"network.bridge.sensor.microphone","timestamp":"2023-03-21T14:52:40.885835367","value":1} +{"meta":{"sensorID":"0","sensorType":"microphone"},"name":"network.bridge.sensor.microphone","timestamp":"2023-03-21T14:53:10.464592551","value":1} +{"meta":{"sensorID":"0","sensorType":"microphone"},"name":"network.bridge.sensor.microphone","timestamp":"2023-03-21T14:53:17.921731597","value":1}