-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiotsaRFID.h
54 lines (43 loc) · 1.3 KB
/
iotsaRFID.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
#ifndef _IOTSA_RFID_H_
#define _IOTSA_RFID_H_
#include "iotsa.h"
#include "iotsaApi.h"
//
// RFID module. Reads RFID cards.
//
//
// Pins for RFID-RC522 module. Read RFID cards.
//
#define PIN_RFID_RESET 16
#define PIN_RFID_SDA 5
#define PIN_RFID_MOSI 13
#define PIN_RFID_MISO 12
#define PIN_RFID_SCK 14
//
// Interval to poll RFID reader. A read takes about 25ms, so don't do it every loop.
//
#define RFID_POLL_INTERVAL 200
// Current mode of operation.
typedef enum { card_idle, card_ok, card_bad, card_add, card_remove} cardMode;
typedef void (*callbackFunc)(String& uid);
typedef void (*modeCallbackFunc)(cardMode mode);
class IotsaRFIDMod : public IotsaApiMod {
public:
IotsaRFIDMod(IotsaApplication &_app, IotsaAuthenticationProvider *_auth=NULL) : IotsaApiMod(_app, _auth) {}
void setup() override;
void serverSetup() override;
void loop() override;
String info() override;
callbackFunc cardPresented;
callbackFunc unknownCardPresented;
modeCallbackFunc modeChanged;
protected:
bool getHandler(const char *path, JsonObject& reply) override;
bool putHandler(const char *path, const JsonVariant& request, JsonObject& reply) override;
private:
void configSave() override;
void configLoad() override;
void handler();
void handleCard(String& uid);
};
#endif // _IOTSA_RFID_H_