Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PN532 by
mac_link.h@11:e7bbcfa61859, 2016-11-17 (annotated)
- Committer:
- dwini
- Date:
- Thu Nov 17 11:32:02 2016 +0000
- Revision:
- 11:e7bbcfa61859
- Parent:
- 6:418ee8924317
Fix use of DMSG instead of printf
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 __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 | |
| screamer | 6:418ee8924317 | 8 | /** | 
| screamer | 6:418ee8924317 | 9 | * The MACLink class | 
| screamer | 6:418ee8924317 | 10 | */ | 
| yihui | 3:4189a10038e6 | 11 | class MACLink { | 
| yihui | 3:4189a10038e6 | 12 | public: | 
| yihui | 3:4189a10038e6 | 13 | MACLink(PN532Interface &interface) : pn532(interface) { | 
| yihui | 3:4189a10038e6 | 14 | |
| yihui | 3:4189a10038e6 | 15 | }; | 
| yihui | 3:4189a10038e6 | 16 | |
| yihui | 3:4189a10038e6 | 17 | /** | 
| screamer | 6:418ee8924317 | 18 | * @brief Activate PN532 as a target | 
| screamer | 6:418ee8924317 | 19 | * @param timeout max time to wait, 0 means no timeout | 
| screamer | 6:418ee8924317 | 20 | * @return > 0 success | 
| screamer | 6:418ee8924317 | 21 | * = 0 timeout | 
| screamer | 6:418ee8924317 | 22 | * < 0 failed | 
| screamer | 6:418ee8924317 | 23 | */ | 
| yihui | 3:4189a10038e6 | 24 | int8_t activateAsTarget(uint16_t timeout = 0); | 
| yihui | 3:4189a10038e6 | 25 | |
| yihui | 3:4189a10038e6 | 26 | /** | 
| screamer | 6:418ee8924317 | 27 | * @brief write a PDU packet, the packet should be less than (255 - 2) bytes | 
| screamer | 6:418ee8924317 | 28 | * @param header packet header | 
| screamer | 6:418ee8924317 | 29 | * @param hlen length of header | 
| screamer | 6:418ee8924317 | 30 | * @param body packet body | 
| screamer | 6:418ee8924317 | 31 | * @param blen length of body | 
| screamer | 6:418ee8924317 | 32 | * @return true success | 
| screamer | 6:418ee8924317 | 33 | * false failed | 
| screamer | 6:418ee8924317 | 34 | */ | 
| yihui | 3:4189a10038e6 | 35 | bool write(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0); | 
| yihui | 3:4189a10038e6 | 36 | |
| yihui | 3:4189a10038e6 | 37 | /** | 
| screamer | 6:418ee8924317 | 38 | * @brief read a PDU packet, the packet will be less than (255 - 2) bytes | 
| screamer | 6:418ee8924317 | 39 | * @param buf the buffer to contain the PDU packet | 
| screamer | 6:418ee8924317 | 40 | * @param len lenght of the buffer | 
| screamer | 6:418ee8924317 | 41 | * @return >=0 length of the PDU packet | 
| screamer | 6:418ee8924317 | 42 | * <0 failed | 
| screamer | 6:418ee8924317 | 43 | */ | 
| yihui | 3:4189a10038e6 | 44 | int16_t read(uint8_t *buf, uint8_t len); | 
| yihui | 3:4189a10038e6 | 45 | |
| yihui | 3:4189a10038e6 | 46 | uint8_t *getHeaderBuffer(uint8_t *len) { | 
| yihui | 3:4189a10038e6 | 47 | return pn532.getBuffer(len); | 
| yihui | 3:4189a10038e6 | 48 | }; | 
| yihui | 3:4189a10038e6 | 49 | |
| yihui | 3:4189a10038e6 | 50 | private: | 
| yihui | 3:4189a10038e6 | 51 | PN532 pn532; | 
| yihui | 3:4189a10038e6 | 52 | }; | 
| yihui | 3:4189a10038e6 | 53 | |
| yihui | 3:4189a10038e6 | 54 | #endif // __MAC_LINK_H__ | 
