summaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-01-11 16:04:52 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-01-11 16:04:52 +0100
commitc2d3de8820cc2ad3f394b6672853af257d32e6f6 (patch)
tree5adebf80eb9ff293694146ac48363c2fc8ae2c30 /NitrokeyManager.cc
parent0c6f3234acea5888dd6c3c3aeee8cebcce59ba06 (diff)
downloadlibnitrokey-c2d3de8820cc2ad3f394b6672853af257d32e6f6.tar.gz
libnitrokey-c2d3de8820cc2ad3f394b6672853af257d32e6f6.tar.bz2
Helper functions for getting device state
get status for Pro and Storage check is device connected use make_shared for keeping instance reference fixed accessing active volume flag Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index c49a449..f71c362 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -90,7 +90,7 @@ namespace nitrokey{
}
bool NitrokeyManager::disconnect() {
- if (device == nullptr){
+ if (!is_connected()){
return false;
}
const auto res = device->disconnect();
@@ -98,6 +98,10 @@ namespace nitrokey{
return res;
}
+ bool NitrokeyManager::is_connected(){
+ return device != nullptr;
+ }
+
void NitrokeyManager::set_debug(bool state) {
if (state){
Log::instance().set_loglevel(Loglevel::DEBUG);
@@ -111,7 +115,12 @@ namespace nitrokey{
return response.data().get_card_serial_hex();
}
- string NitrokeyManager::get_status() {
+ stick10::GetStatus::ResponsePayload NitrokeyManager::get_status(){
+ auto response = GetStatus::CommandTransaction::run(*device);
+ return response.data();
+ }
+
+ string NitrokeyManager::get_status_as_string() {
auto response = GetStatus::CommandTransaction::run(*device);
return response.data().dissect();
}
@@ -597,6 +606,10 @@ namespace nitrokey{
return get_major_firmware_version() <= m[device->get_device_model()];
}
+ DeviceModel NitrokeyManager::get_connected_device_model(){
+ return device->get_device_model();
+ }
+
int NitrokeyManager::get_major_firmware_version(){
switch(device->get_device_model()){
case DeviceModel::PRO:{
@@ -682,6 +695,11 @@ namespace nitrokey{
return strdup(p.data().dissect().c_str());
}
+ stick20::DeviceConfigurationResponsePacket::ResponsePayload NitrokeyManager::get_status_storage(){
+ auto p = stick20::GetDeviceStatus::CommandTransaction::run(*device);
+ return p.data();
+ }
+
const char * NitrokeyManager::get_SD_usage_data_as_string(){
auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(*device);
return strdup(p.data().dissect().c_str());