Skip to content
Snippets Groups Projects
Commit 7cb455b6 authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'mqtt-user-pwd' into dev

parents b59e8a16 c8d9962f
No related branches found
No related tags found
1 merge request!19dev to master
Pipeline #8231 passed
...@@ -5,4 +5,4 @@ venv/ ...@@ -5,4 +5,4 @@ venv/
*/out/ */out/
*/build/ */build/
logs/ logs/
datasets datasets/
LICENSE 0 → 100644
MIT License
Copyright (c) 2019 OpenLicht
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[![pipeline status](/../badges/dev/pipeline.svg)](/../pipelines)
[![pipeline status](/../badges/dev/coverage.svg)](/../pipelines)
# ERASER - OpenLicht Knowledge Base # ERASER - OpenLicht Knowledge Base
## Overview ## Overview
There are a few subprojects in this repository: There are the following subprojects in this repository:
- Base - Base
- **eraser-base**: The core part of the framework containing the [grammar](/../blob/dev/eraser-base/src/main/jastadd/main.relast), various attributes, the [parser](/../blob/dev/eraser-base/src/main/jastadd/eraser.parser) for model specification files, and Java classes for the [openHAB communication](/../tree/dev/eraser-base/src/main/java/de/tudresden/inf/st/eraser/openhab2) via [MQTT](/../blob/dev/eraser-base/src/main/java/de/tudresden/inf/st/eraser/openhab2/mqtt/MQTTUpdater.java) - **eraser-base**: The core part of the framework containing the [grammar](/../../blob/master/eraser-base/src/main/jastadd/main.relast), various attributes, the [parser](/../../blob/master/eraser-base/src/main/jastadd/eraser.parser) for model specification files, and Java classes for the [openHAB communication](/../../tree/master/eraser-base/src/main/java/de/tudresden/inf/st/eraser/openhab2) via [MQTT](/../../blob/master/eraser-base/src/main/java/de/tudresden/inf/st/eraser/openhab2/mqtt/MQTTUpdater.java)
- Utility - Utility
- **commons.color**: Utilities for converting color spaces (XYZ, RGB, HSB) - **commons.color**: Utilities for converting color spaces (XYZ, RGB, HSB)
- **eraser.rest** and **eraser.spark**: REST-API to communicate with the framework
- **eraser.starter**: The main entry point to start the application
- **feedbackloop.\***: Component specification and implementation of the MAPE-K feedback loop
- **project-template**: Template to quickly create new subprojects used by `make-new-project.py` - **project-template**: Template to quickly create new subprojects used by `make-new-project.py`
- Demos - Demos
- **integration** and **openhab-mock**: Playground projects testing some features - **integration** and **openhab-mock**: Playground projects testing some features
- **skywriter-hue-integration**: The first real demonstrator integrating the [Skywriter gesture recogintion](http://docs.pimoroni.com/skywriter) with a [Hue](http://www.meethue.com/) using a simple rule - **skywriter-hue-integration**: The first real demonstrator integrating the [Skywriter gesture recogintion](http://docs.pimoroni.com/skywriter) with a [Hue](http://www.meethue.com/) using a simple rule
- Machine Learning Integration - **benchmark**: Small benchmark to replay previously recoreded sensor events
- **org.openhab.action.machinelearn**: openHAB connector of the Machine Learning Part (implemented by Kay) - Machine Learning Integration (deprecated)
- **org.openlicht.action.reinforcementlearning**: Reinforcement-Learning of preferences (implemented by Kay) - org.openhab.action.machinelearn: openHAB connector of the Machine Learning Part
- **stub.org.openhab.core.scriptengine.action**: Stub to make the other two projects build - org.openlicht.action.reinforcementlearning: Reinforcement-Learning of preferences
- stub.org.openhab.core.scriptengine.action: Stub to make the other two projects build
## Setup and Building ## Setup and Building
This project uses Gradle as the build tool. For detailed information, see [setup guidelines](/../wikis/setup) This project uses Gradle as the build tool. For detailed information, see [setup guidelines](/../../wikis/setup)
## Running the demo ## Running the demo
......
...@@ -227,6 +227,8 @@ MqttRoot mqtt_root_body = ...@@ -227,6 +227,8 @@ MqttRoot mqtt_root_body =
INCOMING EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setIncomingPrefix(n); return mrb; :} INCOMING EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setIncomingPrefix(n); return mrb; :}
| OUTGOING EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setOutgoingPrefix(n); return mrb; :} | OUTGOING EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setOutgoingPrefix(n); return mrb; :}
| HOST EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setHostByName(n); return mrb; :} | HOST EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setHostByName(n); return mrb; :}
| USER EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setUser(n); return mrb; :}
| PASSWORD EQUALS TEXT.n mqtt_root_body.mrb {: mrb.setPassword(n); return mrb; :}
| {: return new MqttRoot(); :} | {: return new MqttRoot(); :}
; ;
......
...@@ -48,7 +48,7 @@ aspect MQTT { ...@@ -48,7 +48,7 @@ aspect MQTT {
} else { } else {
result = new MQTTSenderStub(); result = new MQTTSenderStub();
} }
return result.setHost(getHost()); return result.setHost(getHost(), getUser(), getPassword());
} }
//--- getMqttRoot --- //--- getMqttRoot ---
......
// ---------------- MQTT ------------------------------ // ---------------- MQTT ------------------------------
MqttRoot ::= Topic:MqttTopic* <IncomingPrefix:String> <OutgoingPrefix:String> [Host:ExternalHost] ; MqttRoot ::= Topic:MqttTopic* <IncomingPrefix:String> <OutgoingPrefix:String> <User:String> <Password:String> [Host:ExternalHost] ;
MqttTopic ::= <TopicString:String> ; MqttTopic ::= <TopicString:String> ;
rel Item.Topic? <-> MqttTopic.Item* ; rel Item.Topic? <-> MqttTopic.Item* ;
...@@ -12,10 +12,21 @@ import java.util.concurrent.TimeUnit; ...@@ -12,10 +12,21 @@ import java.util.concurrent.TimeUnit;
public interface MQTTSender extends AutoCloseable { public interface MQTTSender extends AutoCloseable {
/** /**
* Sets the host running the MQTT broker. * Sets the host running the MQTT broker (no username/password set).
* @param host host name (IP address or domain name) and port * @param host host name (IP address or domain name) and port
*/ */
MQTTSender setHost(ExternalHost host); default MQTTSender setHost(ExternalHost host) {
return setHost(host, null, null);
}
/**
* Sets the host, username and password running the MQTT broker.
* @param host host name (IP address or domain name) and port
* @param username username for authentication
* @param password password for authentication
*/
MQTTSender setHost(ExternalHost host, String username, String password);
/** /**
* Set the timeout used for connecting and disconnecting. * Set the timeout used for connecting and disconnecting.
......
...@@ -29,11 +29,17 @@ public class MQTTSenderImpl implements MQTTSender { ...@@ -29,11 +29,17 @@ public class MQTTSenderImpl implements MQTTSender {
private TimeUnit publishTimeoutUnit; private TimeUnit publishTimeoutUnit;
@Override @Override
public MQTTSender setHost(ExternalHost host) { public MQTTSender setHost(ExternalHost host, String username, String password) {
/* The host running the MQTT broker. */ /* The host running the MQTT broker. */
URI hostUri = URI.create("tcp://" + host.getHostName() + ":" + host.getPort()); URI hostUri = URI.create("tcp://" + host.getHostName() + ":" + host.getPort());
logger.debug("Host is {}", hostUri); logger.debug("Host is {}", hostUri);
MQTT mqtt = new MQTT(); MQTT mqtt = new MQTT();
if (username != null && !username.isEmpty()) {
mqtt.setUserName(username);
}
if (password != null && !password.isEmpty()) {
mqtt.setPassword(password);
}
mqtt.setHost(hostUri); mqtt.setHost(hostUri);
connection = mqtt.futureConnection(); connection = mqtt.futureConnection();
setConnectTimeout(2, TimeUnit.SECONDS); setConnectTimeout(2, TimeUnit.SECONDS);
......
...@@ -20,7 +20,7 @@ public class MQTTSenderStub implements MQTTSender { ...@@ -20,7 +20,7 @@ public class MQTTSenderStub implements MQTTSender {
private Logger logger = LogManager.getLogger(MQTTSenderStub.class); private Logger logger = LogManager.getLogger(MQTTSenderStub.class);
private PublishCallback callback; private PublishCallback callback;
public MQTTSender setHost(ExternalHost host) { public MQTTSender setHost(ExternalHost host, String username, String password) {
return this; return this;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment