Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'maven'

group 'org.iot.dsa'
version '0.13.0'
version '0.14.0'

sourceCompatibility = 1.6
targetCompatibility = 1.6
Expand Down
14 changes: 7 additions & 7 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ Nodes are where application specific logic is bound to the link architecture. N
will use various lifecycle callbacks to trigger their logic.

First you must create a root node. It is the hook for the rest of your functionality. The
convention is to name it RootNode, but make sure it is in a unique package so that multiple links
convention is to name it MainNode, but make sure it is in a unique package so that multiple links
can be run in the same process.

Then you will probably create additional nodes that will be descendants in the tree rooted by your
root node.

### Root Node
### Main Node

All links require a single root node and it must subclass
[org.iot.dsa.dslink.DSRootNode](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/dslink/DSRootNode.html).
The convention is to name the class RootNode but the package must be unique from any other
RootNodes so that multiple links can be run in the same process.
[org.iot.dsa.dslink.DSMainNode](https://iot-dsa-v2.github.io/sdk-dslink-java-v2/javadoc/index.html?org/iot/dsa/dslink/DSMainNode.html).
The convention is to name the class MainNode but the package must be unique from any other
MainNodes so that multiple links can be run in the same process.

When a link launches the first time, the type of the root node is looked up **dslink.json**.
The config _rootType_ must store the fully qualified class name of the root node. After the first
launch, the configuration database is serialized and the _rootType_ config will longer have an
The config _mainType_ must store the fully qualified class name of the root node. After the first
launch, the configuration database is serialized and the _mainType_ config will longer have an
impact.

### Additional Nodes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.iot.dsa.io;
package com.acuity.iot.dsa.dslink.io;

import java.nio.ByteBuffer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.iot.dsa.io;
package com.acuity.iot.dsa.dslink.io;

/**
* A buffer for storing chars being pushed from a reader. Useful when chars are coming
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.iot.dsa.io;
package com.acuity.iot.dsa.dslink.io;

/**
* Unchecked IOException.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class DS1ConnectionInit extends DSNode {
///////////////////////////////////////////////////////////////////////////

private static final String DSA_VERSION = "1.1.2";
private static final String[] SUPPORTED_FORMATS = new String[]{"msgpack", "json"};
//private static final String[] SUPPORTED_FORMATS = new String[]{"json"};
//private static final String[] SUPPORTED_FORMATS = new String[]{"msgpack", "json"};
private static final String[] SUPPORTED_FORMATS = new String[]{"json"};

private String BROKER_REQ = "Broker Request";
private String BROKER_RES = "Broker Response";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
package com.acuity.iot.dsa.dslink.protocol.protocol_v1;

import com.acuity.iot.dsa.dslink.transport.DSBinaryTransport;
import com.acuity.iot.dsa.dslink.transport.DSTextTransport;
import com.acuity.iot.dsa.dslink.transport.DSTransport;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.iot.dsa.dslink.DSIRequester;
import org.iot.dsa.dslink.DSLink;
import org.iot.dsa.dslink.DSLinkConfig;
import org.iot.dsa.dslink.DSLinkConnection;
import org.iot.dsa.io.DSIReader;
import org.iot.dsa.io.DSIWriter;
import org.iot.dsa.io.json.JsonReader;
import org.iot.dsa.io.json.JsonWriter;
import org.iot.dsa.io.msgpack.MsgpackReader;
import org.iot.dsa.io.msgpack.MsgpackWriter;
import org.iot.dsa.time.DSTime;
import org.iot.dsa.util.DSException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import org.iot.dsa.dslink.requester.OutboundSubscribeHandler;
import org.iot.dsa.io.DSIWriter;
import org.iot.dsa.logging.DSLogger;
import org.iot.dsa.node.*;
import org.iot.dsa.node.DSElement;
import org.iot.dsa.node.DSList;
import org.iot.dsa.node.DSMap;
import org.iot.dsa.node.DSNull;
import org.iot.dsa.node.DSStatus;
import org.iot.dsa.time.DSDateTime;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import org.iot.dsa.dslink.DSIRequester;
import org.iot.dsa.dslink.requester.OutboundInvokeHandler;
import org.iot.dsa.dslink.requester.OutboundListHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,38 @@ private void encodeChild(ApiObject child, DSIWriter out) {
} else if (displayName != null) {
out.key("$name").value(displayName);
}
e = cacheMap.remove("is");
e = cacheMap.remove("$is");
if (e != null) {
out.key("$is").value(e);
} else {
out.key("$is").value("node");
}
if (child.isAction()) {
ActionSpec action = child.getAction();
e = cacheMap.remove("invokable");
e = cacheMap.remove("$invokable");
if (e != null) {
out.key("$invokable").value(e);
} else {
out.key("$invokable").value(action.getPermission().toString());
}
} else if (child.isValue()) {
out.key("$type");
e = cacheMap.remove("type");
e = cacheMap.remove("$type");
if (e != null) {
out.value(e);
} else {
encodeType(child.getValue(), cacheMeta, out);
}
if (!child.isReadOnly()) {
e = cacheMap.remove("writable");
e = cacheMap.remove("$writable");
if (e != null) {
out.key("$writable").value(e);
} else {
out.key("$writable").value(child.isConfig() ? "config" : "write");
out.key("$writable").value(child.isAdmin() ? "config" : "write");
}
}
} else if (child.isConfig()) {
e = cacheMap.remove("permission");
} else if (child.isAdmin()) {
e = cacheMap.remove("$permission");
if (e != null) {
out.key("$permission").value(e);
} else {
Expand All @@ -202,18 +202,18 @@ private void encodeChild(ApiObject child, DSIWriter out) {
*/
private void encodeTarget(ApiObject object, DSIWriter out) {
if (object instanceof DSInfo) {
DSMetadata.getMetadata((DSInfo)object, cacheMap.clear());
DSMetadata.getMetadata((DSInfo) object, cacheMap.clear());
} else {
object.getMetadata(cacheMap.clear());
}
DSElement e = cacheMap.remove("is");
DSElement e = cacheMap.remove("$is");
if (e == null) {
out.beginList().value("$is").value("node").endList();
} else {
out.beginList().value("$is").value(e).endList();

}
e = cacheMap.get("name");
e = cacheMap.get("$name");
if (e == null) {
String safeName = object.getName();
if (DSPath.encodeName(safeName, cacheBuf)) {
Expand All @@ -228,8 +228,8 @@ private void encodeTarget(ApiObject object, DSIWriter out) {
encodeTargetAction(object, out);
} else if (object.isValue()) {
encodeTargetValue(object, out);
} else if (object.isConfig()) {
e = cacheMap.remove("permission");
} else if (object.isAdmin()) {
e = cacheMap.remove("$permission");
if (e == null) {
out.beginList().value("$permission").value("config").endList();
} else {
Expand All @@ -253,7 +253,7 @@ private void encodeTargetAction(ApiObject object, DSIWriter out) {
if (action instanceof DSAction) {
dsAction = (DSAction) action;
}
DSElement e = cacheMap.remove("invokable");
DSElement e = cacheMap.remove("$invokable");
out.beginList().value("$invokable");
if (e == null) {
out.value(action.getPermission().toString()).endList();
Expand Down Expand Up @@ -281,7 +281,7 @@ private void encodeTargetAction(ApiObject object, DSIWriter out) {
}
out.endList();
if (action.getResultType().isValues()) {
e = cacheMap.remove("columns");
e = cacheMap.remove("$columns");
out.beginList().value("$columns");
if (e == null) {
out.beginList();
Expand All @@ -302,7 +302,7 @@ private void encodeTargetAction(ApiObject object, DSIWriter out) {
}
out.endList();
}
e = cacheMap.remove("result");
e = cacheMap.remove("$result");
if (e != null) {
out.beginList().value("$result").value(e).endList();
} else if (!action.getResultType().isVoid()) {
Expand All @@ -328,7 +328,7 @@ private void encodeTargetMetadata(DSMap metadata, DSIWriter out) {
case '@':
out.value(name);
default:
cacheBuf.append("@");
cacheBuf.append("@"); //TODO ?
DSPath.encodeName(name, cacheBuf);
out.value(cacheBuf.toString());
cacheBuf.setLength(0);
Expand All @@ -343,7 +343,7 @@ private void encodeTargetMetadata(DSMap metadata, DSIWriter out) {
* Called by encodeTarget for values.
*/
private void encodeTargetValue(ApiObject object, DSIWriter out) {
DSElement e = cacheMap.remove("type");
DSElement e = cacheMap.remove("$type");
out.beginList();
out.value("$type");
if (e != null) {
Expand All @@ -352,7 +352,7 @@ private void encodeTargetValue(ApiObject object, DSIWriter out) {
encodeType(object.getValue(), cacheMeta, out);
}
out.endList();
e = cacheMap.remove("writable");
e = cacheMap.remove("$writable");
if (e != null) {
out.beginList()
.value("$writable")
Expand All @@ -361,7 +361,7 @@ private void encodeTargetValue(ApiObject object, DSIWriter out) {
} else if (!object.isReadOnly()) {
out.beginList()
.value("$writable")
.value(object.isConfig() ? "config" : "write")
.value(object.isAdmin() ? "config" : "write")
.endList();
}
}
Expand All @@ -372,7 +372,11 @@ private void encodeType(DSIValue value, DSMetadata meta, DSIWriter out) {
meta.setType(value);
}
fixType(meta.getMap());
out.value(cacheMap.remove(DSMetadata.TYPE));
DSElement e = cacheMap.remove(DSMetadata.TYPE);
if (e == null) {
throw new IllegalArgumentException("Missing type");
}
out.value(e);
}

private void encodeUpdate(Update update, DSIWriter out) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.iot.dsa.util.DSException;

/**
* The default connection implementation. Performs connection initialization with the broker, then
* creates a transport and a protocol based on the broker response.
* The default V2 connection implementation. Performs connection initialization with the broker,
* then creates a transport and a protocol based on the broker response.
*
* @author Aaron Hansen
*/
Expand Down Expand Up @@ -220,8 +220,8 @@ private void sendF2() throws Exception {
}
writer.writeString(token, buffer);
buffer.put((byte) 0x01); //isResponder
writer.writeString("", buffer); //blank session string
writer.writeIntLE(0, buffer); //last ack
writer.writeString("", buffer); //TODO remove
writer.writeIntLE(0, buffer); //TODO remove
writer.writeString("", buffer); //blank server path
byte[] sharedSecret = getLink().getKeys().generateSharedSecret(brokerPubKey);
byte[] authBytes = new byte[brokerSalt.length + sharedSecret.length];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.acuity.iot.dsa.dslink.test;

import com.acuity.iot.dsa.dslink.transport.DSTransport;
import com.acuity.iot.dsa.dslink.protocol.protocol_v1.DS1ConnectionInit;
import com.acuity.iot.dsa.dslink.protocol.protocol_v1.DS1LinkConnection;
import com.acuity.iot.dsa.dslink.protocol.protocol_v1.DS1Session;
import com.acuity.iot.dsa.dslink.transport.DSTransport;
import java.util.logging.Level;
import org.iot.dsa.dslink.DSLink;
import org.iot.dsa.dslink.DSLinkConfig;
import org.iot.dsa.dslink.DSRootNode;
import org.iot.dsa.dslink.DSMainNode;
import org.iot.dsa.node.DSMap;

/**
Expand All @@ -20,9 +20,9 @@ public class TestLink extends DSLink {
public TestLink() {
}

public TestLink(DSRootNode rootNode) {
public TestLink(DSMainNode MainNode) {
setSaveEnabled(false);
setNodes(rootNode);
setNodes(MainNode);
DSLinkConfig cfg = new DSLinkConfig();
cfg.setDslinkJson(new DSMap().put("configs", new DSMap()));
cfg.setLinkName("dslink-java-testing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.io.InputStream;
import java.nio.ByteBuffer;
import org.iot.dsa.dslink.DSLinkConnection;
import org.iot.dsa.io.DSByteBuffer;
import org.iot.dsa.io.DSIoException;
import com.acuity.iot.dsa.dslink.io.DSByteBuffer;
import com.acuity.iot.dsa.dslink.io.DSIoException;

/**
* Routes requests and responses back to self.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.logging.Logger;
import org.iot.dsa.dslink.DSLinkConnection;
import org.iot.dsa.io.DSIReader;
import org.iot.dsa.io.DSIWriter;
import org.iot.dsa.node.DSLong;
import org.iot.dsa.node.DSNode;
import org.iot.dsa.node.DSString;
Expand Down
Loading