MySensors Library & Examples  2.3.2
LogOTANode.ino
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-2019 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  * DESCRIPTION
22  *
23  * Example for sending debug messages over the air (OTA).
24  *
25  */
26 
27 // Enable debug
28 #define MY_DEBUG
29 
30 // Enable OTA debugging to Node 0
31 #define MY_DEBUG_OTA (0)
32 
33 // Allow sending logs without MY_DEBUG_OTA enabled
34 #define MY_OTA_LOG_SENDER_FEATURE
35 
36 // Disable echoing of debug messages
37 //#define MY_DEBUG_OTA_DISABLE_ECHO
38 
39 // Enable and select radio type attached
40 #define MY_RADIO_RF24
41 //#define MY_RADIO_NRF5_ESB
42 //#define MY_RADIO_RFM69
43 //#define MY_RADIO_RFM95
44 
45 #include <MySensors.h>
46 
47 void setup()
48 {
49 }
50 
52 {
53  // Send the sketch version information to the gateway and Controller
54  sendSketchInfo("DebugSensor", "1.0");
55 }
56 
57 // Arduino loop
58 int c=0;
59 void loop()
60 {
61  // Wait some time
62  if (sleep(3000)==MY_SLEEP_NOT_POSSIBLE) {
63  delay(3000);
64  }
65 
66  // Count loops
67  c++;
68 
69  // A debug message
70  DEBUG_OUTPUT(PSTR("DEBUG\nc=%" PRId16 "\nmillis=%" PRId32 "\n"), c, hwMillis());
71 
72  // Send a log message to a node, requesting that the message is echoed back to this node
73  OTALog(0, true, PSTR("LOG\nc=%" PRId16 "\nmillis=%" PRId32 "\n"), c, hwMillis());
74 }
void OTALog(uint8_t logNode, bool echo, const char *fmt,...)
Send a log message to a node.
bool sendSketchInfo(const char *name, const char *version, const bool requestEcho=false)
API declaration for MySensors.
#define DEBUG_OUTPUT(x,...)
debug NULL
Definition: MyConfig.h:2157
void setup()
Called after node initialises but before main loop.
Definition: LogOTANode.ino:47
int8_t sleep(const uint32_t sleepingMS, const bool smartSleep=false)
void presentation()
Node presentation.
Definition: LogOTANode.ino:51
void loop()
Main loop.
Definition: LogOTANode.ino:59
#define MY_SLEEP_NOT_POSSIBLE
Sleeping not possible.
Definition: MySensorsCore.h:83