1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-10-30 22:56:22 +00:00

Add work on OSNMA receiver

This commit is contained in:
Carles Fernandez 2023-06-01 14:41:01 +02:00
parent cc8fa9a4d2
commit ce50e160a7
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 43 additions and 23 deletions

View File

@ -28,6 +28,7 @@
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <numeric> #include <numeric>
#include <string>
#include <typeinfo> // for typeid #include <typeinfo> // for typeid
@ -121,13 +122,6 @@ void osnma_msg_receiver::read_nma_header(uint8_t nma_header)
d_osnma_data.d_nma_header.cid = get_cid(nma_header); d_osnma_data.d_nma_header.cid = get_cid(nma_header);
d_osnma_data.d_nma_header.cpks = get_cpks(nma_header); d_osnma_data.d_nma_header.cpks = get_cpks(nma_header);
d_osnma_data.d_nma_header.reserved = get_nma_header_reserved(nma_header); d_osnma_data.d_nma_header.reserved = get_nma_header_reserved(nma_header);
// debug
const auto it = OSNMA_TABLE_2.find(d_osnma_data.d_nma_header.cpks);
if (it != OSNMA_TABLE_2.cend())
{
LOG(WARNING) << "Chain and Public Key Status: " << it->second;
}
} }
@ -194,10 +188,9 @@ void osnma_msg_receiver::read_dsm_block(const std::shared_ptr<OSNMA_msg>& osnma_
dsm_msg[i * 13 + j] = d_dsm_message[d_osnma_data.d_dsm_header.dsm_id][i * 13 + j]; dsm_msg[i * 13 + j] = d_dsm_message[d_osnma_data.d_dsm_header.dsm_id][i * 13 + j];
} }
} }
process_dsm_message(dsm_msg);
d_dsm_message[d_osnma_data.d_dsm_header.dsm_id] = std::array<uint8_t, 256>{}; d_dsm_message[d_osnma_data.d_dsm_header.dsm_id] = std::array<uint8_t, 256>{};
d_dsm_id_received[d_osnma_data.d_dsm_header.dsm_id] = std::array<uint8_t, 16>{}; d_dsm_id_received[d_osnma_data.d_dsm_header.dsm_id] = std::array<uint8_t, 16>{};
// d_number_of_blocks[d_osnma_data.d_dsm_header.dsm_id] = 0; process_dsm_message(dsm_msg);
} }
} }
@ -273,7 +266,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
d_osnma_data.d_dsm_kroot_message.p_dk = std::vector<uint8_t>(l_pdk_bytes, 0); d_osnma_data.d_dsm_kroot_message.p_dk = std::vector<uint8_t>(l_pdk_bytes, 0);
for (uint32_t k = 0; k < l_ds_bytes; k++) for (uint32_t k = 0; k < l_ds_bytes; k++)
{ {
d_osnma_data.d_dsm_kroot_message.ds[k] = dsm_msg[13 + bytes_lk + l_ds_bytes + k]; d_osnma_data.d_dsm_kroot_message.p_dk[k] = dsm_msg[13 + bytes_lk + l_ds_bytes + k];
} }
// validation? // validation?
} }
@ -291,7 +284,6 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
d_osnma_data.d_dsm_pkr_message.npkt = (dsm_msg[129] & 0b11110000) >> 4; d_osnma_data.d_dsm_pkr_message.npkt = (dsm_msg[129] & 0b11110000) >> 4;
d_osnma_data.d_dsm_pkr_message.npktid = (dsm_msg[129] & 0b00001111); d_osnma_data.d_dsm_pkr_message.npktid = (dsm_msg[129] & 0b00001111);
// Table 5
uint32_t l_npk = 0; uint32_t l_npk = 0;
const auto it = OSNMA_TABLE_5.find(d_osnma_data.d_dsm_pkr_message.npkt); const auto it = OSNMA_TABLE_5.find(d_osnma_data.d_dsm_pkr_message.npkt);
if (it != OSNMA_TABLE_5.cend()) if (it != OSNMA_TABLE_5.cend())
@ -343,25 +335,34 @@ void osnma_msg_receiver::read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma
d_mack_message[index + 3] = static_cast<uint8_t>(value & 0x000000FF); d_mack_message[index + 3] = static_cast<uint8_t>(value & 0x000000FF);
index = index + 4; index = index + 4;
} }
read_mack_header(osnma_msg); read_mack_header();
read_mack_info_and_tags(osnma_msg); read_mack_info_and_tags();
read_mack_key(osnma_msg); read_mack_key();
read_mack_padding(osnma_msg); read_mack_padding();
} }
void osnma_msg_receiver::read_mack_header(const std::shared_ptr<OSNMA_msg>& osnma_msg)
void osnma_msg_receiver::read_mack_header()
{ {
uint8_t lt_bits = 0;
const auto it = OSNMA_TABLE_11.find(d_osnma_data.d_dsm_kroot_message.ts);
if (it != OSNMA_TABLE_11.cend())
{
lt_bits = it->second;
}
} }
void osnma_msg_receiver::read_mack_info_and_tags(const std::shared_ptr<OSNMA_msg>& osnma_msg)
void osnma_msg_receiver::read_mack_info_and_tags()
{ {
} }
void osnma_msg_receiver::read_mack_key(const std::shared_ptr<OSNMA_msg>& osnma_msg) void osnma_msg_receiver::read_mack_key()
{ {
} }
void osnma_msg_receiver::read_mack_padding(const std::shared_ptr<OSNMA_msg>& osnma_msg)
void osnma_msg_receiver::read_mack_padding()
{ {
} }

View File

@ -62,10 +62,10 @@ private:
void read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg); void read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
void process_dsm_message(const std::vector<uint8_t>& dsm_msg); void process_dsm_message(const std::vector<uint8_t>& dsm_msg);
void read_mack_header(const std::shared_ptr<OSNMA_msg>& osnma_msg); void read_mack_header();
void read_mack_info_and_tags(const std::shared_ptr<OSNMA_msg>& osnma_msg); void read_mack_info_and_tags();
void read_mack_key(const std::shared_ptr<OSNMA_msg>& osnma_msg); void read_mack_key();
void read_mack_padding(const std::shared_ptr<OSNMA_msg>& osnma_msg); void read_mack_padding();
std::array<std::array<uint8_t, 256>, 16> d_dsm_message{}; std::array<std::array<uint8_t, 256>, 16> d_dsm_message{};
std::array<std::array<uint8_t, 16>, 16> d_dsm_id_received{}; std::array<std::array<uint8_t, 16>, 16> d_dsm_id_received{};

View File

@ -123,6 +123,25 @@ const std::unordered_map<uint8_t, uint16_t> OSNMA_TABLE_10 = {
{15, 0}, {15, 0},
{15, 0}}; // key: ks, value: lk_bits {15, 0}}; // key: ks, value: lk_bits
const std::unordered_map<uint8_t, uint8_t> OSNMA_TABLE_11 = {
{0, 0},
{1, 0},
{2, 0},
{3, 0},
{4, 0},
{5, 20},
{6, 24},
{7, 26},
{8, 32},
{9, 40},
{10, 0},
{11, 0},
{12, 0},
{13, 0},
{14, 0},
{15, 0},
};
const std::unordered_map<std::string, uint16_t> OSNMA_TABLE_15 = { const std::unordered_map<std::string, uint16_t> OSNMA_TABLE_15 = {
{std::string("ECDSA P-256"), 512}, {std::string("ECDSA P-256"), 512},
{std::string("ECDSA P-521"), 1056}, {std::string("ECDSA P-521"), 1056},