Skip to content

Commit

Permalink
Fixing some basic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leonschenk committed Sep 27, 2022
1 parent 0c093ae commit 8e040ae
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*
*/
public class ZstackConsoleNcpSecurityCommand extends ZstackConsoleAbstractCommand {
private static int INVALID_NODE_ADDR = 0xFFFE;

@Override
public String getCommand() {
return "ncpsecurity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,7 @@ protected void outputCopywrite(PrintWriter out) {
}
out.println(" */");
br.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void main(final String[] args) {
doc.getDocumentElement().normalize();

NodeList nList = doc.getElementsByTagName("protocol");
protocol = (Protocol) processNode(nList.item(0));
protocol = processNode(nList.item(0));

} catch (Exception e) {
e.printStackTrace();
Expand All @@ -63,7 +63,8 @@ public static void main(final String[] args) {
}
}

private static Object processNode(Node node) {
@SuppressWarnings("unchecked")
private static <T> T processNode(Node node) {
System.out.println("\nCurrent Element :" + node.getNodeName());

NodeList nodes = node.getChildNodes();
Expand All @@ -77,16 +78,16 @@ private static Object processNode(Node node) {

for (int temp = 0; temp < nodes.getLength(); temp++) {
if (nodes.item(temp).getNodeName().equals("command")) {
protocol.commands.add((Command) processNode(nodes.item(temp)));
protocol.commands.add(processNode(nodes.item(temp)));
}
if (nodes.item(temp).getNodeName().equals("structure")) {
protocol.structures.add((Structure) processNode(nodes.item(temp)));
protocol.structures.add(processNode(nodes.item(temp)));
}
if (nodes.item(temp).getNodeName().equals("enum")) {
protocol.enumerations.add((Enumeration) processNode(nodes.item(temp)));
protocol.enumerations.add(processNode(nodes.item(temp)));
}
}
return protocol;
return (T) protocol;
case "command":
Command command = new Command();

Expand Down Expand Up @@ -116,28 +117,28 @@ private static Object processNode(Node node) {
if (command.request_parameters == null) {
command.request_parameters = new ArrayList<>();
}
command.request_parameters = (List<Parameter>) processNode(nodes.item(temp));
command.request_parameters = processNode(nodes.item(temp));
}
if (nodes.item(temp).getNodeName().equals("response")) {
if (command.response_parameters == null) {
command.response_parameters = new ArrayList<>();
}
command.response_parameters = (List<Parameter>) processNode(nodes.item(temp));
command.response_parameters = processNode(nodes.item(temp));
}
}
System.out.println("Done: Command - " + command.name);
return command;
return (T) command;
case "request":
case "response":
case "parameters":
List<Parameter> parameters = new ArrayList<>();

for (int temp = 0; temp < nodes.getLength(); temp++) {
if (nodes.item(temp).getNodeName().equals("parameter")) {
parameters.add((Parameter) processNode(nodes.item(temp)));
parameters.add(processNode(nodes.item(temp)));
}
}
return parameters;
return (T) parameters;
case "parameter":
Parameter parameter = new Parameter();
for (int temp = 0; temp < nodes.getLength(); temp++) {
Expand Down Expand Up @@ -165,7 +166,7 @@ private static Object processNode(Node node) {
}
}
System.out.println("Done: Parameter - " + parameter.name);
return parameter;
return (T) parameter;
case "structure":
Structure structure = new Structure();
structure.parameters = new ArrayList<>();
Expand All @@ -182,11 +183,11 @@ private static Object processNode(Node node) {
}

if (nodes.item(temp).getNodeName().equals("parameters")) {
structure.parameters = (List<Parameter>) processNode(nodes.item(temp));
structure.parameters = processNode(nodes.item(temp));
}
}
System.out.println("Done: Structure - " + structure.name);
return structure;
return (T) structure;
case "enum":
Enumeration enumeration = new Enumeration();
enumeration.values = new ArrayList<Value>();
Expand All @@ -205,7 +206,7 @@ private static Object processNode(Node node) {
Element dataTypeElement = (Element) nodes.item(temp);
enumeration.fullyDefined = "true"
.equalsIgnoreCase(dataTypeElement.getAttribute("fully_defined"));
enumeration.values = (List<Value>) processNode(nodes.item(temp));
enumeration.values = processNode(nodes.item(temp));
}
if (nodes.item(temp).getNodeName().equals("format")) {
enumeration.format = nodes.item(temp).getTextContent().trim();
Expand All @@ -215,16 +216,16 @@ private static Object processNode(Node node) {
}
}
System.out.println("Done: Enum - " + enumeration.name);
return enumeration;
return (T) enumeration;
case "values":
List<Value> values = new ArrayList<>();

for (int temp = 0; temp < nodes.getLength(); temp++) {
if (nodes.item(temp).getNodeName().equals("value")) {
values.add((Value) processNode(nodes.item(temp)));
values.add(processNode(nodes.item(temp)));
}
}
return values;
return (T) values;
case "value":
Value value = new Value();
for (int temp = 0; temp < nodes.getLength(); temp++) {
Expand All @@ -244,7 +245,7 @@ private static Object processNode(Node node) {
}
}
System.out.println("Done: Value - " + value.name);
return value;
return (T) value;
default:
System.out.println("Uknown node " + node.getNodeName());
break;
Expand Down
7 changes: 0 additions & 7 deletions com.zsmartsystems.zigbee.dongle.zstack/build.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ public void sendCommand(final int msgTag, final ZigBeeApsFrame apsFrame) {
// Remember the time to reduce unnecessary polling
lastSendCommandTime = System.currentTimeMillis();

// TODO: How to differentiate group and device addressing?????
ZstackAfDataRequestSreq request = new ZstackAfDataRequestSreq();
request.setClusterID(apsFrame.getCluster());
request.setDstAddr(apsFrame.getDestinationAddress());
Expand All @@ -454,7 +453,6 @@ public void sendCommand(final int msgTag, final ZigBeeApsFrame apsFrame) {

request.addOptions(AfDataOptions.AF_DISCV_ROUTE);
if (apsFrame.getAckRequest()) {
// TODO: is this really necessary
request.addOptions(AfDataOptions.AF_ACK_REQUEST);
}
if (apsFrame.getSecurityEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ public Integer setTxPower(int txPower) {
* @return {@link ZstackResponseCode} returned from the NCP
*/
public ZstackResponseCode setChannelMask(ZigBeeChannelMask channelMask) {
// TODO: ZCD_NV_CHANLIST
ZstackUtilSetChannelsSreq request = new ZstackUtilSetChannelsSreq();
request.setChannels(channelMask.getChannelMask());
ZstackUtilSetChannelsSrsp response = protocolHandler.sendTransaction(request, ZstackUtilSetChannelsSrsp.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void serializeBoolean() {
class Request extends ZstackFrameRequest {
@Override
public int[] serialize() {
// TODO Auto-generated method stub
return null;
}
}
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ include ':com.zsmartsystems.zigbee.dongle.ember'
include ':com.zsmartsystems.zigbee.dongle.conbee'
include ':com.zsmartsystems.zigbee.dongle.telegesis'
include ':com.zsmartsystems.zigbee.dongle.telegesis.autocode'
include ':com.zsmartsystems.zigbee.dongle.zstack'
include ':com.zsmartsystems.zigbee.dongle.zstack.autocode'
include ':com.zsmartsystems.zigbee.console'
include ':com.zsmartsystems.zigbee.console.ember'
include ':com.zsmartsystems.zigbee.console.main'
include ':com.zsmartsystems.zigbee.console.telegesis'
include ':com.zsmartsystems.zigbee.console.zstack'
include ':com.zsmartsystems.zigbee.serial'
include ':com.zsmartsystems.zigbee.test'
include ':com.zsmartsystems.zigbee.p2repo'
Expand All @@ -25,10 +28,13 @@ project(':com.zsmartsystems.zigbee.dongle.ember').projectDir = "$rootDir/com.zsm
project(':com.zsmartsystems.zigbee.dongle.conbee').projectDir = "$rootDir/com.zsmartsystems.zigbee.dongle.conbee" as File
project(':com.zsmartsystems.zigbee.dongle.telegesis').projectDir = "$rootDir/com.zsmartsystems.zigbee.dongle.telegesis" as File
project(':com.zsmartsystems.zigbee.dongle.telegesis.autocode').projectDir = "$rootDir/com.zsmartsystems.zigbee.dongle.telegesis.autocode" as File
project(':com.zsmartsystems.zigbee.dongle.zstack').projectDir = "$rootDir/com.zsmartsystems.zigbee.dongle.zstack" as File
project(':com.zsmartsystems.zigbee.dongle.zstack.autocode').projectDir = "$rootDir/com.zsmartsystems.zigbee.dongle.zstack.autocode" as File
project(':com.zsmartsystems.zigbee.console').projectDir = "$rootDir/com.zsmartsystems.zigbee.console" as File
project(':com.zsmartsystems.zigbee.console.ember').projectDir = "$rootDir/com.zsmartsystems.zigbee.console.ember" as File
project(':com.zsmartsystems.zigbee.console.main').projectDir = "$rootDir/com.zsmartsystems.zigbee.console.main" as File
project(':com.zsmartsystems.zigbee.console.telegesis').projectDir = "$rootDir/com.zsmartsystems.zigbee.console.telegesis" as File
project(':com.zsmartsystems.zigbee.console.zstack').projectDir = "$rootDir/com.zsmartsystems.zigbee.console.zstack" as File
project(':com.zsmartsystems.zigbee.serial').projectDir = "$rootDir/com.zsmartsystems.zigbee.serial" as File
project(':com.zsmartsystems.zigbee.test').projectDir = "$rootDir/com.zsmartsystems.zigbee.test" as File
project(':com.zsmartsystems.zigbee.p2repo').projectDir = "$rootDir/releng/p2repo" as File

0 comments on commit 8e040ae

Please sign in to comment.