aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:02:31 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:02:31 +0100
commite853275784e48823be0f39f0855efbe85c0f905c (patch)
tree2b428a23bddbd87c08ee47351bc31768f54b63fe /NK_C_API.h
parent3f3fdebbc795dc3805cd5be105ce994286598f16 (diff)
parentcd1cfdbfc4113186f80dbadf5eb76543b22e34bd (diff)
downloadlibnitrokey-e853275784e48823be0f39f0855efbe85c0f905c.tar.gz
libnitrokey-e853275784e48823be0f39f0855efbe85c0f905c.tar.bz2
Merge branch 'pr_138' into contributions
Improve support for multiple devices Fixes #138
Diffstat (limited to 'NK_C_API.h')
-rw-r--r--NK_C_API.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/NK_C_API.h b/NK_C_API.h
index 520d5e0..3effbfe 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -57,6 +57,29 @@ extern "C" {
NK_STORAGE = 2
};
+ /**
+ * The connection info for a Nitrokey device as a linked list.
+ */
+ struct NK_device_info {
+ /**
+ * The model of the Nitrokey device.
+ */
+ enum NK_device_model model;
+ /**
+ * The USB device path for NK_connect_with_path.
+ */
+ char* path;
+ /**
+ * The serial number.
+ */
+ char* serial_number;
+ /**
+ * The pointer to the next element of the linked list or null
+ * if this is the last element in the list.
+ */
+ struct NK_device_info* next;
+ };
+
/**
* Stores the status of a Storage device.
*/
@@ -797,6 +820,19 @@ extern "C" {
*/
NK_C_API char* NK_list_devices_by_cpuID();
+ /**
+ * Returns a linked list of all connected devices, or null if no devices
+ * are connected or an error occured. The linked list must be freed by
+ * calling NK_free_device_info.
+ * @return a linked list of all connected devices
+ */
+ NK_C_API struct NK_device_info* NK_list_devices();
+
+ /**
+ * Free a linked list returned by NK_list_devices.
+ * @param the linked list to free or null
+ */
+ NK_C_API void NK_free_device_info(struct NK_device_info* device_info);
/**
* Connects to the device with given ID. ID's list could be created with NK_list_devices_by_cpuID.
@@ -809,6 +845,14 @@ extern "C" {
NK_C_API int NK_connect_with_ID(const char* id);
/**
+ * Connects to a device with the given path. The path is a USB device
+ * path as returned by hidapi.
+ * @param path the device path
+ * @return 1 on successful connection, 0 otherwise
+ */
+ NK_C_API int NK_connect_with_path(const char* path);
+
+ /**
* Blink red and green LED alternatively and infinitely (until device is reconnected).
* @return command processing error code
*/