interact your wearable and an iot device

31
Interact your Wearable and an IoT Device Jeff Prestes

Upload: jeff-prestes

Post on 16-Jul-2015

310 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Interact your wearable and an iot device

Interact your Wearable and an

IoT Device

Jeff Prestes

Page 2: Interact your wearable and an iot device

About me…

@jeffprestes

github.com/jeffprestes

slideshare.net/jeffprestes

Developer Advocate

Java, PHP, JavaScript,

Android Developer

Football fan,

father and IoT Researcher

Page 3: Interact your wearable and an iot device

This is not IoT… (IMHO)

so cool.. but this is Robotics!!

Page 4: Interact your wearable and an iot device

And this is not new…

(who has gray hair can say… P)

Page 5: Interact your wearable and an iot device

Billions of devices, sensors, including mobile phones...

connected and exchanging data.

Page 6: Interact your wearable and an iot device

Server Side

Electronic(sometimes mechanic

and sculptor on wood or iron)

Client/Desktop

Mobile(Beacons e Weareables)

Operation Systems

Page 7: Interact your wearable and an iot device

Italian Polymath. What was da Vinci? Scientist?

Engineer? Mathematic? Painter? Sculptor?

Musician? Botanic? Anatomist?

Source: Wikipedia - http://en.wikipedia.org/wiki/Leonardo_da_Vinci

Could IoT bring us a broad vision

of Technology?

No more specialists…

But new Polymath Developers

Page 8: Interact your wearable and an iot device

Single Board Computers

Page 9: Interact your wearable and an iot device
Page 10: Interact your wearable and an iot device

Voice input data Vibrating Heart rate

Main Smart Watches Capabilities

from IoT Integration perspective

Page 11: Interact your wearable and an iot device

Help blind and handicap people to

perform simple tasks

Help people to get environment

important alerts

Makes some simple tasks faster and fun like to

do payments

Possibilities ?

What else?

Page 12: Interact your wearable and an iot device

Options to exchange data between

smartphone and IoT Device

Page 13: Interact your wearable and an iot device

✔ Serial, easy, syncronized and realiable

✖ Tight to one device and need to pair to each new Device

Bluetooth

Page 14: Interact your wearable and an iot device

✔ Fast and strait-forward

✖ Verbose, complex and few reliable

Socket

Page 15: Interact your wearable and an iot device

✔ Soft, reliable, bi-directional, simple

development, convenient (no pairing needed)

✖ No instantaneous

Message Queue via TCP

Page 16: Interact your wearable and an iot device

MQ Telemetry Transport is a light-weight

publish/subscribe messaging protocol

created by IBM and Arcon (Eurotech)

it’s an open standard! the most used one!

best to:

~ Where the network is expensive, has low bandwidth or is unreliable

~ When running on an embedded device with limited processor or

memory resources

Page 17: Interact your wearable and an iot device

Open a topic

Publish:

“It’s burning”

Subscribe

Receives

How it would works…

A Real Example for MQTT

Page 18: Interact your wearable and an iot device

Meteorologist project

in the UK

Page 19: Interact your wearable and an iot device

Now let’s get started to talk about good things…

Page 20: Interact your wearable and an iot device
Page 21: Interact your wearable and an iot device

Demo

Page 22: Interact your wearable and an iot device

How it works…

Page 23: Interact your wearable and an iot device

Watch purchase sequence screenshots

Notification

Action

Processing

Processs is done

Page 24: Interact your wearable and an iot device

GoogleApiClient mGoogleClient= new GoogleApiClient.Builder(this)

.addApi(Wearable.API)

.build();

ConnectionResult connectionResult =

mGoogleClient.blockingConnect(30, TimeUnit.SECONDS);

if (!connectionResult.isSuccess()) {

Log.e(TAG, "Failed to connect to GoogleApiClient.");

return;

}

PutDataMapRequest putDataMapRequest = PutDataMapRequest.create("/new/candies/beacon");

putDataMapRequest.getDataMap().putLong("DataStamp", System.currentTimeMillis());

putDataMapRequest.getDataMap().putString("content", message);

try {

Wearable.DataApi.putDataItem(mGoogleClient, putDataMapRequest.asPutDataRequest());

} catch (Exception ex) {

Log.e(Util.class.getSimpleName(), "Error when send message to watch", ex);

}

Smart Watch and PhoneThey need to exchange data via message service

Code for the phone

Page 25: Interact your wearable and an iot device

public void onDataChanged(DataEventBuffer dataEvents) {

//super.onDataChanged(dataEvents);

setUpGoogleClientIfNeeded();

for(DataEvent event : dataEvents) {

if(event.getType() == DataEvent.TYPE_CHANGED) {

String message = Util.extractMessage(event,"/new/candies/beacon");

if(message != null && !Util.isForeground(getApplicationContext(), ”br.com.novatrix.candies")) {

Log.d(TAG, message);

Uri uri = Uri.parse(message);

Util.dispatchNotification(getApplicationContext(), uri);

return;

}

message = Util.extractMessage(event, "/candies/notification");

if(message != null && message.equalsIgnoreCase("cancel")) {

Util.cancelNotification(getApplicationContext());

}

}

}

}

Smart Watch and Mobile PhoneThey need to exchange data via message service

Code for the watch

Page 26: Interact your wearable and an iot device

provides open source MQTT clients in several languages

(C for embedded, C++, Go, Java, Android, JavaScript, Python)

http://www.eclipse.org/paho/

under iot.eclipse.org project

sandbox available at: iot.eclipse.org:1883

Page 27: Interact your wearable and an iot device

String topic = "jeffprestes/candies/world";

int qos = 2;

String broker = ”iot.eclipse.org";

String clientId = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

String port = "1883";

String queueUrl = "tcp://" + this.broker + ":" + this.port;

MemoryPersistence persistence = new MemoryPersistence();

client = new MqttClient(queueUrl, clientId, persistence);

IMqttToken conToken = client.connect(connOpts);

client.subscribe(TOPIC, 1);

Connecting to MQTT Server

Page 28: Interact your wearable and an iot device

String msgToMachine = "alive"

MqttMessage message = new MqttMessage(msgToMachine.getBytes());

message.setQos(qos);

try {

client.publish(topic, message);

} catch(MqttException e) {

Log.e("PublishingMQTT", e.getLocalizedMessage(), e)

}

Posting a message at queue

Page 29: Interact your wearable and an iot device

Electronic Schema

Page 30: Interact your wearable and an iot device
Page 31: Interact your wearable and an iot device

Thanks.

Jeff Prestes

@jeffprestes

Slideshare.com/jeffprestes

Github.com/jeffprestes

@braintree_dev

developer.paypal.com

developers.braintreepayments.com