@@ -245,6 +245,23 @@ inline bool has_complete_status(std::map<std::string, boost::any>& dict)
245
245
return boost::any_cast<std::string>(dict[kStatusKey ]) == kComplete ;
246
246
}
247
247
248
+ void on_device_found (const DevicePointer* device_ptr, std::string device_identifier, std::string eventString, json &result)
249
+ {
250
+ /*
251
+ Interface type can be one of the followings:
252
+ -1 - invalid interface type
253
+ 0 - unknown interface type
254
+ 1 - usb interface type
255
+ 2 - wifi interface type
256
+ */
257
+ int interface_type = AMDeviceGetInterfaceType (device_ptr->device_info );
258
+ if (interface_type == kUSBInterfaceType ) {
259
+ devices[device_identifier] = { device_ptr->device_info , nullptr };
260
+ result[kEventString ] = eventString;
261
+ get_device_properties (device_identifier, result);
262
+ }
263
+ }
264
+
248
265
void device_notification_callback (const DevicePointer* device_ptr)
249
266
{
250
267
std::string device_identifier = get_cstring_from_cfstring (AMDeviceCopyDeviceIdentifier (device_ptr->device_info ));
@@ -254,9 +271,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
254
271
{
255
272
case kADNCIMessageConnected :
256
273
{
257
- devices[device_identifier] = { device_ptr->device_info , nullptr };
258
- result[kEventString ] = kDeviceFound ;
259
- get_device_properties (device_identifier, result);
274
+ on_device_found (device_ptr, device_identifier, kDeviceFound , result);
260
275
break ;
261
276
}
262
277
case kADNCIMessageDisconnected :
@@ -280,9 +295,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
280
295
}
281
296
case kADNCIMessageTrusted :
282
297
{
283
- devices[device_identifier] = { device_ptr->device_info , nullptr };
284
- result[kEventString ] = kDeviceTrusted ;
285
- get_device_properties (device_identifier, result);
298
+ on_device_found (device_ptr, device_identifier, kDeviceTrusted , result);
286
299
break ;
287
300
}
288
301
}
0 commit comments