RADIUSdesk

Hands-On MQTT Usage

Background

  • Although the heartbeat system used in MESHdesk / APdesk allows for remote command execution there might be situations where you need the immediate command execution.
  • Security is a big thing where I stay and with this hands on lab we will see how to make use of the MQTT implementation to switch outdoor lights remotely on and off using one of the mesh nodes' GPIOs
  • For this lab we have:
    • MESHdesk managing a mesh network that has the following hardware
      • 3x Xiaomi 4C Units
      • 2x Dragino MS14

  • 1x 4 Channel Arduino Relay Module connected to one of the Dragino units.
  • 3x outdoor lights connected to the 4 Channel Arduino Relay Module.
    • One will be installed at the garage.
    • One will be installed at the driveway.
    • One will be installed at the backyard.

  • MESHdesk allows you to manage hardware from various vendors in one mesh network.
  • In this mesh network we have Xiaomi which are Mediatek based and currently sold in many places.
  • We also have Dragino which are Atheros based and have been on the market for more than a decade.

GPIO Pins of Dragino MS14

  • The Dragino exposes a couple of GPIO pins on a header.

  • The GPIO pins will be connected to the Arduino Relay Module.

  • We will use the following mapping
Dragino Arduino Comment
GPIO19 In1 Driving the relay to the garage light
GPIO21 In2 Driving the relay to the backyard light
GPIO18 In3 Driving the relay to the driveway light
GPIO24 In4 Extra for future expansion
3.3v Vcc Use the 3.3V since the 5V is to high for the GPIO pin output to trigger a low / high
GND Gnd

GPIO Helper Scripts

  • The latest version of the MESHdesk firmware includes the following folder /etc/MESHdesk/gpio_utils.
  • There we will keep helper scripts for GPIO management.
  • The following is currently there:
    • /etc/MEHdesk/gpio_utils/gpio_set_clear.sh
    • /etc/MEHdesk/gpio_utils/gpio_flash.sh
  • If we want to set GPIO 18 on the Dragino we can issue the following /etc/MEHdesk/gpio_utils/gpio_set_clear.sh 18 1.
  • To clear it /etc/MEHdesk/gpio_utils/gpio_set_clear.sh 18 0.
  • If we want to flash (on-off) GPIO 18 a couple of times: /etc/MEHdesk/gpio_utils/gpio_flash.sh 18 15
  • The default on-off transition is with one second intervals. There is an optional parameter where you can set the interval in seconds.
  • /etc/MEHdesk/gpio_utils/gpio_flash.sh 18 15 30 will increase the transition interval to 30 seconds.

Now that we have our mapping and know about our helper scripts we can bring it together in RADIUSdesk to create predefined commands which we can use on our Dragino.

Predefined Commands

  • Predefined Commands can be used in two places.
    • When building schedules that can be associated with mesh nodes and access points.
    • When sending commands to mesh nodes and access points.
  • To manage predefined commands you need to go to OtherSchedules and click on the Predefined Commands button to launch the applet.

  • We added the following commands for our three lights.

  • Note that we did not make those commands available to sub-providers. This way we can keep certain predefined commands private to an access provider.
  • These commands can now be used when defining schedules e.g. if you want to set the lights on and off on certain times or when you want to send the command to the mesh node or access point immediately.

Since this is a page about hands on work we end with a demonstration video showing things in action.

In action video