Fix compilation errors for MQTT gateway
This commit is contained in:
@@ -51,6 +51,7 @@ char *ltoa(long value, char* result, int base);
|
||||
char *ultoa(long num, char *str, int radix);
|
||||
char *utoa(int num, char *str, int radix);
|
||||
char *dtostrf(float f, int width, int decimals, char *result);
|
||||
unsigned long millis(void);
|
||||
void delay(unsigned int millis);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user