esp-ena/main/ena-storage.h

84 lines
2.1 KiB
C
Raw Normal View History

2020-07-11 12:11:34 +02:00
#ifndef _ena_STORAGE_H_
#define _ena_STORAGE_H_
#include "ena-crypto.h"
#include "ena-datastructures.h"
2020-07-11 12:11:34 +02:00
#define ENA_STORAGE_LOG "ESP-ENA-storage" // TAG for Logging
#define PARTITION_NAME "ena"
#define ENA_STOARGE_TEK_STORE_PERIOD (14) // Period of storing TEKs // length of a stored detection -> RPI keysize + AEM size + 4 Bytes for ENIN + 4 Bytes for RSSI
#define ENA_STOARGE_TEMP_DETECTIONS_MAX (1000) // Maximum number of temporary stored detections
2020-07-11 12:11:34 +02:00
/**
* read bytes at given address
*/
void ena_storage_read(size_t address, void *data, size_t size);
2020-07-11 12:11:34 +02:00
/**
* store bytes at given address
*/
void ena_storage_write(size_t address, void *data, size_t size);
2020-07-11 12:11:34 +02:00
/**
* deletes bytes at given address and shift other data back
*/
void ena_storage_shift_delete(size_t address, size_t end_address, size_t size);
2020-07-11 12:11:34 +02:00
/**
* get last stored TEK
*
* return cound
2020-07-11 12:11:34 +02:00
*/
uint8_t ena_storage_read_last_tek(ena_tek_t *tek);
2020-07-11 12:11:34 +02:00
/**
* store TEK
2020-07-11 12:11:34 +02:00
*/
void ena_storage_write_tek(ena_tek_t *tek);
2020-07-11 12:11:34 +02:00
/**
* get number of stored temporary detections
2020-07-11 12:11:34 +02:00
*/
uint32_t ena_storage_temp_detections_count(void);
2020-07-11 12:11:34 +02:00
/**
* get temporary detection (RPI + AEM + RSSI with UNIX timestamp) at given index
2020-07-11 12:11:34 +02:00
*/
void ena_storage_read_temp_detection(uint32_t index, ena_temp_detection_t *detection);
2020-07-11 12:11:34 +02:00
/**
* store temporary detection (RPI + AEM + RSSI with UNIX timestamp)
*
* returns index
*/
uint32_t ena_storage_write_temp_detection(ena_temp_detection_t *detection);
2020-07-11 12:11:34 +02:00
/**
* remove temporary detection at given index
*/
void ena_storage_remove_temp_detection(uint32_t index);
/**
* get number of stored detections
*/
uint32_t ena_storage_detections_count(void);
/**
* get detection (RPI + AEM + RSSI with ENIN) at given index
2020-07-11 12:11:34 +02:00
*/
void ena_storage_read_detection(uint32_t index, ena_detection_t *detection);
2020-07-11 12:11:34 +02:00
/**
* store detection (RPI + AEM + RSSI with ENIN)
2020-07-11 12:11:34 +02:00
*/
void ena_storage_write_detection(ena_detection_t *detection);
2020-07-11 12:11:34 +02:00
void ena_storage_erase(void);
void ena_storage_dump_tek(void);
void ena_storage_dump_temp_detections(void);
2020-07-11 12:11:34 +02:00
void ena_storage_dump_detections(void);
#endif