As some of you that follows me on Twitter may already know, I was at MakerFaireRome a few weeks back, and I couldn’t resist to buy the new Intel Edison board, the follow-up of Intel Galileo. Now, the board promises to be a lot of fun: it has a dual core Atom CPU (!), plus an Intel Quark microcontroller, 1 GB of RAM, 4 GB of disk, WiFi and Bluetooth: basically, everything in a really small form factor. There are some interesting things that I would really like to try, for example SparkFun sells a LiPo battery, and I am really curious how long it could last while powering up all the good stuff that I cited above, but that’s not the main topic for this post.
What I really wanted to try actually is the Intel XDK: for some reason, Intel decided to develop its own SDK for mobile applications, that uses open source frameworks such as Apache Cordova (that I didn’t know about, and which I am quite curious about now!) to allow developers to create their applications using HTML5, CSS and JavaScript and deploy them on all the OSes (Android, iOS, Windows Phone). At some point they also decided to extend their SDK to support their IoT efforts (XDK IoT Edition), and that’s what I was finally able to try yesterday: attach some hardware, deploy an app on the Edison and its companion app on Android, and see how the two of them react together (of course, you can develop apps for the Edison using the Android IDE, but there are more powerful ways to do that…).
The hardware
I have to admit that I put together a very simple experiment very quickly, so nothing fancy here: I dug up a proto shield for Arduino that I prepared some time ago, with just a couple of LEDs and a couple of buttons, and I put them together on the Intel Edison and Arduino breakout board, which is basically a board that exposes some USB ports, a slot for the Edison itself, and a set of headers to connect Arduino shields.
The thing that took more time was updating the Edison firmware: it is as simple as download the files from the Intel Website and put them in a partition that appears when you connect the board to a computer, except for the fact that noone tells you that the partition should be formatted in FAT32 before doing that (by default it is FAT): if you don’t, when you connect to the board through the serial port and execute the update, Linux is not able to read the files and fails (by the way, they use Yocto, of course!).
XDK, IoT Edition
Anyway, once done that, I fired up the XDK: what Intel did was put together a C/C++ library that supports the usual hardware protocols (digital and analog I/O, SPI, PWM…), and they made a wrapper in Python and one in JavaScript, and this one is the one that the IDE uses: basically, you write an app using Node.JS, using any of the Node.JS libraries plus the one interfacing with the hardware, and then the IDE builds up the dependencies (whenever they need to be built) and packages them on the board. It supports deployment, start and stop from the IDE, and remote debugging (“remote” because the computer and the Edison communicate through a LAN, not through serial).
Now, I am quite new to Node.JS (i.e., it was the first time that I used it, since it is known that I consider JavaScript to be one of the worst languages ever), so what I did was take an existing template and play with it: the code that you see up there simply reads the status of the two buttons and updates the two LEDs according to which button is pressed (a standalone application, if you wish, that you can write as easily with the Arduino IDE). The “new” part is that it also fires up a Web server and creates a Websocket that periodically publishes the status of the buttons to whoever is connected to it. Starting the app, thus, means starting the standalone job and the Web server, that waits for anyone to connect to it.
The standalone part of the application was working (I did not make a video: it is too stupid as code to be worth it 🙂 ): it was time to find out how the smartphone counterpart works.
XDK, the smartphone counterpart
I started another existing template for smartphones, that was designed as a counterpart for another IoT template: basically, it shows a big grey circle and a text field, and it connects to the server that you specify on bootup, listening to the Websocket and updating the circle color and the text field whenever an update message arrives. The code is quite simple, and I made almost no modifications to the template: I maintained the same graphical layout and simply changed the message content that it receives from the Websocket (according to what I developed previously for the IoT app).
The editor part of the SDK is basically the same between the IoT and the smartphone parts: you are editing JavaScript in both cases. The smartphone part has several more tabs apart from the editor: first of all, the emulator. I am not sure but I think it uses the Intel virtualized capabilities of the hardware if available, or maybe it is only an emulator with HTML5 support: it was really fast to bootup (I am not sure because I was using it on Windows*, and I have no idea whether the virtualized capabilities are automatically started. I have not read much of the documentation for the XDK yet…); once started, it allows you to execute and debug an application, and see it using different graphical dispositions (the one in the screenshot is Nexus 4, but you have some Apple models and some Windows ones, plus others).
The IDE allows you to upload the app to the cloud and test it somehow: this is something I have to tried yet, so I cannot tell you much about it. If you don’t what to follow that route, you can simply test it on your devices: you need to install an Intel companion app that handles the communication with the XDK, and after that you can launch the execution on the device.
These are two screenshots that I took on my Nexus 5: the messages assume that someone is “knocking” by pressing the buttons on the shield connected to the Edison board. So it works! 🙂
Finally, you can build the APK: the XDK produces an ARM and an Intel version of the app, and you can download them and install them wherever you please, or put the in the various online markets. Of course, you can get the equivalents for iOS and Windows Phone (I have not tried, since I have no devices to try them).
Conclusions
All in all, the XDK is quite nice: it allows you to develop apps for IoT and smartphones using the same IDE, which for me is a very big plus. I found out the IDE to be a little unstable when moving from one app to the other, but then I installed an update and now it may be more stable (I found out about the update when I already finished my tests, so I have not tried it yet). I really need to explore more the Node.JS libraries on the IoT side and the JavaScript client libraries on the smartphone side (the XDK presents you with libraries for Facebook, Dropbox, Flickr, iTunes and much more, but I have no idea what they do or how they work), and also the Cordova API, that should allow the Web code to interact with the sensors inside the smartphone.
I have to say that I am quite interested in the idea of developing apps for all the smartphone OSes in one shot (yeah, I know is not a new idea…): as of today, I have only written native Android code, and I want to see what you can do using the HTML5 + JavaScript pair…