summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-29 14:26:37 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:58 +0200
commit77e388ed2dbbe262e61ddf514f7554e236a1c1a1 (patch)
treeddfd7a1995599a424dc3d0434dcb8fda606b8465
parent195cc3fd7a52af0db40c33f3287aa32cec64631f (diff)
downloadlibnitrokey-77e388ed2dbbe262e61ddf514f7554e236a1c1a1.tar.gz
libnitrokey-77e388ed2dbbe262e61ddf514f7554e236a1c1a1.tar.bz2
Let device identify itself by model
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--device.cc5
-rw-r--r--include/device.h8
2 files changed, 10 insertions, 3 deletions
diff --git a/device.cc b/device.cc
index 0427d29..4f11e23 100644
--- a/device.cc
+++ b/device.cc
@@ -45,8 +45,6 @@ int Device::send(const void *packet) {
}
int Device::recv(void *packet) {
- // FIXME change CommError return value to int (return value of
- // hid_get_feature_report)
int status;
int retry_count = 0;
@@ -86,10 +84,13 @@ int Device::recv(void *packet) {
Stick10::Stick10() {
m_vid = 0x20a0;
m_pid = 0x4108;
+ m_model = DeviceModel::PRO;
}
Stick20::Stick20() {
m_vid = 0x20a0;
m_pid = 0x4109;
m_retry_timeout = std::chrono::milliseconds(500);
+ m_model = DeviceModel::STORAGE;
+
}
diff --git a/include/device.h b/include/device.h
index 1c95c56..1f6d486 100644
--- a/include/device.h
+++ b/include/device.h
@@ -19,6 +19,11 @@ enum class CommError {
ERR_STATUS_NOT_OK = -4
};
+enum class DeviceModel{
+ PRO,
+ STORAGE
+};
+
class Device {
public:
Device();
@@ -45,13 +50,14 @@ class Device {
int get_last_command_status() const;
void set_last_command_status(uint8_t _err) { last_command_status = _err;} ;
bool last_command_sucessfull() const {return last_command_status == 0;};
-
+ DeviceModel get_device_model() const {return m_model;}
private:
uint8_t last_command_status;
protected:
uint16_t m_vid;
uint16_t m_pid;
+ DeviceModel m_model;
/*
* While the project uses Signal11 portable HIDAPI