Skip to content

Commit

Permalink
retry scan
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Sieb committed Jun 15, 2024
1 parent 2fc43fa commit 0a70481
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions esphome/components/gpio/one_wire/gpio_one_wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ void GPIOOneWireBus::setup() {
this->search();
}

void GPIOOneWireBus::loop() {
if (this->devices_.empty() && (this->retries_++ < 5))
this->search();
}

bool GPIOOneWireBus::can_proceed() { return (!this->devices_.empty() || (this->retries_ >= 5)); }

void GPIOOneWireBus::dump_config() {
ESP_LOGCONFIG(TAG, "GPIO 1-wire bus:");
LOG_PIN(" Pin: ", this->t_pin_);
Expand Down
3 changes: 3 additions & 0 deletions esphome/components/gpio/one_wire/gpio_one_wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace gpio {
class GPIOOneWireBus : public one_wire::OneWireBus, public Component {
public:
void setup() override;
void loop() override;
bool can_proceed() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::BUS; }

Expand All @@ -30,6 +32,7 @@ class GPIOOneWireBus : public one_wire::OneWireBus, public Component {
uint8_t last_discrepancy_{0};
bool last_device_flag_{false};
uint64_t address_;
int retries_{0};

void reset_search() override;
uint64_t search_int() override;
Expand Down

0 comments on commit 0a70481

Please sign in to comment.