diff -r 780cc08df263 -r ca47c742a25d thermferm/thermferm.c --- a/thermferm/thermferm.c Tue Apr 02 15:29:16 2024 +0200 +++ b/thermferm/thermferm.c Wed Apr 03 12:14:45 2024 +0200 @@ -1037,6 +1037,18 @@ } mqtt_connect(); + /* + * First scan the one-wire bus + */ + rc = pthread_create(&threads[t], NULL, my_one_wire_loop, (void *)t ); + if (rc) { + fprintf(stderr, "my_one_wire_loop thread didn't start rc=%d\n", rc); + syslog(LOG_NOTICE, "my_one_wire_loop thread didn't start rc=%d", rc); + } else { + t++; + mDelay(250); /* Wait a while to detect the devices */ + } + if ((rc = devices_detect())) { syslog(LOG_NOTICE, "Detected %d new devices", rc); wrconfig(); @@ -1066,14 +1078,6 @@ t++; } - rc = pthread_create(&threads[t], NULL, my_one_wire_loop, (void *)t ); - if (rc) { - fprintf(stderr, "my_one_wire_loop thread didn't start rc=%d\n", rc); - syslog(LOG_NOTICE, "my_one_wire_loop thread didn't start rc=%d", rc); - } else { - t++; - } - #ifdef USE_SIMULATOR rc = pthread_create(&threads[t], NULL, my_simulator_loop, (void *)t ); if (rc) {