Skip to content

Commit 2f99379

Browse files
krish2718carlescufi
authored andcommitted
wifi: utils: Move channel helpers to public API
These can be used for channel validation outside the utils. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent c6f2152 commit 2f99379

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

include/zephyr/net/wifi_utils.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,49 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str,
103103
struct wifi_band_channel *chan,
104104
uint8_t max_channels);
105105

106+
107+
/**
108+
* @brief Validate a channel against a band.
109+
*
110+
* @param band Band to validate the channel against.
111+
* @param chan Channel to validate.
112+
*
113+
* @retval true if the channel is valid for the band.
114+
* @retval false if the channel is not valid for the band.
115+
*/
116+
bool wifi_utils_validate_chan(uint8_t band,
117+
uint16_t chan);
118+
119+
/**
120+
* @brief Validate a channel against the 2.4 GHz band.
121+
*
122+
* @param chan Channel to validate.
123+
*
124+
* @retval true if the channel is valid for the band.
125+
* @retval false if the channel is not valid for the band.
126+
*/
127+
bool wifi_utils_validate_chan_2g(uint16_t chan);
128+
129+
/**
130+
* @brief Validate a channel against the 5 GHz band.
131+
*
132+
* @param chan Channel to validate.
133+
*
134+
* @retval true if the channel is valid for the band.
135+
* @retval false if the channel is not valid for the band.
136+
*/
137+
bool wifi_utils_validate_chan_5g(uint16_t chan);
138+
139+
/**
140+
* @brief Validate a channel against the 6 GHz band.
141+
*
142+
* @param chan Channel to validate.
143+
*
144+
* @retval true if the channel is valid for the band.
145+
* @retval false if the channel is not valid for the band.
146+
*/
147+
bool wifi_utils_validate_chan_6g(uint16_t chan);
148+
106149
/**
107150
* @}
108151
*/

subsys/net/l2/wifi/wifi_utils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static enum wifi_frequency_bands wifi_utils_map_band_str_to_idx(char *band_str)
4444
}
4545

4646

47-
static bool wifi_utils_validate_chan_2g(uint16_t chan)
47+
bool wifi_utils_validate_chan_2g(uint16_t chan)
4848
{
4949
if ((chan >= 1) && (chan <= 14)) {
5050
return true;
@@ -54,7 +54,7 @@ static bool wifi_utils_validate_chan_2g(uint16_t chan)
5454
}
5555

5656

57-
static bool wifi_utils_validate_chan_5g(uint16_t chan)
57+
bool wifi_utils_validate_chan_5g(uint16_t chan)
5858
{
5959
uint16_t i;
6060

@@ -68,7 +68,7 @@ static bool wifi_utils_validate_chan_5g(uint16_t chan)
6868
}
6969

7070

71-
static bool wifi_utils_validate_chan_6g(uint16_t chan)
71+
bool wifi_utils_validate_chan_6g(uint16_t chan)
7272
{
7373
if (((chan >= 1) && (chan <= 233) && (!((chan - 1)%4))) ||
7474
(chan == 2)) {
@@ -79,7 +79,7 @@ static bool wifi_utils_validate_chan_6g(uint16_t chan)
7979
}
8080

8181

82-
static bool wifi_utils_validate_chan(uint8_t band,
82+
bool wifi_utils_validate_chan(uint8_t band,
8383
uint16_t chan)
8484
{
8585
bool result = false;

0 commit comments

Comments
 (0)