sami - samsung developer conference - nov 2014

49
© 2014 Samsung Developer Conference. All rights reserved. www.samsungdevcon.com SAMI Ecosystem & APIs Jerome Dubreuil – Dan Serfaty

Upload: jerome-dubreuil

Post on 13-Apr-2017

273 views

Category:

Internet


0 download

TRANSCRIPT

FileNewTemplate

SAMIEcosystem & APIs

Jerome Dubreuil Dan Serfaty

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Welcome to the SAMI talk. Today were going to present SAMI and what it means to developers and users.1

Brief history

About usPast lives in startups and big companiesEarly fans of cloud technologies and platforms connecting devices

About SAMIStarted 2013Clean slate, no legacyFocus on developer and ecosystem from day 1Mindset of a startup, strength and maturity of the enterprise

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Before we start, lets talk about history a little bit.

!! be more personal

2

Why?

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Why are we here? In just a few years, most of us will have dozens if not hundred of connected devices. Health, SmartHome, Cars, Gadgets, etc.Number of connected devices will be staggeringSo:-To prepare for this world-To create REAL value for the users=> WE the developers need change our approach, we need to understand a fundamental thing

3

Everything is data

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

E-V-E-R-Y-T-H-I-N-GAnd for that:-We need to adopt a new mindset-We need A NEW PARADIGM

4

A new paradigm

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Were INTRODUCING SAMI for this new paradigm5

A new paradigm

Digitalize and abstract the physical worldAny device, any dataNo silo, unlimited data fusion

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Everything is data = today theres a lot of data. Tomorrow: orders of magnitude moreAny device: this is critical. Fully device & data agnosticBreak silos = true iot and data-based health will only work if there are no silos. 6

A new paradigm

Fully openAny device can connect, send + receive dataAny application can access user dataFull privacy control

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Open = any device, any data, any applicationAny application = UI, data analysis, anything

7

Data Driven Development

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

DDD is an emerging concept

8

You focus on the device and the applications

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

9

SAMI takes care of the data

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

10

A very simple use case

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Big things always start with a small stepso lets imagine a SIMPLE EXAMPLE

11

AppLive monitoringHistorical Graphs

A very simple use caseUse case: multiple sensors in a house65,60,60067,80,65072,62,63065,62,602{ temp:65, noise: 60, co2: 600}Format: CSV, every minuteTemp: 65F, Noise: 60dbCO2: 600 ppm Bedroom Room 1KitchenLiving RoomBedroom Room 2

}

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

12

The developer experience

Create a Device Type

Create an applicationdeveloper.samsungsami.io

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Explain the agenda of the prez with regards to that graphic

13

DevicesConnecting devices to SAMI

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Time check=6

14

Whats a device in SAMI?A device is any registered node that can send and receive data using the SAMI platform

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

A device is any source of data that needs to input it into SAMI or receive messages form the platform. In our example, this would be an instance of the new home sensor we are developing.15

Whats a device type?A device type describes a class of devices and the data it is sendingA device type has a Manifest that:Describes the data coming inProcesses incoming data in real-timeNormalizes data for SAMI

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

A device type is how we define the class of devices that will be used to create multiple instances of our home sensor. It is necessary to define it before any real devices can send data.This is done using a Manifest, that is an essential part of defining a new Device Type. The Manifest is a contract that the creator of the device will implement.The manifest defines what the data going into SAMI is, and how to generate that data based on what the device will send (input data format, json, xml, etc)Normalizes: will be explained in a few slides16

Creating a Device Type and a Manifest

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

So let me quickly show you what our developer web site looks like when you want to create a new device type.You specify a name (Display name), a unique name (this is akin to a package name, or a group id in maven). It identifies the device type in a human readable way and can be used with our api calls to reference that device type.And finally the content of the manifest. We will see later what goes in that box.17

Creating a Device Type and a ManifestBefore submitting, develop your Manifest locally in an IDE using tools available on the developer portal:Manifest SDK (download)Documentation, samples, tutorial

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

