Está en la página 1de 27

ZigBee Integration with the OSGi platform

Wireless Network Lab, CNR-ISTI Francesco Furfari

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Objectives

Easy 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

UPnP Client ZigBee Network WS Client Gateway SIP Client

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Use Case

A PC or an embedded system augmented with a ZigBee Network Controller that joins pre-existing ZigBee Networks
Home Environments Industrial Environments

WAN / W-LAN

Host PC or Embedded System

ZigBee Network Controller

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Project Info

Suite of software components (bundles) designed and developed by CNR-ISTI within the European Project PERSONA, with the contribution of ITACA (Spanish partner) 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 unassertedduring the development of that technology. Once the market matures and the patented technology is in wide use, the submarine patent surfaces and the company owning the patent tries to claim patent royalties from across the industry used that 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

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Abstract Architecture

SAIL: Sensor Abstraction and Integration Layers


3-Layered Architecture The Abstraction Layer is used to define services as proxies of physical sensors services as logical sensor representing WSN applications composed by many devices (data aggregation)

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Concrete Architecture

SAIL 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,

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

ZigBee4OSGi Stack overview


Abstraction Layer
HA Profile Driver
<uses> <uses> <uses>

Custom CustomHA HA Driver Extensions Driver Extensions (.dvrx) Custom CustomCluster Cluster Libraries Libraries Access Layer

ZigBee Cluster Library


<uses>

<uses>

ZigBee BaseDriver API <interfaces> ZigBee Base Driver Abstract ZigBee Controller API <interfaces> Native Drivers HW dependent Drivers (HW dependent)
Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

ZigBee BaseDriver API


ZigBeeException <<Interface>> ZigBeeNode
<<Interface>> Cluster invoke (Cluster) void send (Cluster) + Cluster invoke (Cluster) Add /RemoveClusterListener () <Interface> + void send (Cluster) Bind /Unbind + Add / RemoveClusterListener () + Cluster invoke (Cluster) + Bind /Unbind + Properties + void send (Cluster)
+ + + +

ZigBeeDevice

<implements>

ZigBeeDevice Impl

+ Add/RemoveClusterListener() + Properties + Bind/Unbind + Properties

<registers>

<defines> ZigBee BaseDriver API ZigBee BaseDriver


Drivers steps 1. Dongle initialization 2. Network Creation (optional) 3. Network Scanning 4. Device & Service Discovery 5. Device Control
Francesco Furfari <francesco.furfari@isti.cnr.it> 6th November 2009, Pisa Italy

it.cnr.isti.zigbee.api.Cluster
Cluster is basically an array of byte ([]byte) to yield the ZCL Frame to the dongle.

Frame

Command

Response

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Extensions and Dependencies -1


The OSGi module layer requires the declaration of every dependency within the Manifest file of the Bundle A ClassLoader is associated to each Bundle , and only the classes of the packages declared in the Manifest may be loaded (importpackage header)

ZB specification is extendible. How to extend the driver to load non-standard classes? thats, classes Not based on the ZigBee cluster library?
1. By using the dynamic-import mechanism of OSGi

2. The Eclipse way (extension points)


3. By using the Service Registry + Factory design pattern
Francesco Furfari <francesco.furfari@isti.cnr.it> 6th November 2009, Pisa Italy

Extensions and Dependencies-2


DeviceFactory <interface>
uses getInstance()

Refinement Driver Bundle

implements

Not allowed instantiation

uses

HADevice <interface>
implements

3rd-party Bundle

Registers

Device Factory Service

creates

Custom Device

creates

Custom Custom Clusters Clusters

uses uses

ZigBeeDevice <interface>
Francesco Furfari <francesco.furfari@isti.cnr.it> 6th November 2009, Pisa Italy

ZigBeeDevice refinement process - 1


OSGi Service Registry
OnOffLight service 5. Uses ClusterFactories 7. registers 6. creates
Cluster Cluster Clusters

4. Creates specialized Object

HA Refinement Driver

3. select by deviceID

OnOffLight DeviceFactory service

Xxx ClusterFactory service


Basic, Identify, OnOff,

2. OSGi framework notifies new service ZigBeeDevice service 1. registers


ProfileID DeviceID ClusterID-List

ZigBee BaseDriver

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

ZigBeeDevice refinement process - 2

When the basedriver discovers a ZigBee Node, it registers all its endpoints 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 are implemented by the ZigBeeDevice service. A ClusterFactory is used to instantiate the clusters implemented by the ZigBeeDevice
6th November 2009, Pisa Italy

OnOffLight

<refines> ZigBee Device

Francesco Furfari <francesco.furfari@isti.cnr.it>

ZigBee Class Hierarchy


Device Node

Home Automation Driver Custom Device Driver (drvx)


EndPoints

HA Device HA Device HA Devices

ZCL Frame
Cluster Cluster Clusters Read / Write Command Command Attributes Report (Subscribe) Command Command Commands IO Parameters byte[] Invoke (byte[]) ZigBee Device

ZigBee Cluster Library Custom Cluster Library

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Too many Cluster class

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

ZCL.library
ZCLCluster Commands Attributes

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
6th November 2009, Pisa Italy

Francesco Furfari <francesco.furfari@isti.cnr.it>

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() .

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Defining custom HA devices


Define Clusters Commands Commands getPayload() Commands Response Responses getPayload() Clusters Attributes Cluster Cluster Factory HA Device Device Factory How extend override extend override declare extend extend extend invoke use AbstractCommand DefaultSerializer to write the parameters ResponseImpl DefaultDeserializer to read the parameners AttributeImpl as Type ZCLClusterBase HAClusterFactoryBase HADeviceBase GenericHADeviceFactory

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

SW & Utility Classes - 2

DeviceFactory

Zigbee.ha.driver

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

SW & Utility Classes - 3

HADeviceBase

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

SW & Utility Classes - 4

ClusterFactory
gluecode in zigbee.ha.driver

zigbee.zcl.library

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

SW & Utility Classes - 5

Clusters, Commands and Attributes

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Design issues

Gluecode
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

b10 profileID match b9 deviceID match b1- b8 #Cluster Matches

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Tools

ZigBee Tester (Device inspector)


Reflection to provide a command interface

Commissioning
Binding facilities Store configuration Remote Commissioning

On Demand Provisioning

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Commissioning tool - 1
Lonwork Builder Deployment Tool

ZigBee Tester

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Commissioning tool - 2

M2M_for_Model driven development http://www.eclipse.org/modeling/gmf/

OSGi
Francesco Furfari <francesco.furfari@isti.cnr.it> 6th November 2009, Pisa Italy

On demand provisioning

Supposing the EndDevice (0x0041) is a non-standard device, by using getComplexDescription() we can get the URL of a Profile/Cluster Extension ( a dvrx bundle) that will install the refined service for the custom ZigBee Device.
4. Refines 0x0041

dvrx for 0x0041


3. Intall .dvrx bundle

EndDevice 0x0041

internet
Bundle Repository (e.g. Nexus)

2. LoadBundle(<DeviceURL>)

HA Driver
1. getComplexDescription()

ZigBee Device 0x0041 EndDevice


0x0041

OSGi Platform

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

Thats all folk

Francesco Furfari <francesco.furfari@isti.cnr.it>

6th November 2009, Pisa Italy

27

También podría gustarte