betaas apis webinar adaptation, service and extended service programming interfaces 1 h ow to i...

24
BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 HOW TO INTERACT THROUGH BETAAS APIS

Upload: jeffery-clarke

Post on 28-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 1

Adaptation, Service and Extended Service Programming Interfaces

HOW TO INTERACT THROUGHBETAAS APIS

Page 2: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 2

Dec 2014 BETaaS: a horizontal platform for IoT

Jan 2015 How to interact through BETaaS API

Feb 2015 How to use local and remote cloud instances at BETaaS

Feb 2015 CoAP Adaptation Plugin

Feb 2015 Running apps BETaaS enabled proprietary devices

Feb 2015 How to setup security environment in BETaaS

WEBINARS AGENDA

Page 3: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 3

THE LAYERED ARCHITECTURE

GW

GW

GW

Page 4: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 4

EXTERNAL INTERACTIONS - ADAPTATION

Things

Page 5: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 5

EXTERNAL INTERACTIONS - SERVICESmartphones,Laptops, etc.

Things

Page 6: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 6

INTERACTIONS - EXTENDED SERVICES

Extended Services

Things

Smartphones,

Laptops, etc.

Custom Business Logic

Page 7: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 7

ADAPTATION INTERFACE (1/3)

To be implemented by every OSGi adaptor bundle

Sub-project: betaas-plugins\betaas-adaptation-plugin

Once installed, the bundle is automatically exploited by BETaaS

Thing Simulator Adaptor Plug-in

CoAP Plug-in

ETSIPlug-in …

Java Interfaces: IAdaptorPlugin

Page 8: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 8

ADAPTATION INTERFACE (2/3)

Adaptation bundles are used by BETaaS to:

Plug-inBundle

DISCOVER new Things+ Context

Information

GETsensors

measurementsand/or SUBSCRIBE

SETactuator

s

Page 9: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 9

ADAPTATION INTERFACE (3/3)

public Vector<HashMap<String, String>> discover()

public String getData(String sensorID);public boolean register(String sensorID);public boolean unregister(String sensorID);

public String setData(String sensorID, String value);

Key Value

ID 0323Ar-BTU2-a

type Presence

… …

Key Value

ID MNOS-4520-21

type Humidity

latitude 43.192416

… …

public boolean notify(String type, String resourceID, HashMap<String, String> value);

Interface IAdaptorListener (USED)

Interface IAdaptorPlugin (IMPLEMENTED)

Key Value

measurement 7.21

latitude 43.192418

… …

Page 10: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 10

SERVICE INTERFACE (1/2)

Used by external applications to:

> Request the resources allocation

> Get the list of allocated Thing Services

> Get and Set data using Thing Services

> Retrieve extended services data

> Request the execution of background tasks on Thing Services data

Sub-project: betaas-service\betaas-service-servicemanager

Java Interfaces: ServiceManagerExternalIF

Available both through SOAP and REST

Services description also available at http://<karaf host>:8181/cxf

Page 11: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 11

SERVICE INTERFACE (2/2)

public String installApplication(String manifestContent);

public String getApplicationServices(String appID);

public boolean uninstallApplication(String appID, String manifestContent);

public String getThingServiceData(String appID, String serviceID, String token);

public boolean setThingServiceData(String appID, String serviceID, String data, String token);

public String getExtendedServiceData(String appID, String extServUniqueName, String additionalInfo);

public boolean register(String appID, String serviceID, String token);

public boolean unregister(String appID, String serviceID, String token);

public String getTaskData(String appID, String taskID);

Page 12: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 12

MANIFEST – AN EXAMPLE<?xml version='1.0'?><manifest>

<Application><name>eu.betaas.test.testBETaaSREST</name><credentials>MIIGogIBAzCCBlwGCSqGSIb3DQEHAaCCBk[…]</credentials><notificationAddress>http://192.168.31.44:8080/TestBETaaSREST/</notificationAddress>

</Application><ServiceDescriptionTerm>

<ServiceDefinition><Feature>STREET LAMP</Feature><Areas>

<Environment>Public</Environment><Altitude>30</Altitude><Latitude>43.656998</Latitude><Longitude>10.437418</Longitude><Radius>1000.0</Radius>

</Areas><Delivery>betaas.delivery.SET</Delivery><Trust>3</Trust><QoS>

<MaxInterRequestTimeSec>5</MaxInterRequestTimeSec><MaxResponseTimeSec>15</MaxResponseTimeSec><MinAvailability>1</MinAvailability>

</QoS><credentials></credentials>

</ServiceDefinition></ServiceDescriptionTerm>

</manifest>

Page 13: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 13

SERVICE INTERFACE – AN EXAMPLE

Page 14: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 14

SERVICE INTERFACE – INTRUSION DETECTION

Uses SOAP service interfaces

Allocates one TS for PRESENCE anywhere in the HOME

GET TS data (combined value) and requests a simple data TASK

<Feature>presence</Feature><Areas>

<Environment>

Private</Environment><LocationKeyword>

