VOL-771 OLT heartbeat
additional GRPC endpoint for heartbeat that answers with a connection signature to detect OLT reboot /drivers restart

Change-Id: Ib4eb0f162519701c0535ca53f0875f0f83dcb833
diff --git a/protos/openolt.proto b/protos/openolt.proto
index 0dc175b..a7915c8 100644
--- a/protos/openolt.proto
+++ b/protos/openolt.proto
@@ -46,6 +46,13 @@
         };
     }
 
+    rpc HeartbeatCheck(Empty) returns (Heartbeat) {
+        option (google.api.http) = {
+          post: "/v1/HeartbeatCheck"
+          body: "*"
+        };
+    }
+
     rpc EnableIndication(Empty) returns (stream Indication) {}
 }
 
@@ -102,6 +109,10 @@
     bytes pkt = 4;
 }
 
+message Heartbeat {
+    fixed32 heartbeat_signature = 1;
+}
+
 message Onu {
     fixed32 intf_id = 1;
     fixed32 onu_id = 2;
diff --git a/src/server.cc b/src/server.cc
index 8000476..2e8bc1b 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Open Networking Foundation 
+    Copyright (C) 2018 Open Networking Foundation
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 #include <iostream>
 #include <memory>
 #include <string>
+#include <time.h>
 
 #include "Queue.h"
 #include <iostream>
@@ -37,6 +38,7 @@
 using grpc::Status;
 
 const char *serverPort = "0.0.0.0:9191";
+int signature;
 
 class OpenoltService final : public openolt::Openolt::Service {
 
@@ -90,6 +92,8 @@
             ServerContext* context,
             const ::openolt::Empty* request,
             ServerWriter<openolt::Indication>* writer) override {
+        std::cout << "Connection to Voltha established. Indications enabled"
+        << std::endl;
         while (1) {
             auto oltInd = oltIndQ.pop();
             writer->Write(oltInd);
@@ -97,6 +101,15 @@
         }
         return Status::OK;
     }
+
+    Status HeartbeatCheck(
+            ServerContext* context,
+            const openolt::Empty* request,
+            openolt::Heartbeat* response) override {
+        response->set_heartbeat_signature(signature);
+
+        return Status::OK;
+    }
 };
 
 void RunServer() {
@@ -109,7 +122,13 @@
 
   std::unique_ptr<Server> server(builder.BuildAndStart());
 
-  std::cout << "Server listening on " << server_address << std::endl;
+  time_t now;
+  time(&now);
+  signature = (int)now;
+
+  std::cout << "Server listening on " << server_address
+  << ", connection signature : " << signature << std::endl;
+
 
   server->Wait();
 }