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