Skip to content

Commit

Permalink
Merge pull request #9 from JoakimSoderberg/disconnected_fix
Browse files Browse the repository at this point in the history
When getAddress fails in getTempCByIndex() return DEVICE_DISCONNECTED_C.
  • Loading branch information
milesburton committed Jun 7, 2013
2 parents f8d1a4d + 1c76057 commit 785351a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DallasTemperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,17 @@ bool DallasTemperature::requestTemperaturesByIndex(uint8_t deviceIndex)
float DallasTemperature::getTempCByIndex(uint8_t deviceIndex)
{
DeviceAddress deviceAddress;
getAddress(deviceAddress, deviceIndex);
if (!getAddress(deviceAddress, deviceIndex))
return DEVICE_DISCONNECTED_C;
return getTempC((uint8_t*)deviceAddress);
}

// Fetch temperature for device index
float DallasTemperature::getTempFByIndex(uint8_t deviceIndex)
{
DeviceAddress deviceAddress;
getAddress(deviceAddress, deviceIndex);
if (!getAddress(deviceAddress, deviceIndex))
return DEVICE_DISCONNECTED_F;
return getTempF((uint8_t*)deviceAddress);
}

Expand Down

0 comments on commit 785351a

Please sign in to comment.