kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added backlog replay threshold, currently one day
rodzic
93dd085729
commit
413e116707
|
@ -45,6 +45,10 @@
|
||||||
* Address offset in memory
|
* Address offset in memory
|
||||||
*/
|
*/
|
||||||
#define BACKLOG_ADDRESS 0
|
#define BACKLOG_ADDRESS 0
|
||||||
|
/**
|
||||||
|
* Defines the number of backlogs that should be valid before we start replaying
|
||||||
|
*/
|
||||||
|
#define BACKLOG_REPLAY_THRESHOLD 24 /* One day */
|
||||||
|
|
||||||
void record_backlog(tracker_datapoint* dp);
|
void record_backlog(tracker_datapoint* dp);
|
||||||
struct tracker_datapoint* get_backlog(void);
|
struct tracker_datapoint* get_backlog(void);
|
||||||
|
|
|
@ -226,6 +226,23 @@ struct tracker_datapoint* read_check_backlog_item(uint16_t index)
|
||||||
|
|
||||||
return (struct tracker_datapoint*)buffer;
|
return (struct tracker_datapoint*)buffer;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns the number of backlogs indicated as valid in is_backlog_valid.
|
||||||
|
*
|
||||||
|
* Should correspond with the actual number of valid backlogs
|
||||||
|
*/
|
||||||
|
uint16_t is_backlog_valid_count(void)
|
||||||
|
{
|
||||||
|
uint16_t i, count = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < BACKLOG_COUNT; i++) {
|
||||||
|
if (is_backlog_valid[i] == BACKLOG_VALID_FLAG) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Gets a valid backlog item. Returns NULL if none available.
|
* Gets a valid backlog item. Returns NULL if none available.
|
||||||
*/
|
*/
|
||||||
|
@ -238,6 +255,11 @@ struct tracker_datapoint* get_backlog(void)
|
||||||
load_is_backlog_valid();
|
load_is_backlog_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return early if we haven't reached our replay threshold */
|
||||||
|
if (is_backlog_valid_count() < BACKLOG_REPLAY_THRESHOLD) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < BACKLOG_COUNT; i++) {
|
for (i = 0; i < BACKLOG_COUNT; i++) {
|
||||||
|
|
||||||
/* Find an read index we think is valid */
|
/* Find an read index we think is valid */
|
||||||
|
|
Ładowanie…
Reference in New Issue