Commit fd300697 authored by aligungr's avatar aligungr

RRC developments

parent bda839bc
......@@ -113,10 +113,13 @@ struct NwUeRrcToRls : NtsMessage
{
enum PR
{
ASSIGN_CURRENT_CELL,
RRC_PDU_DELIVERY,
RESET_STI,
} present;
// ASSIGN_CURRENT_CELL
int cellId{};
// RRC_PDU_DELIVERY
rrc::RrcChannel channel{};
OctetString pdu{};
......@@ -251,14 +254,14 @@ struct NwUeRlsToRls : NtsMessage
DOWNLINK_RRC,
RADIO_LINK_FAILURE,
TRANSMISSION_FAILURE,
ASSIGN_SERVING_CELL,
ASSIGN_CURRENT_CELL,
} present;
// RECEIVE_RLS_MESSAGE
// UPLINK_RRC
// DOWNLINK_RRC
// SIGNAL_CHANGED
// ASSIGN_SERVING_CELL
// ASSIGN_CURRENT_CELL
int cellId{};
// RECEIVE_RLS_MESSAGE
......
......@@ -64,7 +64,7 @@ void RlsControlTask::onLoop()
case NwUeRlsToRls::UPLINK_RRC:
handleUplinkRrcDelivery(w->cellId, w->pduId, w->rrcChannel, std::move(w->data));
break;
case NwUeRlsToRls::ASSIGN_SERVING_CELL:
case NwUeRlsToRls::ASSIGN_CURRENT_CELL:
m_servingCell = w->cellId;
break;
default:
......
......@@ -80,6 +80,23 @@ void UeRlsTask::onLoop()
}
break;
}
case NtsMessageType::UE_RRC_TO_RLS: {
auto *w = dynamic_cast<NwUeRrcToRls *>(msg);
switch (w->present)
{
case NwUeRrcToRls::ASSIGN_CURRENT_CELL: {
auto *m = new NwUeRlsToRls(NwUeRlsToRls::ASSIGN_CURRENT_CELL);
m->cellId = w->cellId;
m_ctlTask->push(m);
break;
}
case NwUeRrcToRls::RRC_PDU_DELIVERY: {
break;
}
}
break;
}
default:
m_logger->unhandledNts(msg);
break;
......
......@@ -12,6 +12,7 @@
#include <lib/rrc/encode.hpp>
#include <ue/nas/task.hpp>
#include <ue/rls/task.hpp>
namespace nr::ue
{
......@@ -21,18 +22,40 @@ void UeRrcTask::performCellSelection()
if (m_state == ERrcState::RRC_CONNECTED)
return;
if (!lookForSuitableCell())
lookForAcceptableCell();
int lastCell = m_base->shCtx.currentCell.get<int>([](auto &value) { return value.cellId; });
CurrentCellInfo cellInfo;
if (!lookForSuitableCell(cellInfo))
{
lookForAcceptableCell(cellInfo);
}
int selectedCell = cellInfo.cellId;
m_base->shCtx.currentCell.set(cellInfo);
if (selectedCell != 0 && selectedCell != lastCell)
{
m_logger->info("Selected cell id[%d] category[%s]", selectedCell, ToJson(cellInfo.category).str().c_str());
}
if (selectedCell != lastCell)
{
auto *w = new NwUeRrcToRls(NwUeRrcToRls::ASSIGN_CURRENT_CELL);
w->cellId = selectedCell;
m_base->rlsTask->push(w);
m_base->nasTask->push(new NwUeRrcToNas(NwUeRrcToNas::NAS_NOTIFY));
}
}
bool UeRrcTask::lookForSuitableCell()
bool UeRrcTask::lookForSuitableCell(CurrentCellInfo &cellInfo)
{
Plmn selectedPlmn = m_base->shCtx.selectedPlmn.get();
if (!selectedPlmn.hasValue())
return false;
int lastCell = m_base->shCtx.currentCell.get<int>([](auto &value) { return value.cellId; });
int outOfPlmnCells = 0;
int sib1MissingCells = 0;
int barredCells = 0;
......@@ -72,7 +95,7 @@ bool UeRrcTask::lookForSuitableCell()
}
// TODO: Check TAI if forbidden by service area or forbidden list
// TODO: Do we need to check by access identity
// TODO: Do we need to check by access identity?
// It seems suitable
candidates.push_back(item.first);
......@@ -96,24 +119,16 @@ bool UeRrcTask::lookForSuitableCell()
auto &selectedId = candidates[0];
auto &selectedCell = m_cellDesc[selectedId];
CurrentCellInfo cellInfo;
cellInfo = {};
cellInfo.cellId = selectedId;
cellInfo.plmn = selectedCell.sib1.plmn;
cellInfo.tac = selectedCell.sib1.tac;
cellInfo.category = ECellCategory::SUITABLE_CELL;
m_base->shCtx.currentCell.set(cellInfo);
if (lastCell != selectedId)
{
m_logger->info("Selected cell id[%d] category[SUITABLE]", selectedId);
// TODO: Notify RLS
m_base->nasTask->push(new NwUeRrcToNas(NwUeRrcToNas::NAS_NOTIFY));
}
return true;
}
bool UeRrcTask::lookForAcceptableCell()
bool UeRrcTask::lookForAcceptableCell(CurrentCellInfo &cellInfo)
{
// TODO
return false;
......
......@@ -104,8 +104,8 @@ class UeRrcTask : public NtsTask
/* Idle Mode Operations */
void performCellSelection();
bool lookForSuitableCell();
bool lookForAcceptableCell();
bool lookForSuitableCell(CurrentCellInfo &cellInfo);
bool lookForAcceptableCell(CurrentCellInfo &cellInfo);
/* Cell Management */
void handleCellSignalChange(int cellId, int dbm);
......
......@@ -76,6 +76,23 @@ Json ToJson(const EDeregCause &v)
}
}
Json ToJson(const ECellCategory &v)
{
switch (v)
{
case ECellCategory::BARRED_CELL:
return "BARRED";
case ECellCategory::RESERVED_CELL:
return "RESERVED";
case ECellCategory::ACCEPTABLE_CELL:
return "ACCEPTABLE";
case ECellCategory::SUITABLE_CELL:
return "SUITABLE";
default:
return "?";
}
}
bool operator==(const SingleSlice &lhs, const SingleSlice &rhs)
{
if ((int)lhs.sst != (int)rhs.sst)
......
......@@ -207,6 +207,7 @@ Json ToJson(const SingleSlice &v);
Json ToJson(const NetworkSlice &v);
Json ToJson(const PlmnSupport &v);
Json ToJson(const EDeregCause &v);
Json ToJson(const ECellCategory &v);
namespace std
{
......
......@@ -49,7 +49,7 @@ class Locked
inline T get()
{
T copy{};
access([&copy](auto &value) { copy = value; });
access([&copy](const auto &value) { copy = value; });
return copy;
}
......@@ -57,7 +57,7 @@ class Locked
inline U get(Func &&fun)
{
U copy{};
access([&copy, &fun](auto &value) { copy = fun(value); });
access([&copy, &fun](const auto &value) { copy = fun(value); });
return copy;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment