// Load other JavaScript NodeJS like modules from the template path var example = require("example"); example.helloWorld(); // We get the current time and store it in now var now = new Date().getTime(); //// // Logging //// console.log("this is a information message"); console.warn("this is a warning message"); console.error("this is a error message"); //// // Publishing messages /// // Publish a device:ping without any data devsim.publish("device:ping"); // Publish a sensor update using sensor:data // It sends for UID 1 the bat1-voltage with value 10.2V // and UID 2 the bat1-state with value 5 ("full") devsim.publish("sensor:data", [ {"uid": 1, "value": 10.2, "time": now}, {"uid": 2, "value": 5, "time": now} ]); // Publish a device:data (heartbeat) with an interval of 1000 milliseconds. // simulating the device is in the "active" state and has no error(s) devsim.setInterval(function() { devsim.publish("device:data", [{ "state": "active", "error": false, }]); }, 1000); //// // Storage //// devsim.set("token", 1337); var boem = devsim.get("token"); devsim.del("token");