-
Notifications
You must be signed in to change notification settings - Fork 0
/
rfid.hpp
95 lines (73 loc) · 1.18 KB
/
rfid.hpp
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
88
89
90
91
92
93
94
95
/**
* rfid.hpp
*
* Created on: Jun 12, 2019
* Author: Christian Adams <[email protected]>
*/
#ifndef RFID_HPP_
#define RFID_HPP_
#include <Arduino.h>
#include <MFRC522.h>
#define RFID_POWER 7
#define RFID_POWER_ON HIGH
#define RFID_POWER_OFF LOW
//#define RFID_POWER_ON LOW
//#define RFID_POWER_OFF HIGH
#define RFID_CS 9
#define RFID_RST 8
#define ADD_CARD_TIMEOUT 30000 // 30 seconds
#define SCAN_FOR_CARD_TIMEOUT 30000 // 30 seconds
/**
*
*/
typedef struct rfid_card {
uint8_t id;
bool valid;
uint8_t uid[4];
char name[11];
} rfid_card_t;
/**
*
*/
void rfid_init(void);
/**
*
*/
void rfid_power(uint8_t status);
/**
*
*/
void rfid_power_on(void);
/**
*
*/
void rfid_power_off(void);
/**
*
*/
void rfid_print_uid_serial(uint8_t uid[4]);
/**
*
*/
bool rfid_uid_string_to_uid(String uid_string, uint8_t uid[4]);
/**
*
*/
void rfid_print_name_serial(char name[11]);
/**
*
*/
void rfid_print_card_serial(rfid_card_t* rfid_card);
/**
*
*/
bool rfid_scan_for_card(unsigned long timeout, uint8_t uid[4]);
/**
*
*/
bool rfid_scan_for_master(unsigned long timeout);
/**
*
*/
void scan_for_card(bool* listen_for_card, bool* opening);
#endif /* RFID_HPP_ */