Implementation of pack and unpack functions for nfapi_nr_srs_normalized_channel_iq_matrix_t

This commit is contained in:
Roberto Louro Magueta
2022-06-10 20:41:22 +01:00
parent cc52682bc2
commit 5df658141b
6 changed files with 175 additions and 15 deletions
@@ -4060,6 +4060,25 @@ int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len);
*/
int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp);
/*! \brief Encodes a nfapi_nr_srs_normalized_channel_iq_matrix_t to a buffer
*
* \param pMessageBuf A pointer to a nfapi_nr_srs_normalized_channel_iq_matrix_t structure
* \param pPackedBuf A pointer to the buffer that the nfapi_nr_srs_normalized_channel_iq_matrix_t will be packed into
* \param packedBufLen The size of the buffer
* \return number of bytes written to the buffer
*/
int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen);
/*! \brief Decodes a nfapi_nr_srs_normalized_channel_iq_matrix_t from a buffer
*
* \param pMessageBuf A pointer to an encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
* \param messageBufLen The size of the encoded nfapi_nr_srs_normalized_channel_iq_matrix_t
* \param pUnpackedBuf A pointer to the nfapi_nr_srs_normalized_channel_iq_matrix_t
* \param unpackedBufLen The size of nfapi_nr_srs_normalized_channel_iq_matrix_t structure.
* \return 0 means success, -1 means failure.
*/
int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen);
/*! \brief Encodes a nfapi_nr_srs_beamforming_report_t to a buffer
*
* \param pMessageBuf A pointer to a nfapi_nr_srs_beamforming_report_t structure
+67 -3
View File
@@ -3099,6 +3099,40 @@ return 1;
//SRS INDICATION
int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) {
nfapi_nr_srs_normalized_channel_iq_matrix_t *nr_srs_normalized_channel_iq_matrix = (nfapi_nr_srs_normalized_channel_iq_matrix_t*)pMessageBuf;
uint8_t *pWritePackedMessage = pPackedBuf;
uint8_t *end = pPackedBuf + packedBufLen;
if(!(push8(nr_srs_normalized_channel_iq_matrix->normalized_iq_representation, &pWritePackedMessage, end) &&
push16(nr_srs_normalized_channel_iq_matrix->num_gnb_antenna_elements, &pWritePackedMessage, end) &&
push16(nr_srs_normalized_channel_iq_matrix->num_ue_srs_ports, &pWritePackedMessage, end) &&
push16(nr_srs_normalized_channel_iq_matrix->prg_size, &pWritePackedMessage, end) &&
push16(nr_srs_normalized_channel_iq_matrix->num_prgs, &pWritePackedMessage, end))) {
return 0;
}
uint16_t channel_matrix_size = nr_srs_normalized_channel_iq_matrix->num_prgs*nr_srs_normalized_channel_iq_matrix->num_ue_srs_ports*nr_srs_normalized_channel_iq_matrix->num_gnb_antenna_elements;
if (nr_srs_normalized_channel_iq_matrix->normalized_iq_representation == 0) {
channel_matrix_size <<= 1;
} else {
channel_matrix_size <<= 2;
}
for(int i = 0; i < channel_matrix_size; i++) {
if (!push8(nr_srs_normalized_channel_iq_matrix->channel_matrix[i], &pWritePackedMessage, end)) {
return 0;
}
}
// Message length
uintptr_t msgHead = (uintptr_t)pPackedBuf;
uintptr_t msgEnd = (uintptr_t)pWritePackedMessage;
return (msgEnd-msgHead);
}
static uint8_t pack_nr_srs_reported_symbol(nfapi_nr_srs_reported_symbol_t *prgs, uint8_t **ppWritePackedMsg, uint8_t *end) {
if(!push16(prgs->num_prgs, ppWritePackedMsg, end)) {
@@ -3114,9 +3148,7 @@ static uint8_t pack_nr_srs_reported_symbol(nfapi_nr_srs_reported_symbol_t *prgs,
return 1;
}
int pack_nr_srs_beamforming_report(void *pMessageBuf,
void *pPackedBuf,
uint32_t packedBufLen) {
int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) {
nfapi_nr_srs_beamforming_report_t *nr_srs_beamforming_report = (nfapi_nr_srs_beamforming_report_t*)pMessageBuf;
@@ -5850,6 +5882,38 @@ return 1;
//SRS INDICATION
int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) {
nfapi_nr_srs_normalized_channel_iq_matrix_t *nr_srs_normalized_channel_iq_matrix = (nfapi_nr_srs_normalized_channel_iq_matrix_t*)pUnpackedBuf;
uint8_t *pReadPackedMessage = pMessageBuf;
uint8_t *end = pMessageBuf + messageBufLen;
memset(pUnpackedBuf, 0, unpackedBufLen);
if(!(pull8(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->normalized_iq_representation, end) &&
pull16(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->num_gnb_antenna_elements, end) &&
pull16(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->num_ue_srs_ports, end) &&
pull16(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->prg_size, end) &&
pull16(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->num_prgs, end))) {
return -1;
}
uint16_t channel_matrix_size = nr_srs_normalized_channel_iq_matrix->num_prgs*nr_srs_normalized_channel_iq_matrix->num_ue_srs_ports*nr_srs_normalized_channel_iq_matrix->num_gnb_antenna_elements;
if (nr_srs_normalized_channel_iq_matrix->normalized_iq_representation == 0) {
channel_matrix_size <<= 1;
} else {
channel_matrix_size <<= 2;
}
for(int i = 0; i < channel_matrix_size; i++) {
if (!pull8(&pReadPackedMessage, &nr_srs_normalized_channel_iq_matrix->channel_matrix[i], end)) {
return 0;
}
}
return 0;
}
static uint8_t unpack_nr_srs_reported_symbol(nfapi_nr_srs_reported_symbol_t *prgs, uint8_t **ppReadPackedMsg, uint8_t *end) {
if(!pull16(ppReadPackedMsg, &prgs->num_prgs, end)) {