Skip to content

Commit 0ae1834

Browse files
committed
Fix: implement missing saveScratchPadByIndex/recallScratchPadByIndex
DallasTemperature.h declares saveScratchPadByIndex() and recallScratchPadByIndex(), and both are documented and used in the SaveRecallScratchPad example, but their implementations were dropped from DallasTemperature.cpp during the race-condition refactor merged in #264. Any sketch calling either method now fails at link time with "undefined reference to DallasTemperature::saveScratchPadByIndex(...)" (and the recall counterpart). Restore the two thin wrapper functions that resolve a device index to its address via getAddress() and delegate to the existing saveScratchPad()/recallScratchPad() overloads, matching their pre-refactor behavior.
1 parent dadbbf7 commit 0ae1834

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎DallasTemperature.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ void DallasTemperature::writeScratchPad(const uint8_t* deviceAddress, const uint
237237
}
238238
}
239239

240+
bool DallasTemperature::saveScratchPadByIndex(uint8_t deviceIndex) {
241+
DeviceAddress deviceAddress;
242+
if (!getAddress(deviceAddress, deviceIndex)) return false;
243+
return saveScratchPad(deviceAddress);
244+
}
245+
246+
bool DallasTemperature::recallScratchPadByIndex(uint8_t deviceIndex) {
247+
DeviceAddress deviceAddress;
248+
if (!getAddress(deviceAddress, deviceIndex)) return false;
249+
return recallScratchPad(deviceAddress);
250+
}
251+
240252
bool DallasTemperature::saveScratchPad(const uint8_t* deviceAddress) {
241253
if (_wire->reset() == 0) return false;
242254

0 commit comments

Comments
 (0)