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

IoT – with and against – Android

IoT – with and against – Android

RunTastic’s Christianus Kaar is a prime example for the success of building hardware: he transformed his easy-to-intimidate firm into a powerhouse owned by Germany’s most powerful media company.
This story looks at the various ways an Android device can be made to communicate with real hardware.
Look forward to a demonstration of obscure and common techniques ranging from the use of the headphone output to Bluetooth LE, the ADK and a large variety of other ways to make real things go beep and boom.

droidcon Italy

May 17, 2016
Tweet

More Decks by droidcon Italy

Other Decks in Technology

Transcript

  1. What r u talking about? IoT for – and against

    – Android What can one say against Android? A lot...
  2. This is wrong - II • Android is huge •

    Android needs maintenance • Android is no RTOS • Data needs syncing
  3. Solution 1: go RT • Android can be expanded to

    be an RTOS • Be careful: huge level of effort Evaluating Android OS for Embedded Real-Time Systems Claudio Maia, Luıs Nogueira, Luıs Miguel Pinho RTDroid: A Design for Real-Time Android Yin Yan, Sree Harsha Konduri, Amit Kulkarni, Varun Anand, Steven Y. Ko, Lukasz Ziarek
  4. Don't play Ping-Pong! • Interconnects are slow – 112500bps •

    Awaiting confirmation defeats purpose – Yeah, the bridge will crash... – ...but the warning window hasn't popped up yet
  5. Be as lazy as you can • Sleep to save

    energy – Running CPU burns energy • Interrupt wake-up – Intelligent trigger logic is half of the game
  6. ADK?!? • First-gen phones could not act as USB host

    • ADK: “virtual host” – Pretends to be a computer – Takes MSR orders
  7. Just do it • USB Serial connection can be established

    • Connect hardware via USB OTG cable • Profit • A small hint: if it's mains powered – Charge the user's phone
  8. WiFi, GSM and friends They might not be 100% reliable

    They might not be 100% safe But you can bet your hide That they are already there
  9. TCP/IP is everywhere • Berkeley sockets • Native on many,

    if not most process computers • Native on Android • Already at your client's
  10. GSM can be cheap • A man walks into a

    store – Not the right way • Dedicated M2M or IoT operators – 1MB / 1 Euro – 3 Euro for SIM card set-up • Ask your carrier rep
  11. One Cable, Two Problems • Power over Ethernet – Less

    cabling effort • Both power and data
  12. Beware: power drain • ESP8266 needs 200mA • WiFi is

    not cheap energy-wise • WiFi can be “cluttered”
  13. Beware: sucky antennas • Raspberry Pi 3 – WiFi works

    barely (2m range) • Antenna design is not high priority
  14. Custom or ready? • + – Easy to hack together

    – Does what you need • - – Not proven – Must be implemented by hand • + – Linus Law – Ready • - – Not 100% custom – Simplifies reverse engineering (+???)
  15. Firmata • Text-oriented protocol • “Wiring over IP” • Wide-spread

    Wide-spread – I don't need to like it... I don't need to like it...
  16. What is Bluetooth • Frequency hopping short-range RF protocol •

    Relatively low power • Serial Port Profile == virtual socket • Available just about everywhere
  17. TAMHAN is B.A.D (c) • Solution: Annette Systems HesABadTam •

    Plays Snup Tok – Ana Si Sayed • Communicates via XML
  18. Request to Bluetooth SIG • Profile “Punishing device” • Yes,

    we're checking...sorry, but no... – SmellsLikeGinger (Zenzero) – Plays DJ Shadow – Organ Donor – Speaks CSV
  19. Bluetooth LE / Bluetooth Smart • Physically close to Bluetooth

    – Frequency hopping, etc • Different intentions – Intended for IoT – Energy saving – Low latency, “bursty transmissions” – Low complexity
  20. Normative things • Managed by Bluetooth SIG • @bluetooth_mdw Martin

    Wooley • Specs available for free: – https://www.bluetooth.org/en- us/specification/adopted-specifications
  21. Mind the GAP! • Generic Access Profile • Specifies device

    roles – PERIPHERAL: IoT-”Gadget”, passive – CENTRAL: Smartphone, etc
  22. I'm alive • Peripherals advertise their presence – Advertising Interval

    • Up to 31 Bytes of extra data • Optional: Scan Response Request – Central to Peripheral – Answering is possible
  23. I got a GATT! • Generic ATTribute profile – Used

    after connection establishment – One center per peripheral per time • “KV store” of Bluetooth LE – GATT Server: Peripheral, holds data – GATT Client: asks for data
  24. Profiles • Collection of KV storage schemata • If you

    want to build an X, better implement Y • https://developer.bluetooth.org/TechnologyOver view/Pages/Profiles.aspx#GATT
  25. Services • Schemata of KV storages • How do I

    store my data? • https://developer.bluetooth.org/gatt/services/Pa ges/ServicesHome.aspx
  26. “Serial Characteristics” • Simple Implementation – Popular in China •

    Characteristic 1: In • Characteristic 2: Out • Beware the packet length
  27. How to get started • Transistor, Diode and Antenna stay

    home – Friend wanted to implement BT 1.0 – Still working on it • Buy a module – Ask your local distributor
  28. How to get started - II • Electrical link –

    UART – SPI • AT-Commands – Smells like modem
  29. It is not easy but don't give up now It

    is not easy Happyness is an option
  30. Conclusion • Android is great for – Visualization tasks –

    Command and Control tasks – GUI tasks • Android sucks at – RT – HW control
  31. Conclusion - II • Process computers excel at – Controlling

    processes – Running Hardware – Adapting data flows
  32. Conclusion - III • Every job is different • Choose

    the right tool for the job – Amount of devices produced – Environment of existing devices – Needs of client
  33. What r u talking about? IoT for – and against

    – Android What can one say against Android? A lot... Send me the slides! [email protected]