27
6th November 2009, Pisa Italy Francesco Furfari <francesco.furfari @isti.cnr .it> Zi gBee Inte gration with th e OSGi pla tf orm Wireless Ne twork Lab, CNR-ISTI Francesco Furfari

ZigBee4OSGi Stack

Embed Size (px)

Citation preview

Page 1: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 1/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

ZigBee Integration withthe OSGi platformWireless Network Lab, CNR-ISTI

Francesco Furfari

Page 2: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 2/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

ObjectivesEasy integration of software clients based on different technologies (e.g. Web

Services, UPnP Control Points, and any other) with ZigBee networks.Design of a modular and extendible gateway able to be managed remotely

WSClient

UPnPClient

SIP

Client

Gateway

ZigBee Network

Page 3: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 3/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Use CaseA PC or an embedded system augmented with a ZigBee Network Controllerthat joinspre-existing ZigBee Networks

Home Environments

Industrial Environments

Host PCor

EmbeddedSystem

ZigBeeNetwork

Controller

WAN / W-LAN

Page 4: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 4/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Project InfoSuite of software components (bundles) designed and developed by CNR-ISTIwithin the European Project PERSONA, with the contribution of ITACA (Spanishpartner) for accessing to the Texas Instrument USB Dongle (CC2480),

Most of the software is Copyright 2008 – 2010 CNR◦ Dependencies with other permissive licenses reported in the NOTICE file of each bundle

All Software Licensed under the Apache License, Version 2.0◦ It defines clauses which avoid the bad surprise of submarine patents. Submarine patents are patents that

