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/mac_link.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 __MAC_LINK_H__ |
yihui | 0:88960f3eeb2c | 4 | #define __MAC_LINK_H__ |
yihui | 0:88960f3eeb2c | 5 | |
yihui | 0:88960f3eeb2c | 6 | #include "PN532.h" |
yihui | 0:88960f3eeb2c | 7 | |
yihui | 0:88960f3eeb2c | 8 | class MACLink { |
yihui | 0:88960f3eeb2c | 9 | public: |
yihui | 0:88960f3eeb2c | 10 | MACLink(PN532Interface &interface) : pn532(interface) { |
yihui | 0:88960f3eeb2c | 11 | |
yihui | 0:88960f3eeb2c | 12 | }; |
yihui | 0:88960f3eeb2c | 13 | |
yihui | 0:88960f3eeb2c | 14 | /** |
yihui | 0:88960f3eeb2c | 15 | * @brief Activate PN532 as a target |
yihui | 0:88960f3eeb2c | 16 | * @param timeout max time to wait, 0 means no timeout |
yihui | 0:88960f3eeb2c | 17 | * @return > 0 success |
yihui | 0:88960f3eeb2c | 18 | * = 0 timeout |
yihui | 0:88960f3eeb2c | 19 | * < 0 failed |
yihui | 0:88960f3eeb2c | 20 | */ |
yihui | 0:88960f3eeb2c | 21 | int8_t activateAsTarget(uint16_t timeout = 0); |
yihui | 0:88960f3eeb2c | 22 | |
yihui | 0:88960f3eeb2c | 23 | /** |
yihui | 0:88960f3eeb2c | 24 | * @brief write a PDU packet, the packet should be less than (255 - 2) bytes |
yihui | 0:88960f3eeb2c | 25 | * @param header packet header |
yihui | 0:88960f3eeb2c | 26 | * @param hlen length of header |
yihui | 0:88960f3eeb2c | 27 | * @param body packet body |
yihui | 0:88960f3eeb2c | 28 | * @param blen length of body |
yihui | 0:88960f3eeb2c | 29 | * @return true success |
yihui | 0:88960f3eeb2c | 30 | * false failed |
yihui | 0:88960f3eeb2c | 31 | */ |
yihui | 0:88960f3eeb2c | 32 | bool write(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0); |
yihui | 0:88960f3eeb2c | 33 | |
yihui | 0:88960f3eeb2c | 34 | /** |
yihui | 0:88960f3eeb2c | 35 | * @brief read a PDU packet, the packet will be less than (255 - 2) bytes |
yihui | 0:88960f3eeb2c | 36 | * @param buf the buffer to contain the PDU packet |
yihui | 0:88960f3eeb2c | 37 | * @param len lenght of the buffer |
yihui | 0:88960f3eeb2c | 38 | * @return >=0 length of the PDU packet |
yihui | 0:88960f3eeb2c | 39 | * <0 failed |
yihui | 0:88960f3eeb2c | 40 | */ |
yihui | 0:88960f3eeb2c | 41 | int16_t read(uint8_t *buf, uint8_t len); |
yihui | 0:88960f3eeb2c | 42 | |
yihui | 0:88960f3eeb2c | 43 | uint8_t *getHeaderBuffer(uint8_t *len) { |
yihui | 0:88960f3eeb2c | 44 | return pn532.getBuffer(len); |
yihui | 0:88960f3eeb2c | 45 | }; |
yihui | 0:88960f3eeb2c | 46 | |
yihui | 0:88960f3eeb2c | 47 | private: |
yihui | 0:88960f3eeb2c | 48 | PN532 pn532; |
yihui | 0:88960f3eeb2c | 49 | }; |
yihui | 0:88960f3eeb2c | 50 | |
yihui | 0:88960f3eeb2c | 51 | #endif // __MAC_LINK_H__ |