Skip to content

Commit

Permalink
Only updates the supplied deviceAddress if a valid index is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchyboy9 committed May 18, 2024
1 parent 65112b5 commit e39e8ab
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions DallasTemperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ bool DallasTemperature::validAddress(const uint8_t* deviceAddress) {
// finds an address at a given index on the bus
// returns true if the device was found
bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index) {
if (index < devices) {
uint8_t depth = 0;

uint8_t depth = 0;
_wire->reset_search();

_wire->reset_search();

while (depth <= index && _wire->search(deviceAddress)) {
if (depth == index && validAddress(deviceAddress))
return true;
depth++;
while (depth <= index && _wire->search(deviceAddress)) {
if (depth == index && validAddress(deviceAddress))
return true;
depth++;
}
}

return false;

}

// attempt to determine if the device at the given address is connected to the bus
Expand Down

0 comments on commit e39e8ab

Please sign in to comment.