Permalink
Browse files

added functionality to request href of a device with corresponding

decoded qr-code (add <location> tag to device.xml)
  • Loading branch information...
RamsauerDaniel RamsauerDaniel
RamsauerDaniel authored and RamsauerDaniel committed Jul 15, 2017
1 parent 442a145 commit 840357fcbaaee4cc57ab594cb65672fec23aeb86
Showing with 527 additions and 335 deletions.
  1. +9 −1 iotsys-bacnet/src/at/ac/tuwien/auto/iotsys/gateway/connectors/bacnet/BacnetDeviceLoaderImpl.java
  2. +9 −1 iotsys-coap/src/at/ac/tuwien/auto/iotsys/gateway/connectors/coap/CoapDeviceLoaderImpl.java
  3. +2 −0 iotsys-common/src/at/ac/tuwien/auto/iotsys/commons/ObjectBroker.java
  4. +12 −3 iotsys-common/src/at/ac/tuwien/auto/iotsys/commons/persistent/models/Device.java
  5. +10 −2 iotsys-enocean/src/at/ac/tuwien/auto/iotsys/gateway/connectors/enocean/EnoceanDeviceLoaderImpl.java
  6. +25 −2 iotsys-gateway/config/devices.xml
  7. +26 −0 iotsys-gateway/src/at/ac/tuwien/auto/iotsys/gateway/obix/objectbroker/ObjectBrokerImpl.java
  8. +2 −1 iotsys-gateway/src/at/ac/tuwien/auto/iotsys/gateway/obix/server/CoAPHelper.java
  9. +6 −1 iotsys-gateway/src/at/ac/tuwien/auto/iotsys/gateway/obix/server/CoAPServer.java
  10. +7 −0 iotsys-gateway/src/at/ac/tuwien/auto/iotsys/gateway/obix/server/ObixServer.java
  11. +6 −1 iotsys-gateway/src/at/ac/tuwien/auto/iotsys/gateway/obix/server/ObixServerImpl.java
  12. +14 −2 iotsys-knx/src/at/ac/tuwien/auto/iotsys/gateway/connectors/knx/KNXDeviceLoaderImpl.java
  13. +10 −2 iotsys-mbus/src/at/ac/tuwien/auto/iotsys/gateway/connector/mbus/MBusDeviceLoaderImpl.java
  14. +28 −1 iotsys-obix/src/obix/Obj.java
  15. +5 −0 iotsys-obix/src/obix/io/ObixEncoder.java
  16. +320 −312 iotsys-rfid/src/at/ac/tuwien/auto/iotsys/gateway/connectors/rfid/RfidDeviceLoaderImpl.java
  17. +10 −1 iotsys-virtual/src/at/ac/tuwien/auto/iotsys/gateway/connectors/virtual/VirtualDeviceLoaderImpl.java
  18. +9 −2 .../at/ac/tuwien/auto/iotsys/gateway/connectors/weatherforecast/WeatherForecastDeviceLoaderImpl.java
  19. +9 −1 iotsys-wmbus/src/at/ac/tuwien/auto/iotsys/gateway/connector/wmbus/WMBusDeviceLoaderImpl.java
  20. +8 −2 iotsys-xbee/src/at/ac/tuwien/auto/iotsys/gateway/connectors/xbee/XBeeDeviceLoaderImpl.java
