Introducing Eclipse Mita

A Language for Embedded IoT

The Internet of Things (IoT) is all about connectivity and scalability. A lot of great technology exists on the cloud side of the IoT which enables fast prototyping, yet scales as the amount of data and number of devices increases. However, the things (embedded, connected sensor devices such as the Bosch Cross Domain Development Kit - XDK) in IoT remain elusive to a lot of developers.

Example

Let's have a look at an example and use the Bosch XDK to build a shock detector connected using MQTT over WLAN:

// Mita has packages which are the main unit of isolation
package main;
 
// Every Mita program must import a platform, here we use the XDK
import platforms.xdk110;
 
// System resources are configured using the setup keyword.
// Here, we configure the WLAN connectivity of the XDK.
setup devnet : WLAN {
    ssid = "MyWifiName";
    psk = "supersecretkey";
}
 
// Software resources are resources nonetheless and thus are set up
// using the setup keyword. Notice how we refer to the devnet WLAN setup
// as means of transport, and instantiate a signal to the /events topic.
setup backend : MQTT {
    transport = devnet;
    url = "mqtt://iot.eclipse.org:1883";
    clientId = "shockDetector42";
   
    var events = topic(name="/events");
}
 
// Functions use the fn or function keyword. If the return type were omitted
// the Mita compiler would infer it automatically. Also, notice the type
// parameter of the array.
fn mean(x : array<uint32>) : uint32 {
    ...
}
 
// Variables can be immutable (let) or mutable (var).
// For arrayPosition we do not have to explicitely give a type as our
// type inference infers it from the initialization.
let acceleration = new array<uint32>(size=10);
var arrayPosition = 0;
 
// The every keyword handles events. Here we use time as an event source and
// run at a regular interval.
every 10 milliseconds {
    // Sensor data (and other modalities) are available due to the platform import above.
    // One can use some resources even if they were not configured beforehand.
    acceleration[arrayPosition] = accelerometer.magnitude.read();
    arrayPosition = (arrayPosition + 1) % acceleration.length();
 
    // The mean() function can be called using the familiar OO-style notation.
    // The expression on the left side of the dot becomes the first argument
    // of the function call.
    if(acceleration.mean() > 5000) {
        // Writing to the signal instance we've created in the signal block
        // above sends out the MQTT message (backend is an MQTT resource
        // after all). Using backticks we can use string interpolation.
        // Here we construct a JSON string inline to the function call.
        backend.events.write(`{ "type": "shock", "mag": ${acceleration.mean()} }`);
    }
}
 
// Events are described and offered by the platforms.
// This pressed event exists because the xdk110 platform imported
// above declares it.
every button_one.pressed {
    for(var i = 0; i < acceleration.length(); i++) {
        acceleration[i] = 0;
    }
    arrayPosition = 0;
}

https://www.eclipse.org/community/eclipse_newsletter/2018/march/mita.php

 

+1 (1 Vote)
RE: Introducing Eclipse Mita - new language for XDK
Answer
4/12/18 11:30 AM as a reply to Achim Kern.
Hello Achim,

thank you for presenting Eclipse MITA here.

In the context of the XDK, Eclipse MITA is referred to as XDK Live . Development with XDK Live is possible already as well.

Kind regards,
Alex
+1 (1 Vote)