-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sys.cpp
66 lines (56 loc) · 990 Bytes
/
Sys.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Sys.cpp
*
* Created on: May 15, 2016
* Author: lieven
*/
#include <Arduino.h>
#include <Sys.h>
#include <Log.h>
/*
*
* ATTENTION : LOGF call Sys::hostname, could invoke another call to Sys::hostname with LOGF,....
*
*
*
*/
uint32_t Sys::getFreeHeap(){
return ESP.getFreeHeap();
}
char Sys::_hostname[30];
uint64_t Sys::_boot_time=0;
uint64_t Sys::millis()
{
return ::millis();
}
uint64_t Sys::now()
{
return _boot_time+Sys::millis();
}
void Sys::setNow(uint64_t n)
{
_boot_time = n-Sys::millis();
}
void Sys::hostname(const char* h)
{
strncpy(_hostname , h,strlen(h)+1);
}
void Sys::setHostname(const char* h)
{
strncpy(_hostname , h,strlen(h)+1);
}
void Sys::init(){
// sprintf(_hostname,"wibo_%X",ESP.getChipId());
}
const char* Sys::hostname()
{
return _hostname;
}
void Sys::delay(unsigned int delta)
{
uint32_t end = ::millis()+ delta;
while ( ::millis() < end );
}
extern "C" uint64_t SysMillis() {
return Sys::millis();
}