Update device detection json output to include the interface over which the device was found (e.g. Wifi, USB, etc) and to correctly start a session before fetching device attributes. Previously without a session, devices connected over wifi would return null for some attributes including BuildVersion and DeviceClass. (#554)

diff --git a/src/ios-deploy/ios-deploy.m b/src/ios-deploy/ios-deploy.m
index fcb574e..008ebd4 100644
--- a/src/ios-deploy/ios-deploy.m
+++ b/src/ios-deploy/ios-deploy.m
@@ -456,6 +456,13 @@
     return res;
 }
 
+void connect_and_start_session(AMDeviceRef device) {
+    AMDeviceConnect(device);
+    assert(AMDeviceIsPaired(device));
+    check_error(AMDeviceValidatePairing(device));
+    check_error(AMDeviceStartSession(device));
+}
+
 CFStringRef get_device_full_name(const AMDeviceRef device) {
     CFStringRef full_name = NULL,
                 device_udid = AMDeviceCopyDeviceIdentifier(device),
@@ -521,7 +528,7 @@
 
 NSDictionary* get_device_json_dict(const AMDeviceRef device) {
     NSMutableDictionary *json_dict = [NSMutableDictionary new];
-    AMDeviceConnect(device);
+    connect_and_start_session(device);
     
     CFStringRef device_udid = AMDeviceCopyDeviceIdentifier(device);
     if (device_udid) {
@@ -1214,13 +1221,6 @@
     CFRelease(s);
 }
 
-void connect_and_start_session(AMDeviceRef device) {
-    AMDeviceConnect(device);
-    assert(AMDeviceIsPaired(device));
-    check_error(AMDeviceValidatePairing(device));
-    check_error(AMDeviceStartSession(device));
-}
-
 void start_remote_debug_server(AMDeviceRef device) {
 
     dbgServiceConnection = NULL;
@@ -2539,6 +2539,7 @@
     if (detect_only) {
         if (_json_output) {
             NSLogJSON(@{@"Event": @"DeviceDetected",
+                        @"Interface": (__bridge NSString *)device_interface_name,
                         @"Device": get_device_json_dict(device)
                         });
         } else {
@@ -2770,6 +2771,7 @@
             NSLogVerbose(@"[....] Disconnected %@ from %@.", device_uuid, device_interface_name);
             if (detect_only && _json_output) {
                 NSLogJSON(@{@"Event": @"DeviceDisconnected",
+                            @"Interface": (__bridge NSString *)device_interface_name,
                             @"Device": get_device_json_dict(info->dev)
                             });
             }