LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
osdpcommands.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_OSDPCOMMANDS_HPP
8#define LOGICALACCESS_OSDPCOMMANDS_HPP
9
12
13#include <vector>
14#include <functional>
15
16namespace logicalaccess
17{
18#define CMD_ODSP "ODSP"
19
20enum class TemporaryControleCode : uint8_t
21{
22 NOP = 0x00,
25};
26
27enum class PermanentControlCode : uint8_t
28{
29 NotPermanentState = 0x00,
31};
32
33enum class OSDPColor : uint8_t
34{
35 Black = 0x00,
36 Red = 0x01,
37 Green = 0x02,
38 Amber = 0x03,
39 Blue = 0x04
40};
41
42enum class ReaderTamperStatus : uint8_t
43{
44 Normal = 0x00,
45 NotConnected = 0x01,
46 Tamper = 0x02
47};
48
49enum class DataFormatCode : uint8_t
50{
51 RawFormat = 0x00,
52 WiegandFormat = 0x01
53};
54
55enum class ReadDirection : uint8_t
56{
57 ForwardRead = 0x00,
58 ReverseRead = 0x01
59};
60
61enum class FileTransferStatus : int16_t
62{
64 Processed = 1,
65 Rebooting = 2,
66 Finishing = 3,
67 Abort = -1,
69 InvalidData = -3
70};
71
72enum class BiometricType : uint8_t
73{
74 Default = 0x00,
75 RightThumbPrint = 0x01,
80 LeftThumbPrint = 0x06,
85 RightIrisScan = 0x0b,
86 RightRetinaScan = 0x0c,
87 LeftIrisScan = 0x0d,
88 LeftRetinaScan = 0x0e,
89 FullFaceImage = 0x0f,
90 RightHandGeometry = 0x10,
91 LeftHandGeometry = 0x11
92};
93
94enum class BiometricFormat : uint8_t
95{
96 Default = 0x00,
97 RawPGM = 0x01,
98 ANSI_Template71 = 0x02
99};
100
101enum class BiometricStatus : uint8_t
102{
103 Success = 0x00,
104 Timeout = 0x01,
105 UnknownError = 0xff
106};
107
108typedef struct t_led_cmd
109{
110 uint8_t reader;
111 uint8_t ledNumber;
113 uint8_t tempOnTime;
114 uint8_t tempOffTime;
117 uint8_t timerLSB;
118 uint8_t timerMSB;
120 uint8_t permOnTime;
121 uint8_t permOffTime;
125
126typedef struct t_buz_cmd
127{
128 uint8_t reader;
129 uint8_t toneCode;
130 uint8_t onTime;
131 uint8_t offTime;
132 uint8_t count;
134
135#define OSDP_CMD_TEXT_MAX_LEN 32
136
137typedef struct t_text_cmd
138{
139 uint8_t reader;
140 uint8_t controlCode;
141 uint8_t tempTime;
142 uint8_t offsetRow;
143 uint8_t offsetCol;
144 uint8_t length;
147
148typedef struct t_pdid_report
149{
150 uint8_t vendorCode1;
151 uint8_t vendorCode2;
152 uint8_t vendorCode3;
153 uint8_t modelNumber;
154 uint8_t version;
155 uint32_t serialNumber;
160
161typedef struct t_pdcap_report
162{
164 uint8_t compliance;
165 uint8_t numberOf;
167
168typedef struct t_lstat_report
169{
171 uint8_t powerStatus;
173
174#define OSDP_EVENT_MAX_LEN 64
175
176typedef struct t_carddata_raw
177{
180 uint16_t bitCount;
183
184typedef struct t_carddata_fmt
185{
191
192typedef struct t_keypad
193{
195 uint8_t digitCount;
198
199typedef struct t_com
200{
201 uint8_t address;
202 uint32_t baudrate;
204
205typedef struct t_ftstat
206{
207 uint8_t action;
208 uint16_t delay;
210 uint16_t updateMsgMax;
212
213#define OSDP_BIOTEMPLATE_MAX_LEN 512
214
215typedef struct t_bioreadr
216{
220 uint8_t bioQuality;
221 uint8_t bioLength;
224
225typedef struct t_biomatchr
226{
229 uint8_t score;
231
232typedef struct t_pivdata
233{
234 uint8_t objectId1;
235 uint8_t objectId2;
236 uint8_t objectId3;
237 uint8_t elementId;
238 uint8_t dataOffset;
240
241typedef std::function<void(uint8_t, ByteVector, uint16_t)> OsdpReaderEvent;
242typedef std::function<void(s_bioreadr&)> OsdpBioReadEvent;
243typedef std::function<void(s_biomatchr&)> OsdpBioMatchEvent;
244typedef std::function<void(bool, bool)> OsdpTamperEvent;
245
249class LLA_READERS_OSDP_API OSDPCommands : public Commands
250{
251 public:
254 {
255 initCommands();
256 }
257
258 explicit OSDPCommands(std::string ct)
259 : Commands(ct)
260 {
261 initCommands();
262 }
263
265 {
266 }
267
268 void initCommands(unsigned char address = 0, bool installMode = false);
269
270 std::shared_ptr<OSDPChannel> poll() const;
271
272 std::shared_ptr<OSDPChannel> challenge() const;
273
274 std::shared_ptr<OSDPChannel> sCrypt() const;
275
276 std::shared_ptr<OSDPChannel> keySet(const ByteVector& key) const;
277
278 std::shared_ptr<OSDPChannel> led(s_led_cmd &led) const;
279
280 std::shared_ptr<OSDPChannel> buz(s_buz_cmd &led) const;
281
282 std::shared_ptr<OSDPChannel> text(s_text_cmd &text) const;
283
284 s_com setCommunicationSettings(uint8_t address, uint32_t baudrate) const;
285
286 s_ftstat fileTransfer(ByteVector file, uint8_t transferType = 0x01) const;
287
288 s_ftstat fileTransfer(uint32_t totalSize, uint32_t offset, ByteVector fragment, uint8_t transferType = 0x01) const;
289
290 std::shared_ptr<OSDPChannel> setProfile(unsigned char profile) const;
291
292 std::shared_ptr<OSDPChannel> getProfile() const;
293
294 s_pdid_report pdID() const;
295
296 std::vector<s_pdcap_report> pdCAP() const;
297
298 s_lstat_report localStatus() const;
299
300 s_lstat_report localStatus(std::shared_ptr<OSDPChannel> channel) const;
301
302 ByteVector inputStatus() const;
303
304 ByteVector inputStatus(std::shared_ptr<OSDPChannel> channel) const;
305
306 ByteVector outputStatus() const;
307
308 ByteVector outputStatus(std::shared_ptr<OSDPChannel> channel) const;
309
310 ReaderTamperStatus readerTamperStatus() const;
311
312 ReaderTamperStatus readerTamperStatus(std::shared_ptr<OSDPChannel> channel) const;
313
314 std::shared_ptr<OSDPChannel> abort() const;
315
316 std::shared_ptr<OSDPChannel> bioRead(BiometricType type, BiometricFormat format, uint8_t quality) const;
317
318 std::shared_ptr<OSDPChannel> bioMatch(BiometricType type, BiometricFormat format, uint8_t quality, ByteVector& bioTemplate) const;
319
320 std::shared_ptr<OSDPChannel> getPIVData(s_pivdata& data) const;
321
322 std::shared_ptr<OSDPChannel> sendTransparentCommand(const ByteVector &command) const;
323
324 std::shared_ptr<OSDPChannel> disconnectFromSmartcard() const;
325
326 void setSecureChannel(std::shared_ptr<OSDPChannel> channel)
327 {
328 m_channel = channel;
329 }
330
331 std::shared_ptr<OSDPChannel> getChannel() const
332 {
333 return m_channel;
334 }
335
337 {
338 handleCardEvent = cardHandler;
339 }
340
342 {
343 handleKeypadEvent = keypadHandler;
344 }
345
347 {
348 handleBioReadEvent = bioreadHandler;
349 }
350
352 {
353 handleTamperEvent = tamperHandler;
354 }
355
356 private:
357
358 std::shared_ptr<OSDPChannel> stransmit() const;
359
360 std::shared_ptr<OSDPChannel> transmit() const;
361
362 std::shared_ptr<OSDPChannel> m_channel;
363
365
367
369
371
373};
374}
375
376#endif /* LOGICALACCESS_OSDPCOMMANDS_HPP */
The base commands class for all card commands.
Definition: commands.hpp:21
OSDP Commands class.
Definition: osdpcommands.hpp:250
void setCardEventHandler(OsdpReaderEvent cardHandler)
Definition: osdpcommands.hpp:336
~OSDPCommands()
Definition: osdpcommands.hpp:264
OsdpTamperEvent handleTamperEvent
Definition: osdpcommands.hpp:372
void setKeypadEventHandler(OsdpReaderEvent keypadHandler)
Definition: osdpcommands.hpp:341
OsdpReaderEvent handleKeypadEvent
Definition: osdpcommands.hpp:366
std::shared_ptr< OSDPChannel > getChannel() const
Definition: osdpcommands.hpp:331
OsdpBioReadEvent handleBioReadEvent
Definition: osdpcommands.hpp:368
OSDPCommands(std::string ct)
Definition: osdpcommands.hpp:258
void setTamperEventHandler(OsdpTamperEvent tamperHandler)
Definition: osdpcommands.hpp:351
OsdpReaderEvent handleCardEvent
Definition: osdpcommands.hpp:364
void setSecureChannel(std::shared_ptr< OSDPChannel > channel)
Definition: osdpcommands.hpp:326
OsdpBioMatchEvent handleBioMatchEvent
Definition: osdpcommands.hpp:370
OSDPCommands()
Definition: osdpcommands.hpp:252
std::shared_ptr< OSDPChannel > m_channel
Definition: osdpcommands.hpp:362
void setBioReadEventHandler(OsdpBioReadEvent bioreadHandler)
Definition: osdpcommands.hpp:346
A Raw format.
Definition: rawformat.hpp:18
A Wiegand format.
Definition: wiegandformat.hpp:18
Commands.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
BiometricStatus
Definition: osdpcommands.hpp:102
struct logicalaccess::t_buz_cmd s_buz_cmd
struct logicalaccess::t_pivdata s_pivdata
OSDPColor
Definition: osdpcommands.hpp:34
struct logicalaccess::t_pdcap_report s_pdcap_report
struct logicalaccess::t_text_cmd s_text_cmd
struct logicalaccess::t_bioreadr s_bioreadr
std::function< void(s_biomatchr &)> OsdpBioMatchEvent
Definition: osdpcommands.hpp:243
struct logicalaccess::t_lstat_report s_lstat_report
struct logicalaccess::t_led_cmd s_led_cmd
struct logicalaccess::t_carddata_fmt s_carddata_fmt
struct logicalaccess::t_keypad s_keypad
ReadDirection
Definition: osdpcommands.hpp:56
BiometricFormat
Definition: osdpcommands.hpp:95
ReaderTamperStatus
Definition: osdpcommands.hpp:43
FileTransferStatus
Definition: osdpcommands.hpp:62
std::function< void(uint8_t, ByteVector, uint16_t)> OsdpReaderEvent
Definition: osdpcommands.hpp:241
std::function< void(s_bioreadr &)> OsdpBioReadEvent
Definition: osdpcommands.hpp:242
BiometricType
Definition: osdpcommands.hpp:73
struct logicalaccess::t_com s_com
DataFormatCode
Definition: osdpcommands.hpp:50
std::function< void(bool, bool)> OsdpTamperEvent
Definition: osdpcommands.hpp:244
struct logicalaccess::t_biomatchr s_biomatchr
struct logicalaccess::t_pdid_report s_pdid_report
struct logicalaccess::t_ftstat s_ftstat
TemporaryControleCode
Definition: osdpcommands.hpp:21
PermanentControlCode
Definition: osdpcommands.hpp:28
struct logicalaccess::t_carddata_raw s_carddata_raw
OSDP channel.
#define OSDP_BIOTEMPLATE_MAX_LEN
Definition: osdpcommands.hpp:213
#define CMD_ODSP
Definition: osdpcommands.hpp:18
#define OSDP_CMD_TEXT_MAX_LEN
Definition: osdpcommands.hpp:135
#define OSDP_EVENT_MAX_LEN
Definition: osdpcommands.hpp:174
Definition: osdpcommands.hpp:226
uint8_t score
Definition: osdpcommands.hpp:229
uint8_t readerNumber
Definition: osdpcommands.hpp:227
BiometricStatus status
Definition: osdpcommands.hpp:228
Definition: osdpcommands.hpp:216
uint8_t readerNumber
Definition: osdpcommands.hpp:217
uint8_t bioLength
Definition: osdpcommands.hpp:221
uint8_t bioQuality
Definition: osdpcommands.hpp:220
BiometricStatus status
Definition: osdpcommands.hpp:218
BiometricType bioType
Definition: osdpcommands.hpp:219
uint8_t bioTemplate[OSDP_BIOTEMPLATE_MAX_LEN]
Definition: osdpcommands.hpp:222
Definition: osdpcommands.hpp:127
uint8_t reader
Definition: osdpcommands.hpp:128
uint8_t onTime
Definition: osdpcommands.hpp:130
uint8_t toneCode
Definition: osdpcommands.hpp:129
uint8_t count
Definition: osdpcommands.hpp:132
uint8_t offTime
Definition: osdpcommands.hpp:131
Definition: osdpcommands.hpp:185
uint8_t characterCount
Definition: osdpcommands.hpp:188
ReadDirection readDirection
Definition: osdpcommands.hpp:187
uint8_t readerNumber
Definition: osdpcommands.hpp:186
uint8_t data[OSDP_EVENT_MAX_LEN]
Definition: osdpcommands.hpp:189
Definition: osdpcommands.hpp:177
uint16_t bitCount
Definition: osdpcommands.hpp:180
uint8_t readerNumber
Definition: osdpcommands.hpp:178
uint8_t data[OSDP_EVENT_MAX_LEN]
Definition: osdpcommands.hpp:181
DataFormatCode formatCode
Definition: osdpcommands.hpp:179
Definition: osdpcommands.hpp:200
uint8_t address
Definition: osdpcommands.hpp:201
uint32_t baudrate
Definition: osdpcommands.hpp:202
Definition: osdpcommands.hpp:206
uint8_t action
Definition: osdpcommands.hpp:207
uint16_t updateMsgMax
Definition: osdpcommands.hpp:210
uint16_t delay
Definition: osdpcommands.hpp:208
FileTransferStatus statusDetail
Definition: osdpcommands.hpp:209
Definition: osdpcommands.hpp:193
uint8_t data[OSDP_EVENT_MAX_LEN]
Definition: osdpcommands.hpp:196
uint8_t readerNumber
Definition: osdpcommands.hpp:194
uint8_t digitCount
Definition: osdpcommands.hpp:195
Definition: osdpcommands.hpp:109
TemporaryControleCode tempControlCode
Definition: osdpcommands.hpp:112
uint8_t timerMSB
Definition: osdpcommands.hpp:118
PermanentControlCode permControlCode
Definition: osdpcommands.hpp:119
uint8_t timerLSB
Definition: osdpcommands.hpp:117
OSDPColor tempOnColor
Definition: osdpcommands.hpp:115
uint8_t tempOnTime
Definition: osdpcommands.hpp:113
uint8_t ledNumber
Definition: osdpcommands.hpp:111
uint8_t tempOffTime
Definition: osdpcommands.hpp:114
OSDPColor tempOffColor
Definition: osdpcommands.hpp:116
OSDPColor permOffColor
Definition: osdpcommands.hpp:123
uint8_t permOnTime
Definition: osdpcommands.hpp:120
uint8_t permOffTime
Definition: osdpcommands.hpp:121
uint8_t reader
Definition: osdpcommands.hpp:110
OSDPColor permOnColor
Definition: osdpcommands.hpp:122
Definition: osdpcommands.hpp:169
uint8_t tamperStatus
Definition: osdpcommands.hpp:170
uint8_t powerStatus
Definition: osdpcommands.hpp:171
Definition: osdpcommands.hpp:162
uint8_t numberOf
Definition: osdpcommands.hpp:165
uint8_t functionCode
Definition: osdpcommands.hpp:163
uint8_t compliance
Definition: osdpcommands.hpp:164
Definition: osdpcommands.hpp:149
uint8_t firmwareBuild
Definition: osdpcommands.hpp:158
uint8_t vendorCode3
Definition: osdpcommands.hpp:152
uint32_t serialNumber
Definition: osdpcommands.hpp:155
uint8_t vendorCode2
Definition: osdpcommands.hpp:151
uint8_t firmwareMinor
Definition: osdpcommands.hpp:157
uint8_t vendorCode1
Definition: osdpcommands.hpp:150
uint8_t modelNumber
Definition: osdpcommands.hpp:153
uint8_t version
Definition: osdpcommands.hpp:154
uint8_t firmwareMajor
Definition: osdpcommands.hpp:156
Definition: osdpcommands.hpp:233
uint8_t dataOffset
Definition: osdpcommands.hpp:238
uint8_t objectId3
Definition: osdpcommands.hpp:236
uint8_t objectId1
Definition: osdpcommands.hpp:234
uint8_t objectId2
Definition: osdpcommands.hpp:235
uint8_t elementId
Definition: osdpcommands.hpp:237
Definition: osdpcommands.hpp:138
uint8_t reader
Definition: osdpcommands.hpp:139
uint8_t length
Definition: osdpcommands.hpp:144
uint8_t data[OSDP_CMD_TEXT_MAX_LEN]
Definition: osdpcommands.hpp:145
uint8_t offsetRow
Definition: osdpcommands.hpp:142
uint8_t tempTime
Definition: osdpcommands.hpp:141
uint8_t controlCode
Definition: osdpcommands.hpp:140
uint8_t offsetCol
Definition: osdpcommands.hpp:143