seb astien / Robotics RFID Reader
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers robotics_rfid_reader.h Source File

robotics_rfid_reader.h

Go to the documentation of this file.
00001 #ifndef ROBOTICS_RFID_READER_H
00002 #define ROBOTICS_RFID_READER_H
00003 
00004 
00005 /**
00006  * @file robotics_rfid_reader.h
00007  * @author sepro
00008  * @version 1.0
00009  * @class RoboticsRfidReader
00010  * @date 31/01/2021
00011  */
00012 
00013 #include "mbed.h"
00014 
00015 /**
00016  * Example
00017  * @code
00018  * #define ID_BADGE "1 7 221 87 161"
00019  * RoboticsRfidReader myRfid(D1, D0);
00020  *
00021  * int main() {
00022  * unsigned char buffer[30];
00023  * bool lineRead;
00024  * printf("RFID TEST \r\n");
00025  *
00026  * while (true) {
00027  *   lineRead = myRfid.rfidRead(buffer);
00028  *   if (lineRead) {
00029  *     printf("buffer : %s", buffer);
00030  *     printf("\r\n");
00031  *     if (strstr((char *)tampon, ID_BADGE))) {
00032  *       printf(" OK \r\n");
00033  *     } else {
00034  *       printf(" NOK \r\n");
00035  *     }
00036  *   }
00037  * }
00038  * }
00039  * @endcode
00040  */
00041 
00042 class RoboticsRfidReader {
00043 
00044 public:
00045   /**
00046    * @brief RoboticsRfid constructor
00047    * @param Tx : Tx pin
00048    * @param Rx : Rx Pin
00049    */
00050   RoboticsRfidReader(PinName Tx, PinName Rx);
00051 
00052   /**
00053    * @brief Non blockin readin on serial. '\n' for End Of Line
00054    * @param tampon  : reception buffer
00055    * @return true if the read is complete, false otherwise
00056    *         tampon will contain the string (in a char* )
00057    *
00058    */
00059   bool rfidRead(unsigned char *tampon);
00060 
00061 private:
00062   UnbufferedSerial _rfid;
00063   unsigned char _c;
00064 };
00065 
00066 #endif