aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-12-11 10:51:53 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-12-11 10:51:53 +0100
commit17309629889269e99d14b4e880675682d8b6435f (patch)
treeab37c07e186315410d0187b52c4d5b5492555662 /NitrokeyManager.cc
parent7797c8fb5fa69068dd659c369bc774ca74f592fe (diff)
downloadlibnitrokey-17309629889269e99d14b4e880675682d8b6435f.tar.gz
libnitrokey-17309629889269e99d14b4e880675682d8b6435f.tar.bz2
Allow to execute client-supplied function on each retry and cancel with itwip-retry_function
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index b29b27d..6c3634e 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -12,6 +12,8 @@
std::mutex nitrokey::proto::send_receive_mtx;
+nitrokey::proto::retry_type nitrokey::proto::on_retry = [](int){return 0;};
+
namespace nitrokey{
std::mutex mex_dev_com_manager;
@@ -61,6 +63,10 @@ using nitrokey::misc::strcpyT;
NitrokeyManager::~NitrokeyManager() {
}
+ void NitrokeyManager::set_retry_function(const nitrokey::proto::retry_type retry_func){
+ nitrokey::proto::on_retry = retry_func;
+ }
+
bool NitrokeyManager::set_current_device_speed(int retry_delay, int send_receive_delay){
if (retry_delay < 20 || send_receive_delay < 20){
LOG("Delay set too low: " + to_string(retry_delay) +" "+ to_string(send_receive_delay), Loglevel::WARNING);