diff options
author | cslashm <cslashm@gmail.com> | 2018-08-01 09:24:53 +0200 |
---|---|---|
committer | cslashm <cslashm@gmail.com> | 2018-09-24 21:57:42 +0200 |
commit | bb6e3bbc0f0a6c4ac126f56ba75b39d0dfac01a6 (patch) | |
tree | 7c6e03ce2a27685b09bf65a06536113d954b574e /src/device/device_ledger.hpp | |
parent | Merge pull request #4429 (diff) | |
download | monero-bb6e3bbc0f0a6c4ac126f56ba75b39d0dfac01a6.tar.xz |
Replace USB-CCID (smartcard) by USB-HID
Remove PCSC dependencies which is a bit hard (not user friendly) to install on linux and Mac
Split Ledger logic and device IO
Diffstat (limited to 'src/device/device_ledger.hpp')
-rw-r--r-- | src/device/device_ledger.hpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp index 4a3625b2b..87b65996d 100644 --- a/src/device/device_ledger.hpp +++ b/src/device/device_ledger.hpp @@ -33,13 +33,7 @@ #include <cstddef> #include <string> #include "device.hpp" -#ifdef WIN32 -#include <winscard.h> -#define MAX_ATR_SIZE 33 -#else -#include <PCSC/winscard.h> -#include <PCSC/wintypes.h> -#endif +#include "device_io_hid.hpp" #include <boost/thread/mutex.hpp> #include <boost/thread/recursive_mutex.hpp> @@ -89,22 +83,23 @@ namespace hw { mutable boost::recursive_mutex device_locker; mutable boost::mutex command_locker; - //PCSC management - std::string full_name; - SCARDCONTEXT hContext; - SCARDHANDLE hCard; - DWORD length_send; - BYTE buffer_send[BUFFER_SEND_SIZE]; - DWORD length_recv; - BYTE buffer_recv[BUFFER_RECV_SIZE]; - unsigned int id; + //IO + hw::io::device_io_hid hw_device; + std::string full_name; + unsigned int length_send; + unsigned char buffer_send[BUFFER_SEND_SIZE]; + unsigned int length_recv; + unsigned char buffer_recv[BUFFER_RECV_SIZE]; + unsigned int sw; + unsigned int id; void logCMD(void); void logRESP(void); - unsigned int exchange(unsigned int ok=0x9000, unsigned int mask=0xFFFF); + unsigned int exchange(unsigned int ok=0x9000, unsigned int mask=0xFFFF); void reset_buffer(void); - int set_command_header(BYTE ins, BYTE p1 = 0x00, BYTE p2 = 0x00); - int set_command_header_noopt(BYTE ins, BYTE p1 = 0x00, BYTE p2 = 0x00); - void send_simple(BYTE ins, BYTE p1 = 0x00); + int set_command_header(unsigned char ins, unsigned char p1 = 0x00, unsigned char p2 = 0x00); + int set_command_header_noopt(unsigned char ins, unsigned char p1 = 0x00, unsigned char p2 = 0x00); + void send_simple(unsigned char ins, unsigned char p1 = 0x00); + // hw running mode device_mode mode; @@ -127,7 +122,7 @@ namespace hw { device_ledger(const device_ledger &device) = delete ; device_ledger& operator=(const device_ledger &device) = delete; - explicit operator bool() const override {return this->hContext != 0;} + explicit operator bool() const override {return this->connected(); } bool reset(void); @@ -141,6 +136,7 @@ namespace hw { bool release() override; bool connect(void) override; bool disconnect() override; + bool connected(void) const; bool set_mode(device_mode mode) override; |