apply to a certain technology, but are hidden — unpublished or unasserted — during the development of thattechnology. Once the market matures and the patented technology is in wide use, the submarine patentsurfaces and the company owning the patent tries to claim patent royalties from across the industry usedthat licensed technology. (http://oreilly.com/catalog/osfreesoft/book/)

IPR concerns◦ http://freaklabs.org/index.php/Blog/Zigbee/Zigbee-Linux-and-the-GPL.html◦ ZigBee License:◦ Different Licenses

for each doc

Page 5: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 5/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Abstract ArchitectureSAIL: Sensor Abstraction and Integration Layers

◦ 3-Layered Architecture◦ The Abstraction Layer is used to define

services as proxies of physical sensorsservices as logical sensor representing WSN applications composedby many devices (data aggregation)

Page 6: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 6/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Concrete ArchitectureSAIL has been implemented by using the OSGi platform

OSGi defines many useful things on top of Java, to name a few :◦ It adds a modularization layer to build component-based architectures◦ It provides a cooperation model to build service oriented architectures

Based on the Service Registry◦ Many specifications already defined for Devices and Gateway Management:

Device Access Specification, Wire Admin, Config Admin, Initial Provision, …

Page 7: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 7/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Abstraction Layer

Access Layer

ZigBee4OSGi Stack overview

Native Drivers(HW dependent)

Abstract ZigBee Controller API<interfaces>

ZigBee Base Driver

ZigBee BaseDriver API<interfaces>

ZigBee Cluster Library

HA Profile Driver

Custom ClusterLibraries

Custom ClusterLibraries

Custom HADriver Extensions

Custom HADriver Extensions (.dvrx)

<uses>

<uses>

<uses><uses>

HW dependent Drivers

<uses>

Page 8: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 8/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

ZigBeeException<<Interface>>

+ Cluster invoke (Cluster)+ void send (Cluster)+ Add / RemoveClusterListener ()+ Bind / Unbind

+ Properties

ZigBeeNode<<Interface>>

+ Cluster invoke (Cluster)+ void send (Cluster)+ Add / RemoveClusterListener ()+ Bind / Unbind

+ Properties

ZigBee BaseDriver

ZigBeeDevice<Interface>

+ Cluster invoke (Cluster)+ void send (Cluster)+ Add / RemoveClusterListener ()+ Bind / Unbind

+ Properties <registers>

<implements> ZigBeeDeviceImpl

ZigBee BaseDriver API

ZigBee BaseDriver API

<defines>

Driver’s steps1. Dongle initialization2. Network Creation (optional)3. Network Scanning4. Device & Service Discovery5. Device Control

Page 9: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 9/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

it.cnr.isti.zigbee.api.Cluster

Frame

Response

Command

Cluster is basically an array of byte ([]byte)to yield the ZCL Frame to the dongle.

Page 10: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 10/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Extensions and Dependencies -1The OSGi module layer requires the declaration of everydependency within the Manifest file of the BundleA ClassLoader is associated to each Bundle , and only the classesof the packages declared in the Manifest may be loaded (import-package header)

ZB specification is extendible.How to extend the driver to load non- standard classes? that’s,

classes Not based on the ZigBee cluster library?

1. By using the dynamic-import mechanism of OSGi2. The Eclipse way (extension points)3. By using the Service Registry + Factory design pattern

Page 11: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 11/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Extensions and Dependencies-2

3rd-party

Bundle

DeviceFactory<interface>

DeviceFactoryService

RefinementDriverBundle

usesgetInstance()

Registers

implements

HADevice<interface>

Custom

Device

implements

uses

ZigBeeDevice<interface>

uses

CustomClustersCustomClusters

creates

uses

creates

Not allowedinstantiation

Page 12: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 12/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

OSGi Service Registry

ZigBee BaseDriver1. registers

ZigBeeDeviceservice

HA RefinementDriver

OnOffLightDeviceFactory

service

ProfileIDDeviceID

ClusterID-List

3. select bydeviceID

XxxClusterFactory

service

2. OSGi frameworknotifies new service

OnOffLightservice4. Creates

specializedObject

Basic,Identify,OnOff , …

5. Uses ClusterFactories

ClusterClusterClusters

6. creates7. registers

ZigBeeDevice refinement process - 1

Page 13: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 13/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

ZigBeeDevice refinement process - 2When the basedriver discovers a ZigBee Node, it registers all itsendpoints as ZigBeeDevice services with the OSGi Framework

Refinement Drivers (i.e. HA driver) use the ― profileID‖ and ―deviceID‖properties of the ZigBeeDevice service, to select the proper Device

Factory that can instantiate a more specialized service.

A specialized service (e.g. OnOffLight Device) is a collection of mandatory and optional clusters

The DeviceFactory must verify whether all mandatory clusters areimplemented by the ZigBeeDevice service.

A ClusterFactory is used to instantiate the clusters implemented by theZigBeeDevice

ZigBeeDevice

OnOffLight

<refines>

Page 14: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 14/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

ZigBee Class HierarchyDevice Node

HA Device

EndPoints

HA Device

ClusterCluster

Command

HA Devices

Clusters

CommandCommands IO Parameters

CommandCommandAttributes

Read / Write

Report (Subscribe)ZigBeeDevice

byte[] Invoke (byte[])

ZCL Frame

Home Automation DriverCustom Device Driver (drvx)

ZigBee Cluster LibraryCustom Cluster Library

Page 15: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 15/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Too many ―Cluster‖ class

Basedriver.api◦ Cluster invoke (Cluster cluster) method of ZigBeeDevice

ZCL.library◦ ZCLCluster

CommandsAttributes

HA gluecode◦ Used to hide the specifics of ZigBee protocol

Light.On() returns void …. Not a DefaultResponse

Light.Subscription() combines the binding and report configuration commands

Page 16: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 16/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

SW & Utility Classes - 1

Packaging style◦ .api (interfaces)◦ .impl (implementation)◦ .core (main entities)◦ ―Base‖ postfix for abstract classes◦ Functional methods style

myObj = new myClass ().add().add().add() ….

Page 17: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 17/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Defining custom HA devicesDefine How use

Cluster’s Commands extend AbstractCommand

Command’s getPayload() override DefaultSerializer to write the parameters

Command’s Response extend ResponseImpl

Response’s getPayload() override DefaultDeserializer to read the parameners

Cluster’s Attributes declare AttributeImpl as Type

Cluster extend ZCLClusterBase

Cluster Factory extend HAClusterFactoryBase

HA Device extend HADeviceBase

Device Factory invoke GenericHADeviceFactory

Page 18: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 18/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

SW & Utility Classes - 2

DeviceFactory

Zigbee.ha.driver

Page 19: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 19/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

SW & Utility Classes - 3

HADeviceBase

Page 20: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 20/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

SW & Utility Classes - 4

ClusterFactorygluecode in zigbee.ha.driver

zigbee.zcl.library

Page 21: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 21/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

SW & Utility Classes - 5Clusters, Commands and Attributes

Page 22: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 22/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Design issuesGluecode

◦ Utility vs Complex Design

ZigBee device hierarchy◦ Commands description not available

Device composition and declaration◦ Xml approach◦ Annotation approach◦ Declarative Services◦ Model driven

Device Access Specification◦ Matching algorithm

b1- b8 #Cluster Matches

b9 deviceID match

b10 profileID match

Page 23: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 23/276th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Tools

ZigBee Tester (Device inspector)◦ Reflection to provide a command interface

Commissioning◦ Binding facilities◦ Store configuration◦ Remote Commissioning

On Demand Provisioning

Page 24: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 24/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Commissioning tool - 1

Lonwork Builder

ZigBee Tester

Deployment Tool

Page 25: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 25/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

Commissioning tool - 2M2M_for_Model driven developmenthttp://www.eclipse.org/modeling/gmf/

OSGi

Page 26: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 26/27

6th November 2009, Pisa ItalyFrancesco Furfari <[email protected]>

On demand provisioningSupposing the EndDevice (0x0041) is a non-standard device, by usinggetComplexDescription() we can get the URL of a Profile/ClusterExtension ( a dvrx bundle) that will install the refined service for thecustom ZigBee Device.

EndDevice0x0041OSGi Platform

ZigBeeDevice0x0041

HA Driver

BundleRepository(e.g. Nexus)

1. getComplexDescription()

internet

2. LoadBundle(<DeviceURL>)

dvrx for0x0041

3. Intall .dvrx bundle

4. Refines 0x0041EndDevice

0x0041

Page 27: ZigBee4OSGi Stack

8/13/2019 ZigBee4OSGi Stack

http://slidepdf.com/reader/full/zigbee4osgi-stack 27/27

That’s all folk

27