SlideShare una empresa de Scribd logo
1 de 23
GDG LAb IoT
Antonino Orlando
orlando.antonino@gmail.com
Simone Pulcini
simone.pulcini@gmail.com
e il team GDG Roma L-Ab

DroidCon – 7 Febbraio 2014

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

1
Antonino Orlando
●

orlando.antonino@gmail.com

●

http://it.linkedin.com/in/orlandoantonino

●

https://plus.google.com/+AntoninoOrlando

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

2
Simone Pulcini
●

simone.pulcini@gmail.com

●

http://www.linkedin.com/in/simonepulcini

●

https://plus.google.com/+SimonePulcini

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

3
GDG LAb IoT

obiettivo:

trasmettere concetti e tecniche per utilizzare Android nel
magico mondo di IOT
Le cose possono imparare a parlare e identificarsi.

Indossando dei piccoli circuiti a radiofrequenza, e
avvicinandoli a un dispositivo dotato di NFC ricevono
l'energia per parlare ed ascoltare.
Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

4
GDG LAb IoT
Android è capace di recepire questi
messaggi per poi comunicare con
dei Server attraverso

i servizi Google Cloud Messaging, messi a disposizione
gratuitamente da Google.
E' quello che succede ai concerti oppure per i pagamenti
elettronici.

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

5
GDG LAb IoT
Nel Workshop esploreremo le principali
tecniche per creare un sistema semplice,

ma completo, per l'identificazione/controllo
di oggetti e quindi la gestione con ogni tipo di applicativi.

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

6
GDG LAb IoT
Il codice che ci verrà messo a disposizione
conterrà anche la logica per utilizzare servizi

REST con Google App Engine.
E' importante sottolineare che con questo CodeLab cerchiamo
di far comprendere come integrare e far interoperare
tecniche e sistemi diversi

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

7
Google Cloud Messaging
- invio di messaggi push
Richiede:

- Android 2.2 o superiore;
- Google Play Store installato;
- L'utente deve avere almeno un profilo
Google configurato (per versioni < 4.0.4);
- Payload dal server alle app limitato (~4K).

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

8
Near Field Communication

- RFID (Radio Frequency Identification)
- permette una comunicazione bidirezionale: entro un raggio
di 4 cm
- opera alla frequenza di 13,56 MHz e può raggiungere una
velocità di trasmissione massima di 424 kbit/s.

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

9
Registrazione GCM

hello

Registration ID

Store my reg_id

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

10
Invio di una notifica

forward a push notification

Send a notification to reg_id

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

11
GDG Lab IoT

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

12
Prima di cominciare
- installare ADT Bundle
- Google Play Services (da Android SDK Extras)
- Android Support Library (da Android SDK Extras)

- webserver (apache) + php
- registrare account Google Developers Console
https://code.google.com/apis/console

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

13
Progetti di base
- SendByNFC
https://github.com/orlando-antonino/SendByNFC.git

- GDGLAb_IoT
https://github.com/orlando-antonino/GdgLAb_IoT.git
- Backend AppEngine
https://github.com/spulci/gdg_rome/tree/master/GdgRomeI
OTDemoModel
Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

14
Let's start!

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

15
Backend su Google App Engine
●

Sogno un backend……

●

●

●

●

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

PaaS (Platform as a Service)

Piattaforma Enterprise
scalabile
Ospita applicazioni in
Java, Php, GO
Una server farm a portata
di clic

16
GAE: dietro le quinte
●

GAE: è un servlet container basato su Jetty

●

Supporta le servlet 2.5

●

●

Supporta diversi framework noti (talvolta con alcuni
workaround): JPA, JDO, JSF, Struts 1, Struts 2, Spring…..
Ma il vero punto di forza è lo «scaling automatico» in base
al traffico generato

●

Gratuito fino a determinati livelli di traffico

●

SLA per i servizi billed in high replication del 99,5%

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

17
JPA: Overview
●

●

●

●

●

