mirror of
https://github.com/Lurkars/esp-ena.git
synced 2024-11-22 10:06:11 +01:00
option to reset last check via config, TEK storage functions
This commit is contained in:
parent
af3888ec87
commit
8b38bde332
@ -7,6 +7,12 @@ menu "Exposure Notification API"
|
|||||||
help
|
help
|
||||||
Dump storage (stored TEKs, temp. beacons and perm. beacons) to serial output after scan.
|
Dump storage (stored TEKs, temp. beacons and perm. beacons) to serial output after scan.
|
||||||
|
|
||||||
|
config ENA_RESET_LAST_CHECK
|
||||||
|
bool "Reset last exposure check"
|
||||||
|
default false
|
||||||
|
help
|
||||||
|
Resets the last exposure check date on start.
|
||||||
|
|
||||||
config ENA_STORAGE_TEK_MAX
|
config ENA_STORAGE_TEK_MAX
|
||||||
int "Max. TEKs"
|
int "Max. TEKs"
|
||||||
default 14
|
default 14
|
||||||
@ -91,4 +97,5 @@ menu "Exposure Notification API"
|
|||||||
Defines the TEK rolling period in 10 minute steps. (Default 144 => 24 hours)
|
Defines the TEK rolling period in 10 minute steps. (Default 144 => 24 hours)
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
|
||||||
endmenu
|
endmenu
|
@ -179,10 +179,17 @@ void ena_storage_write_last_exposure_date(uint32_t timestamp)
|
|||||||
ena_storage_write(ENA_STORAGE_LAST_EXPOSURE_DATE_ADDRESS, ×tamp, sizeof(uint32_t));
|
ena_storage_write(ENA_STORAGE_LAST_EXPOSURE_DATE_ADDRESS, ×tamp, sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ena_storage_tek_count(void)
|
||||||
|
{
|
||||||
|
uint32_t count = 0;
|
||||||
|
ena_storage_read(ENA_STORAGE_TEK_COUNT_ADDRESS, &count, sizeof(uint32_t));
|
||||||
|
ESP_LOGD(ENA_STORAGE_LOG, "read TEK count: %u", count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ena_storage_read_last_tek(ena_tek_t *tek)
|
uint32_t ena_storage_read_last_tek(ena_tek_t *tek)
|
||||||
{
|
{
|
||||||
uint32_t tek_count = 0;
|
uint32_t tek_count = ena_storage_tek_count();
|
||||||
ena_storage_read(ENA_STORAGE_TEK_COUNT_ADDRESS, &tek_count, sizeof(uint32_t));
|
|
||||||
if (tek_count < 1)
|
if (tek_count < 1)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -195,6 +202,13 @@ uint32_t ena_storage_read_last_tek(ena_tek_t *tek)
|
|||||||
return tek_count;
|
return tek_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ena_storage_get_tek(uint32_t index, ena_tek_t *tek)
|
||||||
|
{
|
||||||
|
ena_storage_read(ENA_STORAGE_TEK_START_ADDRESS + index * sizeof(ena_tek_t), tek, sizeof(ena_tek_t));
|
||||||
|
ESP_LOGD(ENA_STORAGE_LOG, "read %d tek %u:", index, tek->enin);
|
||||||
|
ESP_LOG_BUFFER_HEXDUMP(ENA_STORAGE_LOG, tek->key_data, ENA_KEY_LENGTH, ESP_LOG_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
void ena_storage_write_tek(ena_tek_t *tek)
|
void ena_storage_write_tek(ena_tek_t *tek)
|
||||||
{
|
{
|
||||||
uint32_t tek_count = 0;
|
uint32_t tek_count = 0;
|
||||||
|
@ -91,6 +91,10 @@ void ena_start(void)
|
|||||||
ena_storage_erase_all();
|
ena_storage_erase_all();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ENA_RESET_LAST_CHECK
|
||||||
|
ena_storage_write_last_exposure_date(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ena_storage_read_last_exposure_date() == 0xFFFFFFFF)
|
if (ena_storage_read_last_exposure_date() == 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
ena_storage_erase_all();
|
ena_storage_erase_all();
|
||||||
|
@ -113,6 +113,14 @@ uint32_t ena_storage_read_last_exposure_date(void);
|
|||||||
*/
|
*/
|
||||||
void ena_storage_write_last_exposure_date(uint32_t timestamp);
|
void ena_storage_write_last_exposure_date(uint32_t timestamp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get number of stored TEKs
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* total number of TEKs stored
|
||||||
|
*/
|
||||||
|
uint32_t ena_storage_tek_count(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get last stored TEK
|
* @brief get last stored TEK
|
||||||
*
|
*
|
||||||
@ -123,6 +131,15 @@ void ena_storage_write_last_exposure_date(uint32_t timestamp);
|
|||||||
*/
|
*/
|
||||||
uint32_t ena_storage_read_last_tek(ena_tek_t *tek);
|
uint32_t ena_storage_read_last_tek(ena_tek_t *tek);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get stored TEK at given index
|
||||||
|
*
|
||||||
|
* @param[in] index the index of the TEK to read
|
||||||
|
* @param[out] tek pointer to write TEK to
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ena_storage_get_tek(uint32_t index, ena_tek_t *tek);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief store given TEK
|
* @brief store given TEK
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user