Library for the Robotics RedBee™RFID Reader.

Committer:
Sebastien Prouff
Date:
Wed Nov 10 16:48:19 2021 +0100
Revision:
1:63229f10d6e0
Parent:
0:9765e979a653
Feature : add documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sebastien Prouff 0:9765e979a653 1 #ifndef ROBOTICS_RFID_READER_H
Sebastien Prouff 0:9765e979a653 2 #define ROBOTICS_RFID_READER_H
Sebastien Prouff 0:9765e979a653 3
Sebastien Prouff 0:9765e979a653 4
Sebastien Prouff 0:9765e979a653 5 /**
Sebastien Prouff 0:9765e979a653 6 * @file robotics_rfid_reader.h
Sebastien Prouff 0:9765e979a653 7 * @author sepro
Sebastien Prouff 0:9765e979a653 8 * @version 1.0
Sebastien Prouff 0:9765e979a653 9 * @class RoboticsRfidReader
Sebastien Prouff 0:9765e979a653 10 * @date 31/01/2021
Sebastien Prouff 0:9765e979a653 11 */
Sebastien Prouff 0:9765e979a653 12
Sebastien Prouff 0:9765e979a653 13 #include "mbed.h"
Sebastien Prouff 0:9765e979a653 14
Sebastien Prouff 0:9765e979a653 15 /**
Sebastien Prouff 0:9765e979a653 16 * Example
Sebastien Prouff 0:9765e979a653 17 * @code
Sebastien Prouff 0:9765e979a653 18 * #define ID_BADGE "1 7 221 87 161"
Sebastien Prouff 0:9765e979a653 19 * RoboticsRfidReader myRfid(D1, D0);
Sebastien Prouff 0:9765e979a653 20 *
Sebastien Prouff 0:9765e979a653 21 * int main() {
Sebastien Prouff 0:9765e979a653 22 * unsigned char buffer[30];
Sebastien Prouff 0:9765e979a653 23 * bool lineRead;
Sebastien Prouff 0:9765e979a653 24 * printf("RFID TEST \r\n");
Sebastien Prouff 0:9765e979a653 25 *
Sebastien Prouff 0:9765e979a653 26 * while (true) {
Sebastien Prouff 0:9765e979a653 27 * lineRead = myRfid.rfidRead(buffer);
Sebastien Prouff 0:9765e979a653 28 * if (lineRead) {
Sebastien Prouff 0:9765e979a653 29 * printf("buffer : %s", buffer);
Sebastien Prouff 0:9765e979a653 30 * printf("\r\n");
Sebastien Prouff 0:9765e979a653 31 * if (strstr((char *)tampon, ID_BADGE))) {
Sebastien Prouff 0:9765e979a653 32 * printf(" OK \r\n");
Sebastien Prouff 0:9765e979a653 33 * } else {
Sebastien Prouff 0:9765e979a653 34 * printf(" NOK \r\n");
Sebastien Prouff 0:9765e979a653 35 * }
Sebastien Prouff 0:9765e979a653 36 * }
Sebastien Prouff 0:9765e979a653 37 * }
Sebastien Prouff 0:9765e979a653 38 * }
Sebastien Prouff 0:9765e979a653 39 * @endcode
Sebastien Prouff 0:9765e979a653 40 */
Sebastien Prouff 0:9765e979a653 41
Sebastien Prouff 0:9765e979a653 42 class RoboticsRfidReader {
Sebastien Prouff 0:9765e979a653 43
Sebastien Prouff 0:9765e979a653 44 public:
Sebastien Prouff 0:9765e979a653 45 /**
Sebastien Prouff 0:9765e979a653 46 * @brief RoboticsRfid constructor
Sebastien Prouff 0:9765e979a653 47 * @param Tx : Tx pin
Sebastien Prouff 0:9765e979a653 48 * @param Rx : Rx Pin
Sebastien Prouff 0:9765e979a653 49 */
Sebastien Prouff 0:9765e979a653 50 RoboticsRfidReader(PinName Tx, PinName Rx);
Sebastien Prouff 0:9765e979a653 51
Sebastien Prouff 0:9765e979a653 52 /**
Sebastien Prouff 0:9765e979a653 53 * @brief Non blockin readin on serial. '\n' for End Of Line
Sebastien Prouff 0:9765e979a653 54 * @param tampon : reception buffer
Sebastien Prouff 0:9765e979a653 55 * @return true if the read is complete, false otherwise
Sebastien Prouff 0:9765e979a653 56 * tampon will contain the string (in a char* )
Sebastien Prouff 0:9765e979a653 57 *
Sebastien Prouff 0:9765e979a653 58 */
Sebastien Prouff 0:9765e979a653 59 bool rfidRead(unsigned char *tampon);
Sebastien Prouff 0:9765e979a653 60
Sebastien Prouff 0:9765e979a653 61 private:
Sebastien Prouff 0:9765e979a653 62 UnbufferedSerial _rfid;
Sebastien Prouff 0:9765e979a653 63 unsigned char _c;
Sebastien Prouff 0:9765e979a653 64 };
Sebastien Prouff 0:9765e979a653 65
Sebastien Prouff 0:9765e979a653 66 #endif