14 while (this->available() > 0) {
16 if (!this->read_byte(&data)) {
17 ESP_LOGW(TAG,
"Reading data from RDM6300 failed!");
18 this->status_set_warning();
22 if (this->read_state_ == RDM6300_STATE_WAITING_FOR_START) {
23 if (data == RDM6300_START_BYTE) {
24 this->read_state_ = 0;
28 }
else if (this->read_state_ < 12) {
29 uint8_t value = (data >
'9') ? data -
'7' : data -
'0';
30 if (this->read_state_ % 2 == 0) {
31 this->buffer_[this->read_state_ / 2] = value << 4;
33 this->buffer_[this->read_state_ / 2] += value;
36 }
else if (data == 0x0D || data == 0x0A) {
38 }
else if (data != RDM6300_END_BYTE) {
39 ESP_LOGW(TAG,
"Invalid end byte from RDM6300!");
40 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
43 for (uint8_t i = 0; i < 5; i++)
45 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
47 ESP_LOGW(TAG,
"Checksum from RDM6300 doesn't match! (0x%02X!=0x%02X)",
checksum, this->buffer_[5]);
50 this->status_clear_warning();
51 const uint32_t result =
encode_uint32(this->buffer_[1], this->buffer_[2], this->buffer_[3], this->buffer_[4]);
52 bool report = result != last_id_;
53 for (
auto *card : this->cards_) {
54 if (card->process(result)) {
58 for (
auto *trig : this->triggers_)
59 trig->process(result);
62 ESP_LOGD(TAG,
"Found new tag with ID %" PRIu32, result);