File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -152,19 +152,19 @@ bool DallasTemperature::validAddress(const uint8_t* deviceAddress) {
152152// finds an address at a given index on the bus
153153// returns true if the device was found
154154bool DallasTemperature::getAddress (uint8_t * deviceAddress, uint8_t index) {
155+ if (index < devices) {
156+ uint8_t depth = 0 ;
155157
156- uint8_t depth = 0 ;
158+ _wire-> reset_search () ;
157159
158- _wire->reset_search ();
159-
160- while (depth <= index && _wire->search (deviceAddress)) {
161- if (depth == index && validAddress (deviceAddress))
162- return true ;
163- depth++;
160+ while (depth <= index && _wire->search (deviceAddress)) {
161+ if (depth == index && validAddress (deviceAddress))
162+ return true ;
163+ depth++;
164+ }
164165 }
165166
166167 return false ;
167-
168168}
169169
170170// attempt to determine if the device at the given address is connected to the bus
You can’t perform that action at this time.
0 commit comments