From 2cf96bda87ac04c96cad663f83211118bf20c8b0 Mon Sep 17 00:00:00 2001 From: cesaaargm Date: Mon, 24 Jun 2024 14:41:49 +0200 Subject: [PATCH] =?UTF-8?q?[TAS-226]=20[FEAT]=20Remove=20tags=20skipped=20?= =?UTF-8?q?=E2=89=A5=2010=20times?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Take into account TOW to decide whether to skip a tag or not. Still, I dont like the logic of iterating over and over the tags. Once a tag is verified once, it should be not checked unless next TOW subframe came (new Data or new Key available) Adittionally: solved a small specification bug for ADKD=12, improved reporting (status of Tag is a string now) --- src/core/libs/osnma_msg_receiver.cc | 15 +++++++++------ src/core/system_parameters/osnma_helper.cc | 12 +++++++++++- src/core/system_parameters/osnma_helper.h | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/core/libs/osnma_msg_receiver.cc b/src/core/libs/osnma_msg_receiver.cc index 8447fb5fc..c515228ba 100644 --- a/src/core/libs/osnma_msg_receiver.cc +++ b/src/core/libs/osnma_msg_receiver.cc @@ -980,7 +980,10 @@ void osnma_msg_receiver::process_mack_message() << std::endl; } } - else { + else if(it.second.TOW > d_osnma_data.d_nav_data.TOW_sf0){ + // case 1: adkd=12 and t.Tow + 300 < current TOW + // case 2: adkd=0/4 and t.Tow + 30 < current TOW + // case 3: any adkd and t.Tow > current TOW it.second.skipped ++; LOG(WARNING) << "Galileo OSNMA: Tag verification :: SKIPPED (x"<< it.second.skipped <<")for Tag Id= " << it.second.tag_id @@ -1063,7 +1066,7 @@ bool osnma_msg_receiver::verify_tag(Tag& tag) if (tag.ADKD == 0 || tag.ADKD == 4) applicable_key = d_tesla_keys[tag.TOW + 30]; else // ADKD 12 - applicable_key = d_tesla_keys[tag.TOW + 300]; + applicable_key = d_tesla_keys[tag.TOW + 330]; if (d_osnma_data.d_dsm_kroot_message.mf == 0) // C: HMAC-SHA-256 { @@ -1284,7 +1287,7 @@ void osnma_msg_receiver::remove_verified_tags() << ", PRNd=" << static_cast(it->second.PRN_d) << ", status= " - << it->second.status + << d_helper->verification_status_str(it->second.status) << std::endl; it = d_tags_awaiting_verify.erase(it); } @@ -1303,7 +1306,7 @@ void osnma_msg_receiver::remove_verified_tags() << ", PRNd=" << static_cast(it->second.PRN_d) << ", status= " - << it->second.status + << d_helper->verification_status_str(it->second.status) << std::endl; it = d_tags_awaiting_verify.erase(it); } @@ -1478,14 +1481,14 @@ bool osnma_msg_receiver::tag_has_key_available(Tag& t){ } else if (t.ADKD == 12) { - auto it = d_tesla_keys.find(t.TOW + 300); + auto it = d_tesla_keys.find(t.TOW + 330); if (it != d_tesla_keys.end()) { LOG(INFO)<< "Galileo OSNMA: hasKey = true " << std::endl; return true; } } - LOG(INFO) << "Galileo OSNMA: hasKey = false " << std::endl; + LOG(INFO) << "Galileo OSNMA: hasKey = false "; return false; } std::vector osnma_msg_receiver::hash_chain(uint32_t num_of_hashes_needed, std::vector key, uint32_t GST_SFi, const uint8_t lk_bytes) diff --git a/src/core/system_parameters/osnma_helper.cc b/src/core/system_parameters/osnma_helper.cc index 9ce394543..aa338f408 100644 --- a/src/core/system_parameters/osnma_helper.cc +++ b/src/core/system_parameters/osnma_helper.cc @@ -63,4 +63,14 @@ std::vector Osnma_Helper::bytes(const std::string& binaryString) { } return bytes; -} \ No newline at end of file +} + +std::string Osnma_Helper::verification_status_str(int status) +{ + switch (status) { + case 0: return "SUCCESS"; + case 1: return "FAIL"; + case 2: return "UNVERIFIED"; + default: return "UNKNOWN"; + } +} diff --git a/src/core/system_parameters/osnma_helper.h b/src/core/system_parameters/osnma_helper.h index 9bf1d860d..2f8df078b 100644 --- a/src/core/system_parameters/osnma_helper.h +++ b/src/core/system_parameters/osnma_helper.h @@ -29,7 +29,7 @@ public: uint32_t compute_gst(uint32_t WN, uint32_t TOW) const; std::vector gst_to_uint8(uint32_t GST) const; std::vector bytes(const std::string& binaryString); + std::string verification_status_str(int status); }; - #endif // GNSS_SDR_OSNMA_HELPER_H