]> git.meshlink.io Git - meshlink/blobdiff - examples/manynodes.c
manynodes: add few backbone nodes and many portable nodes to make tests
[meshlink] / examples / manynodes.c
index 7b23fc5197f14aa7a7e19f9d59cac1cd1ee54d36..d158e5b9423176cdb5289efe96765a75c662d78e 100644 (file)
@@ -257,7 +257,8 @@ static void parse_command(char *buf) {
                }
                nodeindex = atoi(arg);
                printf("Index is now %d\n",nodeindex);
-       
+       } else if(!strcasecmp(buf, "stop")) {
+               meshlink_stop(mesh[nodeindex]);
        } else if(!strcasecmp(buf, "quit")) {
                printf("Bye!\n");
                fclose(stdin);
@@ -273,6 +274,7 @@ static void parse_command(char *buf) {
                        "/eg <path>            Export graph as json file.\n"
                        "/test                 Test functionality sending some data to all nodes\n"
                        "/select <number>      Select the active node running the user commands\n"
+                       "/stop                 Call meshlink_stop, use /select first to select which node to stop\n"
                        "/quit                 Exit this program.\n"
                        );
        } else {
@@ -372,7 +374,12 @@ int main(int argc, char *argv[]) {
                snprintf(nodename, sizeof nodename, "%snode%d", namesprefix,i);
                snprintf(filename, sizeof filename, "%s/%s", basebase, nodename);
                bool itsnew = access(filename, R_OK);
-               mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
+               if (n/(i+1) > n/4) {
+                       mesh[i] = meshlink_open(filename, nodename, "manynodes", DEV_CLASS_BACKBONE);
+               }
+               else {
+                       mesh[i] = meshlink_open(filename, nodename, "manynodes", DEV_CLASS_PORTABLE);
+               }
                meshlink_set_log_cb(mesh[i], MESHLINK_WARNING, log_message);
                if(!mesh[i]) {
                        fprintf(stderr, "errno is: %d\n", meshlink_errno);