2020-07-11 12:11:34 +02:00
# ifndef _ena_STORAGE_H_
# define _ena_STORAGE_H_
# include "ena-crypto.h"
2020-07-13 20:32:53 +02:00
# 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"
2020-07-13 20:32:53 +02:00
# 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
*/
2020-07-13 20:32:53 +02:00
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
*/
2020-07-13 20:32:53 +02:00
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
*/
2020-07-12 14:14:06 +02:00
void ena_storage_shift_delete ( size_t address , size_t end_address , size_t size ) ;
2020-07-11 12:11:34 +02:00
/**
2020-07-13 20:32:53 +02:00
* get last stored TEK
*
* return cound
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +02:00
uint8_t ena_storage_read_last_tek ( ena_tek_t * tek ) ;
2020-07-11 12:11:34 +02:00
/**
2020-07-13 20:32:53 +02:00
* store TEK
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +02:00
void ena_storage_write_tek ( ena_tek_t * tek ) ;
2020-07-11 12:11:34 +02:00
/**
2020-07-13 20:32:53 +02:00
* get number of stored temporary detections
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +02:00
uint32_t ena_storage_temp_detections_count ( void ) ;
2020-07-11 12:11:34 +02:00
/**
2020-07-13 20:32:53 +02:00
* get temporary detection ( RPI + AEM + RSSI with UNIX timestamp ) at given index
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +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
*/
2020-07-13 20:32:53 +02:00
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 ) ;
/**
2020-07-13 20:32:53 +02:00
* get detection ( RPI + AEM + RSSI with ENIN ) at given index
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +02:00
void ena_storage_read_detection ( uint32_t index , ena_detection_t * detection ) ;
2020-07-11 12:11:34 +02:00
/**
2020-07-13 20:32:53 +02:00
* store detection ( RPI + AEM + RSSI with ENIN )
2020-07-11 12:11:34 +02:00
*/
2020-07-13 20:32:53 +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 ) ;
2020-07-12 14:14:06 +02:00
void ena_storage_dump_temp_detections ( void ) ;
2020-07-11 12:11:34 +02:00
void ena_storage_dump_detections ( void ) ;
# endif