PEL: Fill in host state change callback

If the host is up, start sending PELs.

If the host is off, move all of the PELs that are sent but
not acked back to the queue to be sent again next time.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I66d382a85afc88f6b23367fb515df4dbe5326be1
diff --git a/extensions/openpower-pels/host_notifier.cpp b/extensions/openpower-pels/host_notifier.cpp
index b935f7e..f9e0418 100644
--- a/extensions/openpower-pels/host_notifier.cpp
+++ b/extensions/openpower-pels/host_notifier.cpp
@@ -128,6 +128,26 @@
 
 void HostNotifier::hostStateChange(bool hostUp)
 {
+    _retryCount = 0;
+
+    if (hostUp && !_pelQueue.empty())
+    {
+        doNewLogNotify();
+    }
+    else if (!hostUp)
+    {
+        stopCommand();
+
+        // Reset the state on any PELs that were sent but not acked back
+        // to new so they'll get sent again.
+        for (auto id : _sentPELs)
+        {
+            _pelQueue.push_back(id);
+            _repo.setPELHostTransState(id, TransmissionState::newPEL);
+        }
+
+        _sentPELs.clear();
+    }
 }
 
 void HostNotifier::commandResponse(ResponseStatus status)
@@ -169,4 +189,25 @@
     }
 }
 
+void HostNotifier::stopCommand()
+{
+    _retryCount = 0;
+
+    if (_inProgressPEL != 0)
+    {
+        _pelQueue.push_front(_inProgressPEL);
+        _inProgressPEL = 0;
+    }
+
+    if (_retryTimer.isEnabled())
+    {
+        _retryTimer.setEnabled(false);
+    }
+
+    if (_hostIface->cmdInProgress())
+    {
+        _hostIface->cancelCmd();
+    }
+}
+
 } // namespace openpower::pels