You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
894 B
Python

#!/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())