Created
January 8, 2022 22:58
-
-
Save cpq/2ad7505198d71a6d26e7405dbaaa5cd5 to your computer and use it in GitHub Desktop.
language yada yada
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Blink LED | |
2 = pin // pin = 2 | |
0 = on // on = 0 | |
pin 2 G // gpio.mode(pin, OUTPUT) | |
1000 { !on = on pin on W } T | |
'mqtt://broker.hivemq.com:1883' M = c | |
c 'elk/rx' { | |
'topic' $1 'message' $2 '{%Q:%Q, %Q:%Q}' c P // mqtt.publish | |
} S // mqtt.subscribe(c, topic, func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Blink LED | |
let led = { pin: 2, on: false }; // LED state | |
gpio.mode(led.pin, 2); // Set LED pin to output mode | |
setTimeout(function() { led.on = !led.on; gpio.write(led.pin, led.on); }, 1000); | |
// Report some data to MQTT | |
let conn = mqtt.connect('mqtt://broker.hivemq.com:1883'); // Create MQTT connection | |
mqtt.subscribe(conn, 'elk/rx', function(topic, message) { // Subscribe to 'elk/rx' topic | |
log('MQTT: ' + topic + ' -> ' + message); | |
let response = {ram: ram(), usage: usage(), received: message}; | |
mqtt.publish(conn, 'elk/tx', str(response)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment