(VOL-4972) enabling pon and onu object get apis in bbsim
Change-Id: I81932e4a8a1370ce83624f1deaf385c2809d568c
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index ebe08d6..43987f1 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -1838,23 +1838,34 @@
"OnuId": onu.ID,
"OnuSn": onu.Sn(),
}).Debug("Send ONU Re-Discovery")
+ if onu.InternalState.Current() != OnuStateDiscovered {
+ // ONU Re-Discovery
+ if err := onu.InternalState.Event(OnuTxInitialize); err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": onu.PonPortID,
+ "OnuSn": onu.Sn(),
+ "OnuId": onu.ID,
+ }).Infof("Failed to transition ONU to %s state: %s", OnuStateInitialized, err.Error())
+ }
- // ONU Re-Discovery
- if err := onu.InternalState.Event(OnuTxInitialize); err != nil {
- log.WithFields(log.Fields{
- "IntfId": onu.PonPortID,
- "OnuSn": onu.Sn(),
- "OnuId": onu.ID,
- }).Infof("Failed to transition ONU to %s state: %s", OnuStateInitialized, err.Error())
+ if err := onu.InternalState.Event(OnuTxDiscover); err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": onu.PonPortID,
+ "OnuSn": onu.Sn(),
+ "OnuId": onu.ID,
+ }).Infof("Failed to transition ONU to %s state: %s", OnuStateDiscovered, err.Error())
+ }
+ } else {
+ //if onu is already discovered dont change the state ut rather fire the indication again (this case happens if voltha misses the indications)
+ msg := bbsim.Message{
+ Type: bbsim.OnuDiscIndication,
+ Data: bbsim.OnuDiscIndicationMessage{
+ OperState: bbsim.UP,
+ },
+ }
+ onu.Channel <- msg
}
- if err := onu.InternalState.Event(OnuTxDiscover); err != nil {
- log.WithFields(log.Fields{
- "IntfId": onu.PonPortID,
- "OnuSn": onu.Sn(),
- "OnuId": onu.ID,
- }).Infof("Failed to transition ONU to %s state: %s", OnuStateDiscovered, err.Error())
- }
}
// deprecated, delegate this to the uniPort