There are certainly many definitions. I give you my own definition (one that guides me in designing my DSL).
A connected thing is a device
composed of sensors (position, temperature, heart beat, âŠ)
with an autonomy
with (sometimes) a display (ie: screen of watch, Withing, âŠ)
that can (sometimes) interact with other devices (ie: sending messages between 2 AppleWatch)
that can connect to a network (internet)
Some devices can directly connect to internet because they directly embed a wifi component or a rj45 plug or they use a âgatewayâ (or a hub) to connect to the network (in the first case, the gateway is embedded).
In the case of Atta DSL, a connected thing is a Gateway class with a list of sensors. Each sensors is âautonomousâ and publish data to the Gateway instance (and the Gateway instance is in charge to provide sensorsâ data to the world).
The MQTT Gateway
Today, Iâve finalize a first (alpha) version of the MQTT Gateway class. I will commit source code soon, but here are some explanations:
the MQTTGateway class extends MQTTDevice class and implements Gateway interface and commonGatewayAbilities trait (I love traits).
Create a sensor
MQTTGateway (and other Gateway implementations) can use pre-defined Atta sensors or you can create your own sensors:
Once the sensor is started (when its gateway is started), each 1000 ms, the generateData() is called and it updates the value of the sensor.
And when the sensor is notified by the gateway, it produces a message with data (data() method) and notifies the gateway with the message.
The sensor works in a thread.
Use the sensor(s) with the MQTTGateway
First of all, you need a MQTT Broker. You can use for example Moquette (Java MQTT Broker) or Mosca (NodeJS MQTT Broker)
This is a quick an dirty sample of MQTT broker with Mosca:
Itâs very simple (Iâm using ES2015, so you can run it with babel).
Once the broker is ready (and started), hereâs the groovy script to simulate gateway(s):
So itâs very easy to create a lot of sensors and a lot of gateways to âstressâ your broker. :)
Using the MQTT Gateway with Golo
Golo is my favorite âtiny languageâ for the JVM (disclaimer: I commit sometimes on the Golo project). Golo is incubating at the Eclipse Foundation.
I try to develop Atta DSL, keeping in mind that it can be used with other languages. So, it is already possible to use it with Golo.
The difficulty (for the moment) is that closures are not implemented in the same way with Golo or Groovy. So, Iâve created some methods in MQTTGateway class and MQTTDevice class to be used from Golo. I will create later modules to make the use with Golo more fluent.
And now we can use it like that: I want 1000 connected poneys!
You can see that itâs very easy to stress a MQTT Broker. Next time, weâll see the CoAP Gateway and this probably will be the opportunity to publish a first version of Atta.