diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-12-01 16:01:54 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-12-01 16:01:54 +0100 |
commit | 1236bcee420da713e373a4a6b8cec279749c3d74 (patch) | |
tree | a35c578a6b5666d96bb3733ee868028ddd1acd88 /NitrokeyManager.cc | |
parent | 57773ad5f7b6eb5e6a2020dd1bd4264bdd823808 (diff) | |
download | libnitrokey-1236bcee420da713e373a4a6b8cec279749c3d74.tar.gz libnitrokey-1236bcee420da713e373a4a6b8cec279749c3d74.tar.bz2 |
Connect with serialconnect_with_serial
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index a950e4b..9ba270e 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -231,6 +231,22 @@ using nitrokey::misc::strcpyT; return true; } + bool NitrokeyManager::connect_with_serial(std::string serial) { + std::lock_guard<std::mutex> lock(mex_dev_com_manager); + vector< shared_ptr<Device> > devices = { make_shared<Stick10>(), make_shared<Stick20>() }; + for (shared_ptr<Device> & p : devices){ + p->set_path(serial); + if(p->connect()){ + device = p; //previous device will be disconnected automatically + current_device_id = serial; + nitrokey::log::Log::setPrefix(serial); + LOGD1("Device successfully changed"); + return true; + } + } + return false; + } + bool NitrokeyManager::connect() { std::lock_guard<std::mutex> lock(mex_dev_com_manager); vector< shared_ptr<Device> > devices = { make_shared<Stick10>(), make_shared<Stick20>() }; |