-
Notifications
You must be signed in to change notification settings - Fork 163
/
RF24Network_config.h
162 lines (132 loc) · 5.65 KB
/
RF24Network_config.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
Copyright (C) 2011 James Coliz, Jr. <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
#ifndef __RF24NETWORK_CONFIG_H__
#define __RF24NETWORK_CONFIG_H__
/** @brief A reserved valid address for use with RF24Mesh (when a mesh node requests an assigned address) */
#ifndef NETWORK_DEFAULT_ADDRESS
#define NETWORK_DEFAULT_ADDRESS 04444
#endif // NETWORK_DEFAULT_ADDRESS
/** @brief A sentinel address value for multicasting purposes */
#define NETWORK_MULTICAST_ADDRESS 0100
/** @brief A sentinel value for internally indicating that the frame should be automatically routed as necessary */
#define NETWORK_AUTO_ROUTING 070
#ifdef DOXYGEN_FORCED
/**
* @brief Adds a delay to node prior to transmitting @ref NETWORK_ADDR_RESPONSE messages
*
* By default this is undefined for speed. This defined number of milliseconds is
* only applied to the master node when replying to a child trying to connect to the
* mesh network.
* @note It is advised to define this if any child node is running CircuitPython because
* the execution speed in pure python is inherently slower than it is in C++.
*/
#define SLOW_ADDR_POLL_RESPONSE 10
#endif // defined DOXYGEN_FORCED
/** The number of 'pipes' available for addressing in the current device
* Networks with NRF24L01 devices only have 6 pipes
* NRF52x networks support up to 8 pipes
*/
#define NUM_PIPES 6
#if !defined(__AVR_ATtiny85__) && !defined(__AVR_ATtiny84__)
/********** USER CONFIG - non ATTiny **************/
//#define ENABLE_SLEEP_MODE //AVR only
/** @brief When defined, this will allow the use of multicasting messages */
#define RF24NetworkMulticast
/* Saves memory by disabling fragmentation */
//#define DISABLE_FRAGMENTATION
/* System defines */
/**
* @brief Maximum size of fragmented network frames and fragmentation cache.
* @note This buffer can now be any size > 24. Previously this needed to be a multiple of 24 (changed in v1.0.15).
* @note If used with RF24Ethernet, this value is used to set the buffer sizes.
* @note For nodes driven by an ATTiny based chip, this is set to 72. However, defining `DISABLE_FRAGMENTION` truncates
* the actual transmitted payload to 24 bytes (which is also the default behavior on ATTiny devices).
*/
#ifndef MAX_PAYLOAD_SIZE
#if defined linux || defined __linux
#define MAX_PAYLOAD_SIZE 1514
#else
#define MAX_PAYLOAD_SIZE 144
#endif
#endif // MAX_PAYLOAD_SIZE
/**
* @brief The allocated size of the incoming frame buffer.
*
* This is the user-cache, where incoming data is stored.
* Data is stored using Frames: Header (8 bytes) + Message_Size (2 bytes) + Message_Data (? bytes)
* @note Over-The-Air (OTA) transmissions don't include the message size in the transmitted packet.
*/
#define MAIN_BUFFER_SIZE (MAX_PAYLOAD_SIZE + FRAME_HEADER_SIZE)
/* Disable user payloads. Saves memory when used with RF24Ethernet or software that uses external data.*/
//#define DISABLE_USER_PAYLOADS
/* Enable tracking of success and failures for all transmissions, routed and user initiated */
//#define ENABLE_NETWORK_STATS
#ifndef DISABLE_DYNAMIC_PAYLOADS
/** Enable dynamic payloads - If using different types of nRF24L01 modules, some may be incompatible when using this feature **/
#define ENABLE_DYNAMIC_PAYLOADS
#endif // DISABLE_DYNAMIC_PAYLOADS
/* Debug Options */
//#define RF24NETWORK_DEBUG
//#define RF24NETWORK_DEBUG_MINIMAL
//#define RF24NETWORK_DEBUG_ROUTING
//#define RF24NETWORK_DEBUG_FRAGMENTATION
//#define RF24NETWORK_DEBUG_FRAGMENTATION_L2
/*************************************/
#else // Different set of defaults for ATTiny - fragmentation is disabled and user payloads are set to 3 max
/********** USER CONFIG - ATTiny **************/
//#define ENABLE_SLEEP_MODE //AVR only
#define RF24NetworkMulticast
// NOTE: Only 24 bytes of a payload are used when DISABLE_FRAGMENTATION is defined
#define MAX_PAYLOAD_SIZE 72
#define MAIN_BUFFER_SIZE (MAX_PAYLOAD_SIZE + FRAME_HEADER_SIZE)
#define DISABLE_FRAGMENTATION
#define ENABLE_DYNAMIC_PAYLOADS
//#define DISABLE_USER_PAYLOADS
#endif
/*************************************/
#endif // RF24_NETWORK_CONFIG_H
#ifdef __cplusplus
#if (defined(__linux) || defined(linux)) && !defined(__ARDUINO_X86__) && !defined(USE_RF24_LIB_SRC)
#include <RF24/RF24_config.h>
// ATXMega
#elif defined(XMEGA)
#include "../../rf24lib/rf24lib/RF24_config.h"
#else
#include <RF24_config.h>
#endif
#if !defined(ARDUINO_ARCH_AVR)
// sprintf is used by RF24NetworkHeader::toString
#ifndef sprintf_P
#define sprintf_P sprintf
#endif
#endif
#ifdef RF24NETWORK_DEBUG
#define IF_RF24NETWORK_DEBUG(x) ({ x; })
#else
#define IF_RF24NETWORK_DEBUG(x)
#endif
#if defined(RF24NETWORK_DEBUG_MINIMAL)
#define IF_RF24NETWORK_DEBUG_MINIMAL(x) ({ x; })
#else
#define IF_RF24NETWORK_DEBUG_MINIMAL(x)
#endif
#if defined(RF24NETWORK_DEBUG_FRAGMENTATION)
#define IF_RF24NETWORK_DEBUG_FRAGMENTATION(x) ({ x; })
#else
#define IF_RF24NETWORK_DEBUG_FRAGMENTATION(x)
#endif
#if defined(RF24NETWORK_DEBUG_FRAGMENTATION_L2)
#define IF_RF24NETWORK_DEBUG_FRAGMENTATION_L2(x) ({ x; })
#else
#define IF_RF24NETWORK_DEBUG_FRAGMENTATION_L2(x)
#endif
#if defined(RF24NETWORK_DEBUG_ROUTING)
#define IF_RF24NETWORK_DEBUG_ROUTING(x) ({ x; })
#else
#define IF_RF24NETWORK_DEBUG_ROUTING(x)
#endif
#endif // RF24_CONFIG_H