Skip to content

Commit

Permalink
improved debug output for SMADeviceCacheEntry.
Browse files Browse the repository at this point in the history
  • Loading branch information
jollyjinx committed Aug 15, 2023
1 parent bb7152a commit 80dfe59
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/sma2mqttLibrary/SMALighthouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public actor SMALighthouse
{
case inProgress(Task<SMADevice, Error>)
case ready(SMADevice)
case failed(Date)
case failed(String, Date)

var asyncDescription: String
{ get async
Expand All @@ -38,7 +38,7 @@ public actor SMALighthouse
case .inProgress: return "inProgress()\n"
case let .ready(smaDevice): let deviceDescription = await smaDevice.asyncDescription
return "ready(\(smaDevice.address)): \(deviceDescription)\n"
case let .failed(date): return "failed(\(date))\n"
case let .failed(address, date): return "failed(\(address),\(date))\n"
}
}
}
Expand Down Expand Up @@ -113,10 +113,10 @@ public extension SMALighthouse
case let .inProgress(task):
return try? await task.value

case let .failed(date):
case let .failed(address, date):
if date.isWithin(timeInterval: 30.0)
{
JLog.info("still ignoring:\(remoteAddress)")
JLog.info("still ignoring:\(address) == \(remoteAddress)")
return nil
}
JLog.info("renabling:\(remoteAddress)")
Expand All @@ -139,7 +139,7 @@ public extension SMALighthouse
{
JLog.error("\(remoteAddress): was not able to initialize:\(error) - ignoring address")

smaDeviceCache[remoteAddress] = .failed(Date())
smaDeviceCache[remoteAddress] = .failed(remoteAddress, Date())
return nil
}
}
Expand Down

0 comments on commit 80dfe59

Please sign in to comment.