Unverified Commit d8a6a55a authored by Kevin Di Lallo's avatar Kevin Di Lallo Committed by GitHub
Browse files

Merge pull request #139 from pastorsx/sp_dev_update_beta_services

MEC Service fixes
parents 5dbf5bfc 057f5953
Loading
Loading
Loading
Loading
+31 −16
Original line number Diff line number Diff line
@@ -222,7 +222,11 @@ func processActiveScenarioUpdate() {
	}

	// Update POA Cellular and Wifi info
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi)
	poaTypeList := [3]string{mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi}
	conType := ""
	for _, poaType := range poaTypeList {

		poaNameList := sbi.activeModel.GetNodeNames(poaType)
		for _, name := range poaNameList {
			zone, netLoc, err := getNetworkLocation(name)
			if err != nil {
@@ -236,9 +240,20 @@ func processActiveScenarioUpdate() {
				longitude, latitude = parsePosition(poa.Position)
			}

		sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "SERVICEABLE", uePerNetLocMap[netLoc], longitude, latitude)
			switch poaType {
			case mod.NodeTypePoa4G:
				conType = "Macro"
			case mod.NodeTypePoa5G:
				conType = "Smallcell"
			case mod.NodeTypePoaWifi:
				conType = "Wifi"
			default:
				conType = "Unknown"
			}
			sbi.updateAccessPointInfoCB(zone, netLoc, conType, "Serviceable", uePerNetLocMap[netLoc], longitude, latitude)
			poaPerZoneMap[zone]++
		}
	}

	// Update Zone info
	zoneNameList := sbi.activeModel.GetNodeNames("ZONE")
@@ -364,7 +379,7 @@ func updateAccessPointPosition(name string) {
	}

	// Update info
	sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "", -1, longitude, latitude)
	sbi.updateAccessPointInfoCB(zone, netLoc, "", "", -1, longitude, latitude)
}

func updateAllAccessPointPosition() {
@@ -388,7 +403,7 @@ func updateAllAccessPointPosition() {
			longitude, latitude = parsePosition(poa.Position)
		}

		sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "", -1, longitude, latitude)
		sbi.updateAccessPointInfoCB(zone, netLoc, "", "", -1, longitude, latitude)
	}
}

