forked from Seeed-Shield/NFC_Shield_DEV
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathNFCLinkLayer.h
76 lines (57 loc) · 1.63 KB
/
NFCLinkLayer.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
#ifndef NFC_LINK_LAYER_H
#define NFC_LINK_LAYER_H
#include "Arduino.h"
#include "NFCReader.h"
#define SYMM_PTYPE 0x00
#define PAX_PTYPE 0x01
#define AGGREGATE_PTYPE 0x02
#define UNNUMBERED_INFORMATION_PTYPE 0x03
#define CONNECT_PTYPE 0x04
#define DISCONNECT_PTYPE 0x05
#define CONNECTION_COMPLETE_PTYPE 0x06
#define DISCONNECTED_MODE_PTYPE 0x07
#define FRAME_REJECT_PTYPE 0X08
#define INFORMATION_PTYPE 0x0C
#define RECEIVE_READY_TYPE 0x0D
#define RECEIVE_NOT_READY_TYPE 0x0E
#define SERVICE_NAME_PARAM_TYPE 0x06
#define CONNECT_SERVICE_NAME_LEN 0x0F
#define CONNECT_SERVICE_NAME "com.android.npp"
#define CONNECT_SERVER_PDU_LEN CONNECT_SERVICE_NAME_LEN + 4
struct PARAMETER_DESCR {
union {
uint8_t type;
uint8_t sequence;
};
uint8_t length;
uint8_t data[0];
};
struct PDU {
public:
uint8_t field[2];
PARAMETER_DESCR params;
PDU();
uint8_t getDSAP();
uint8_t getSSAP();
uint8_t getPTYPE();
void setDSAP(uint8_t DSAP);
void setSSAP(uint8_t SSAP);
void setPTYPE(uint8_t PTYPE);
bool isConnectClientRequest();
};
class NFCLinkLayer {
public:
NFCLinkLayer(NFCReader *nfcReader);
~NFCLinkLayer();
uint32_t openSNEPServerLink(void);
uint32_t closeSNEPServerLink(void);
uint32_t openSNEPClientLink(void);
uint32_t closeSNEPClientLink(void);
uint32_t serverLinkRxData(uint8_t *&Data);
uint32_t clientLinkTxData(uint8_t *nppMessage, uint32_t len);
private:
NFCReader *_nfcReader;
uint8_t DSAP;
uint8_t SSAP;
};
#endif