GithubHelp home page GithubHelp logo

arasgungore / eebus-in-java Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 70 KB

Java implementation of the EEBUS protocol suite which provides support for the SHIP and SPINE protocols.

Home Page: https://enbility.net

License: MIT License

Go 44.77% Java 55.23%
eebus java network-programming protocols ship spine tcp-ip communication-layer communication-protocol data-exchange

eebus-in-java's Introduction

EEBUS-in-Java

EEBUS Logo

Java implementation of the EEBUS protocol suite which provides support for the SHIP and SPINE protocols. The EEBUS protocols facilitate efficient communication among smart home IoT devices, allowing seamless integration regardless of device brand or type. This open-source framework aims to offer a future-proof solution applicable to various environments and applications.

Table of Contents

Prerequisites

Before you begin, ensure you have the following requirements installed on your machine:

  • Java
  • Maven for building and managing dependencies

Getting Started

To start using the project, follow these steps:

  1. Build the project using Maven:

    mvn clean install
  2. Run the main driver code or utilize the provided classes for your application.

Usage

General Usage

The framework can be utilized as follows:

// Importing the framework
import eebus "github.com/LMF-DHBW/go-eebus"

// Configure EEBUS node
eebusNode = eebus.NewEebusNode("100.90.1.102", true, "gateway", "0001", "DHBW", "Gateway");

// IP-Adr, is gateway, ssl cert name, device ID, brand name, device type
eebusNode.Update = update; // set method called on subscription updates

// Function that creates device structure
buildDeviceModel(eebusNode);

// Start node
eebusNode.Start();

Creating Device Structure

The device structure for an EEBUS node can be created as follows:

eebusNode.DeviceStructure.DeviceType = "Generic";
eebusNode.DeviceStructure.DeviceAddress = "Switch1";
eebusNode.DeviceStructure.Entities = Arrays.asList(
    new resources.EntityModel(
        "Switch",
        0,
        Arrays.asList(
            eebusNode.DeviceStructure.createNodeManagement(false),
            new resources.FeatureModel(
                "ActuatorSwitch",
                1,
                "client",
                resources.ActuatorSwitch("button", "button for leds"),
                Arrays.asList("ActuatorSwitch")
            )
        )
    )
);

// Create node management again, in order to update discovery data
eebusNode.DeviceStructure.Entities.get(0).getFeatures().set(0, eebusNode.DeviceStructure.createNodeManagement(false));

Accepting Requests from Gateway

Requests from the gateway can be accepted as follows:

// Requests are saved in the following list
eebusNode.SpineNode.ShipNode.Requests;

int i = 0; // Select the first entry as an example

// Accept request by connecting with the device
Request req = eebusNode.SpineNode.ShipNode.Requests.get(i);
new Thread(() -> eebusNode.SpineNode.ShipNode.connect(req.getPath(), req.getSki())).start();

// Remove request from list
eebusNode.SpineNode.ShipNode.Requests.remove(i);

Reading Subscription Messages

public void update(resources.DatagramType data, spine.SpineConnection conn) {
    int entitySource = data.getHeader().getAddressSource().getEntity();
    int featureSource = data.getHeader().getAddressSource().getFeature();

    if (conn.DiscoveryInformation.FeatureInformation.get(featureSource).getDescription().getFeatureType().equals("Measurement")) {
        resources.MeasurementDataType Function = JAXB.unmarshal(new StringReader(data.getPayload().getCmd().getFunction()), resources.MeasurementDataType.class);
        // Function.getValue() contains measured value
    }
}

Reading Feature States

for (spine.SpineConnection e : eebusNode.SpineNode.Connections) {
    for (resources.FeatureInformation feature : e.SubscriptionData) {
        if ("ActuatorSwitch".equals(feature.getFeatureType()) && "LED".equals(feature.getEntityType())) {
            resources.FunctionElement state = JAXB.unmarshal(new StringReader(feature.getCurrentState()), resources.FunctionElement.class);
            // state.getFunction() contains the state (on/off)
        }
    }
}

Sending Subscription Messages

for (spine.SpineConnection e : eebusNode.SpineNode.Subscriptions) {
    e.send("notify", resources.makePayload("actuatorSwitchData",
            new resources.FunctionElement("on")));
}

Sending Binding Messages

for (spine.SpineConnection e : eebusNode.SpineNode.Bindings) {
    e.send("write", resources.makePayload("actuatorSwitchData",
            new resources.FunctionElement("toggle")));
}

Feel free to adjust these examples to fit your specific use case.

License

This project is licensed under the MIT License.

Acknowledgements

This Java implementation is inspired by the Go-based EEBUS communication framework go_eebus.

Author

👤 Aras Güngöre

eebus-in-java's People

Contributors

arasgungore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eebus-in-java's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.