Java Persistence API 2.0 (specifica JSR 317)
Mapping di POJO verso un database (Object Relational
Mapping)
Entity: pojo che mappano tabelle di db. Il mapping è
definito tramite annotazioni
Pojo persistenti: pojo il cui stato (valori assegnati alle
proprietà) è memorizzato in un database e tenuto in
sincrono con questo
EntityManager: classe deputata alle operazioni di
persistenza tra pojo e db

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

18
Google Cloud Endpoint
●

●

Sono Web-Services REST che non seguono le
implementazioni ufficiali di Java EE (Java API for RESTful
Web Services JAX-RS)
Sono facili da implementare. Le interfacce esposte si
specificano con annotazioni

4 step:
a)

Crea le API

b)

Annota le API

c)

Genera il codice per il client chiamante

d)

Incorpora il codice generato nel chiamante (e.g. Android
app)

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

19
App Engine Admin Console
●

https://appengine.google.com/

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

20
Best practicies
●

●

●

●

Loggate sempre in modo intelligente usando log levels
adeguati (in esercizio il vostro backend «parla» attraverso il
log!)
Usate enterprise patterns adeguati per evitare di mandare
in sofferenza la vostra infrastruttura

Fate un decoupling elevato della vostra business logic (es:
gli endpoint mostrati sono solo wrappers!!!)
Col tempo e l’esperienza pensate sempre ai vari trade-off
da pagare utilizzando alcuni servizi

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

21
Datastore GAE: JPA 2.0
●

Schemaless

●

Transazioni (supportate) atomiche

●

Alta disponibilità

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

22
Riferimenti
●

●

●

https://developers.google.com/appengine
http://www.radioelectronics.com/info/wireless/nfc/near-fieldcommunications-tags-types.php

http://developer.android.com/google/gcm/in
dex.html

Antonino Orlando, Simone Pulcini e GDG
Roma L-AB

23

Más contenido relacionado

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

