34 #include <sys/select.h>
35 #include <sys/types.h>
38 #include <mraa/common.hpp>
39 #include <mraa/uart.hpp>
40 #include <mraa/gpio.hpp>
42 #define SM130_DEFAULT_UART 0
43 #define SM130_DEFAULT_RESET_PIN 13
88 CMD_SELECT_TAG = 0x83,
89 CMD_AUTHENTICATE = 0x85,
91 CMD_READ_VALUE = 0x87,
93 CMD_WRITE_VALUE = 0x8a,
98 CMD_ANTENNA_POWER = 0x90,
100 CMD_WRITE_PORT = 0x92,
110 TAG_MIFARE_ULTRALIGHT = 0x01,
111 TAG_MIFARE_1K = 0x02,
112 TAG_MIFARE_4K = 0x03,
118 KEY_TYPE_EEPROM_A0 = 0x10,
119 KEY_TYPE_EEPROM_A1 = 0x11,
120 KEY_TYPE_EEPROM_A2 = 0x12,
121 KEY_TYPE_EEPROM_A3 = 0x13,
122 KEY_TYPE_EEPROM_A4 = 0x14,
123 KEY_TYPE_EEPROM_A5 = 0x15,
124 KEY_TYPE_EEPROM_A6 = 0x16,
125 KEY_TYPE_EEPROM_A7 = 0x17,
126 KEY_TYPE_EEPROM_A8 = 0x18,
127 KEY_TYPE_EEPROM_A9 = 0x19,
128 KEY_TYPE_EEPROM_A10 = 0x1a,
129 KEY_TYPE_EEPROM_A11 = 0x1b,
130 KEY_TYPE_EEPROM_A12 = 0x1c,
131 KEY_TYPE_EEPROM_A13 = 0x1d,
132 KEY_TYPE_EEPROM_A14 = 0x1e,
133 KEY_TYPE_EEPROM_A15 = 0x1f,
135 KEY_TYPE_EEPROM_B0 = 0x20,
136 KEY_TYPE_EEPROM_B1 = 0x21,
137 KEY_TYPE_EEPROM_B2 = 0x22,
138 KEY_TYPE_EEPROM_B3 = 0x23,
139 KEY_TYPE_EEPROM_B4 = 0x24,
140 KEY_TYPE_EEPROM_B5 = 0x25,
141 KEY_TYPE_EEPROM_B6 = 0x26,
142 KEY_TYPE_EEPROM_B7 = 0x27,
143 KEY_TYPE_EEPROM_B8 = 0x28,
144 KEY_TYPE_EEPROM_B9 = 0x29,
145 KEY_TYPE_EEPROM_B10 = 0x2a,
146 KEY_TYPE_EEPROM_B11 = 0x2b,
147 KEY_TYPE_EEPROM_B12 = 0x2c,
148 KEY_TYPE_EEPROM_B13 = 0x2d,
149 KEY_TYPE_EEPROM_B14 = 0x2e,
150 KEY_TYPE_EEPROM_B15 = 0x2f,
155 KEY_TYPE_A_AND_TRANSPORT_F = 0xff
164 SM130 (
int uart=SM130_DEFAULT_UART,
int reset=SM130_DEFAULT_RESET_PIN);
230 bool authenticate(uint8_t block, KEY_TYPES_T keyType, std::string key=
"");
280 bool writeBlock4(uint8_t block, std::string contents);
296 bool writeKey(uint8_t eepromSector, KEY_TYPES_T keyType, std::string key);
441 mraa::Gpio m_gpioReset;
443 std::string sendCommand(CMD_T cmd, std::string data);
445 uint32_t getMillis();
451 char m_lastErrorCode;
452 std::string m_lastErrorString;
454 TAG_TYPE_T m_tagType;
458 struct timeval m_startTime;
463 m_lastErrorString.clear();
bool reset()
Definition: sm130.cxx:181
bool writeValueBlock(uint8_t block, int32_t value)
Definition: sm130.cxx:445
bool writeKey(uint8_t eepromSector, KEY_TYPES_T keyType, std::string key)
Definition: sm130.cxx:538
int getUIDLen()
Definition: sm130.h:401
std::string readBlock16(uint8_t block)
Definition: sm130.cxx:309
int32_t readValueBlock(uint8_t block)
Definition: sm130.cxx:349
~SM130()
Definition: sm130.cxx:52
bool authenticate(uint8_t block, KEY_TYPES_T keyType, std::string key="")
Definition: sm130.cxx:250
bool select()
Definition: sm130.cxx:202
bool setAntennaPower(bool on)
Definition: sm130.cxx:644
TAG_TYPE_T getTagType()
Definition: sm130.h:417
bool writePorts(uint8_t val)
Definition: sm130.cxx:675
void hardwareReset()
Definition: sm130.cxx:195
std::string getLastErrorString()
Definition: sm130.h:393
bool haltTag()
Definition: sm130.cxx:696
char getLastErrorCode()
Definition: sm130.h:383
uint8_t readPorts()
Definition: sm130.cxx:659
mraa::Result setBaudRate(int baud=19200)
Definition: sm130.cxx:56
std::string tag2String(TAG_TYPE_T tag)
Definition: sm130.cxx:865
bool writeBlock4(uint8_t block, std::string contents)
Definition: sm130.cxx:488
SM130(int uart=SM130_DEFAULT_UART, int reset=SM130_DEFAULT_RESET_PIN)
Definition: sm130.cxx:39
std::string getUID()
Definition: sm130.h:409
bool setSM130BaudRate(int baud)
Definition: sm130.cxx:728
std::string string2HexString(std::string input)
Definition: sm130.cxx:788
std::string getFirmwareVersion()
Definition: sm130.cxx:164
API for the SM130 RFID Reader Module.
Definition: sm130.h:79
bool sleep()
Definition: sm130.cxx:773
bool writeBlock16(uint8_t block, std::string contents)
Definition: sm130.cxx:395
bool waitForTag(uint32_t timeout)
Definition: sm130.cxx:839
int32_t adjustValueBlock(uint8_t block, int32_t value, bool incr)
Definition: sm130.cxx:594