update storage erase, fix exposure model, optimize exposure loop

This commit is contained in:
Lurkars
2020-10-21 19:12:32 +02:00
parent af56fc6a12
commit af3888ec87
5 changed files with 95 additions and 40 deletions
+12 -3
View File
@@ -22,6 +22,7 @@
#include <stdio.h>
#include "esp_err.h"
#include "ena-storage.h"
#include "ena-crypto.h"
#define ENA_EXPOSURE_LOG "ESP-ENA-exposure" // TAG for Logging
@@ -151,8 +152,8 @@ typedef struct __attribute__((__packed__))
{
uint8_t key_data[ENA_KEY_LENGTH];
uint8_t transmission_risk_level;
uint8_t rolling_start_interval_number;
uint8_t rolling_period;
uint32_t rolling_start_interval_number;
uint32_t rolling_period;
ena_report_type_t report_type;
uint32_t days_since_onset_of_symptoms;
} ena_temporary_exposure_key_t;
@@ -231,7 +232,15 @@ ena_exposure_summary_t *ena_exposure_current_summary(void);
ena_exposure_config_t *ena_exposure_default_config(void);
/**
* @brief reads Temporary Exposue Key and check for exposures
* @brief reads Temporary Exposue Key check for exposures with certain beacon
*
* @param[in] ena_beacon_t the beacon to check against
* @param[in] temporary_exposure_key the temporary exposure keys to check
*/
void ena_exposure_check(ena_beacon_t beacon, ena_temporary_exposure_key_t temporary_exposure_key);
/**
* @brief reads Temporary Exposue Key and check for exposures with all beacons
*
* @param[in] temporary_exposure_key the temporary exposure keys to check
*/
+14 -1
View File
@@ -81,6 +81,14 @@ void ena_storage_read(size_t address, void *data, size_t size);
*/
void ena_storage_write(size_t address, void *data, size_t size);
/**
* @brief erase storage at given address
*
* @param[in] address the address to erase from
* @param[in] size how many bytes to erase
*/
void ena_storage_erase(size_t address, size_t size);
/**
* @brief deletes bytes at given address and shift other data back
*
@@ -224,7 +232,7 @@ void ena_storage_remove_beacon(uint32_t index);
* This function completely deletes all stored data and resets the counters
* of TEKs, temporary beacon and beacon to zero.
*/
void ena_storage_erase(void);
void ena_storage_erase_all(void);
/**
* @brief erase all stored TEKs
@@ -254,6 +262,11 @@ void ena_storage_erase_temporary_beacon(void);
*/
void ena_storage_erase_beacon(void);
/**
* @brief helper to dump a byte array as hash
*/
void ena_storage_dump_hash_array(uint8_t *data, size_t size);
/**
* @brief dump all stored TEKs to serial output
*