From 0ae1834320ee5d48c50310e4f5895e3fede11dfa Mon Sep 17 00:00:00 2001 From: 94xhn <87560781+94xhn@users.noreply.github.com> Date: Mon, 13 Jul 2026 13:23:14 +0800 Subject: [PATCH] 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. --- DallasTemperature.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/DallasTemperature.cpp b/DallasTemperature.cpp index 29b7bc5..15417e2 100644 --- a/DallasTemperature.cpp +++ b/DallasTemperature.cpp @@ -237,6 +237,18 @@ void DallasTemperature::writeScratchPad(const uint8_t* deviceAddress, const uint } } +bool DallasTemperature::saveScratchPadByIndex(uint8_t deviceIndex) { + DeviceAddress deviceAddress; + if (!getAddress(deviceAddress, deviceIndex)) return false; + return saveScratchPad(deviceAddress); +} + +bool DallasTemperature::recallScratchPadByIndex(uint8_t deviceIndex) { + DeviceAddress deviceAddress; + if (!getAddress(deviceAddress, deviceIndex)) return false; + return recallScratchPad(deviceAddress); +} + bool DallasTemperature::saveScratchPad(const uint8_t* deviceAddress) { if (_wire->reset() == 0) return false;