13 static const char *
const TAG =
"pn532_i2c";
40 ESP_LOGV(TAG,
"Reading response");
46 ESP_LOGV(TAG,
"Reading response of length %d", len);
47 if (!this->
read_data(data, 6 + len + 2)) {
48 ESP_LOGD(TAG,
"No response data");
52 if (data[1] != 0x00 && data[2] != 0x00 && data[3] != 0xFF) {
54 ESP_LOGV(TAG,
"read data invalid preamble!");
58 bool valid_header = (
static_cast<uint8_t
>(data[4] + data[5]) == 0 &&
60 data[7] == command + 1);
63 ESP_LOGV(TAG,
"read data invalid header!");
67 data.erase(data.begin(), data.begin() + 6);
70 for (
int i = 0; i < len + 1; i++) {
71 uint8_t dat = data[i];
74 checksum = ~checksum + 1;
76 if (data[len + 1] != checksum) {
77 ESP_LOGV(TAG,
"read data invalid checksum! %02X != %02X", data[len], checksum);
81 if (data[len + 2] != 0x00) {
82 ESP_LOGV(TAG,
"read data invalid postamble!");
86 data.erase(data.begin(), data.begin() + 2);
87 data.erase(data.end() - 2, data.end());
93 std::vector<uint8_t> data;
98 if (data[1] != 0x00 && data[2] != 0x00 && data[3] != 0xFF) {
100 ESP_LOGV(TAG,
"read data invalid preamble!");
104 bool valid_header = (
static_cast<uint8_t
>(data[4] + data[5]) == 0 &&
108 ESP_LOGV(TAG,
"read data invalid header!");
115 uint8_t full_len = data[4];
117 uint8_t
len = full_len - 1;
124 PN532::dump_config();
125 LOG_I2C_DEVICE(
this);
bool read_data(std::vector< uint8_t > &data, uint8_t len) override
bool write_data(const std::vector< uint8_t > &data) override
optional< std::array< uint8_t, N > > read_bytes_raw()
enum PN532ReadReady read_ready_(bool block)
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
No error found during execution of method.
bool is_read_ready() override
uint8_t read_response_length_()
Implementation of SPI Controller mode.
void dump_config() override
bool read_response(uint8_t command, std::vector< uint8_t > &data) override
void IRAM_ATTR HOT delay(uint32_t ms)