home</LocationKeyword>

<Floor>1</Floor></Areas>

Page 15: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 15

EXTENDED SERVICE INTERFACE (1/2)

Extended service are OSGi bundles that use Service Layer APIs (ServiceManagerInternalIF) to:

> Request the resources allocation

> Get and Set data using Thing Services

> Request the execution of background tasks on Thing Services data

Sub-project: betaas-service\betaas-service-servicemanagerJava Interface: IExtendedService

Standard Java calls to APIs methods

Extended Services must implement an interface

Page 16: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 16

EXTENDED SERVICE INTERFACE (2/2)

public String getUniqueID();

public void notifyInstallation(boolean success, String msg, String extServId, ArrayList<String> servList,ArrayList<String> tokenList);

public void notifySLAViolation(String serviceID);

public void notifyData(String serviceID, JsonObject data);

public String getResult(String additionalInfo);

Methods to provide:

Page 17: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar

EXTENDED SERVICE – LEZ TRAFFIC MGMTTraffic Intensity data

Cars position

MUNICIPALITY

GW

Compute dynamic fees

User App

Adaptation APIs

Extended Service APIsServiceAPIs

• Discovery of GPS and Traffic sensors • Registration to data updates

• Allocate 2 TS (GPS and Traffic)• Registration to data updates• Request usage of Extended Service• Request data from Extended Service (current fee)

17

Page 18: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar

MOBILE APP INTERACTION

18

Difficulty to implement a “receptor” service (for PUSH mode)> Use Google Cloud Messaging

> Proprietary system> Not free> Vendor lock-in

> Use open source queuing tools (RabbitMQ)

> Implement your own server

> RabbitMQ> Battery consumption

> Not possible in some systems> Good luck!

Difficulty to interact with SOAP interfaces in mobile development> Complexity> Lack of libraries

Page 19: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar

MOBILE APP INTERACTION

19

Install App

App Id

Get services IDs

Services IDs

Get Data

Data

Set Data

OK/KO

Get Data

Data

Set Data

OK/KO

Use of the REST interface in PULL mode:

loop

loop

Page 20: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 20

<?xml version='1.0'?><manifest>

<Application><name>IntrusionDetection</name><credentials>MIIGogIBAzCCBlwGCSqGSIb3DQEHAaCCBk[…]</credentials><notificationAddress>http://localhost:8080/betaasapptester/</notificationAddress>

</Application><ServiceDescriptionTerm>

<ServiceDefinition><Feature>presence</Feature><Areas>

<Environment>Private</Environment><LocationKeyword>home</LocationKeyword><Floor>1</Floor>

</Areas><Delivery>betaas.delivery.RTPULL</Delivery><Trust>5</Trust><QoS>

<MaxInterRequestTimeSec>5</MaxInterRequestTimeSec><MaxResponseTimeSec>15</MaxResponseTimeSec><MinAvailability>2</MinAvailability>

</QoS><credentials></credentials>

</ServiceDefinition></ServiceDescriptionTerm>

</manifest>

MOBILE APP INTERACTION

Page 21: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 21

Install Application: HTTP Method: POST URL: http://<sm-IP>:8181/cfx/sm/application/ Headers: “Content-Type : application/xml” Body: manifest string Returns: <Gateway ID0>::<App Id>

Get Services IDs: HTTP Method: GET URL: http://<sm-IP>:8181/cfx/sm/application/<appID> Returns: { InstallationInfo: { serviceList : [<service1>, <service2>...], tokenList : [<token1>, <token2>...] } }

MOBILE APP INTERACTION – REST API 1/2

Page 22: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 22

Get data: HTTP Method: GET URL: http://<sm-IP>:8181/cfx/sm/data/<applicationID>/<serviceID> Headers: “token : <token>” Returns: true/false

Uninstall application: HTTP Method: DELETE URL: http://<sm-IP>:8181/cfx/sm/application/<applicationID> Headers: “token : <token>” Returns: 200 OK

MOBILE APP INTERACTION – REST API 2/2

Full specification: http://<sm-IP>:8181/cfx/sm?_wadl

Page 23: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar 23

MOBILE APP INTERACTION - SAMPLE

GatewayFragment GatewayManager REST serverGWCommunicatorREST REST client

Mobile App

UI Thread AsyncTask (background thread)

BETaaS Gateway

installApplication(gwId) installApplication(gwId)postResource(appData) POST …

200 OK - 0/1

[200 OK, appId]

getResource(app)GET …

200 OK – {InstallationInfo…}[200 OK, {Installatio…}]

{<appId>, [serv1, serv2], …

notifyDataUpdate(res)

getPresence(servId)

loop

getPresence(servId)getResource(servId)

GET …

200 OK - appId

[200 OK, 0/1]true/false

notifyApplicationInstalled(d)

loop

Page 24: BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S

BETaaS APIs Webinar

www.betaas.eu

HOW TO USE LOCAL AND REMOTE CLOUD INSTANCES AT BETAAS

February 2015

NEXT WEBINAR