- subscription_helper sgnb_add_subscr_req;
- subscription_response_helper subscr_response;
-
- sgnb_add_subscr_req.clear();
- sgnb_add_subscr_req.set_request(request_id, req_seq);
- sgnb_add_subscr_req.set_function_id(function_id);
- sgnb_add_subscr_req.add_action(action_id, action_type);
-
-
- sgnb_add_subscr_req.set_event_def(&event_buf[0], event_buf_len);
- mdclog_write(MDCLOG_INFO, "Encoded event trigger definition into PDU of size %lu bytes\n", event_buf_len);
-
- //======================================================
- // Purely for testing purposes ... write subscription ASN binary to file
- // FILE *pfile;
- // pfile = fopen("event_trigger.pr", "wb");
- // fwrite(event_buf, 1, event_buf_len, pfile);
- // fclose(pfile);
- //======================================================
-
-
- // keep sending subscription request till successfull for all gnodebs ?
- auto it = my_config.gNodeB_list.begin();
- while(my_config.gNodeB_list.size() > 0 && RunProg){
- int attempt = 0;
- res = false;
-
- while(!res){
- mdclog_write(MDCLOG_INFO, "Sending subscription request for %s ... Attempt number = %d\n", (*it).c_str(), attempt);
- res = add_subscription(sub_handler, my_xapp.get(), sgnb_add_subscr_req, subscr_response, *it);
- if (!res){
- sleep(5);
- };
- attempt ++;
- if (attempt > MAX_SUBSCRIPTION_ATTEMPTS){
- break;
- }
- }
-
- if(res){
- mdclog_write(MDCLOG_INFO, "Successfully subscribed for gNodeB %s", (*it).c_str());
- // remove node from list,
- // move to next gnobde
- it = my_config.gNodeB_list.erase(it);
- }
-
- if (it == my_config.gNodeB_list.end()){
- it = my_config.gNodeB_list.begin();
- }
-
- }
-
-
- std::cout <<"SUBSCRIPTION REQUEST :: Successfully subscribed to events for all gNodeBs " << std::endl;