From 2e7423456fea5fea0a39a265622651009d4556e2 Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Thu, 23 Jul 2020 07:23:50 +0100
Subject: [PATCH] Fixed Autostart not initializing GPIO

---
 discovery.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/discovery.c b/discovery.c
index 27fdd28..c9261a7 100644
--- a/discovery.c
+++ b/discovery.c
@@ -525,15 +525,6 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
     }
 
 
-    g_print("%s: devices=%d autostart=%d\n",__FUNCTION__,devices,autostart);
-
-    if(devices==1 && autostart) {
-        d=&discovered[0];
-	if(d->status==STATE_AVAILABLE) {
-          if(start_cb(NULL,NULL,(gpointer)d)) return;
-	}
-    }
-
 #ifdef CLIENT_SERVER
 
     loadProperties("remote.props");
@@ -620,6 +611,16 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
     gtk_widget_show_all(discovery_dialog);
 fprintf(stderr,"showing device dialog\n");
 
+    // autostart if enabled and only one device
+    g_print("%s: devices=%d autostart=%d\n",__FUNCTION__,devices,autostart);
+
+    if(devices==1 && autostart) {
+        d=&discovered[0];
+	if(d->status==STATE_AVAILABLE) {
+          if(start_cb(NULL,NULL,(gpointer)d)) return;
+	}
+    }
+
 }
 
 
-- 
2.45.2