forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatform.h
More file actions
59 lines (49 loc) · 1.54 KB
/
Copy pathPlatform.h
File metadata and controls
59 lines (49 loc) · 1.54 KB
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
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2022
// MIT License
#ifndef AO_PLATFORM_H
#define AO_PLATFORM_H
#ifdef AO_CUSTOM_CONSOLE
#ifndef AO_CUSTOM_CONSOLE_MAXMSGSIZE
#define AO_CUSTOM_CONSOLE_MAXMSGSIZE 196
#endif
void ao_set_console_out(void (*console_out)(const char *msg));
namespace ArduinoOcpp {
void ao_console_out(const char *msg);
}
#define AO_CONSOLE_PRINTF(X, ...) \
do { \
char msg [AO_CUSTOM_CONSOLE_MAXMSGSIZE]; \
if (snprintf(msg, AO_CUSTOM_CONSOLE_MAXMSGSIZE, X, ##__VA_ARGS__) < 0) { \
sprintf(msg + AO_CUSTOM_CONSOLE_MAXMSGSIZE - 7, " [...]"); \
} \
ArduinoOcpp::ao_console_out(msg); \
} while (0)
#else
#define ao_set_console_out(X) \
do { \
X("[AO] CONSOLE ERROR: ao_set_console_out ignored if AO_CUSTOM_CONSOLE " \
"not defined\n"); \
char msg [100]; \
snprintf(msg, 100, " > see %s:%i",__FILE__,__LINE__); \
X(msg); \
X("\n > see ArduinoOcpp/Platform.h\n"); \
} while (0)
#endif
#ifndef AO_CONSOLE_PRINTF
//begin with Arduino support, add more later
#include <Arduino.h>
#ifndef AO_USE_SERIAL
#define AO_USE_SERIAL Serial
#endif
#define AO_CONSOLE_PRINTF(X, ...) AO_USE_SERIAL.printf_P(PSTR(X), ##__VA_ARGS__)
#endif
#ifndef ao_tick_ms
#include <Arduino.h>
#define ao_tick_ms millis
#endif
#ifndef ao_avail_heap
#include <Arduino.h>
#define ao_avail_heap ESP.getFreeHeap
#endif
#endif