The large and vibrant community of Android developers can now leverage all the libraries, services and knowledge to move from mobile towards the IoT world. The key for success is that even the existing code could be shared in the same project to target mobile, wearables and now embedded boards. This talk will explain what Android Things is and many of its features, giving some practical example on how to integrate code for mobile platform.
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni Di Gialluca - Codemotion Rome 2018
1. Android Things,
from mobile apps to physical world
Stefano Sanna
ROME - APRIL 13/14 2018
Giovanni Di Gialluca
2. OUTLINE
• Android State Of The Nation and (quick) history
• Android Things in one slide
• Hardware and software: board and firmware
• Environment: who’s in, who’s out
• Hello Android Things!
• Setup of a project
• Overview of Android Things API
• Merging Mobile & IoT
• Vision and greetings
13. Environment
• Same architecture
• Same IDE (Android Studio)
• Same programming languages
• Same framework
• Same app (Activity) lifecycle
• Same UI widgets (UI?)
• Same application packaging
• Same reliable security for apps and firmware upgrade
• Same passionate community
14. Android vs Android Things: IN & OUT
Cast
Drive
Firebase Analytics
Firebase Cloud Messaging
Firebase Realtime Database
Firebase Remote Config
Firebase Storage
Fit
Instance ID
Location
Nearby
Places
Mobile Vision
CalendarContract
ContactsContract
DocumentsContract
DownloadManager
MediaStore
Settings
Telephony
UserDictionary
VoicemailContract
AdMob
Android Pay
Firebase Authentication, Links, Invites…
Maps
Play Games
Search
Sign-In
16. Supported board
NXP Pico i.MX7D NXP Pico i.MX6UL Raspberry Pi3 Model B
PRICE $64 $43 $22
SDK PRICE $79 $69 $22
CPU 1 GHz dual-core ARM 500Mhz ARM 1.2GHz quad-core ARM
RAM 512MB 512MB 1GB
STORAGE 4GB eMMC 4GB eMMC microSD
GPU NO NO Videocore
CAMERA CSI-2 NO CSI-2
AUDIO Analog Analog USB 2.0 + Analog
NET Ethernet, WiFi ac, BT 4.1 Ethernet, WiFi n, BT 4.1 Ethernet, WiFi n, BT 4.1
USB USB 2.0 HOST + 2x OTG 2x USB 2.0 OTG 4x USB 2.0 HOST
GPIO 7x UART, 4x I2C, 4x SPI, 2x
CAN, misc GPIO
8x UART, 4x I2C, 4x SPI, misc 48
GPIO
2x UART, 2x I2C, 2x SPI, up to 26
GPIO
17. Raspberry Pi3 Model B
• Damn cheap!
• Good performances.
• Ethernet + WiFi
• HDMI + Camera
• Lot of extension boards and kits: AI+VR+IoT!
• You’ll never brick it: different configurations can be tested
just swapping the SD. No eMMC.
• Warning: no ADB via USB, a network is strictly required
23. Device updates
An UpdateManager utility
class provides a easy way
for the Android Things
board to check if there is a
new update
24. Device updates
Using the Console, you can easily create new product
releases based on new Android Things versions or new app
versions or both and push them to devices already deployed
29. Things Support Library
GPIO
PWM
I2C
SPI
I2S
Single-PIN analog/digital I/O
Serial
UART
Pulse-Width-Modulation to control servo
Slow serial bus for sensors
Fast serial bus for boards interconnection
Point-to-Point serial port
Serial bus for audio streaming
30. Driver Library
From Hardware specs to interface
• By Google
https://github.com/androidthings/contrib-drivers
• By Intel
https://github.com/intel-iot-devkit/android-things-samples
• By us
https://github.com/giovannidg/androidthingsdrivers
https://github.com/gerdavax/BrickPi3_AndroidThings
31. Change settings programmatically
• ScreenManager
• Brightness,
• Orientation
• TimeManager
• Time format
• Time zone
• Time auto update
• DeviceManager
• Factory reset
• Set system locales
• Reboot
adb shell reboot –p
unplug the power cord is not polite
35. Mobile
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
......
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean managed = MyKeyCodes.manageKeyCode(keyCode);
if (managed) return true;
return super.onKeyDown(keyCode, event);
}
}
36. keycodelib
public class MyKeyCodes {
public static final int VOLUME_UP_KEY = KeyEvent.KEYCODE_VOLUME_UP;
/**
* @param keyCode
* @return true if the event was managed
*/
public static boolean manageKeyCode(int keyCode) {
if (keyCode == VOLUME_UP_KEY) {
Log.d("KEY_LOG", “Ring the bell");
return true; // indicate we handled the event
}
return false;
}
}
37. Things
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
mInputDriver = new ButtonInputDriver("BCM4",
Button.LogicState.PRESSED_WHEN_LOW,
MyKeyCodes.VOLUME_UP_KEY// the keycode to send
);
mInputDriver.register();
} catch (IOException e) { } // error configuring button...
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean managed = MyKeyCodes.manageKeyCode(keyCode);
if (managed) return true;
return super.onKeyDown(keyCode, event);
}
39. Tensor Flow
OpenSource library for Machine Learning
§ Developed by Google,
Available For every OS
§ a computational graph is a series of
tensorflow operation (nodes), each EDGE is
a multidimensional data called Tensor
§ Public neural network pre-trained with one
million of images, or you can train your
neural Network with a provided pythOn
library
§ Neural network model for image
recognition called “Inception“ with 1000
categories
40. BrikPi + Tensorflow
§ SPI to control
motors and sensors
§ TensorFlow for
object recognition
41. BrikPi
Raspberry Pi3 extension module with:
§ 4 Mindstorms NXT/EV3 Motor ports
§ 4 Mindstorms NXT/EV3 Sensor ports
§ Extra I2C sensor bus
§ SPI interface to Raspberry Pi3
§ Uniform request/response binary protocol
§ Seamless power management (internal, external, both)
43. Android Things
Giovanni Di Gialluca
giovanni.digialluca@gmail.com
https://github.com/giovannidg
www.linkedin.com/in/giovanni-di-gialluca
Stefano «gerdavax» Sanna
gerdavax@gmail.com
@gerdavax
https://www.linkedin.com/in/gerdavax