+15 −11
Original line number Diff line number Diff line
@@ -403,15 +403,7 @@ func checkNotificationRegisteredUsers(oldZoneId string, newZoneId string, oldApI
			zonal.CallbackData = subscription.ClientCorrelator

			if newZoneId != oldZoneId {
				if userSubscriptionEnteringMap[subsId] != "" && newZoneId != "" {
					zonal.ZoneId = newZoneId
					zonal.CurrentAccessPointId = newApId
					event := new(clientNotifOMA.UserEventType)
					*event = clientNotifOMA.ENTERING_UserEventType
					zonal.UserEventType = event
					sendNotification(subscription.CallbackReference.NotifyURL, context.TODO(), subsIdStr, zonal)
					log.Info("User Notification" + "(" + subsIdStr + "): " + "Entering event in zone " + newZoneId + " for user " + userId)
				}
				//process LEAVING events prior to entering ones
				if oldZoneId != "" {
					if userSubscriptionLeavingMap[subsId] != "" {
						zonal.ZoneId = oldZoneId
@@ -423,6 +415,16 @@ func checkNotificationRegisteredUsers(oldZoneId string, newZoneId string, oldApI
						log.Info("User Notification" + "(" + subsIdStr + "): " + "Leaving event in zone " + oldZoneId + " for user " + userId)
					}
				}
				if userSubscriptionEnteringMap[subsId] != "" && newZoneId != "" {
					zonal.ZoneId = newZoneId
					zonal.CurrentAccessPointId = newApId
					event := new(clientNotifOMA.UserEventType)
					*event = clientNotifOMA.ENTERING_UserEventType
					zonal.UserEventType = event
					sendNotification(subscription.CallbackReference.NotifyURL, context.TODO(), subsIdStr, zonal)
					log.Info("User Notification" + "(" + subsIdStr + "): " + "Entering event in zone " + newZoneId + " for user " + userId)
				}

			} else {
				if newApId != oldApId {
					if userSubscriptionTransferringMap[subsId] != "" {
@@ -1424,8 +1426,6 @@ func updateAccessPointInfo(zoneId string, apId string, conTypeStr string, opStat
		apInfo = new(AccessPointInfo)
		apInfo.AccessPointId = apId
		apInfo.ResourceURL = hostUrl.String() + basePath + "zones/" + zoneId + "/accessPoints/" + apId
		conType := convertStringToConnectionType(conTypeStr)
		apInfo.ConnectionType = &conType
	}

	// Update info
@@ -1433,6 +1433,10 @@ func updateAccessPointInfo(zoneId string, apId string, conTypeStr string, opStat
		opStatus := convertStringToOperationStatus(opStatusStr)
		apInfo.OperationStatus = &opStatus
	}
	if conTypeStr != "" {
		conType := convertStringToConnectionType(conTypeStr)
		apInfo.ConnectionType = &conType
	}
	if nbUsers != -1 {
		apInfo.NumberOfUsers = int32(nbUsers)
	}
+20 −16
Original line number Diff line number Diff line
@@ -1551,11 +1551,11 @@ func measRepUeReportSubscriptionsDELETE(w http.ResponseWriter, r *http.Request)
func plmnInfoGET(w http.ResponseWriter, r *http.Request) {

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	u, _ := url.Parse(r.URL.String())
	log.Info("url: ", u.RequestURI())
	q := u.Query()
	appInsId := q.Get("app_ins_id")
	appInsIdArray := strings.Split(appInsId, ",")
	//u, _ := url.Parse(r.URL.String())
	//log.Info("url: ", u.RequestURI())
	//q := u.Query()
	//appInsId := q.Get("app_ins_id")
	//appInsIdArray := strings.Split(appInsId, ",")

	var response InlineResponse2001
	atLeastOne := false
@@ -1565,8 +1565,11 @@ func plmnInfoGET(w http.ResponseWriter, r *http.Request) {
	var timeStamp TimeStamp
	timeStamp.Seconds = int32(seconds)

	//forcing to ignore the appInsId parameter
	//commenting the check but keeping the code

	//if AppId is set, we return info as per AppIds, otherwise, we return the domain info only
	if appInsId != "" {
	/*if appInsId != "" {

		for _, meAppName := range appInsIdArray {
			meAppName = strings.TrimSpace(meAppName)
@@ -1590,6 +1593,7 @@ func plmnInfoGET(w http.ResponseWriter, r *http.Request) {
			}
		}
	} else {
	*/
	keyName := baseKey + "DOM:*"
	err := rc.ForEachJSONEntry(keyName, populatePlmnInfo, &response)
	if err != nil {
@@ -1600,7 +1604,7 @@ func plmnInfoGET(w http.ResponseWriter, r *http.Request) {
	if len(response.PlmnInfo) > 0 {
		atLeastOne = true
	}
	}
	//}

	if atLeastOne {
		jsonResponse, err := json.Marshal(response)
+56 −22
Original line number Diff line number Diff line
@@ -206,46 +206,80 @@ func updateUeData(name string, ownMacId string, apMacId string) {
	}
}

func updateApInfo(name string, apMacId string, longitude *float32, latitude *float32, staMacIds []string) {
func convertFloatToGeolocationFormat(value *float32) int32 {

	//get from DB
	jsonApInfoComplete, _ := rc.JSONGetEntry(baseKey+"AP:"+name, ".")
	if value == nil {
		return 0
	}
	str := fmt.Sprintf("%f", *value)
	strArray := strings.Split(str, ".")
	integerPart, err := strconv.Atoi(strArray[0])
	if err != nil {
		log.Error("Can't convert float to int")
		return 0
	}
	fractionPart, err := strconv.Atoi(strArray[1])
	if err != nil {
		log.Error("Can't convert float to int")
		return 0
	}

	var oldStaMacIds []string
	//9 first bits are the integer part, last 23 bits are fraction part
	valueToReturn := (integerPart << 23) + fractionPart
	return int32(valueToReturn)
}

	needUpdate := false
func isUpdateApInfoNeeded(jsonApInfoComplete string, newLong int32, newLat int32, staMacIds []string) bool {

	if jsonApInfoComplete != "" {
	var oldStaMacIds []string
	var oldLat int32 = 0
	var oldLong int32 = 0

	if jsonApInfoComplete != "" {
		apInfoComplete := convertJsonToApInfoComplete(jsonApInfoComplete)

		oldStaMacIds = apInfoComplete.StaMacIds
	} else {
		needUpdate = true

		if apInfoComplete.ApLocation.GeoLocation != nil {
			oldLat = apInfoComplete.ApLocation.GeoLocation.Lat
			oldLong = apInfoComplete.ApLocation.GeoLocation.Long
		}
	}

	if !needUpdate {
	//if AP moved
	if oldLat != newLat || oldLong != newLong {
		return true
	}

	//if number of STAs connected changes
	if len(oldStaMacIds) != len(staMacIds) {
			needUpdate = true
		} else {
			needUpdate = !reflect.DeepEqual(oldStaMacIds, staMacIds)
		return true
	}

	//if the list of connected STAs is different
	return !reflect.DeepEqual(oldStaMacIds, staMacIds)

}

	if needUpdate {
func updateApInfo(name string, apMacId string, longitude *float32, latitude *float32, staMacIds []string) {

	//get from DB
	jsonApInfoComplete, _ := rc.JSONGetEntry(baseKey+"AP:"+name, ".")

	newLat := convertFloatToGeolocationFormat(latitude)
	newLong := convertFloatToGeolocationFormat(longitude)

	if isUpdateApInfoNeeded(jsonApInfoComplete, newLong, newLat, staMacIds) {
		//updateDB
		var apInfoComplete ApInfoComplete
		var apLocation ApLocation
		var geoLocation GeoLocation
		var apId ApIdentity
		if latitude != nil {
			geoLocation.Lat = int32(*latitude)
		}
		if longitude != nil {
			geoLocation.Long = int32(*longitude)
		}
		geoLocation.Lat = newLat
		geoLocation.Long = newLong

		apLocation.GeoLocation = &geoLocation
		apInfoComplete.ApLocation = apLocation

		apInfoComplete.StaMacIds = staMacIds
		apId.MacId = apMacId
		apInfoComplete.ApId = apId