if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
return;
if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
return;
- meshlink_stop(mesh[0]);
- if(!meshlink_join(mesh[0], arg))
+ meshlink_stop(mesh[nodeindex]);
+ if(!meshlink_join(mesh[nodeindex], arg))
fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
else {
fprintf(stderr, "Invitation accepted!\n");
fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
else {
fprintf(stderr, "Invitation accepted!\n");
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
- printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[0], node));
+ printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[nodeindex], node));
exportmeshgraph_end(NULL);
} else if(!strcasecmp(buf, "test")) {
testmesh();
exportmeshgraph_end(NULL);
} else if(!strcasecmp(buf, "test")) {
testmesh();
+ } else if(!strcasecmp(buf, "select")) {
+ if(!arg) {
+ fprintf(stderr, "/select requires an argument!\n");
+ return;
+ }
+ nodeindex = atoi(arg);
+ printf("Index is now %d\n",nodeindex);
+
"/link Link all nodes together.\n"
"/eg <path> Export graph as json file.\n"
"/test Test functionality sending some data to all nodes\n"
"/link Link all nodes together.\n"
"/eg <path> Export graph as json file.\n"
"/test Test functionality sending some data to all nodes\n"
- if(!meshlink_send(mesh[0], destination, msg, strlen(msg) + 1)) {
+ if(!meshlink_send(mesh[nodeindex], destination, msg, strlen(msg) + 1)) {
fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, meshlink_strerror(meshlink_errno));
return;
}
fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, meshlink_strerror(meshlink_errno));
return;
}
bool itsnew = access(filename, R_OK);
mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
meshlink_set_log_cb(mesh[i], MESHLINK_WARNING, log_message);
bool itsnew = access(filename, R_OK);
mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
meshlink_set_log_cb(mesh[i], MESHLINK_WARNING, log_message);
if(!mesh[i]) {
fprintf(stderr, "errno is: %d\n", meshlink_errno);
fprintf(stderr, "Could not open %s: %s\n", filename, meshlink_strerror(meshlink_errno));
if(!mesh[i]) {
fprintf(stderr, "errno is: %d\n", meshlink_errno);
fprintf(stderr, "Could not open %s: %s\n", filename, meshlink_strerror(meshlink_errno));