2020-06-08 11:15:05 +02:00
/*
* Copyright ( c ) 2020 Olaf Landsiedel
*
* SPDX - License - Identifier : Apache - 2.0
*/
# ifndef CONTACTS_H
# define CONTACTS_H
# include <zephyr.h>
# include <zephyr/types.h>
# include "covid.h"
2021-02-01 22:57:53 +01:00
# include "covid_types.h"
//short term contacts: number of people we meet in the 5 minute window. Records any contact, will later be checked whether this contact is longer than 5 minutes
# ifndef MAX_CONTACTS
# define MAX_CONTACTS 1000
# endif
//number of contact during on day.
# ifndef MAX_PERIOD_CONTACTS
# define MAX_PERIOD_CONTACTS 400
# endif
//number of perdios (=days) we record data for
# ifndef PERIODS
# define PERIODS 14
# endif
2020-06-08 11:15:05 +02:00
2021-01-28 00:24:22 +01:00
typedef struct period_contact {
uint32_t duration ;
uint16_t cnt ;
2021-02-01 22:57:53 +01:00
int8_t max_rssi ; //TODO also store avg rssi?
2021-01-28 00:24:22 +01:00
rolling_proximity_identifier_t rolling_proximity_identifier ;
associated_encrypted_metadata_t associated_encrypted_metadata ;
} period_contact_t ;
2021-02-01 22:57:53 +01:00
typedef struct period_contacts {
int cnt ;
period_contact_t period_contacts [ MAX_PERIOD_CONTACTS ] ;
} period_contacts_t ;
typedef struct contact {
uint32_t most_recent_contact_time ; //TODO: what is the correct type here?
uint32_t first_contact_time ; //TODO: what is the correct type here?
uint16_t cnt ;
2021-03-17 14:49:07 +01:00
rssi_t max_rssi ;
2021-02-01 22:57:53 +01:00
rolling_proximity_identifier_t rolling_proximity_identifier ;
associated_encrypted_metadata_t associated_encrypted_metadata ;
} contact_t ;
2020-06-08 11:15:05 +02:00
void init_contacts ( ) ;
2020-06-12 12:25:31 +02:00
int check_add_contact ( uint32_t contact_time , rolling_proximity_identifier_t * rpi , associated_encrypted_metadata_t * aem , int8_t rssi ) ;
2020-06-08 11:15:05 +02:00
void key_change ( int current_period_index ) ;
void add_infected_key ( period_t * period ) ;
2020-06-12 12:25:31 +02:00
uint32_t get_next_infected_key_id ( ) ;
2020-06-08 11:15:05 +02:00
void print_rpi ( rolling_proximity_identifier_t * rpi ) ;
void print_aem ( associated_encrypted_metadata_t * aem ) ;
# endif