Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Control your Embedded Linux remotely by using M...

Arduino
December 04, 2018

Control your Embedded Linux remotely by using MQTT and a web interface

To manage remotely your IoT device without knowing the IP address of the device we used MQTT and a set of custom go libraries. With this architecture Arduino Create Agent allows users to deploy container remotely. A journey on Docker client, APT command line, sockets, systemd and much more on Arm and Intel Linux devices.

Arduino

December 04, 2018
Tweet

More Decks by Arduino

Other Decks in Technology

Transcript

  1. 2 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT ABOUT ME LUCA CIPRIANI CIO, ARDUINO @MASTROLINUX
  2. 4 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT ARDUINO - KNOWN FOR MICROCONTROLLERS MKR FOX 1200 MKR WAN 1300 MKR GSM 1400 MKR NB 1500 MKR WIFI 1010 MKR ETH SHIELD MKR1000
  3. 6 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT USE CASE Give users a quick and easy web interface to • Check the status of the system • Configure networking • Install packages • Deploy apps/containers, Arduino Sketches
  4. 7 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT CONTROL LINUX FROM THE WEB • Old problem, Old solutions • HTTPS is hard to achieve • Bi-directional communication • Work on most network topologies • Create a web server, contact it via http • Cannot have HTTPS unless domain name is registered and IP address is static/known • UDP port are often closed
  5. 8 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT KNOWN SOLUTIONS DID NOT FIT USE CASE Here is a random list • Ubuntu Landscape • Zentyal • Ajenti • Webmin • Others
  6. 9 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT LANDSCAPE - DO NOT BE OVERKILL We do not want to store users’ data unless needed or with big advantages for both users and us. We do not want to deal with state synchronization. Scaling is really expensive!
  7. 11 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT ZENTIAL - OUR TARGET ARE NOT SMB You have to control a Raspberry, not a small office, do you really need a whole OS?
  8. 13 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT AJENTI - GOOD PRODUCT BUT STILL WEB SERVER They have a nice, well designed product but has the same issues we mentioned already. HTTP server based system!
  9. 15 Remote Control of IoT Linux Devices | LinuxLab 2018

    - Firenze, IT ARDUINO CONNECTOR FEATURES One single binary ~20MB (no external deps) 01 Works on every Debian-like Linux distros 02 Works on slow connections 05 No need to know the IP in advance 06 Secure only connections 03 MQTT (Stable TCP socket with the remote server) 04
  10. 16 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT MQTT is: • Well known • Widely used • Feature complete • Simple enough • Bi-directional I like AMQP more ;)
  11. 17 Remote Control of IoT Linux Devices | LinuxLab 2018

    - Firenze, IT SERVER SIDE WHAT YOU NEED MQTT Server 01 SSL Support 02 MQTT over Websocket (optional) 05 MQTT Client 03 Oauth2 server (optional) 04
  12. 18 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT SHOW ME THE CODE Go Language runs on: arm v5, v6, v7 arm64 v8 x86 x86_64 Public repo: https://github.com/arduino /arduino-connector
  13. 19 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT {} --> $aws/things/{{id}}/stats/post INFO: { "memory":{ "FreeMem":1317964, "TotalMem":15859984, "AvailableMem":8184204, "Buffers":757412, "Cached":6569888, "FreeSwapMem":0, "TotalSwapMem":0 }, <-- $aws/things/{{id}}/stats EXAMPLE API {} --> $aws/things/{{id}}/apt/list/post INFO: {"packages":[ {"Name":"firefox","Status":"upgradable"," Architecture":"amd64","Version":"57.0.3+b uild1-0ubuntu0.17.10.1"}, ...], "page":0,"pages":1} <-- $aws/things/{{id}}/apt/list
  14. 20 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT Use /proc Luke! And remember, everything is a file in Linux We released https://github.com/arduino/go-system-stats STATS API
  15. 21 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT APT integration is dummy, APT lib api are in C++ only and nearly impossible to integrate with Go, so we used the CLI as an API We released https://github.com/arduino/go-apt-client/ A combination of dpkg + apt commands wrapped in an API Supports managing repos APT INTEGRATION
  16. 23 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT NetworkManager has stable API (0.98 is really stable) We released https://github.com/arduino/gonetworkmanager You can add ETH or WiFi networks NETWORK MANAGER INTEGRATION
  17. 25 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT We install docker if not previously installed and if target supports it. Docker Go APIs are really easy to manage (imagine why) Works with private registry Runs on huge servers (we tried with Intel Data Center with 64 core CPU) And Small devices (like Beaglebone Black and Raspberry Pi) DOCKER INTEGRATION
  18. 27 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT We can run Arduino compiled code directly as a Linux binary Integrations with all Hardware sensors and GPIO is provided by the MRAA library https://github.com/intel-iot-devkit/mraa ARDUINO INTEGRATION
  19. 28 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT Support for all Debian Based devices. Porting to other OS is simple.
  20. 29 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT Communicate with the hardware directly from Arduino to Linux API and vice-versa
  21. 30 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT Run Shell commands in Arduino and manage hardware directly https://create.arduino.cc/projecthub/Arduino_Genuino/arduino-linux-on- up2-board-with-intel-mraa-a30f87
  22. 32 Remote Control of IoT Linux Devices | LinuxLab2018 -

    Firenze, IT Let’s give it a try! https://create.arduino.cc