thermferm/thermferm.c

changeset 656
ca47c742a25d
parent 654
e981d0185485
child 660
a28ef4d9afa4
--- 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) {

mercurial