transfer UniPort OperState only for first Uni Port

Change-Id: I1c6298dd80befefa51f755c66532e08ae76c29a8
Signed-off-by: Holger Hildebrandt <holger.hildebrandt@adtran.com>
diff --git a/VERSION b/VERSION
index 9e2143d..05471f1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.6-dev
+0.1.7-dev
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 2486127..1744406 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -878,15 +878,22 @@
 
 // Enable listen on UniPortState changes and update core port state accordingly
 func (dh *DeviceHandler) enableUniPortStateUpdate(a_deviceID string) {
-	// TODO!!!: In py code the PPTP UNI states are updated based on event notifications (from where?)
-	//   these notifcations are handled in port_state_handler() to transfer core states ACTIVE or UNKNOWN
-	//   For VEIP ports enale_ports() directly sets ACTIVE (forced)
-	// to shortcut processing temporarily here we set the OperState ACTIVE here forced generally for the moment
+	//  py code was updated 2003xx to activate the real ONU UNI ports per OMCI (VEIP or PPTP)
+	//    but towards core only the first port active state is signalled
+	//    with following remark:
+	//       # TODO: for now only support the first UNI given no requirement for multiple uni yet. Also needed to reduce flow
+	//       #  load on the core
+
+	// dh.lock_ports(false) ONU port activation via OMCI //TODO!!! not yet supported
+
 	for uniNo, uniPort := range dh.uniEntityMap {
-		logger.Infow("onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo})
-		uniPort.SetOperState(vc.OperStatus_ACTIVE)
-		//maybe also use getter funvtions on uniPort - perhaps later ...
-		go dh.coreProxy.PortStateUpdate(context.TODO(), a_deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
+		// only if this port is validated for operState transfer}
+		if (1<<uniPort.uniId)&ActiveUniPortStateUpdateMask == (1 << uniPort.uniId) {
+			logger.Infow("onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo})
+			uniPort.SetOperState(vc.OperStatus_ACTIVE)
+			//maybe also use getter functions on uniPort - perhaps later ...
+			go dh.coreProxy.PortStateUpdate(context.TODO(), a_deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
+		}
 	}
 }
 
diff --git a/internal/pkg/onuadaptercore/platform.go b/internal/pkg/onuadaptercore/platform.go
index 8edf4d1..2aef6e1 100644
--- a/internal/pkg/onuadaptercore/platform.go
+++ b/internal/pkg/onuadaptercore/platform.go
@@ -120,6 +120,11 @@
 	maxNniPortNum = ((1 << (bitsforNNIID + 1)) - 1)
 )
 
+//Mask to indicate which possibly active ONU UNI state  is really reported to the core
+// compare python code - at the moment restrict active state to the first ONU UNI port
+// check is limited to max 16 uni ports - cmp above UNI limit!!!
+var ActiveUniPortStateUpdateMask = 0x0001
+
 //MinUpstreamPortID value
 var MinUpstreamPortID = 0xfffd