mac_rar_pdu_nr: update public interface to make it easier to access

* provide all subPDUs as const vector&
* return UL grant directly
master
Andre Puschmann 4 years ago
parent 6925b40722
commit 01acf95566

@ -15,6 +15,7 @@
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/srslog/srslog.h" #include "srslte/srslog/srslog.h"
#include <memory> #include <memory>
#include <stdint.h> #include <stdint.h>
@ -34,21 +35,20 @@ public:
mac_rar_subpdu_nr(mac_rar_pdu_nr* parent_); mac_rar_subpdu_nr(mac_rar_pdu_nr* parent_);
// RAR content length in bits (38.321 Sec 6.2.3) // RAR content length in bits (38.321 Sec 6.2.3)
static const uint32_t UL_GRANT_NBITS = 27; static const uint32_t UL_GRANT_NBITS = SRSLTE_RAR_UL_GRANT_NBITS;
static const uint32_t TA_COMMAND_NBITS = 12; static const uint32_t TA_COMMAND_NBITS = 12;
// getter // getter
bool read_subpdu(const uint8_t* ptr); bool read_subpdu(const uint8_t* ptr);
bool has_more_subpdus(); bool has_more_subpdus();
uint32_t get_total_length(); uint32_t get_total_length();
bool has_rapid(); bool has_rapid() const;
uint8_t get_rapid(); uint8_t get_rapid() const;
uint16_t get_temp_crnti(); uint16_t get_temp_crnti() const;
uint32_t get_ta(); uint32_t get_ta() const;
void get_ul_grant(std::array<uint8_t, UL_GRANT_NBITS>& grant); std::array<uint8_t, UL_GRANT_NBITS> get_ul_grant() const;
bool has_backoff() const;
bool has_backoff(); uint8_t get_backoff() const;
uint8_t get_backoff();
// setter // setter
uint32_t write_subpdu(const uint8_t* start_); uint32_t write_subpdu(const uint8_t* start_);
@ -82,7 +82,10 @@ public:
bool pack(); bool pack();
bool unpack(const uint8_t* payload, const uint32_t& len); bool unpack(const uint8_t* payload, const uint32_t& len);
uint32_t get_num_subpdus(); uint32_t get_num_subpdus();
// Returns reference to a single subPDU
const mac_rar_subpdu_nr& get_subpdu(const uint32_t& index); const mac_rar_subpdu_nr& get_subpdu(const uint32_t& index);
// Returns reference to all subPDUs
const std::vector<mac_rar_subpdu_nr>& get_subpdus();
uint32_t get_remaining_len(); uint32_t get_remaining_len();

@ -151,6 +151,11 @@ typedef enum SRSLTE_API {
*/ */
#define SRSLTE_SEARCH_SPACE_IS_COMMON(SS_TYPE) ((SS_TYPE) < srslte_search_space_type_ue) #define SRSLTE_SEARCH_SPACE_IS_COMMON(SS_TYPE) ((SS_TYPE) < srslte_search_space_type_ue)
/**
* @brief RAR content length in bits (see TS 38.321 Sec 6.2.3)
*/
#define SRSLTE_RAR_UL_GRANT_NBITS (27)
/** /**
* @brief Indicates the MCS table the UE shall use for PDSCH and/or PUSCH without transform precoding * @brief Indicates the MCS table the UE shall use for PDSCH and/or PUSCH without transform precoding
*/ */

@ -91,27 +91,27 @@ uint32_t mac_rar_subpdu_nr::get_total_length()
return (header_length + payload_length); return (header_length + payload_length);
} }
bool mac_rar_subpdu_nr::has_rapid() bool mac_rar_subpdu_nr::has_rapid() const
{ {
return (type == rar_subh_type_t::RAPID); return (type == rar_subh_type_t::RAPID);
} }
uint8_t mac_rar_subpdu_nr::get_rapid() uint8_t mac_rar_subpdu_nr::get_rapid() const
{ {
return rapid; return rapid;
} }
uint32_t mac_rar_subpdu_nr::get_ta() uint32_t mac_rar_subpdu_nr::get_ta() const
{ {
return ta; return ta;
} }
uint16_t mac_rar_subpdu_nr::get_temp_crnti() uint16_t mac_rar_subpdu_nr::get_temp_crnti() const
{ {
return temp_crnti; return temp_crnti;
} }
bool mac_rar_subpdu_nr::has_backoff() bool mac_rar_subpdu_nr::has_backoff() const
{ {
return (type == rar_subh_type_t::BACKOFF); return (type == rar_subh_type_t::BACKOFF);
} }
@ -121,9 +121,9 @@ void mac_rar_subpdu_nr::set_backoff(const uint8_t backoff_indicator_)
backoff_indicator = backoff_indicator_; backoff_indicator = backoff_indicator_;
} }
void mac_rar_subpdu_nr::get_ul_grant(std::array<uint8_t, UL_GRANT_NBITS>& grant_) std::array<uint8_t, mac_rar_subpdu_nr::UL_GRANT_NBITS> mac_rar_subpdu_nr::get_ul_grant() const
{ {
grant_ = ul_grant; return ul_grant;
} }
std::string mac_rar_subpdu_nr::to_string() std::string mac_rar_subpdu_nr::to_string()
@ -197,6 +197,11 @@ const mac_rar_subpdu_nr& mac_rar_pdu_nr::get_subpdu(const uint32_t& index)
return subpdus.at(index); return subpdus.at(index);
} }
const std::vector<mac_rar_subpdu_nr>& mac_rar_pdu_nr::get_subpdus()
{
return subpdus;
}
uint32_t mac_rar_pdu_nr::get_remaining_len() uint32_t mac_rar_pdu_nr::get_remaining_len()
{ {
return remaining_len; return remaining_len;

@ -291,8 +291,7 @@ int mac_rar_pdu_unpack_test7()
TESTASSERT(subpdu.get_ta() == tv_ta); TESTASSERT(subpdu.get_ta() == tv_ta);
TESTASSERT(subpdu.get_rapid() == tv_rapid); TESTASSERT(subpdu.get_rapid() == tv_rapid);
std::array<uint8_t, mac_rar_subpdu_nr::UL_GRANT_NBITS> msg3_grant; std::array<uint8_t, mac_rar_subpdu_nr::UL_GRANT_NBITS> msg3_grant = subpdu.get_ul_grant();
subpdu.get_ul_grant(msg3_grant);
TESTASSERT(memcmp(msg3_grant.data(), tv_msg3_grant, msg3_grant.size()) == 0); TESTASSERT(memcmp(msg3_grant.data(), tv_msg3_grant, msg3_grant.size()) == 0);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

Loading…
Cancel
Save