added heartbeat cpp + h, needs functionality

This commit is contained in:
Starystars67
2020-02-04 17:29:04 +00:00
parent 996d96639c
commit 3ba8e55e59
4 changed files with 51 additions and 1 deletions

36
src/heartbeat.cpp Normal file
View File

@@ -0,0 +1,36 @@
//
// Created by Mitch on 04/02/2020.
//
#include "heartbeat.h"
#include <stdio.h>
#include <time.h>
const int NUM_SECONDS = 10;
void HeartbeatInit()
{
/// Make initial connection to backend services to get UUID, then call Heartbeat()
}
void Heartbeat()
{
double time_counter = 0;
clock_t this_time = clock();
clock_t last_time = this_time;
while(true)
{
this_time = clock();
time_counter += (double)(this_time - last_time);
last_time = this_time;
if(time_counter > (double)(NUM_SECONDS * CLOCKS_PER_SEC))
{
time_counter -= (double)(NUM_SECONDS * CLOCKS_PER_SEC);
}
}
}