Skip to content

Commit

Permalink
Rename is_connected to be more specific
Browse files Browse the repository at this point in the history
Signed-off-by: Szczepan Zalega <[email protected]>
  • Loading branch information
szszszsz committed Mar 11, 2017
1 parent 5650e48 commit 6061ee1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions NitrokeyManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace nitrokey{

bool NitrokeyManager::_disconnect_no_lock() {
//do not use directly without locked mutex,
//used by is_connected, disconnect
//used by could_be_enumerated, disconnect
if (device == nullptr){
return false;
}
Expand All @@ -119,7 +119,7 @@ namespace nitrokey{
bool NitrokeyManager::is_connected() throw(){
std::lock_guard<std::mutex> lock(mex_dev_com);
if(device != nullptr){
auto connected = device->is_connected();
auto connected = device->could_be_enumerated();
if(connected){
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int Device::recv(void *packet) {
return status;
}

bool Device::is_connected() {
bool Device::could_be_enumerated() {
Log::instance()(__FUNCTION__, Loglevel::DEBUG_L2);
std::lock_guard<std::mutex> lock(mex_dev_com);
if (mp_devhandle==nullptr){
Expand Down
7 changes: 6 additions & 1 deletion include/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class Device {
*/
virtual int recv(void *packet);

bool is_connected();
/***
* Returns true if some device is visible by OS with given VID and PID
* whether the device is connected through HID API or not.
* @return true if visible by OS
*/
bool could_be_enumerated();

void show_stats();
// ErrorCounters get_stats(){ return m_counters; }
Expand Down

0 comments on commit 6061ee1

Please sign in to comment.