Java now correctly subscribes to nodes with hex addresses (up to 0xffff)

This commit is contained in:
giomba 2019-11-08 08:30:46 +01:00
parent 08440358f0
commit 109322dba8
1 changed files with 2 additions and 3 deletions

View File

@ -10,7 +10,7 @@ public class Main {
System.err.println("Usage: ");
System.err.println("$ exe <prefix> <n>");
System.err.println(" prefix IPv6 /64 prefix (mind the format!)");
System.err.println(" n number of nodes");
System.err.println(" n last node number (dec)");
System.err.println();
System.err.println("Example:");
System.err.println("$ exe 2001:db8:0:0 10");
@ -21,10 +21,9 @@ public class Main {
final int n = Integer.parseInt(args[1]);
System.err.println("[I] now subscribing to node [2; " + n + "] in " + prefix + "/64");
// TODO pay attention to this for-cycle and mind the hexadecimal values!
/* subscribe to every node */
for (int i = 2; i <= n; i++) { // node 1 is the gateway, skip. And mind the <=
String uri_string = "coap://[" + prefix + ":" + COOJA_MAGIC + "::" + Integer.toString(i) + "]" + resource;
String uri_string = "coap://[" + prefix + ":" + COOJA_MAGIC + "::" + Integer.toString(i, 16) + "]" + resource;
System.err.println("[I] subscribing to " + uri_string);
Node node = new Node(uri_string);
}