aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:23:46 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:58 +0200
commit4e8c2da50e134951a833bd135fc87e89808ec59b (patch)
tree2b9e1335e3b655d19587a98b710e55447e4723ca /include
parent0038f840f8279483e4a8fcb9edf800425fdb9fec (diff)
downloadlibnitrokey-4e8c2da50e134951a833bd135fc87e89808ec59b.tar.gz
libnitrokey-4e8c2da50e134951a833bd135fc87e89808ec59b.tar.bz2
Get device status command for storage stick
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
-rw-r--r--include/stick20_commands.h42
1 files changed, 35 insertions, 7 deletions
diff --git a/include/stick20_commands.h b/include/stick20_commands.h
index ec1b088..c684e95 100644
--- a/include/stick20_commands.h
+++ b/include/stick20_commands.h
@@ -2,8 +2,8 @@
#define STICK20_COMMANDS_H
#include "inttypes.h"
#include "command.h"
-//#include <string>
-//#include <sstream>
+#include <string>
+#include <sstream>
#include "device_proto.h"
@@ -182,11 +182,39 @@ class SendPasswordMatrixSetup : semantics::non_constructible {
struct EmptyPayload> CommandTransaction;
};
-class GetDeviceStatus : semantics::non_constructible {
- public:
- typedef Transaction<CommandID::GET_DEVICE_STATUS, struct EmptyPayload,
- struct EmptyPayload> CommandTransaction;
-};
+#define d(x) ss << #x":\t" << x << std::endl;
+
+ class GetDeviceStatus : Command<CommandID::GET_DEVICE_STATUS> {
+ public:
+ static const int OUTPUT_CMD_RESULT_STICK20_STATUS_START = 20 +1;
+ static const int payload_absolute_begin = 8;
+ static const int padding_size = OUTPUT_CMD_RESULT_STICK20_STATUS_START - payload_absolute_begin;
+ struct ResponsePayload {
+ uint8_t _padding[padding_size];
+ //data starts from 21st byte of packet -> 13th byte of payload
+ uint8_t command_counter;
+ uint8_t last_command;
+ uint8_t status;
+ uint8_t progress_bar_value;
+ bool isValid() const { return true; }
+
+ std::string dissect() const {
+ std::stringstream ss;
+ d(command_counter);
+ d(last_command);
+ d(status);
+ d(progress_bar_value);
+ ss << "_padding:\t"
+ << ::nitrokey::misc::hexdump((const char *)(_padding),
+ sizeof _padding);
+ return ss.str();
+ }
+ } __packed;
+
+ typedef Transaction<command_id(), struct EmptyPayload, struct ResponsePayload>
+ CommandTransaction;
+ };
+
class SendPassword : semantics::non_constructible {
public: