Skip to content

List only devices connected by usb #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions IOSDeviceLib/IOSDeviceLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ inline bool has_complete_status(std::map<std::string, boost::any>& dict)
return boost::any_cast<std::string>(dict[kStatusKey]) == kComplete;
}

void on_device_found(const DevicePointer* device_ptr, std::string device_identifier, std::string eventString, json &result)
{
/*
Interface type can be one of the followings:
-1 - invalid interface type
0 - unknown interface type
1 - usb interface type
2 - wifi interface type
*/
int interface_type = AMDeviceGetInterfaceType(device_ptr->device_info);
if (interface_type == kUSBInterfaceType) {
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = eventString;
get_device_properties(device_identifier, result);
}
}

void device_notification_callback(const DevicePointer* device_ptr)
{
std::string device_identifier = get_cstring_from_cfstring(AMDeviceCopyDeviceIdentifier(device_ptr->device_info));
Expand All @@ -254,9 +271,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
{
case kADNCIMessageConnected:
{
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = kDeviceFound;
get_device_properties(device_identifier, result);
on_device_found(device_ptr, device_identifier, kDeviceFound, result);
break;
}
case kADNCIMessageDisconnected:
Expand All @@ -280,9 +295,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
}
case kADNCIMessageTrusted:
{
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = kDeviceTrusted;
get_device_properties(device_identifier, result);
on_device_found(device_ptr, device_identifier, kDeviceTrusted, result);
break;
}
}
Expand Down