+static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ const char *levelstr[] = {
+ [MESHLINK_DEBUG] = "\x1b[34mDEBUG",
+ [MESHLINK_INFO] = "\x1b[32mINFO",
+ [MESHLINK_WARNING] = "\x1b[33mWARNING",
+ [MESHLINK_ERROR] = "\x1b[31mERROR",
+ [MESHLINK_CRITICAL] = "\x1b[31mCRITICAL",
+ };
+ fprintf(stderr, "%s\t%s:\x1b[0m %s\n", mesh ? mesh->name : "global",levelstr[level], text);
+}
+
+//Test mesh sending data
+static void testmesh () {
+
+ for(int nindex = 0; nindex < n; nindex++) {
+
+ nodes = meshlink_get_all_nodes(mesh[nindex], nodes, &nnodes);
+ if(!nodes) {
+ fprintf(stderr, "Could not get list of nodes: %s\n", meshlink_strerror(meshlink_errno));
+ } else {
+ printf("%zu known nodes:\n", nnodes);
+ for(int i = 0; i < nnodes; i++) {
+ //printf(" %s\n", nodes[i]->name);
+ if(!meshlink_send(mesh[nindex], nodes[i], "magic", strlen("magic") + 1)) {
+ fprintf(stderr, "Could not send message to '%s': %s\n", nodes[i]->name, meshlink_strerror(meshlink_errno));
+ }
+ }
+
+ }
+
+ }
+}