make UE switch_on non-blocking

this allows a simpler main that just signals NAS to switch on the UE
but doesn't block until the action is completed.

For making sure the UE also attached if the first attempt failed
the NAS needs to be extended to support the correct timers.
master
Andre Puschmann 5 years ago
parent 626259eede
commit 35307a047a

@ -77,9 +77,7 @@ class cell_t
bool equals(cell_t *x) {
return equals(x->phy_cell.earfcn, x->phy_cell.cell.id);
}
bool equals(uint32_t earfcn, uint32_t pci) {
return earfcn == this->phy_cell.earfcn && pci == phy_cell.cell.id;
}
bool equals(uint32_t earfcn, uint32_t pci) { return earfcn == phy_cell.earfcn && pci == phy_cell.cell.id; }
// NaN means an RSRP value has not yet been obtained. Keep then in the list and clean them if never updated
bool greater(cell_t *x) {
return rsrp > x->rsrp || std::isnan(rsrp);

@ -583,15 +583,11 @@ int main(int argc, char* argv[])
pthread_create(&input, nullptr, &input_loop, &args);
cout << "Attaching UE..." << endl;
while (!ue.switch_on() && running) {
sleep(1);
}
ue.switch_on();
if (running) {
if (args.gui.enable) {
ue.start_plot();
}
}
while (running) {
sleep(1);

@ -167,15 +167,9 @@ void ue_stack_lte::stop_impl()
bool ue_stack_lte::switch_on()
{
if (running) {
proc_state_t proc_result = proc_state_t::on_going;
pending_tasks.try_push(ue_queue_id,
task_t{[this, &proc_result](task_t*) { nas.start_attach_request(&proc_result); }});
while (proc_result == proc_state_t::on_going) {
usleep(1000);
}
return proc_result == proc_state_t::success;
pending_tasks.try_push(ue_queue_id, task_t{[this](task_t*) { nas.start_attach_request(nullptr); }});
return true;
}
return false;
}

@ -303,7 +303,9 @@ void nas::start_attach_request(srslte::proc_state_t* result)
if (!plmn_is_selected) {
nas_log->info("No PLMN selected. Starting PLMN Search...\n");
if (not plmn_searcher.launch(this)) {
if (result != nullptr) {
*result = proc_state_t::error;
}
return;
}
callbacks.defer_task([this, result]() {
@ -312,8 +314,9 @@ void nas::start_attach_request(srslte::proc_state_t* result)
}
plmn_search_proc p = plmn_searcher.pop();
nas_log->info("Attach Request from PLMN Search %s\n", p.is_success() ? "finished successfully" : "failed");
if (result != nullptr) {
*result = p.is_success() ? proc_state_t::success : proc_state_t::error;
// stay in this state if attach failed
}
if (not p.is_success()) {
enter_emm_deregistered();
}
@ -321,18 +324,24 @@ void nas::start_attach_request(srslte::proc_state_t* result)
});
} else {
nas_log->error("PLMN selected in state %s\n", emm_state_text[state]);
if (result != nullptr) {
*result = proc_state_t::error;
}
}
break;
case EMM_STATE_REGISTERED:
if (rrc->is_connected()) {
nas_log->info("NAS is already registered and RRC connected\n");
if (result != nullptr) {
*result = proc_state_t::success;
}
} else {
nas_log->info("NAS is already registered but RRC disconnected. Connecting now...\n");
if (not rrc_connector.launch(this, srslte::establishment_cause_t ::mo_data, nullptr)) {
nas_log->error("Cannot initiate concurrent rrc connection procedures\n");
if (result != nullptr) {
*result = proc_state_t::error;
}
return;
}
callbacks.defer_task([this, result]() {
@ -345,16 +354,20 @@ void nas::start_attach_request(srslte::proc_state_t* result)
} else {
nas_log->error("Could not attach from attach_request\n");
}
if (result != nullptr) {
*result = proc.is_success() ? proc_state_t::success : proc_state_t::error;
}
return proc_outcome_t::success;
});
}
break;
default:
nas_log->info("Attach request ignored. State = %s\n", emm_state_text[state]);
if (result != nullptr) {
*result = proc_state_t::error;
}
}
}
void nas::plmn_search_completed(rrc_interface_nas::found_plmn_t found_plmns[rrc_interface_nas::MAX_FOUND_PLMNS],
int nof_plmns)

Loading…
Cancel
Save