diff --git a/firmware/application/app_ert.cpp b/firmware/application/app_ert.cpp index a6cbde5e..6a08888a 100644 --- a/firmware/application/app_ert.cpp +++ b/firmware/application/app_ert.cpp @@ -29,6 +29,7 @@ using namespace portapack; #include "lpc43xx_cpp.hpp" using namespace lpc43xx; +#include "crc.hpp" #include "string_format.hpp" namespace ert { @@ -71,6 +72,21 @@ Consumption Packet::consumption() const { return invalid_consumption; } +bool Packet::crc_ok() const { + if( type() == ERTPacket::Type::SCM ) { + CRC ert_bch { 0x6f63 }; + size_t start_bit = 5; + auto crc_calculated = ert_bch.calculate_byte(0x0000, reader_.read(0, start_bit)); + for(size_t i=start_bit; i;