Fix compilation errors for MQTT gateway

This commit is contained in:
Marcelo Aquino
2016-08-19 13:45:51 -03:00
parent b8d4a6a943
commit cb8c98431e
6 changed files with 53 additions and 63 deletions
+17
View File
@@ -1,7 +1,11 @@
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include "Arduino.h"
// For millis()
static unsigned long millis_at_start = 0;
/**
* C++ version 0.4 char* style "itoa":
* Written by Lukás Chmela
@@ -177,6 +181,19 @@ char *dtostrf(float f, int width, int decimals, char *result)
return result;
}
unsigned long millis(void)
{
timeval curTime;
if (millis_at_start == 0) {
gettimeofday(&curTime, NULL);
millis_at_start = curTime.tv_sec;
}
gettimeofday(&curTime, NULL);
return ((curTime.tv_sec - millis_at_start) * 1000) + (curTime.tv_usec / 1000);
}
void delay(unsigned int millis)
{
struct timespec sleeper;