aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-12-01 16:01:54 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-12-01 16:01:54 +0100
commit1236bcee420da713e373a4a6b8cec279749c3d74 (patch)
treea35c578a6b5666d96bb3733ee868028ddd1acd88 /NitrokeyManager.cc
parent57773ad5f7b6eb5e6a2020dd1bd4264bdd823808 (diff)
downloadlibnitrokey-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.cc16
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>() };