@@ -191,6 +191,8 @@
Integer historyCount = subConfig.getInt("device("
+ i + ").historyCount", 0);
String location = subConfig.getString("device(" + i + ").location");
Device deviceFromDb;
try {
@@ -207,11 +209,12 @@
groupCommEnabled = deviceFromDb.isGroupcommEnabled();
refreshEnabled = deviceFromDb.isRefreshEnabled();
historyCount = deviceFromDb.getHistoryCount();
location = deviceFromDb.getLocation();
}
catch (Exception e) {
}
// Transition step: comment when done
Device d = new Device(type, ipv6, addressString, href, name, displayName, historyCount, historyEnabled, groupCommEnabled, refreshEnabled);
Device d = new Device(type, ipv6, addressString, href, name, displayName, historyCount, historyEnabled, groupCommEnabled, refreshEnabled, location);
objectBroker.getConfigDb().prepareDevice(connectorName, d);
if (type != null && address != null) {
@@ -290,6 +293,11 @@
bacnetDevice.setDisplayName(displayName);
}
// set location of device if available (e.g. QR-Code)
if(location != null && location.length() > 0){
bacnetDevice.setLocation(location);
}
if (ipv6 != null) {
objectBroker.addObj(bacnetDevice, ipv6);
@@ -180,6 +180,8 @@
Boolean refreshEnabled = subConfig.getBoolean(
"device(" + i + ").refreshEnabled", false);
String location = subConfig.getString("device(" + i + ").location");
Device deviceFromDb;
try {
@@ -193,11 +195,12 @@
groupCommEnabled = deviceFromDb.isGroupcommEnabled();
refreshEnabled = deviceFromDb.isRefreshEnabled();
historyCount = deviceFromDb.getHistoryCount();
location = deviceFromDb.getLocation();
}
catch (Exception e) {}
// Transition step: comment when done
Device d = new Device(type, null, addressString, href, name, displayName, historyCount, historyEnabled, groupCommEnabled, refreshEnabled);
Device d = new Device(type, null, addressString, href, name, displayName, historyCount, historyEnabled, groupCommEnabled, refreshEnabled, location);
objectBroker.getConfigDb().prepareDevice(connectorName, d);
if (type != null && address != null) {
try {
@@ -250,6 +253,11 @@
coapDevice.setDisplayName(displayName);
}
// set location of device if available (e.g. QR-Code)
if(location != null && location.length() > 0){
coapDevice.setLocation(location);
}
objectBroker.addObj(coapDevice);
myObjects.add(coapDevice);
coapDevice.initialize();
@@ -63,4 +63,6 @@
public ConfigsDb getConfigDb();
public void setConfigDb(ConfigsDb configDb);
public abstract String getQRCode(String qrcode);
}
@@ -38,13 +38,14 @@
private boolean historyEnabled;
private boolean groupcommEnabled;
private boolean refreshEnabled;
private String location;
public Device(){}
public Device(String type2, String ipv62, String address2, String href2,
String name2, String displayName2, Integer historyCount2,
boolean historyEnabled2, boolean groupCommEnabled2,
boolean refreshEnabled2) {
boolean refreshEnabled2, String location) {
this.type = type2;
this.ipv6 = ipv62;
this.address = address2;
@@ -55,11 +56,12 @@ public Device(String type2, String ipv62, String address2, String href2,
this.historyEnabled = historyEnabled2;
this.groupcommEnabled = groupCommEnabled2;
this.refreshEnabled = refreshEnabled2;
this.location = location;
}
public Device(String type2, String ipv62, String addressString,
String href2, String name2, Integer historyCount2,
boolean historyEnabled2, boolean groupCommEnabled2) {
this(type2, ipv62, addressString, href2, name2, "", historyCount2, historyEnabled2, groupCommEnabled2, false);
boolean historyEnabled2, boolean groupCommEnabled2, String location) {
this(type2, ipv62, addressString, href2, name2, "", historyCount2, historyEnabled2, groupCommEnabled2, false, location);
}
public String getConnectorId() {
@@ -129,4 +131,11 @@ public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}
@@ -177,6 +177,8 @@ public EnoceanDeviceLoaderImpl() {
String addressString = address.toString();
String location = subConfig.getString("device(" + i + ").location");
Device deviceFromDb;
try {
deviceFromDb = devicesFromDb.get(i);
@@ -189,11 +191,12 @@ public EnoceanDeviceLoaderImpl() {
groupCommEnabled = deviceFromDb.isGroupcommEnabled();
refreshEnabled = deviceFromDb.isRefreshEnabled();
historyCount = deviceFromDb.getHistoryCount();
location = deviceFromDb.getLocation();
}
catch (Exception e) {}
// Transition step: comment when done
Device d = new Device(type, ipv6, addressString, href, name, null, historyCount, historyEnabled, groupCommEnabled, refreshEnabled);
Device d = new Device(type, ipv6, addressString, href, name, null, historyCount, historyEnabled, groupCommEnabled, refreshEnabled, location);
objectBroker.getConfigDb().prepareDevice(connectorName, d);
log.info("type: " + type);
@@ -221,7 +224,12 @@ public EnoceanDeviceLoaderImpl() {
if (name != null && name.length() > 0) {
enoceanDevice.setName(name);
}
}
// set location of device if available (e.g. QR-Code)
if(location != null && location.length() > 0){
enoceanDevice.setLocation(location);
}
if (ipv6 != null)
{
@@ -590,7 +590,7 @@
<forceRefresh>false</forceRefresh>
<router>
<!--<ip>192.168.161.59</ip> -->
<ip>192.168.1.100</ip>
<ip>10.0.0.2</ip>
<!-- <ip>192.168.161.61</ip> -->
<port>3671</port>
</router>
@@ -687,7 +687,7 @@
<name>KNX TP1 Suitcase</name>
<enabled>false</enabled>
<router>
<ip>192.168.1.101</ip>
<ip>10.0.0.2</ip>
<port>3671</port>
</router>
<localIP>auto</localIP>
@@ -718,6 +718,8 @@
<address>null, 1/0/0</address>
<href>light1</href>
<historyEnabled>false</historyEnabled>
<groupCommEnabled>true</groupCommEnabled>
<location>light1QR</location>
</device>
<device>
@@ -726,7 +728,20 @@
<address>null, 1/0/1</address>
<href>brightness1</href>
<historyEnabled>false</historyEnabled>
<location>brightness1QR</location>
</device>
<device>
<type>at.ac.tuwien.auto.iotsys.gateway.obix.objects.iot.sensors.impl.knx.PushButtonImplKnx
</type>
<address>1/0/4</address>
<href>switch1</href>
<displayName>Button 1</displayName>
<historyEnabled>false</historyEnabled>
<groupCommEnabled>true</groupCommEnabled>
<location>switch1QR</location>
</device>
</connector>
<connector>
@@ -1368,6 +1383,7 @@
<historyEnabled>false</historyEnabled>
<historyCount>200</historyCount>
<groupCommEnabled>true</groupCommEnabled>
<location>virtualIndoorBrightnessSensorQR</location>
</device>
@@ -1387,6 +1403,7 @@
<historyEnabled>false</historyEnabled>
<historyCount>200</historyCount>
<groupCommEnabled>true</groupCommEnabled>
<location>virtualPresenceQR</location>
</device>
<device>
@@ -1406,12 +1423,14 @@
</type>
<href>virtualRoomTemperatureSensor</href>
<groupCommEnabled>true</groupCommEnabled>
<location>virtualRoomTemperatureSensorQR</location>
</device>
<device>
<type>at.ac.tuwien.auto.iotsys.commons.obix.objects.iot.sensors.impl.TemperatureSensorImpl
</type>
<href>virtualTemperatureSensor</href>
<refreshEnabled>false</refreshEnabled>
<location>virtualTemperatureSensorQR</location>
</device>
<device>
@@ -1484,6 +1503,7 @@
<historyEnabled>false</historyEnabled>
<historyCount>200</historyCount>
<groupCommEnabled>true</groupCommEnabled>
<location>sunblindMiddleAQR</location>
</device>
@@ -1534,6 +1554,7 @@
<historyEnabled>false</historyEnabled>
<historyCount>10</historyCount>
<groupCommEnabled>true</groupCommEnabled>
<location>virtualLightQR</location>
</device>
<device>
@@ -1563,6 +1584,7 @@
<href>virtualBoilerActuatorImpl</href>
<historyEnabled>false</historyEnabled>
<groupCommEnabled>true</groupCommEnabled>
<location>virtualBoilerActuatorImplQR</location>
</device>
</connector>
<connector>
@@ -1620,6 +1642,7 @@
<historyEnabled>false</historyEnabled>
<refreshEnabled>false</refreshEnabled>
<groupCommEnabled>false</groupCommEnabled>
<location>hvacSimSuitcaseQR</location>
</device>
</connector>
@@ -422,8 +422,34 @@ private void closeConnectors()
}
}
@Override
public synchronized String getQRCode(String qrcode) {
return getQRCode(rootObject, qrcode);
}
/**
* returns the href of obj with the corresponding qrcode or an empty string if the device with this qrcode does not exist
* @param obj
* @param qrcode
* @return href
*/
private String getQRCode(Obj obj, String qrcode)
{
String qrCodeObj = "";
if (obj.getHref() == null)
return qrCodeObj;
for (Obj child : obj.list())
{
if(child.getLocation() != null && child.getLocation().equals(qrcode))
qrCodeObj = child.getHref().toString();
}
return qrCodeObj;
}
// @Override
// public boolean doNotListCategorylessObjs() {
// return true;
// }
}
@@ -105,7 +105,8 @@ else if (request.getFirstAccept() == MediaTypeRegistry.APPLICATION_JSON) {
request.respond(CodeRegistry.RESP_CONTENT,
obixResponse,
MediaTypeRegistry.APPLICATION_LINK_FORMAT);
} else if(request.getUriPath().endsWith("qrcode")){
request.respond(CodeRegistry.RESP_CONTENT, obixResponse, MediaTypeRegistry.TEXT_PLAIN);
} else {
request.respond(CodeRegistry.RESP_CONTENT, obixResponse, MediaTypeRegistry.TEXT_XML);
}
@@ -159,7 +159,12 @@ private String getObixResponse(Request request) throws URISyntaxException {
obixResponse.toString(),
MediaTypeRegistry.APPLICATION_LINK_FORMAT);
} else {
} else if(resourcePath.endsWith("qrcode"))
{ // entered if Coap post with /qrcode at the end
// payloadString contains the qrcode
obixResponse = new StringBuffer(obixServer.getQRCode(payloadString));
}
else {
Obj responseObj = null;
if (request instanceof GETRequest) {
@@ -94,4 +94,11 @@
public String getCoRELinks();
public ObjectBroker getObjectBroker();
public UIDb getUidb();
/**
* Get the hred of an obj with the corresponding qrcode
* @param qrcode
* @return href
*/
public String getQRCode(String qrcode);
}
@@ -134,5 +134,10 @@ public String getNormalizedPath(String href) {
return o.getFullContextPath();
}
@Override
public String getQRCode(String qrcode)
{
return objectBroker.getQRCode(qrcode);
}
}
Oops, something went wrong.

0 comments on commit 840357f

Please sign in to comment.