interact your wearable and an iot device

Post on 16-Jul-2015

310 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Interact your Wearable and an

IoT Device

Jeff Prestes

About me…

@jeffprestes

github.com/jeffprestes

slideshare.net/jeffprestes

Developer Advocate

Java, PHP, JavaScript,

Android Developer

Football fan,

father and IoT Researcher

This is not IoT… (IMHO)

so cool.. but this is Robotics!!

And this is not new…

(who has gray hair can say… P)

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

connected and exchanging data.

Server Side

Electronic(sometimes mechanic

and sculptor on wood or iron)

Client/Desktop

Mobile(Beacons e Weareables)

Operation Systems

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

Single Board Computers

Voice input data Vibrating Heart rate

Main Smart Watches Capabilities

from IoT Integration perspective

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?

Options to exchange data between

smartphone and IoT Device

✔ Serial, easy, syncronized and realiable

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

Bluetooth

✔ Fast and strait-forward

✖ Verbose, complex and few reliable

Socket

✔ Soft, reliable, bi-directional, simple

development, convenient (no pairing needed)

✖ No instantaneous

Message Queue via TCP

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

Open a topic

Publish:

“It’s burning”

Subscribe

Receives

How it would works…

A Real Example for MQTT

Meteorologist project

in the UK

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

Demo

How it works…

Watch purchase sequence screenshots

Notification

Action

Processing

Processs is done

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

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

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

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

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

Electronic Schema

Thanks.

Jeff Prestes

@jeffprestes

Slideshare.com/jeffprestes

Github.com/jeffprestes

@braintree_dev

developer.paypal.com

developers.braintreepayments.com

top related