diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-02-28 21:02:30 +0100 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 15:41:51 +0100 | 
| commit | 802dd4543b7634f498bd44909461eae6d7975abb (patch) | |
| tree | 5a244bfa7677f98a82e3ee2922dcea05b1c37a61 /include | |
| parent | f12b6a9c29f8d236ca969f45d3be1cd9ee5a749f (diff) | |
| download | libnitrokey-802dd4543b7634f498bd44909461eae6d7975abb.tar.gz libnitrokey-802dd4543b7634f498bd44909461eae6d7975abb.tar.bz2 | |
Make device-level reconnect on problem with sending
Make it 3 times before throwing exception
Call hid_exit on last device disconnection
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/device.h | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/include/device.h b/include/device.h index 5d7ee12..7b300e5 100644 --- a/include/device.h +++ b/include/device.h @@ -50,6 +50,7 @@ public:      cnt busy_progressbar;      cnt command_result_not_equal_0_recv;      cnt communication_successful; +    cnt low_level_reconnect;      std::string get_as_string();    } m_counters = {}; @@ -59,7 +60,7 @@ public:                     const milliseconds send_receive_delay, const int retry_receiving_count,                     const milliseconds retry_timeout); -    virtual ~Device(){show_stats(); disconnect();} +    virtual ~Device();    // lack of device is not actually an error,    // so it doesn't throw @@ -97,6 +98,9 @@ public:    DeviceModel get_device_model() const {return m_model;}  private:    std::atomic<uint8_t> last_command_status; +  void _reconnect(); +  bool _connect(); +  bool _disconnect();  protected:    const uint16_t m_vid; @@ -115,6 +119,8 @@ protected:    std::atomic<hid_device *>mp_devhandle; + +  static std::atomic_int instances_count;  };  class Stick10 : public Device { | 
