-
Notifications
You must be signed in to change notification settings - Fork 0
/
srix.h
83 lines (70 loc) · 2.13 KB
/
srix.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
#ifndef SRIX_H
#define SRIX_H
#include <stdint.h>
#include <stdlib.h>
#include "error.h"
typedef struct Srix Srix;
/**
* Create a new Srix and set its default values.
* @return null if there is an error, else a Srix struct pointer
*/
Srix *SrixNew();
/**
* Delete a Srix and free its memory.
* @param target Srix instance to delete
*/
void SrixDelete(Srix *target);
/**
* Function that search for available NFC readers and return their number.
* @param target pointer to Srix struct
* @return number of readers found
*/
size_t NfcGetReadersCount(Srix *target);
/**
* Function that return specified nfc reader description (connection string).
* @param target pointer to Srix struct
* @param reader index of reader (0 = first, 1 = second, ecc.)
* @return connstring of reader at specified index
*/
char *NfcGetDescription(Srix *target, int reader);
/**
* Initialize the Srix using Nfc.
* @param target pointer to Srix struct
* @param reader index of nfc reader to use
* @return string error result
*/
const char *SrixNfcInit(Srix *target, int reader);
/**
* Initialize the Srix using values in memory.
* @param target pointer to Srix struct
* @param eeprom pointer to EEPROM array to import
* @param uid UID to import
*/
void SrixMemoryInit(Srix *target, uint32_t eeprom[const static SRIX4K_BLOCKS], uint64_t uid);
/**
* Return UID of an initialized srix.
* @param target pointer to Srix struct
* @return uid uint64 value
*/
uint64_t SrixGetUid(Srix *target);
/**
* Get pointer to a specified block.
* @param target pointer to Srix struct
* @param blockNum number of block to get
* @return pointer to blockNum block
*/
uint32_t *SrixGetBlock(Srix *target, uint8_t blockNum);
/**
* Modify manually a Srix block and add flag automatically.
* @param target pointer to Srix struct
* @param block value to write to blockNum
* @param blockNum index of block to write
*/
void SrixModifyBlock(Srix *target, uint32_t block, uint8_t blockNum);
/**
* Write all modified blocks of target to physical SRIX4K.
* @param target pointer to Srix struct
* @return numeric result, 0 = no error
*/
int SrixWriteBlocks(Srix *target);
#endif /* SRIX_H */