IOT su Android con l'aiuto del Google Cloud Messaging

  • 1. GDG LAb IoT Antonino Orlando orlando.antonino@gmail.com Simone Pulcini simone.pulcini@gmail.com e il team GDG Roma L-Ab DroidCon – 7 Febbraio 2014 Antonino Orlando, Simone Pulcini e GDG Roma L-AB 1
  • 4. GDG LAb IoT obiettivo: trasmettere concetti e tecniche per utilizzare Android nel magico mondo di IOT Le cose possono imparare a parlare e identificarsi. Indossando dei piccoli circuiti a radiofrequenza, e avvicinandoli a un dispositivo dotato di NFC ricevono l'energia per parlare ed ascoltare. Antonino Orlando, Simone Pulcini e GDG Roma L-AB 4
  • 5. GDG LAb IoT Android è capace di recepire questi messaggi per poi comunicare con dei Server attraverso i servizi Google Cloud Messaging, messi a disposizione gratuitamente da Google. E' quello che succede ai concerti oppure per i pagamenti elettronici. Antonino Orlando, Simone Pulcini e GDG Roma L-AB 5
  • 6. GDG LAb IoT Nel Workshop esploreremo le principali tecniche per creare un sistema semplice, ma completo, per l'identificazione/controllo di oggetti e quindi la gestione con ogni tipo di applicativi. Antonino Orlando, Simone Pulcini e GDG Roma L-AB 6
  • 7. GDG LAb IoT Il codice che ci verrà messo a disposizione conterrà anche la logica per utilizzare servizi REST con Google App Engine. E' importante sottolineare che con questo CodeLab cerchiamo di far comprendere come integrare e far interoperare tecniche e sistemi diversi Antonino Orlando, Simone Pulcini e GDG Roma L-AB 7
  • 8. Google Cloud Messaging - invio di messaggi push Richiede: - Android 2.2 o superiore; - Google Play Store installato; - L'utente deve avere almeno un profilo Google configurato (per versioni < 4.0.4); - Payload dal server alle app limitato (~4K). Antonino Orlando, Simone Pulcini e GDG Roma L-AB 8
  • 9. Near Field Communication - RFID (Radio Frequency Identification) - permette una comunicazione bidirezionale: entro un raggio di 4 cm - opera alla frequenza di 13,56 MHz e può raggiungere una velocità di trasmissione massima di 424 kbit/s. Antonino Orlando, Simone Pulcini e GDG Roma L-AB 9
  • 10. Registrazione GCM hello Registration ID Store my reg_id Antonino Orlando, Simone Pulcini e GDG Roma L-AB 10
  • 11. Invio di una notifica forward a push notification Send a notification to reg_id Antonino Orlando, Simone Pulcini e GDG Roma L-AB 11
  • 12. GDG Lab IoT Antonino Orlando, Simone Pulcini e GDG Roma L-AB 12
  • 13. Prima di cominciare - installare ADT Bundle - Google Play Services (da Android SDK Extras) - Android Support Library (da Android SDK Extras) - webserver (apache) + php - registrare account Google Developers Console https://code.google.com/apis/console Antonino Orlando, Simone Pulcini e GDG Roma L-AB 13
  • 14. Progetti di base - SendByNFC https://github.com/orlando-antonino/SendByNFC.git - GDGLAb_IoT https://github.com/orlando-antonino/GdgLAb_IoT.git - Backend AppEngine https://github.com/spulci/gdg_rome/tree/master/GdgRomeI OTDemoModel Antonino Orlando, Simone Pulcini e GDG Roma L-AB 14
  • 15. Let's start! Antonino Orlando, Simone Pulcini e GDG Roma L-AB 15
  • 16. Backend su Google App Engine ● Sogno un backend…… ● ● ● ● Antonino Orlando, Simone Pulcini e GDG Roma L-AB PaaS (Platform as a Service) Piattaforma Enterprise scalabile Ospita applicazioni in Java, Php, GO Una server farm a portata di clic 16
  • 17. GAE: dietro le quinte ● GAE: è un servlet container basato su Jetty ● Supporta le servlet 2.5 ● ● Supporta diversi framework noti (talvolta con alcuni workaround): JPA, JDO, JSF, Struts 1, Struts 2, Spring….. Ma il vero punto di forza è lo «scaling automatico» in base al traffico generato ● Gratuito fino a determinati livelli di traffico ● SLA per i servizi billed in high replication del 99,5% Antonino Orlando, Simone Pulcini e GDG Roma L-AB 17
  • 18. JPA: Overview ● ● ● ● ● Java Persistence API 2.0 (specifica JSR 317) Mapping di POJO verso un database (Object Relational Mapping) Entity: pojo che mappano tabelle di db. Il mapping è definito tramite annotazioni Pojo persistenti: pojo il cui stato (valori assegnati alle proprietà) è memorizzato in un database e tenuto in sincrono con questo EntityManager: classe deputata alle operazioni di persistenza tra pojo e db Antonino Orlando, Simone Pulcini e GDG Roma L-AB 18
  • 19. Google Cloud Endpoint ● ● Sono Web-Services REST che non seguono le implementazioni ufficiali di Java EE (Java API for RESTful Web Services JAX-RS) Sono facili da implementare. Le interfacce esposte si specificano con annotazioni 4 step: a) Crea le API b) Annota le API c) Genera il codice per il client chiamante d) Incorpora il codice generato nel chiamante (e.g. Android app) Antonino Orlando, Simone Pulcini e GDG Roma L-AB 19
  • 20. App Engine Admin Console ● https://appengine.google.com/ Antonino Orlando, Simone Pulcini e GDG Roma L-AB 20
  • 21. Best practicies ● ● ● ● Loggate sempre in modo intelligente usando log levels adeguati (in esercizio il vostro backend «parla» attraverso il log!) Usate enterprise patterns adeguati per evitare di mandare in sofferenza la vostra infrastruttura Fate un decoupling elevato della vostra business logic (es: gli endpoint mostrati sono solo wrappers!!!) Col tempo e l’esperienza pensate sempre ai vari trade-off da pagare utilizzando alcuni servizi Antonino Orlando, Simone Pulcini e GDG Roma L-AB 21
  • 22. Datastore GAE: JPA 2.0 ● Schemaless ● Transazioni (supportate) atomiche ● Alta disponibilità Antonino Orlando, Simone Pulcini e GDG Roma L-AB 22