-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreader.h
87 lines (74 loc) · 2.28 KB
/
reader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef READER_H
#define READER_H
#include <stdint.h>
#include <nfc/nfc.h>
#include "error.h"
#define MAX_DEVICE_COUNT 8
#define MAX_TARGET_COUNT 1
/**
* Single SRIX block.
*/
typedef struct SrixBlock {
uint8_t block[SRIX_BLOCK_LENGTH];
} SrixBlock;
/**
* Struct that represents a NFC Reader.
*/
typedef struct NfcReader {
nfc_connstring libnfc_readers[MAX_DEVICE_COUNT]; /* readers connstring array */
nfc_device *libnfc_reader; /* libnfc reader */
} NfcReader;
/**
* Allocate a nfc reader and set its default values.
* @return null if there is an error, else an nfc reader pointer
*/
NfcReader *NfcReaderNew();
/**
* Close a nfc reader.
* @param reader reader instance where reader is saved
*/
void NfcCloseReader(NfcReader *reader);
/**
* Update available readers on NfcReader instance.
* @param reader pointer to NfcReader
* @return number of readers currently available and saved on instance
*/
size_t NfcUpdateReaders(NfcReader *reader);
/**
* Get a description of a specific reader.
* @param reader pointer to a NfcReader instance
* @param selection index of reader to get
* @return pointer to reader description string
*/
char *NfcGetReaderDescription(NfcReader *reader, int selection);
/**
* Initialize an NFC Reader.
* @param reader pointer to Reader struct
* @param selection id of Reader to initialize
* @return SrixError result
*/
SrixError NfcInitReader(NfcReader *reader, int selection);
/**
* Get UID from Reader as raw byte array.
* @param reader pointer to Reader struct
* @param uid array where save the UID data
* @return SrixError result
*/
SrixError NfcGetUid(NfcReader *reader, uint8_t uid[const static SRIX_UID_LENGTH]);
/**
* Read a specified block from SRIX4K to block array.
* @param reader nfc reader to send command
* @param block array to save read block
* @param blockNum block to read from SRIX
* @return SrixError result
*/
SrixError NfcReadBlock(NfcReader *reader, SrixBlock *block, uint8_t blockNum);
/**
* Write a specified block to SRIX4K.
* @param reader nfc reader to send command
* @param block array of data to write to block
* @param blockNum block to write to SRIX
* @return SrixError result
*/
SrixError NfcWriteBlock(NfcReader *reader, SrixBlock *block, uint8_t blockNum);
#endif /* READER_H */