Forked from LibPN532

Dependents:   NFC_Secure_Access NFC_Secure_Access

Fork of LibPN532 by dotnfc Tang

Committer:
udareaniket
Date:
Sun Apr 22 23:29:20 2018 +0000
Revision:
2:9a2ab3fa7862
Parent:
0:db8030e71f55
Initial commit;

Who changed what in which revision?

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