PN532 NFC library for Seeed Studio's NFC Shield

Fork of PN532 by Yihui Xiong

Committer:
yihui
Date:
Thu Nov 21 04:30:49 2013 +0000
Revision:
3:4189a10038e6
Child:
6:418ee8924317
sync with https://github.com/Seeed-Studio/PN532/releases/tag/v0.9.

Who changed what in which revision?

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