15 while (this->available() > 0) {
17 if (!this->read_byte(&data)) {
18 ESP_LOGW(TAG,
"Reading data from RDM6300 failed!");
19 this->status_set_warning();
23 if (this->read_state_ == RDM6300_STATE_WAITING_FOR_START) {
24 if (data == RDM6300_START_BYTE) {
25 this->read_state_ = 0;
29 }
else if (this->read_state_ < 12) {
30 uint8_t value = (data >
'9') ? data -
'7' : data -
'0';
31 if (this->read_state_ % 2 == 0) {
32 this->buffer_[this->read_state_ / 2] = value << 4;
34 this->buffer_[this->read_state_ / 2] += value;
37 }
else if (data != RDM6300_END_BYTE) {
38 ESP_LOGW(TAG,
"Invalid end byte from RDM6300!");
39 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
42 for (uint8_t i = 0; i < 5; i++)
44 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
46 ESP_LOGW(TAG,
"Checksum from RDM6300 doesn't match! (0x%02X!=0x%02X)",
checksum, this->buffer_[5]);
49 this->status_clear_warning();
50 const uint32_t result =
encode_uint32(this->buffer_[1], this->buffer_[2], this->buffer_[3], this->buffer_[4]);
51 bool report = result != last_id_;
52 for (
auto *card : this->cards_) {
53 if (card->process(result)) {
57 for (
auto *trig : this->triggers_)
58 trig->process(result);
61 ESP_LOGD(TAG,
"Found new tag with ID %" PRIu32, result);