MQTT.fx 0.0.7 released

A new version of MQTT.fx is available featuring:

  • Scripting support
  • Setup/Re-configuration tool
  • Reviewed Connection Profile Editor
  • Reviewed UI and style

007_start

Download latest binaries HERE.

Scripting support

I have added support for scripts executed by the Nashorn Engine.
Thought it might be helpful for testing a MQTT message flow of a certain setup, e.g. simulate sensors sending temperature value messages. All controlled via the UI.

007_executescript

Adding new scripts

New scripts can be easily made available for execution via the UI. The app is scanning a folder named “scripts” located at the MQTT.fx working directory:
OS X: [USER_HOME]/Library/Application Support/MQTT-FX/scripts
Windows: [USER_HOME]\AppData\Local\MQTT-FX\scripts
Linux: [USER_HOME]/MQTT-FX/scripts
If this folder does not exists it is created by MQTT.fx containing a demo script.

007_workingdir

Naming convention:

[INDEX]__[NAME].js
01__Switch_Fountain_Test.js

[INDEX] - controls the order of the entry in the drop down menu
__ - delimiter between index and name
[NAME] - the name of the menu entry (words are delimit by '_')

Hint:
If you name a script “separator”, e.g. 02__separator.js a separator is added to the menu at the “index” position.

007_scripting

Example script:

var Thread = Java.type("java.lang.Thread");
var System = Java.type('java.lang.System');

function execute(action) {
    out("Test Script: " + action.getName());
    for (var i = 0; i < 10; i++) {
        switchON();
        Thread.sleep(500);
        switchOFF();
        Thread.sleep(500);
    }
    action.setExitCode(0);
    action.setResultText("done.");
    out("Test Script: Done");
    return action;
}

function switchON() {
    out("fountain ON");
    mqttManager.publish("home/garden/fountain", "ON");
}

function switchOFF() {
    out("fountain OFF");
    mqttManager.publish("home/garden/fountain", "OFF");
}

function out(message){
    System.out.println(message);
}

The entry point of execution is the function execute(action).
During script execution System.out is hooked by MQTT.fx to print output to the console. Thus with System.out.println() messaged can be printed to the UI-console.

The interface to the broker-connection is the bound mqttManager. Messages can be published via the established broker connection.

Setup/Re-configuration Tool

If no configuration can be found, the app assumes its first start. The user is promoted with a setup dialog to create e new configuration.

Also if a configuration has been found but it seems to be corrupt or the format doesn't fit a newer version also a new configuration can be created or the exiting config can be opened in an external editor (assumed an editor has been assigned to open *.xml-files.

007_setup

Reviewed Connection Profile Editor
Now the Connection Profile Editor is recognising wether the chosen profile has been changed (buttons are enabled/disabled accordingly). Changes can be reverted as not already applied.

007_newprofile

Reviewed UI and Style

Greetings from Yosemity! ;-)

2 thoughts on “MQTT.fx 0.0.7 released

  1. Great work, again! Loving these updates.

    Any plans to make the source available? Just curious :-)

    Also, is there any way to get JavaFX apps to autoupdate / check for updates? would be handy.

    • Thanks Andy, you’re welcome!
      Still not sure about opening the source code. Once I am (more or less) happy with the code I think it will get open source.
      By now there is no standard API for app updates. Anyway I am working on a small Appcast based framework for my apps.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>