From 09f3f6dbbdb6d09b82ea592cb75ed69c04a3bdf8 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 17 Feb 2021 00:02:42 +0000
Subject: [PATCH] Detect ControlVault devices without NFC reader and show error

---
 cvcomm.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/cvcomm.py b/cvcomm.py
index c2e9823..4a2d45a 100644
--- a/cvcomm.py
+++ b/cvcomm.py
@@ -59,11 +59,20 @@
 		self.logger.debug('Enumerating interfaces...')
 		configuration = self.device.get_active_configuration()
 		bcm_interface = None
+		has_contacted = False
+		has_contactless = False
 		for interface in configuration:
 			if interface.bInterfaceClass == 0xff:
 				if bcm_interface is not None:
 					raise Exception('More than one vendor-specific interface found!')
 				bcm_interface = interface
+			if interface.bInterfaceClass == 0xb:
+				if interface.iInterface == 0x5:
+					has_contacted = True
+				if interface.iInterface == 0x6:
+					has_contactless = True
+		if not has_contactless:
+			raise Exception('No contactless reader on this device!')
 		if bcm_interface is None:
 			raise Exception('Cannot find vendor-specific interface')
 		self.logger.debug('Interface found: {}'.format(bcm_interface._str()))

--
Gitblit v1.9.1