Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion DallasTemperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void DallasTemperature::setPullupPin(uint8_t _pullupPin) {
deactivateExternalPullup();
}

void DallasTemperature::begin(void) {
void DallasTemperature::begin(uint8_t* addressBook, uint8_t maxDeviceCount) {
DeviceAddress deviceAddress;

for (uint8_t retry = 0; retry < MAX_INITIALIZATION_RETRIES; retry++) {
Expand All @@ -95,6 +95,14 @@ void DallasTemperature::begin(void) {

while (_wire->search(deviceAddress)) {
if (validAddress(deviceAddress)) {
// Optionally capture the ROM discovered during enumeration into the
// caller-provided address book, so callers don't have to re-discover
// the same devices with getAddress()/search() afterwards — a second
// search pass that can fail intermittently on long or marginal buses.
if (addressBook && devices < maxDeviceCount) {
memcpy(addressBook + (size_t)devices * sizeof(DeviceAddress),
deviceAddress, sizeof(DeviceAddress));
}
devices++;

if (validFamily(deviceAddress)) {
Expand Down
2 changes: 1 addition & 1 deletion DallasTemperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DallasTemperature {
// Setup & Configuration
void setOneWire(OneWire*);
void setPullupPin(uint8_t);
void begin(void);
void begin(uint8_t* addressBook = nullptr, uint8_t maxDeviceCount = 0);
bool verifyDeviceCount(void);

// Device Information
Expand Down