MySensors Library & Examples
2.3.2-62-ge298769
examples
PingPongSensor
MYSLog.h
1
/*
2
* The MySensors Arduino library handles the wireless radio link and protocol
3
* between your home built sensors/actuators and HA controller of choice.
4
* The sensors forms a self healing radio network with optional repeaters. Each
5
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
6
* network topology allowing messages to be routed to nodes.
7
*
8
* Created by Henrik Ekblad <
[email protected]
>
9
* Copyright (C) 2013-2022 Sensnology AB
10
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11
*
12
* Documentation: http://www.mysensors.org
13
* Support Forum: http://forum.mysensors.org
14
*
15
* This program is free software; you can redistribute it and/or
16
* modify it under the terms of the GNU General Public License
17
* version 2 as published by the Free Software Foundation.
18
*
19
*******************************
20
*
21
* Formatted logging to the Serial console.
22
* Compiled in by setting LOGDEBUG
23
*
24
* 2015-05-25 Bruce Lacey V1.0
25
*
26
* Based upon Arduino Playground prior art and should be moved to
27
* the MySensors library at some point as a common debug logging facility
28
*/
29
#ifndef MYSLog_h
30
#define MYSLog_h
31
32
#define LOGDEBUG 1
33
34
#if defined ( LOGDEBUG )
35
#define LOG(fmt, args... ) debugLog( fmt, ## args );
36
#else
37
#define LOG(fmt, args... )
38
#endif
39
40
void
debugLog(
const
char
*fmt, ... )
41
{
42
char
buff[128];
43
va_list args;
44
va_start (args, fmt);
45
vsnprintf(buff,
sizeof
(buff), fmt, args);
46
va_end (args);
47
buff[
sizeof
(buff)/
sizeof
(buff[0])-1]=
'\0'
;
48
Serial.print(buff);
49
}
50
51
void
debugLog(
const
__FlashStringHelper *fmt, ... )
52
{
53
char
buf[128];
// resulting string limited to 128 chars
54
va_list args;
55
va_start (args, fmt);
56
#ifdef __AVR__
57
vsnprintf_P(buf,
sizeof
(buf), (
const
char
*)fmt, args);
// progmem for AVR
58
#else
59
vsnprintf(buf,
sizeof
(buf), (
const
char
*)fmt, args);
// for the rest of the world
60
#endif
61
va_end(args);
62
Serial.print(buf);
63
}
64
65
#endif
Copyright (C) 2013-2019 Sensnology AB. Generated by
doxygen
1.8.17