Using libimobiledevice I can get the ECID of a connected device from the command line by running
$ ideviceinfo -k UniqueChipID
Is there a way to do this using the C API?
You're looking for lockdownd_get_value
, which is part of the libimobiledevice C api. The declaration is:
/**
* Retrieves a preferences plist using an optional domain and/or key name.
*
* @param client An initialized lockdownd client.
* @param domain The domain to query on or NULL for global domain
* @param key The key name to request or NULL to query for all keys
* @param value A plist node representing the result value node
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
LIBIMOBILEDEVICE_API_MSC lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
You can create a lockdown_client_t
using a lockdownd_client_new
. Look at the ideviceinfo
source code for more information on how to set up a lockdown client.
The domain
and key
parameters map to what you've provided on the command line. You didn't specify a domain, so set that to NULL
. key
should be the value of what you passed as the -k
argument, hence UniqueChipID
.
The output will be a plist_t
. You can use the libplist API to convert this to XML or a string.