So - don't click OK yet here... Before we submit our manifest we should actually have developed it locally.How?In your preferred IDE, using the tools we provide on our developer portal.Those include:- a manifest SDK (that you can use to check your manifest for compilation errors, to build unit tests, or simply try a manifest on the command line)- A comprehensive documentation, tutorials, examples18

The ManifestTransforms any input data into normalized output dataOutput data are fields (can be nested):NameType (bool, integer, long, floats, double, string, collections)Unit (allows some level of conversion)Today, full power of a Groovy script, with approvalTomorrow: simplified version, no approval

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

The ManifestIs a contract you implement. It:- transforms any input data into normalized output data. So you could have csv, json, xml, base 64 encoded binary, etc. as long as it can be expressed as an input string that your manifest can understand.- the output data are called fields and - they have a name / identifier (e.g: temp) - a type, we support the basic types you are used to, and collections of those types - a unit, most units should be available SI and non SI and you can create new units if neededToday we offer the full power of a Groovy script. Why Groovy? Its a very simple and popular, scripting language so anyone can pick it up quickly and it allows you to read and transform any data using the full power of a programming language. The scripts have to be approved before they can run on SAMI, the approval is about making sure that the code is safe.Tomorrow, we plan to offer a simplified version that require no approval for cases that require very little processing of the incoming data.19

The Manifest

import com.samsung.sami.manifest.Manifestimport com.samsung.sami.manifest.fields.*import static com.samsung.sami.manifest.fields.StandardFields.*

import javax.measure.unit.NonSI

public class MyDeviceManifest implements Manifest {

public final static FieldDescriptor TEMP_INTEGER = TEMPERATURE.alias(Integer.class) public final static FieldDescriptor NOISE = new FieldDescriptor("noise", NonSI.DECIBEL, Integer.class); public final static FieldDescriptor CO2 = new FieldDescriptor("co2", StandardUnits.PARTS_PER_MILLION, Integer.class);

@Override List normalize(String input) { def fields = [] def values = input.split(",") def tempInF = values[0].asType(Integer.class) def noise = values[1].asType(Integer.class) def co2 = values[2].asType(Integer.class)

fields.add(new Field(TEMP_INTEGER, NonSI.FAHRENHEIT, tempInF)) fields.add(new Field(NOISE, noise)) fields.add(new Field(CO2, co2))

return fields }

@Override List getFieldDescriptors() { return [TEMP_INTEGER, NOISE, CO2] }}

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Lets take a more detailed look at a Manifest:Overview first - 3 main parts:- Declaration: imports, implement Manifest, field descriptors (coming back to it later)normalize() method, processes and transforms the datagetFieldDescriptors: describes the data coming out

Then dive in more details in each section.Explain field descriptor: types, unitsExplain getFieldDescriptors returning a list of FDExplain normalize method, parsing CSV, creating field instances, using the unit the values are expressed in in the input, explain conversion20

Testing your Manifest

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

DANExplain that you can build test cases in java with JUnit and run it in your IDE or in a test environment

21

Testing your Manifest

> java -jar sami-manifest-sdk-1.7.jar -m MyDeviceManifest.groovy -d myDeviceData.csv

==============================================================================Manifest File: MyDeviceManifest.groovyModified On: 10/31/2014 11:02:52==============================================================================Manifest FieldDescriptors: co2 FieldDescriptor[name: co2, normalizedUnit: ppm, valueClass: class java.lang.Integer]temp FieldDescriptor[name: temp, normalizedUnit: , valueClass: class java.lang.Integer]noise FieldDescriptor[name: noise, normalizedUnit: dB, valueClass: class java.lang.Integer]==============================================================================Results after running manifest on provided data file: Field[name: temp, field descriptor: FieldDescriptor[name: temp, normalizedUnit: , valueClass: class java.lang.Integer], unit: F, value: 18]Field[name: noise, field descriptor: FieldDescriptor[name: noise, normalizedUnit: dB, valueClass: class java.lang.Integer], unit: dB, value: 62]Field[name: co2, field descriptor: FieldDescriptor[name: co2, normalizedUnit: ppm, valueClass: class java.lang.Integer], unit: ppm, value: 602]==============================================================================

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

DAN

22

Creating devicesThrough an application using the APIThrough the User Portal

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

