Commit 4c1216c1 authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed in MEC 013 subscription usage

parent c6f05912
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -1089,7 +1089,7 @@ func mec013_subscribe_ue_loc(ue_address string) (body []byte, response *http.Res
	}

	// Set URL
	url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/location/v3/users/subscriptions"
	url := mecUrl + "/" + sandboxName + "/" + mecPlateform + "/location/v3/subscriptions/users"
	fmt.Println("mec013_subscribe_ue_loc: url: " + url)
	// Build message body
	var userLocationEventSubscription = UserLocationEventSubscription{
@@ -1100,7 +1100,9 @@ func mec013_subscribe_ue_loc(ue_address string) (body []byte, response *http.Res
		SubscriptionType:        "UserLocationEventSubscription",
	}
	userLocationEventSubscription.LocationEventCriteria = append(userLocationEventSubscription.LocationEventCriteria, "ENTERING_AREA_EVENT")
	json_body, err := json.Marshal(userLocationEventSubscription)
	var m = map[string]UserLocationEventSubscription{}
	m["userLocationEventSubscription"] = userLocationEventSubscription
	json_body, err := json.Marshal(m)
	if err != nil {
		return nil, nil, err
	}
@@ -1112,11 +1114,19 @@ func mec013_subscribe_ue_loc(ue_address string) (body []byte, response *http.Res
	}
	defer response.Body.Close()

	err = json.Unmarshal([]byte(body), &userLocationEventSubscription)
	fmt.Println("mec013_subscribe_ue_loc: body: " +  string(body))
	var r = map[string]UserLocationEventSubscription{}
	err = json.Unmarshal([]byte(body), &r)
	if err != nil {
		return nil, nil, err
	}
	subscriptions = append(subscriptions, *userLocationEventSubscription.Links.Self)
	if val, ok := r["userLocationEventSubscription"]; ok {
		fmt.Println("mec013_subscribe_ue_loc: userLocationEventSubscription: %v", val)
		subscriptions = append(subscriptions, *val.Links.Self)
	} else {
		err = errors.New("Failed to create User location event subscription")
		return nil, nil, err
	}

	return body, response, nil
}
@@ -1539,6 +1549,11 @@ func delete_subscription_from_list(url string) {
	}
}

func mec013_notification(w http.ResponseWriter, r *http.Request) {
	fmt.Println(">>> mec013_notification: ", r)
	w.WriteHeader(http.StatusOK)
}

func v2x_msg_notification(w http.ResponseWriter, r *http.Request) {
	fmt.Println(">>> v2x_msg_notification: ", r)
	w.WriteHeader(http.StatusOK)
+6 −0
Original line number Diff line number Diff line
@@ -65,6 +65,12 @@ var routes = HttpRoutes{
		"/",
		Index,
	},
	HttpRoute{
		"Index",
		"POST",
		"location/v3/users_notification",
		mec013_notification,
	},
	HttpRoute{
		"Index",
		"POST",