1 /*
2  *  Copyright (c) 2019, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file includes compile-time configurations for Channel Manager.
32  */
33 
34 #ifndef CONFIG_CHANNEL_MANAGER_H_
35 #define CONFIG_CHANNEL_MANAGER_H_
36 
37 /**
38  * @addtogroup config-channel-manager
39  *
40  * @brief
41  *   This module includes configuration variables for Channel Manager.
42  *
43  * @{
44  */
45 
46 /**
47  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE
48  *
49  * Define as 1 to enable Channel Manager support.
50  */
51 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE
52 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 0
53 #endif
54 
55 /**
56  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE
57  *
58  * Define as 1 to enable Channel Manager support for selecting CSL channels.
59  *
60  * `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE` must be enabled in addition.
61  */
62 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE
63 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE 0
64 #endif
65 
66 /**
67  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_DELAY
68  *
69  * The minimum delay (in seconds) used by Channel Manager module for performing a channel change.
70  *
71  * The minimum delay should preferably be longer than maximum data poll interval used by all sleepy-end-devices within
72  * the Thread network.
73  *
74  * Applicable only if Channel Manager feature is enabled (i.e., `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is set).
75  */
76 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_DELAY
77 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_DELAY 120
78 #endif
79 
80 /**
81  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_MONITOR_SAMPLE_COUNT
82  *
83  * The minimum number of RSSI samples per channel by Channel Monitoring feature before the collected data can be used
84  * by the Channel Manager module to (auto) select a better channel.
85  *
86  * Applicable only if Channel Manager and Channel Monitoring features are both enabled (i.e.,
87  * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are set).
88  */
89 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_MONITOR_SAMPLE_COUNT
90 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_MONITOR_SAMPLE_COUNT 500
91 #endif
92 
93 /**
94  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_SKIP_FAVORED
95  *
96  * This threshold specifies the minimum occupancy rate difference between two channels for the Channel Manager to
97  * prefer an unfavored channel over the best favored one. This is used when (auto) selecting a channel based on the
98  * collected channel quality data by "channel monitor" feature.
99  *
100  * The difference is based on the `ChannelMonitor::GetChannelOccupancy()` definition which provides the average
101  * percentage of RSSI samples (within a time window) indicating that channel was busy (i.e., RSSI value higher than
102  * a threshold). Value 0 maps to 0% and 0xffff maps to 100%.
103  *
104  * Applicable only if Channel Manager feature is enabled (i.e., `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is set).
105  */
106 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_SKIP_FAVORED
107 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_SKIP_FAVORED (0xffff * 7 / 100)
108 #endif
109 
110 /**
111  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_CHANGE_CHANNEL
112  *
113  * This threshold specifies the minimum occupancy rate difference required between the current channel and a newly
114  * selected channel for Channel Manager to allow channel change to the new channel.
115  *
116  * The difference is based on the `ChannelMonitor::GetChannelOccupancy()` definition which provides the average
117  * percentage of RSSI samples (within a time window) indicating that channel was busy (i.e., RSSI value higher than
118  * a threshold). Value 0 maps to 0% rate and 0xffff maps to 100%.
119  *
120  * Applicable only if Channel Manager feature is enabled (i.e., `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is set).
121  */
122 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_CHANGE_CHANNEL
123 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_THRESHOLD_TO_CHANGE_CHANNEL (0xffff * 10 / 100)
124 #endif
125 
126 /**
127  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_DEFAULT_AUTO_SELECT_INTERVAL
128  *
129  * The default time interval (in seconds) used by Channel Manager for auto-channel-selection functionality.
130  *
131  * Applicable only if Channel Manager feature is enabled (i.e., `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is set).
132  */
133 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_DEFAULT_AUTO_SELECT_INTERVAL
134 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_DEFAULT_AUTO_SELECT_INTERVAL (3 * 60 * 60)
135 #endif
136 
137 /**
138  * @def OPENTHREAD_CONFIG_CHANNEL_MANAGER_CCA_FAILURE_THRESHOLD
139  *
140  * Default minimum CCA failure rate threshold on current channel before Channel Manager starts channel selection
141  * attempt.
142  *
143  * Value 0 maps to 0% and 0xffff maps to 100%.
144  *
145  * Applicable only if Channel Manager feature is enabled (i.e., `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is set).
146  */
147 #ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_CCA_FAILURE_THRESHOLD
148 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_CCA_FAILURE_THRESHOLD (0xffff * 14 / 100)
149 #endif
150 
151 /**
152  * @}
153  */
154 
155 #endif // CONFIG_CHANNEL_MANAGER_H_
156