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 == 0x0D || data == 0x0A) {
39 }
else if (data != RDM6300_END_BYTE) {
40 ESP_LOGW(TAG,
"Invalid end byte from RDM6300!");
41 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
44 for (uint8_t i = 0; i < 5; i++)
46 this->read_state_ = RDM6300_STATE_WAITING_FOR_START;
48 ESP_LOGW(TAG,
"Checksum from RDM6300 doesn't match! (0x%02X!=0x%02X)",
checksum, this->buffer_[5]);
51 this->status_clear_warning();
52 const uint32_t result =
encode_uint32(this->buffer_[1], this->buffer_[2], this->buffer_[3], this->buffer_[4]);
53 bool report = result != last_id_;
54 for (
auto *card : this->cards_) {
55 if (card->process(result)) {
59 for (
auto *trig : this->triggers_)
60 trig->process(result);
63 ESP_LOGD(TAG,
"Found new tag with ID %" PRIu32, result);