Skip to content

mendix/MxAwsIotConnector

Repository files navigation

Mendix AWS IoT connector

This connector enables you to easily connect to IoT devices and data on AWS IoT.

Usage

The connector consists of types of microflow actions:

  • Actions to determine the devices connected to AWS IoT.
  • Actions to get and set the shadow of devices connected to AWS IoT through the REST Api.
  • Actions to get and set the shadow of devices connected to AWS IoT through MQTT messages.

Mendix AWS IoT toolbox actions

Configuration

The actions need AWS credentials. Most use an AWS access key id, and an AWS secret access key.

For the MQTT actions you need to provide Certificates as provided by AWS IoT. These should be stored in the resources folder of your Mendix project.

Certificates

Things

To get a list of all things registered at AWS IoT you can use Things - get list. This will return a JSON document as provided by AWS IoT. You can use a JSON import mapping to create entities from the JSON returned

List things microflow

List things configuration

To get the details of a device you can use the Thing - describe action.

Thing - describe

State

AWS IoT has a shadow of the device state. It provides a REST Api to this shadow. Through this API you can d determine the last known state of a device, or request a state change of this device.

To read the last known status of a device use the Data - get shadow action. This action needs the endpoint of the REST API. You can copy, paste this from AWS IoT, or you can use the Thing - get endpoint action to determine the endpoint.

Thing - get shadow

To change the status of a device you can update the shadow using the Data - change shadow action.

Thing - update shadow

Messages

In addition to the REST API you can also work with the state of devices through MQTT messages.

To receive messages from devices you need to subscribe to the required topic using the Data - subscribe to MQTT topic. Typically you'll want to do this when you Mendix app is started.

MQTT subscribe unsubscribe

To subscribe you need to provide certificate information as provided by AWS IoT.

MQTT subscribe configuration

Alternatively you can use the Data - subscribe with MQTT topic with client is activity to establish a named connection. This will ensure messages that are sent when your app is down, will be delivered later when it is back up again.

Subscribe with client id

When a message is received the microflow you specified will be called using two string parameters: topic and payload. The payload contains a JSON document that you can import using JSON import mappings. The format of this message depends on the data send by the device.

MQTT on message microflow

To publish a message on an MQTT topic you can use the Data - publish MQTT message action:

MQTT publish mqtt message microflow

Configuration of this action also needs the certificates provided by AWS IoT:

MQTT publish mqtt message configuration

Development

The sourcecode of this connector is on Github: Github AWS IoT connector.

All java jar dependencies are managed using an ivy file. You can download all dependencies by running runivy.cmd. This will save all jars in the userlib folder. There are two different scripts to run ivy:

  • runivy.cmd - downloads all dependencies required for running and testing the project
  • runivy-export.cmd - downloads only the dependencies required for distributing the connector mpk.

Before you start to develop the connector you need to run runivy.cmd. After you validate everything works, run runivy-export.cmd. This will delete all jars in the userlib folder and only download the jars required for creating the connector mpk.

Attribution

This project uses source code from:

License

This connector is licensed under the Apache v2 license.

Changelog

  • 0.9 - 2016-07-13 - initial public release

  • 0.9.1 - 2016-08-15 - Bug fixes

    • Client id should be unique per client
    • Fixed problem with subscribing to multiple topics, messages are now delivered to the correct microflow
  • 0.9.2 - 2016-08-24 - Bug fixes

    • Fixed MQTT topic wildcard subscriptions
  • 0.9.3 - 2016-08-25 - Bug fixes

    • Fixed MQTT topic with $ sign subscriptions
  • 5.0.0 - 2021-03-02 - Subscribe with client id

    • New microflow activity to subscribe with a client id
    • Upgrade to Mendix 7.23.19

About

Mendix connector to integrate with AWS IoT

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •