heartbeat signature changes to align with the openolt agent

Change-Id: Iaff90db7189279a05aaa19a72dcced9b0ecc59f1
diff --git a/VERSION b/VERSION
index 166a50f..393ccdb 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.12.9
+1.12.10
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index 4d83018..a556256 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -108,6 +108,7 @@
 	GemPortIDsLock   sync.RWMutex
 	GemPortIDs       map[uint32]map[uint32]map[uint32]map[int32]map[uint64]bool // map[ponPortId]map[OnuId]map[PortNo]map[GemPortIDs]map[FlowId]bool
 	OmciResponseRate uint8
+	signature        uint32
 }
 
 var olt OltDevice
@@ -152,6 +153,7 @@
 		AllocIDs:            make(map[uint32]map[uint32]map[uint32]map[int32]map[uint64]bool),
 		GemPortIDs:          make(map[uint32]map[uint32]map[uint32]map[int32]map[uint64]bool),
 		OmciResponseRate:    options.Olt.OmciResponseRate,
+		signature:           uint32(time.Now().Unix()),
 	}
 
 	if val, ok := ControlledActivationModes[options.BBSim.ControlledActivation]; ok {
@@ -312,6 +314,7 @@
 
 	if softReboot {
 		for _, pon := range o.Pons {
+			/* No need to send pon events on olt soft reboot
 			if pon.InternalState.Current() == "enabled" {
 				// disable PONs
 				msg := types.Message{
@@ -323,7 +326,7 @@
 				}
 				o.channel <- msg
 			}
-
+			*/
 			for _, onu := range pon.Onus {
 				err := onu.InternalState.Event(OnuTxDisable)
 				oltLogger.WithFields(log.Fields{
@@ -363,6 +366,7 @@
 	o.enableContextCancel()
 	time.Sleep(time.Duration(rebootDelay) * time.Second)
 	o.Unlock()
+	o.signature = uint32(time.Now().Unix())
 
 	if err := o.InternalState.Event(OltInternalTxInitialize); err != nil {
 		oltLogger.WithFields(log.Fields{
@@ -497,6 +501,7 @@
 			}
 			// when the enableContext was canceled the ONUs stopped listening on the channel
 			for _, onu := range pon.Onus {
+				onu.ReDiscoverOnu(true)
 				go onu.ProcessOnuMessages(o.enableContext, stream, nil)
 
 				// update the stream on all the services
@@ -961,17 +966,19 @@
 		}).Error("Can't find Onu")
 	}
 
-	if err := _onu.InternalState.Event(OnuTxDisable); err != nil {
-		oltLogger.WithFields(log.Fields{
-			"IntfId": _onu.PonPortID,
-			"OnuSn":  _onu.Sn(),
-			"OnuId":  _onu.ID,
-		}).Infof("Failed to transition ONU to %s state: %s", OnuStateDisabled, err.Error())
+	if _onu.InternalState.Current() != OnuStateDisabled {
+		if err := _onu.InternalState.Event(OnuTxDisable); err != nil {
+			oltLogger.WithFields(log.Fields{
+				"IntfId": _onu.PonPortID,
+				"OnuSn":  _onu.Sn(),
+				"OnuId":  _onu.ID,
+			}).Infof("Failed to transition ONU to %s state: %s", OnuStateDisabled, err.Error())
+		}
 	}
 
 	// ONU Re-Discovery
 	if o.InternalState.Current() == OltInternalStateEnabled && pon.InternalState.Current() == "enabled" {
-		go _onu.ReDiscoverOnu()
+		go _onu.ReDiscoverOnu(false)
 	}
 
 	return new(openolt.Empty), nil
@@ -1281,7 +1288,7 @@
 }
 
 func (o *OltDevice) HeartbeatCheck(context.Context, *openolt.Empty) (*openolt.Heartbeat, error) {
-	res := openolt.Heartbeat{HeartbeatSignature: uint32(time.Now().Unix())}
+	res := openolt.Heartbeat{HeartbeatSignature: o.signature}
 	oltLogger.WithFields(log.Fields{
 		"signature": res.HeartbeatSignature,
 	}).Trace("HeartbeatCheck")
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index 1e7169c..4d913b6 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -1803,9 +1803,14 @@
 	}
 }
 
-func (onu *Onu) ReDiscoverOnu() {
+/* when ReDiscoverOnu is called during reboot, true is passed so that there is no delay in onu discoveries
+   It is assumed that all onu resources are cleared and no sleep is required
+*/
+func (onu *Onu) ReDiscoverOnu(isReboot bool) {
 	// Wait for few seconds to be sure of the cleanup
-	time.Sleep(5 * time.Second)
+	if !isReboot {
+		time.Sleep(5 * time.Second)
+	}
 
 	onuLogger.WithFields(log.Fields{
 		"IntfId": onu.PonPortID,