free(mesh->self->name);
mesh->name = name;
mesh->self->name = xstrdup(name);
- mesh->self->devclass = devclass;
+ mesh->self->devclass = devclass == DEV_CLASS_UNKNOWN ? mesh->devclass : devclass;
// Initialize configuration directory
if(!config_init(mesh, "current")) {
pthread_mutex_lock(&(mesh->mesh_mutex));
+#if HAVE_CATTA
+
+ if(mesh->discovery) {
+ discovery_start(mesh);
+ }
+
+#endif
+
logger(mesh, MESHLINK_DEBUG, "Starting main_loop...\n");
main_loop(mesh);
logger(mesh, MESHLINK_DEBUG, "main_loop returned.\n");
+#if HAVE_CATTA
+
+ // Stop discovery
+ if(mesh->discovery) {
+ discovery_stop(mesh);
+ }
+
+#endif
+
pthread_mutex_unlock(&(mesh->mesh_mutex));
return NULL;
}
mesh->threadstarted = true;
-#if HAVE_CATTA
-
- if(mesh->discovery) {
- discovery_start(mesh);
- }
-
-#endif
-
assert(mesh->self->ecdsa);
assert(!memcmp((uint8_t *)mesh->self->ecdsa + 64, (uint8_t *)mesh->private_key + 64, 32));
pthread_mutex_lock(&(mesh->mesh_mutex));
logger(mesh, MESHLINK_DEBUG, "meshlink_stop called\n");
-#if HAVE_CATTA
-
- // Stop discovery
- if(mesh->discovery) {
- discovery_stop(mesh);
- }
-
-#endif
-
// Shut down the main thread
event_loop_stop(&mesh->loop);
#endif
}
+void handle_network_change(meshlink_handle_t *mesh, bool online) {
+ (void)online;
+
+ if(!mesh->connections) {
+ return;
+ }
+
+ retry(mesh);
+}
+
static void __attribute__((constructor)) meshlink_init(void) {
crypto_init();
unsigned int seed;