watchdog: Add signal for timeout event

Send out Timeout signal to indicate timeout event.

The new signal will be sent to the object path of the watchdog with
`xyz.openbmc_project.Watchdog` as the interface and the "Timeout"
as Member.

The first argument of signal will be the action taken by the timeout
event to help indicate the event type.

This allow the us to know that the timeout event happened and the action
taken. The action taken might not be the same as expiredAction due to
fallback mode.

Tested:
```
$ ipmitool sel list
  3c |  Pre-Init  |0000000173| Watchdog2 #0xf9 | Power cycle | Asserted
  3d |  Pre-Init  |0000000175| Watchdog2 #0xf9 | Power cycle | Asserted
  3e |  Pre-Init  |0000000176| Watchdog2 #0xf9 | Power cycle | Asserted
  3f |  Pre-Init  |0000000178| Watchdog2 #0xf9 | Power cycle | Asserted
```

Change-Id: I88b3e837c0e011fc6c2a0537bfd98b0720716076
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/src/watchdog.cpp b/src/watchdog.cpp
index 57e9050..7de98ae 100644
--- a/src/watchdog.cpp
+++ b/src/watchdog.cpp
@@ -5,6 +5,7 @@
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/exception.hpp>
+#include <string_view>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 namespace phosphor
@@ -133,6 +134,19 @@
 
         try
         {
+            auto signal = bus.new_signal(
+                objPath.data(), "xyz.openbmc_project.Watchdog", "Timeout");
+            signal.append(convertForMessage(action).c_str());
+            signal.signal_send();
+        }
+        catch (const SdBusError& e)
+        {
+            log<level::ERR>("watchdog: failed to send timeout signal",
+                            entry("ERROR=%s", e.what()));
+        }
+
+        try
+        {
             auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_ROOT,
                                               SYSTEMD_INTERFACE, "StartUnit");
             method.append(target->second);
diff --git a/src/watchdog.hpp b/src/watchdog.hpp
index 63839a8..736e71f 100644
--- a/src/watchdog.hpp
+++ b/src/watchdog.hpp
@@ -6,6 +6,7 @@
 #include <sdbusplus/server/object.hpp>
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/utility/timer.hpp>
+#include <string_view>
 #include <unordered_map>
 #include <utility>
 #include <xyz/openbmc_project/State/Watchdog/server.hpp>
@@ -71,7 +72,8 @@
         WatchdogInherits(bus, objPath),
         bus(bus), actionTargetMap(std::move(actionTargetMap)),
         fallback(std::move(fallback)), minInterval(minInterval),
-        timer(event, std::bind(&Watchdog::timeOutHandler, this))
+        timer(event, std::bind(&Watchdog::timeOutHandler, this)),
+        objPath(objPath)
     {
         // Use default if passed in otherwise just use default that comes
         // with object
@@ -181,6 +183,9 @@
 
     /** @brief Attempt to enter the fallback watchdog or disables it */
     void tryFallbackOrDisable();
+
+    /** @brief Object path of the watchdog */
+    std::string_view objPath;
 };
 
 } // namespace watchdog