to colorize a colorful pixel with a simple touch using nfc technology
Dependencies: Chainable_RGB_LED mbed
use Arch, NFC Shield and Grove - Chainable RGB LED to DIY a touch pixel. Then use an Android with NFC support to colorize it.
The project is on https://github.com/Seeed-Studio/TouchPixel
nfc/snep.h@0:88960f3eeb2c, 2013-12-27 (annotated)
- Committer:
- yihui
- Date:
- Fri Dec 27 01:46:32 2013 +0000
- Revision:
- 0:88960f3eeb2c
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 0:88960f3eeb2c | 1 | |
yihui | 0:88960f3eeb2c | 2 | |
yihui | 0:88960f3eeb2c | 3 | #ifndef __SNEP_H__ |
yihui | 0:88960f3eeb2c | 4 | #define __SNEP_H__ |
yihui | 0:88960f3eeb2c | 5 | |
yihui | 0:88960f3eeb2c | 6 | #include "llcp.h" |
yihui | 0:88960f3eeb2c | 7 | |
yihui | 0:88960f3eeb2c | 8 | #define SNEP_DEFAULT_VERSION 0x10 // Major: 1, Minor: 0 |
yihui | 0:88960f3eeb2c | 9 | |
yihui | 0:88960f3eeb2c | 10 | #define SNEP_REQUEST_PUT 0x02 |
yihui | 0:88960f3eeb2c | 11 | #define SNEP_REQUEST_GET 0x01 |
yihui | 0:88960f3eeb2c | 12 | |
yihui | 0:88960f3eeb2c | 13 | #define SNEP_RESPONSE_SUCCESS 0x81 |
yihui | 0:88960f3eeb2c | 14 | #define SNEP_RESPONSE_REJECT 0xFF |
yihui | 0:88960f3eeb2c | 15 | |
yihui | 0:88960f3eeb2c | 16 | class SNEP { |
yihui | 0:88960f3eeb2c | 17 | public: |
yihui | 0:88960f3eeb2c | 18 | SNEP(PN532Interface &interface) : llcp(interface) { |
yihui | 0:88960f3eeb2c | 19 | headerBuf = llcp.getHeaderBuffer(&headerBufLen); |
yihui | 0:88960f3eeb2c | 20 | }; |
yihui | 0:88960f3eeb2c | 21 | |
yihui | 0:88960f3eeb2c | 22 | /** |
yihui | 0:88960f3eeb2c | 23 | * @brief write a SNEP packet, the packet should be less than (255 - 2 - 3) bytes |
yihui | 0:88960f3eeb2c | 24 | * @param buf the buffer to contain the packet |
yihui | 0:88960f3eeb2c | 25 | * @param len lenght of the buffer |
yihui | 0:88960f3eeb2c | 26 | * @param timeout max time to wait, 0 means no timeout |
yihui | 0:88960f3eeb2c | 27 | * @return >0 success |
yihui | 0:88960f3eeb2c | 28 | * =0 timeout |
yihui | 0:88960f3eeb2c | 29 | * <0 failed |
yihui | 0:88960f3eeb2c | 30 | */ |
yihui | 0:88960f3eeb2c | 31 | int8_t write(const uint8_t *buf, uint8_t len, uint16_t timeout = 0); |
yihui | 0:88960f3eeb2c | 32 | |
yihui | 0:88960f3eeb2c | 33 | /** |
yihui | 0:88960f3eeb2c | 34 | * @brief read a SNEP packet, the packet will be less than (255 - 2 - 3) bytes |
yihui | 0:88960f3eeb2c | 35 | * @param buf the buffer to contain the packet |
yihui | 0:88960f3eeb2c | 36 | * @param len lenght of the buffer |
yihui | 0:88960f3eeb2c | 37 | * @param timeout max time to wait, 0 means no timeout |
yihui | 0:88960f3eeb2c | 38 | * @return >=0 length of the packet |
yihui | 0:88960f3eeb2c | 39 | * <0 failed |
yihui | 0:88960f3eeb2c | 40 | */ |
yihui | 0:88960f3eeb2c | 41 | int16_t read(uint8_t *buf, uint8_t len, uint16_t timeout = 0); |
yihui | 0:88960f3eeb2c | 42 | |
yihui | 0:88960f3eeb2c | 43 | private: |
yihui | 0:88960f3eeb2c | 44 | LLCP llcp; |
yihui | 0:88960f3eeb2c | 45 | uint8_t *headerBuf; |
yihui | 0:88960f3eeb2c | 46 | uint8_t headerBufLen; |
yihui | 0:88960f3eeb2c | 47 | }; |
yihui | 0:88960f3eeb2c | 48 | |
yihui | 0:88960f3eeb2c | 49 | #endif // __SNEP_H__ |