DAN

23

How does the device send data?Today, 2 protocols: REST, WebSocketTomorrow: any protocol (XMPP, MQTT, )

Sample curl call to post a message:curl -X POST "https://api.samsungsami.io/v1.1/messages" -H "Content-type: application/json" -d '{"sdid": "281c2bb26a604ed0b4655d446614d9f4", "data": "65,62,602" }' -H "Authorization: bearer dc7c5016161f419b85e95ca6e7791198

Simulator

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

DAN

24

Visualize live and historical data

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

A quick way to visualize the data that your device is sending and is persisted in SAMI is to use our live and historical visualizer tool. This is available on our user portal, so as a developer having created one more more instances of your sensor you can go there to see what your sensor is sending in real time and check what was sent previously.25

ApplicationsCreating value with SAMI

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Time check=2626

Our use case

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

27

Creating applications

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROMEMention permissions, restrictions etc.

28

How does an application use the SAMI API?Oauth 2Login is through Samsung AccountAll endpoints need an access token

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME

29

How does an application use the SAMI API?More details coming in next session about SDKs, samples and toolsWe are showing here examples based on the raw API

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME

30

How does an application use the SAMI API?> java -jar tyrus-client-cli-1.7.jar "wss://api.samsungsami.io/v1.1/live?userId=6dbf2c80612f11e498030800200c9a66&Authorization=bearer+dc7c5016161f419b85e95ca6e7791198

# Connecting to wss://api.samsungsami.io/v1.1/live?userId=6dbf2c80612f11e498030800200c9a66&Authorization=bearer+dc7c5016161f419b85e95ca6e7791198...# Connected in session 6fbe6f34-a20a-4d4b-bc7d-86420a48dbde# text-message: {"type":"ping", "ts":1414781476400}# text-message: {"mid":"1f1c0dd43e134b6d96fa23a01a6db91e","data":{"temp":18,"noise":62,"co2":602},"ts":1414781536866,"sdtid":"dt7c4f60efdc244ea1ac4b247620a38a4b","cts":1414781536866,"uid":"2","mv":1,"sdid":"ea064adf013b45ae8ed7b72bf40f0d49"}# text-message: {"mid":"0b424e4ccec247dc8b994895a66d885c","data":{"temp":18,"noise":62,"co2":602},"ts":1414781538573,"sdtid":"dt7c4f60efdc244ea1ac4b247620a38a4b","cts":1414781538573,"uid":"2","mv":1,"sdid":"ea064adf013b45ae8ed7b72bf40f0d49"}

Code sample 1: Websocket

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME

31

How does an application use the SAMI API?> curl "https://api.samsungsami.io/v1.1/messages?sdid=ea064adf013b45ae8ed7b72bf40f0d49&startDate=1414693964000&endDate=1414780365000" -H "Authorization: bearer dc7c5016161f419b85e95ca6e7791198"

