Generic library for working with PN532-like chips
Fork of PN532 by
snep.h@11:5b8afec8bee6, 2015-02-04 (annotated)
- Committer:
- r4z0r7o3
- Date:
- Wed Feb 04 19:26:03 2015 +0000
- Revision:
- 11:5b8afec8bee6
- Parent:
- 6:418ee8924317
Fix missing space in tag print()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 3:4189a10038e6 | 1 | |
yihui | 3:4189a10038e6 | 2 | |
yihui | 3:4189a10038e6 | 3 | #ifndef __SNEP_H__ |
yihui | 3:4189a10038e6 | 4 | #define __SNEP_H__ |
yihui | 3:4189a10038e6 | 5 | |
yihui | 3:4189a10038e6 | 6 | #include "llcp.h" |
yihui | 3:4189a10038e6 | 7 | |
yihui | 3:4189a10038e6 | 8 | #define SNEP_DEFAULT_VERSION 0x10 // Major: 1, Minor: 0 |
yihui | 3:4189a10038e6 | 9 | |
yihui | 3:4189a10038e6 | 10 | #define SNEP_REQUEST_PUT 0x02 |
yihui | 3:4189a10038e6 | 11 | #define SNEP_REQUEST_GET 0x01 |
yihui | 3:4189a10038e6 | 12 | |
yihui | 3:4189a10038e6 | 13 | #define SNEP_RESPONSE_SUCCESS 0x81 |
yihui | 3:4189a10038e6 | 14 | #define SNEP_RESPONSE_REJECT 0xFF |
yihui | 3:4189a10038e6 | 15 | |
screamer | 6:418ee8924317 | 16 | /** |
screamer | 6:418ee8924317 | 17 | * The SNEP class |
screamer | 6:418ee8924317 | 18 | */ |
yihui | 3:4189a10038e6 | 19 | class SNEP { |
yihui | 3:4189a10038e6 | 20 | public: |
yihui | 3:4189a10038e6 | 21 | SNEP(PN532Interface &interface) : llcp(interface) { |
yihui | 3:4189a10038e6 | 22 | headerBuf = llcp.getHeaderBuffer(&headerBufLen); |
yihui | 3:4189a10038e6 | 23 | }; |
yihui | 3:4189a10038e6 | 24 | |
yihui | 3:4189a10038e6 | 25 | /** |
screamer | 6:418ee8924317 | 26 | * @brief write a SNEP packet, the packet should be less than (255 - 2 - 3) bytes |
screamer | 6:418ee8924317 | 27 | * @param buf the buffer to contain the packet |
screamer | 6:418ee8924317 | 28 | * @param len lenght of the buffer |
screamer | 6:418ee8924317 | 29 | * @param timeout max time to wait, 0 means no timeout |
screamer | 6:418ee8924317 | 30 | * @return >0 success |
screamer | 6:418ee8924317 | 31 | * =0 timeout |
screamer | 6:418ee8924317 | 32 | * <0 failed |
screamer | 6:418ee8924317 | 33 | */ |
yihui | 3:4189a10038e6 | 34 | int8_t write(const uint8_t *buf, uint8_t len, uint16_t timeout = 0); |
yihui | 3:4189a10038e6 | 35 | |
yihui | 3:4189a10038e6 | 36 | /** |
screamer | 6:418ee8924317 | 37 | * @brief read a SNEP packet, the packet will be less than (255 - 2 - 3) bytes |
screamer | 6:418ee8924317 | 38 | * @param buf the buffer to contain the packet |
screamer | 6:418ee8924317 | 39 | * @param len lenght of the buffer |
screamer | 6:418ee8924317 | 40 | * @param timeout max time to wait, 0 means no timeout |
screamer | 6:418ee8924317 | 41 | * @return >=0 length of the packet |
screamer | 6:418ee8924317 | 42 | * <0 failed |
screamer | 6:418ee8924317 | 43 | */ |
yihui | 3:4189a10038e6 | 44 | int16_t read(uint8_t *buf, uint8_t len, uint16_t timeout = 0); |
yihui | 3:4189a10038e6 | 45 | |
yihui | 3:4189a10038e6 | 46 | private: |
yihui | 3:4189a10038e6 | 47 | LLCP llcp; |
yihui | 3:4189a10038e6 | 48 | uint8_t *headerBuf; |
yihui | 3:4189a10038e6 | 49 | uint8_t headerBufLen; |
yihui | 3:4189a10038e6 | 50 | }; |
yihui | 3:4189a10038e6 | 51 | |
yihui | 3:4189a10038e6 | 52 | #endif // __SNEP_H__ |