700 likes | 914 Views
Middleware for Network Embedded Systems (NES). Franco Fummi, Giovanni Perbellini, Sara Vinco. University of Verona. Verona, November 13, 2007. Agenda. Middleware for NES: an introduction ZigBee: as a Middleware for NES Abstract Middleware Environment (AME):
E N D
Middleware forNetwork Embedded Systems (NES) Franco Fummi, Giovanni Perbellini, Sara Vinco University of Verona Verona, November 13, 2007
Agenda Middleware for NES: an introduction ZigBee: as a Middleware for NES Abstract Middleware Environment (AME): a framework for Middleware-centric NES applications generation
Agenda Middleware for NES: an introduction ZigBee: as a Middleware for NES Abstract Middleware Environment (AME): a framework for Middleware-centric NES applications generation
What’s a Middleware (I) Middleware Middleware sits between the operating system and the application Facilitate the development of applications Provide abstractions hiding low-level details Application Application … APIs MIDDLEWARE Platform interface Platform interface Operating System Operating System … Hardware Hardware
A classification-based layer Application Domain-specific Middleware Services Common Middleware Services Abstraction levels Distribution Middleware Host insfrastructure Middleware Operating System Hardware
MW abstraction levels (I) Host infrastructure MW Includes the communication/concurrency OS mechanisms to create re-usable programming components e.g.,:Java sockets, Java threads Distribution MW Provides distributed/networked programming models: naming, discovery,… e.g.,: CORBA, RMI, DCOM
MW abstraction levels (II) Common MW Services Provides common functions: logging, security, events, … e.g.,: Enterprise Java Beans, CORBAServices Domain Specific MW Services Specific services based on a particular application domain: healthcare, telecom, automotive, …
NES Application Issues Choice of the middleware for NES Designer programming skills HW/SW platform available Complex design flow Cannot port Applications on different HW/SW platforms No application re-use, no interoperability Mandatory: Interoperability through common Interfaces and APIs
NES Middleware classification Middleware classification Database Tuplespace OOM MOM TAO ICE … … … … TinyDB Cougar T-Spaces TinyLime Mires
Example 1: Database - TinyDB Defines Query service interface and its implementation Data-centric approach: Sensor Networks queried ad Database Sensor Network SELECT MAX(mag) FROM sensors WHERE mag > thresh SAMPLE PERIOD 64ms App Query, Trigger Data TinyDB Realized by: Intel-Research-Berkeley and UC Berkeley
Example 2: OOM - TAO The ACE ORB (TAO) Component of ACE (ADAPTIVE Communication Environment) An open-source standard-compliant implementation of CORBA For Networked Embedded Systems Allows clients to invoke operations on distributed objects without concern for object location, OS platform, communication protocols and interconnects, and hardware
Example 3: Message-oriented - Mires Uses a Publish-Subscribe service Three steps The user application subscribe to topics of interest Publishing of services by the nodes Mires routes the services to the destination Built on top of TinyOS Heterogeneity Multi-hop routing doesn’t include a service discovery Scalabilty and mobility only partially Include a Data-aggregation service
Example 4: Tuplespace – T Spaces Tuplespace: globally shared space memory used by processes to communicate The basic element is a Tuple (a vector of typed values) Primitives: Write, Read, Take Communications is decoupled in both time and space: senders and receivers do not need to be available at the same time T-Spaces from IBM: further services Blocking and non-blocking operations Event notification …
Agenda Middleware for NES: an introduction ZigBee: as a Middleware for NES Abstract Middleware Environment (AME): a framework for Middleware-centric NES applications generation
ZigBee Introduction to ZigBee Protocol Overview ZigBee stack ZigBee network and communication ZigBee Profiles Application Development Application schema Example: Hello World Difficulties
What is ZigBee? A high level communication protocol using small, low-power digital radios based on the IEEE 802.15.4 standard for wireless networks ZigBee is targeted at applications that require a Low data rate Long battery life Secure networking
The ZigBee Alliance Organized as an independent, non profit corporation in 2002 Includes major names in Semiconductor, Software Developer, End Product Manifacturer and Service Provider Industries Open and global Activity includes Specification creation Certification Market development and user education
The ZigBee Product Application Profile Certified Product ZigBee Stack Compliant Platform IEEE 802.15.4
ZigBee Compliant Platform Ensures all parts of the stack (other than the application) are compliant with the ZigBee standard Allows Network interoperability but does not imply interoperability at the application layer Application Profile ZigBee Stack IEEE 802.15.4
{ ZigBee Stack Architecture Initiate and join network Manage network Determine device relationships Send and receive messages Application Medium Access (MAC) Physical Radio (PHY) Application ZDO Device management Device discovery Service discovery SSP App Support (APS) Security functions NWK Network organization Route discovery Message relaying Device binding Messaging
Application Profiles Application profiles define what messages are sent over the air for a given application Devices with the same application profiles interoperate end to end Application Profile ZigBee Stack Clusters Clusters IEEE 802.15.4 0: off 1: on 2: scene 1 3: scene 2 0: off 1: on 2: temp set 3: time set
ZigBee Node Types ZigBee Coordinator One required for each ZB network Initiates network formation and stores information about the network ZigBee Router Participates in routing of messages ZigBee End Device Enables very low cost solutions
ZigBee Network Topologies Mesh Star ZigBee Coordinator ZigBee Router Cluster Tree ZigBee End Device
Communication between nodes Addressing Direct (IEEE and NWK addresses) Indirect Group Device discovery Determine the identity of other devices of the network Binding
Binding Creates logical links between two end devices (using the same profile) Binding table stored by the Coordinator Indirect messaging
Application Profiles Application profiles define what messages are sent over the air for a given application Devices with the same application profiles interoperate end to end A profile is: A set of devices A set of clusters to implement a functionality Attributes to represent the device state Commands to enable the communication
Why do we need profiles? Need a common language for exchanging data Need a well defined set of processing actions Interoperability across different manufacturers Simplicity and reliability for end users Consumer flexibility for products
Profile Classes Public Profiles For generically useful applications Developed publicly by members of the ZigBee Alliance Manifacturer specific profiles For manifacturer specific proprietary applications Developed privately by individual manufacturers Must use a ZigBee allocated profile identifier
ZigBee Applications BUILDING AUTOMATION CONSUMER ELECTRONICS ZigBee Wireless Control that Simply Works PC & PERIPHERALS PERSONAL HEALTH CARE TELECOM SERVICES INDUSTRIAL CONTROL HOME CONTROL
Home Automation Profile Management of lighting, heating and cooling system from anywhere in your home Automate control of multiple home systems to improve conservation, convenience and safety Embed intelligence to optimize consumption of natural resource Install, upgrade and network home control system without wires Easily install wireless sensors to monitor a wide variety of conditions Receive automatic notification upon detection of unusual events
Application Development Applications are user defined but they must: Be event driven Follow a precise schema Interact with the ZigBee stack Implement a profile Application Application Profile ZigBee Stack IEEE 802.15.4
Events All ZigBee applications are event-driven An application is a set of callbacks to process events Events can be Local (key pressed) Remote (remote message from another device) Timers
Events are received from the ZigBee stack Events are then transmitted to application level The corresponding callback or function for each event is activated Example: message receipt Event processing Application Profile ZigBee Stack IEEE 802.15.4 Network
Timers Embedded system devices have simple operative systems Scheduling is non-preemptive Timers are used to repeat a sequence of operations (≈ while(true)) while(true){ execute(); } set(TIMER,100); ... if(TIMER){ execute(); }
Application structure Each application must contain: Init method Event-loop method Applications can contain Local functions Callbacks Application Application Profile ZigBee Stack IEEE 802.15.4
Init Method Rules the interaction between the ZigBee stack and the user defined application The application must provide information to the ZigBee stack Node descriptor Hardware specific information Profile information Application Application Profile ZigBee Stack IEEE 802.15.4
Event-loop method The event loop method is invoked whenever an event is transmitted to the application Events processed are: Mandatory (system events) Application specific (timers) Application Profile ZigBee Stack IEEE 802.15.4 Network
Callbacks Callback functions can be used to process specific kinds of events Example: message receipt Used to perform different operations for different kinds of messages Application Profile ZigBee Stack IEEE 802.15.4 Network
Profiles Each application must implement a profile to Define communication protocols Correctly interact with other devices To implement a profile means to decide Attributes Commands to be used, from the ones provided by the protocol A device can contain more than one application running ZDO SSP App Support (APS) NWK Medium Access (MAC) Physical Radio (PHY) App App … ZDO SSP App Support (APS) NWK Medium Access (MAC) Physical Radio (PHY) Application
Application example:“Hello World!” Simple application: two devices exchange messages containing Hello World!
Init method #define GENERICAPP_ENDPOINT 10 #define GENERICAPP_PROFID 0x0F04 #define GENERICAPP_DEVICEID 0x0001 const SimpleDescriptionFormat_t SimpleDesc = { GENERICAPP_ENDPOINT, GENERICAPP_PROFID, GENERICAPP_DEVICEID, GENERICAPP_DEVICE_VERSION, GENERICAPP_FLAGS, GENERICAPP_MAX_CLUSTERS, GenericApp_ClusterList, GENERICAPP_MAX_CLUSTERS, GenericApp_ClusterList }; void Init( byte task_id ) { TaskID = task_id; NwkState = DEV_INIT; TransID = 0; DstAddr.addrMode = AddrNotPresent; DstAddr.endPoint = 0; DstAddr.addr.shortAddr = 0; epDesc.endPoint = GENERICAPP_ENDPOINT; epDesc.task_id = &GenericApp_TaskID; simpleDesc = &SimpleDesc; afRegister( &epDesc ); RegisterForKeys( TaskID ); }
Event-loop method UINT16 Event_Loop ( byte task_id, UINT16 events ) { if ( events & SYS_EVENT_MSG ){ MSGpkt = osal_msg_receive ( TaskID ); while ( MSGpkt ){ switch ( MSGpkt->hdr.event ){ case KEY_CHANGE: HandleKeys((MSGpkt->state, MSGpkt)->keys ); break; case AF_INCOMING_MSG_CMD: MessageMSGCB ( MSGpkt ); break; case ZDO_STATE_CHANGE: GenericApp_NwkState = (devStates_t)(MSGpkt->hdr.status); osal_start_timer( GENERICAPP_SEND_MSG_EVT, GENERICAPP_SEND_MSG_TIMEOUT ); break; default: break; } osal_msg_deallocate( MSGpkt ); MSGpkt = osal_msg_receive ( TaskID ); } return (events ^ SYS_EVENT_MSG); }
Event-loop method if ( events & GENERICAPP_SEND_MSG_EVT ) { SendTheMessage(); osal_start_timer( GENERICAPP_SEND_MSG_EVT, GENERICAPP_SEND_MSG_TIMEOUT ); return (events ^ GENERICAPP_SEND_MSG_EVT); } return 0; }
Callbacks and local functions void HandleKeys ( byte shift, byte keys ){ if ( keys & HAL_KEY_SW_2 ) { ZDApp_SendEndDeviceBindReq( GenericApp_epDesc.endPoint ); } if ( keys & HAL_KEY_SW_4 ) { ZDApp_AutoFindDestination( GenericApp_epDesc.endPoint ); } } } void MessageMSGCB ( afIncomingMSGPacket_t *pkt ){ switch ( pkt->clusterId ) { case GENERICAPP_CLUSTERID: HalLcdWriteScreen("rcvd" ); break; } }
Callbacks and local functions • void GenericApp_SendTheMessage( void ) • { • char theMessageData[] = • "Hello World"; • AF_DataRequest • ( &DstAddr, epDesc, • GENERICAPP_CLUSTERID, • (byte)osal_strlen • ( theMessageData ) + 1, • theMessageData,...) • }
Why ZigBee? Standards based Low cost Can be used globally Reliable and self healing Supports a large number of nodes Easy to deploy Very long battery life Secure But making application development easier would be really useful...
Agenda Middleware for NES: an introduction ZigBee: as a Middleware for NES Abstract Middleware Environment (AME): a framework for Middleware-centric NES applications generation
Agenda (AME) Typical NES Design Flow AME-centric design flow Abstract Middleware Environment (AME) Example 1 (Programming paradigm) Example 2 (Mapping)