hauke / hanfun

ULE Alliance's HAN-FUN common implementation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HAN-FUN

This project aims at providing an implementation of the ULE Alliance HAN-FUN application specification.

Overview

A HAN-FUN network is composed by a concentrator (base) and one or more nodes, in a star configuration, all the nodes connect to the concentrator that serves a router between all the nodes in the network.

A HAN-FUN device, either concentrator or node, is composed of one or more units. Each unit implements a profile, i.e. a predefined configuration of interfaces and any number of optional interfaces.

HAN-FUN interfaces have two roles, Client and Server and define what attributes are present in each role. They also define the commands supported between each role.

In each device there is a special unit, unit 0, that provides core infrastructure services, for example, the Device Management service, the Device Information service and the Attribute Reporting service.

In order to access the HAN-FUN network, a node must first register it self with the base to obtain it's HAN-FUN address, by using the commands available in the Device Management service.

This address will then be used to send/receive packets from the network.

Project Setup

This project is implemented in C++ and depends only on the standard C++ library for usage, however the unit tests and example applications depend on third-party libraries.

The build system used is CMake.

  • Dependencies

    • gcc (>= 4.6)
    • cmake (>= 2.8.11)
  • Building:

    $ mkdir build/
    $ cd build/
    $ cmake ..
    $ make
    $ make doc # Build the documentation
    

The Doxygen generated API documentation can be found here.

The project will follow this convention for development. The following helper scripts are available.

The versions of the project follow the SemVer 2.0.0 specification.

Testing

Currently the build of the unit tests is only supported when compiling using the code from the repository.

To build the unit tests present in the source code, issue the following commands (on the root of the project):

$ git submodule init
$ git submodule update
$ mkdir build
$ cd build
$ CMake -DHAN-FUN_BUILD_TESTS=ON ..
$ make

The unit tests will be run at the end of the compilation if not cross-compiling.

To re-run the tests, issue:

$ make check

Examples

The folder apps/ contains two example applications, one for the concentrator (base) side and one for the node side.

The apps/example_XX.cpp files contain standalone applications that demo API usage. Use make example_XX to build each application or make examples to build all of them.

The applications communicate over TCP/IP. The support for this transport layer is based on the libuv. This is downloaded and build automatically when building the example applications is requested.

To build the example applications, issue the following commands (on the root of the project):

$ mkdir build
$ cd build
$ cmake -DHF_BUILD_APPS=ON ..
$ make

This will build the example applications for the base (build/apps/base) and for the node (build/apps/node).

The base application demonstrates the registration of nodes in a HAN-FUN network and the binding of nodes that have complementary interfaces.

The node application demonstrates, a simple switch or a simple light application.

For example to register a simple switch and simple light to the base and bind the switch to the light so that when the switch toggles it toggles the light.

  • Open three terminals and start the applications;

    $ apps/base    (Base)
    $ apps/node 1  (Simple Switch)
    $ apps/node 2  (Simple Light)
    
  • Change the first node application to a simple switch;

    > ss
    
  • Change the second node application to a simple light;

    > sl
    
  • Start registration on the base and register the simple switch;

    > r 1 1 (on the base terminal)
    > r (on the switch terminal)
    > a (check device address, it should be 1)
    
  • Start registration on the base and register the simple light;

    > r 1 2 (on the base terminal)
    > r (on the light terminal)
    > a (check device address, it should be 2)
    
  • Bind the switch to the light;

    > b 1 2 (on the base terminal)
    
  • Send a toggle command from the switch to the light :

    > toggle (on the switch terminal)
    

The last command should make the node application configured as a light print that a toggle command was received.

Please see the help in the applications for further features.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request (PR).

Author

License

This library is released under dual-license, GLPv2 and Apache 2.0.

Please see the file 'LICENSE' in the root folder for further information.

About

ULE Alliance's HAN-FUN common implementation.

License:Other


Languages

Language:C++ 98.1%Language:CMake 1.5%Language:Shell 0.3%Language:C 0.2%