"data":[ { "mid":"6b29828281ff49dba2feb639e13d6bfa", "data":{ "temp":18, "noise":62, "co2":602 }, "ts":1414780059836, "sdtid":"dt7c4f60efdc244ea1ac4b247620a38a4b", "cts":1414780059836, "uid":"6dbf2c80612f11e498030800200c9a66", "mv":1, "sdid":"ea064adf013b45ae8ed7b72bf40f0d49" },Code sample 2: REST /messages

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME

32

Examples of available APIs

UserProfileDevicesCRUD devices, CRUD tokensDevice TypesDevice Type Information, Manifest Versions, Manifest PropertiesMessages post, read, aggregates, export

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME

We have a foundation for analytics33

Real life exampleBloom TechnologiesJulien Pendershttp://www.bloom-life.com

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Time check=31

34

Meet Bloom

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

A powerful yet simple wearable to track contractions. Building on SAMI.

ConnectWith your body and get new insightTrackClinically relevant informationShareWith your partner or doctor. Unlock new clinical discovery.

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Bloom ManifestDeviceBloom

Device typeBloom contraction monitorBloom Alpha HR monitorBloom Alpha Motion sensor

ManifestsBloomIUPManifestBloomHeartRateManifestBloomAccelerometerManifest

Example of manifest: BloomIUPManifestpublic class BloomIUPManifest implements Manifest { // Custom FieldDesc static final SESSION_ID = new FieldDescriptor("session_id", Integer.class) static final IUP_HORIZONTAL = new FieldDescriptor("iup_horizontal", Float.class) static final IUP_VERTICAL = new FieldDescriptor("iup_vertical", Float.class) // boolean signals, true when contraction is active static final CONTRACTION_VERTICAL = new FieldDescriptor("contraction_vertical", Boolean.class) static final CONTRACTION_HORIZONTAL = new FieldDescriptor("contraction_horizontal", Boolean.class)

@Override List normalize(String input) { ... }

@Override List getFieldDescriptors() { return [IUP_VERTICAL, IUP_HORIZONTAL, CONTRACTION_VERTICAL, CONTRACTION_HORIZONTAL,SESSION_ID] }}

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Real-time data streaming and visualization in SAMI

SAMIContraction signalContraction featuresmaternal HRContraction signalContraction featuresmaternal HRPhone motion sensor message.data =@{@"iup_vertical": @([dataPoint.iup_vertical floatValue]),@"iup_horizontal": @([dataPoint.iup_horizontal floatValue]),@"contraction_vertical": @([dataPoint.contraction_vertical boolValue]),@"contraction_horizontal": @([dataPoint.contraction_horizontal boolValue]),@"session_id": @([dataPoint.sessionId integerValue])};

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Retrieving and visualizing data from SAMISAMIRecording session

NSString* filter = [NSString stringWithFormat:@"session_id:%d",[sessionToRead.identifier integerValue]]; SAMIDLog(@"filter %@",filter); [api2 getNormalizedMessagesWithCompletionBlock:nil sdid:deviceAlphaIUP._id mid:nil fieldPresence:nil filter:filter offset:nil count:nil startDate:@(start) endDate:@(stop) order:nil completionHandler:^(SamiNormalizedMessagesEnvelope *output, NSError *error) { //SAMIDLog(@"output.data %@",output.data); NSArray * messages = output.data; SAMIDLog(@"got %d points [session id %d]",[messages count],[sessionToRead.identifier integerValue]); }];

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Demo

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Demo sequenceTurn system on and visualize data on app (pre-recorded data with contraction)Visualize data in SAMI explain what were looking at, explain that were integrating data streams from multiple devices (bloom & phone)Show SAMI next to app screen show that there is almost no delayShow history page (data retrieval)

Question- Ok to use AirServer to visualize the app???

40

Conclusion

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Time check=3641

Whats next Building applications

PersonalsecurityBusinessProcessesDataAnalysisMachinelearningCoachingmodulesUserInterfacesWellnessProgramsPeopleDevicesServices

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Building applications: its you! Remember, its Data Driven DevelopmentYou have the expertise, you can create any kind of app, small, big, UI, backend processes, etc.And we are here to support you.Its a PLAYGROUND, there will be a way to monetize42

Whats next Getting startedGet started guide, Hello World, tutorials, API referenceToolsLive console to discover the APIManifest SDK Device simulatorAPI SDKs and sample applications (Java/Android, iOS, Python, Ruby, Javascript, Tizen, PHP, )User portal (manage devices, visualize data)Attend the SAMI SDK sessiondeveloper.samsungsami.io

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

JEROME43

Its a journeyNot a destination

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Beginning of a journey where Samsung and the developers will create new magical experiences for the user.

44

Beta

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

This is a playground, so were opening it in beta right now. We will work closely with developers to tune the platform.45

Were hiring

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Q & Aand THANK YOU for your time.Dan Serfaty - linkedin.com/in/danserfatyJerome Dubreuil - linkedin.com/in/jeromedubreuil

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

Time check=4047

Backup

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com

Additional notesAn application can understand what data is by looking at the Manifest Why Groovy: simple, popular scripting language and JVM basedWhy a program: as flexible as possible, no constraint on input dataOnce the Manifest is in the platform, can create new devices in a private way

2014 Samsung Developer Conference. All rights reserved.www.samsungdevcon.com#

49