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)
Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
5/24/18 3:00 AM as a reply to Alexander Sawtschuk.

Hi Achim,

Thanks for the info.

However, not so many examples in Mita, like Bluetooth connection and data exchange with android code, read Analog and digital signal from extension bus, A/D conversion, write to digital output, I2C, internet connection and communication via https/http, UDP etc. XDK Live in the Help of Workbench does not provide full example source code or no sample soource code for the above cases.

Any place we could find more source code in Mita?

Your kindly advice would be very much appreciated.

Ms. Zhu

 

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
5/24/18 11:39 AM as a reply to Bochun Zhu.
Hello Bochum,

Unfortunately, XDK-Live is still in development and as such, not all features from the SDK of the XDK are included, yet. Specifically, the features you asked for are not yet available, but more features will be added continuously. Since Eclipse Mita is an open source project, you can view any progress in that regard in the Eclipse/Mita Repository .

The following modules are currently supported:
 
  • Sensors: Accelerometer, Environmental sensor and Light sensor
  • Utility: Buttons and LEDs
  • Connectivity: BLE and Wi-Fi
  • Protocols: MQTT and HTTP (REST)

Currently, the only way to add platform functionality, other than by waiting for XDK-Workbench updates, is the Foreign Function Interface. It allows integrating C interfaces and calling their functions in your XDK-Live application. For more information, I recommend taking a look at the corresponding section in the XDK Live Documentation .

Please let me know, if that was helpful and feel free to ask if you have further questions.

Kind regards,
Alex
0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
6/20/18 2:38 PM as a reply to Alexander Sawtschuk.

Hello :)

My IDE XDK Workbench v3.3.1 (Build date : 2018-03-21T13:17:04Z) , doesn't support XDKLive Gyroscope.

I noticed at https://github.com/eclipse/mita/blob/master/platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform is added Gyroscope.  

Kindly advise how to update the latest Mita to my IDE.

 

Thanks 

 

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
6/26/18 11:51 AM as a reply to L CC.
Hello L CC,

the easiest way to integrate the latest mita updates and use them in the XDK-Workbench would be to download the latest stable jenkins artifact of the Mita Repository. This link here will immediately start a download for the latest artifact file.

Once you downloaded the artifact, extract it and you will find the directory target containing a few files. One of these files is a zip archive prefixed with org.eclipse.mita.repository . This can be installed in the XDK-Workbench.

Before installing Mita, XDK Live must be removed from the XDK-Workbench, otherwise there will be conflicts between the two plugins.

To delete XDK Live, go to your Workbench and select Help > About XDK Workbench in the top menu bar. In the new window, press the Installation Details button. This will open a new window with a list of all currently installed Plugins. In that list, you will find a plugin caled XDK LIVE Language Feature . Select it and press Uninstall . Review and Confirm the Process, and the XDK Live Language Feature will be removed from the XDK-Workbench.

Note: the plugin also integrates the XDK Live documentation into the XDK-Workbench, which will thus be unavailable. But, the documentation is hosted separately here .

Now that XDK Live ist removed, MITA can be installed. For this, select Help > Install New Software... , then press the button Add... at the top on the right-hand side. Select Archive... in the new popup window, and locate the aforementioned zip file with the prefix org.eclipse.mita.repository from the unpacked target-directory.

Press Ok and select Mita Runtime and Platforms for installation and then go through the Installation Process.

Now that Mita is installed, you will have to use the filetype extension .mita instead of .x for your new XDK Live applications.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
6/26/18 3:26 AM as a reply to Franjo Stjepandic.

Hello Franjo,

Kindly provide again the URL to download latest artifact file for MITA.

 

Thanks again.

 

 

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
6/26/18 6:01 AM as a reply to L CC.

Hi Franjo,

I have downloaded the zip file at https://ci.eclipse.org/mita/job/mita-master/lastSuccessfulBuild/artifact/bundles/org.eclipse.mita.repository/target/

and followed your instrunctions.

But XDK IDE doesn't work properly.

Not able to open application.x file and cannot build XDK Live project. Pls see attached screenshots.

 

 

 

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
6/26/18 12:08 PM as a reply to L CC.
Hello L CC,

Thank you for reaching out in regards to the link to the latest Mita build. It seems the link in my last post is broken.

You can get it via the following URL:

https://ci.eclipse.org/mita/job/mita-pullrequests/lastStableBuild/artifact/bundles/org.eclipse.mita.repository/target/*zip*/target.zip

In regards to your error, you removed all XDK-Live packages and installed the open source Mita packages. As such, you need to rename application.x to application.mita, as I mentioned in my last post.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
7/12/18 3:48 PM as a reply to Franjo Stjepandic.

Hi Franjo,

I updated the mita packages as you have described. I have got the following error at the end of the installation:

An error occurred while collecting items to be installed
session context was:(profile=DefaultProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.mita.library.stdlib,0.1.0.201807110642
No repository found containing: osgi.bundle,org.eclipse.mita.program,0.1.0.201807110642
No repository found containing: osgi.bundle,org.eclipse.mita.program.ide,0.1.0.201807110642
No repository found containing: osgi.bundle,org.eclipse.mita.program.ui,0.1.0.201807110642

Any idea?

Thanks in advance.
Best regards,
Marco

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
7/13/18 1:00 PM as a reply to Marco Täschner.
Hello Marco,

First, I would like to welcome you to the XDK community.

I was able to reproduce your issue. I assume you used the download link I provided in my last post to download the mita build?

If this is correct, please note that you are trying to install an older version of the mita build and this is the cause why you are getting the error during installation.

On that behalf, please note that the download I provided, is directly bound to this older version.

For the latest version of the mita build, I recommend using the following download link:

https://ci.eclipse.org/mita/job/mita-master/lastSuccessfulBuild/artifact/bundles/org.eclipse.mita.repository/target/

Please download the latest version and try to install mita once again, now it should finish without errors.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
7/16/18 12:56 PM as a reply to Franjo Stjepandic.

Hi Franjo,

thanks for the welcome and of course for the helpful hint. It works like a charm :)

Best regards,
Marco

 

0 (0 Votes)
RE: Any more example in Mita, like extension Bus, HTTPs, UDP, etc.
Answer
7/16/18 3:56 PM as a reply to Marco Täschner.
Hello Marco,

I am glad to hear that the solution is working.

Please feel free to ask if you have any kind of further question or concern.

Kind regards,
Franjo
0 (0 Votes)