Skip to content

Commit 1db9974

Browse files
kapbhnordicjm
authored andcommitted
[nrf fromtree] net: l2: wifi: Change arrays to functions
The header file contains mixture of functions and static arrays. Replacing static arrays to functions. Initialize functions in C file. Signed-off-by: Kapil Bhatt <[email protected]> (cherry picked from commit 4b9f5cc)
1 parent 9f94dc7 commit 1db9974

File tree

2 files changed

+256
-189
lines changed

2 files changed

+256
-189
lines changed

include/zephyr/net/wifi.h

Lines changed: 18 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,7 @@ enum wifi_security_type {
5252
};
5353

5454
/** Helper function to get user-friendly security type name. */
55-
static inline const char *wifi_security_txt(enum wifi_security_type security)
56-
{
57-
switch (security) {
58-
case WIFI_SECURITY_TYPE_NONE:
59-
return "OPEN";
60-
case WIFI_SECURITY_TYPE_WEP:
61-
return "WEP";
62-
case WIFI_SECURITY_TYPE_WPA_PSK:
63-
return "WPA-PSK";
64-
case WIFI_SECURITY_TYPE_PSK:
65-
return "WPA2-PSK";
66-
case WIFI_SECURITY_TYPE_PSK_SHA256:
67-
return "WPA2-PSK-SHA256";
68-
case WIFI_SECURITY_TYPE_SAE:
69-
return "WPA3-SAE";
70-
case WIFI_SECURITY_TYPE_WAPI:
71-
return "WAPI";
72-
case WIFI_SECURITY_TYPE_EAP:
73-
return "EAP";
74-
case WIFI_SECURITY_TYPE_UNKNOWN:
75-
default:
76-
return "UNKNOWN";
77-
}
78-
}
55+
const char * const wifi_security_txt(enum wifi_security_type security);
7956

8057
/** IEEE 802.11w - Management frame protection. */
8158
enum wifi_mfp_options {
@@ -92,20 +69,7 @@ enum wifi_mfp_options {
9269
};
9370

9471
/** Helper function to get user-friendly MFP name.*/
95-
static inline const char *wifi_mfp_txt(enum wifi_mfp_options mfp)
96-
{
97-
switch (mfp) {
98-
case WIFI_MFP_DISABLE:
99-
return "Disable";
100-
case WIFI_MFP_OPTIONAL:
101-
return "Optional";
102-
case WIFI_MFP_REQUIRED:
103-
return "Required";
104-
case WIFI_MFP_UNKNOWN:
105-
default:
106-
return "UNKNOWN";
107-
}
108-
}
72+
const char * const wifi_mfp_txt(enum wifi_mfp_options mfp);
10973

11074
/**
11175
* @brief IEEE 802.11 operational frequency bands (not exhaustive).
@@ -127,20 +91,7 @@ enum wifi_frequency_bands {
12791
};
12892

12993
/** Helper function to get user-friendly frequency band name. */
130-
static inline const char *wifi_band_txt(enum wifi_frequency_bands band)
131-
{
132-
switch (band) {
133-
case WIFI_FREQ_BAND_2_4_GHZ:
134-
return "2.4GHz";
135-
case WIFI_FREQ_BAND_5_GHZ:
136-
return "5GHz";
137-
case WIFI_FREQ_BAND_6_GHZ:
138-
return "6GHz";
139-
case WIFI_FREQ_BAND_UNKNOWN:
140-
default:
141-
return "UNKNOWN";
142-
}
143-
}
94+
const char * const wifi_band_txt(enum wifi_frequency_bands band);
14495

14596
#define WIFI_SSID_MAX_LEN 32
14697
#define WIFI_PSK_MAX_LEN 64
@@ -182,34 +133,7 @@ enum wifi_iface_state {
182133
};
183134

184135
/** Helper function to get user-friendly interface state name. */
185-
static inline const char *wifi_state_txt(enum wifi_iface_state state)
186-
{
187-
switch (state) {
188-
case WIFI_STATE_DISCONNECTED:
189-
return "DISCONNECTED";
190-
case WIFI_STATE_INACTIVE:
191-
return "INACTIVE";
192-
case WIFI_STATE_INTERFACE_DISABLED:
193-
return "INTERFACE_DISABLED";
194-
case WIFI_STATE_SCANNING:
195-
return "SCANNING";
196-
case WIFI_STATE_AUTHENTICATING:
197-
return "AUTHENTICATING";
198-
case WIFI_STATE_ASSOCIATING:
199-
return "ASSOCIATING";
200-
case WIFI_STATE_ASSOCIATED:
201-
return "ASSOCIATED";
202-
case WIFI_STATE_4WAY_HANDSHAKE:
203-
return "4WAY_HANDSHAKE";
204-
case WIFI_STATE_GROUP_HANDSHAKE:
205-
return "GROUP_HANDSHAKE";
206-
case WIFI_STATE_COMPLETED:
207-
return "COMPLETED";
208-
case WIFI_STATE_UNKNOWN:
209-
default:
210-
return "UNKNOWN";
211-
}
212-
}
136+
const char * const wifi_state_txt(enum wifi_iface_state state);
213137

214138
/** Wi-Fi interface modes.
215139
*
@@ -235,26 +159,7 @@ enum wifi_iface_mode {
235159
};
236160

237161
/** Helper function to get user-friendly interface mode name. */
238-
static inline const char *wifi_mode_txt(enum wifi_iface_mode mode)
239-
{
240-
switch (mode) {
241-
case WIFI_MODE_INFRA:
242-
return "STATION";
243-
case WIFI_MODE_IBSS:
244-
return "ADHOC";
245-
case WIFI_MODE_AP:
246-
return "ACCESS POINT";
247-
case WIFI_MODE_P2P_GO:
248-
return "P2P GROUP OWNER";
249-
case WIFI_MODE_P2P_GROUP_FORMATION:
250-
return "P2P GROUP FORMATION";
251-
case WIFI_MODE_MESH:
252-
return "MESH";
253-
case WIFI_MODE_UNKNOWN:
254-
default:
255-
return "UNKNOWN";
256-
}
257-
}
162+
const char * const wifi_mode_txt(enum wifi_iface_mode mode);
258163

259164
/** Wi-Fi link operating modes
260165
*
@@ -286,32 +191,7 @@ enum wifi_link_mode {
286191
};
287192

288193
/** Helper function to get user-friendly link mode name. */
289-
static inline const char *wifi_link_mode_txt(enum wifi_link_mode link_mode)
290-
{
291-
switch (link_mode) {
292-
case WIFI_0:
293-
return "WIFI 0 (802.11)";
294-
case WIFI_1:
295-
return "WIFI 1 (802.11b)";
296-
case WIFI_2:
297-
return "WIFI 2 (802.11a)";
298-
case WIFI_3:
299-
return "WIFI 3 (802.11g)";
300-
case WIFI_4:
301-
return "WIFI 4 (802.11n/HT)";
302-
case WIFI_5:
303-
return "WIFI 5 (802.11ac/VHT)";
304-
case WIFI_6:
305-
return "WIFI 6 (802.11ax/HE)";
306-
case WIFI_6E:
307-
return "WIFI 6E (802.11ax 6GHz/HE)";
308-
case WIFI_7:
309-
return "WIFI 7 (802.11be/EHT)";
310-
case WIFI_LINK_MODE_UNKNOWN:
311-
default:
312-
return "UNKNOWN";
313-
}
314-
}
194+
const char * const wifi_link_mode_txt(enum wifi_link_mode link_mode);
315195

316196
/** Wi-Fi scanning types. */
317197
enum wifi_scan_type {
@@ -329,12 +209,8 @@ enum wifi_ps {
329209
WIFI_PS_ENABLED,
330210
};
331211

332-
/** @cond INTERNAL_HIDDEN */
333-
static const char * const wifi_ps2str[] = {
334-
[WIFI_PS_DISABLED] = "Power save disabled",
335-
[WIFI_PS_ENABLED] = "Power save enabled",
336-
};
337-
/** @endcond */
212+
/** Helper function to get user-friendly ps name. */
213+
const char * const wifi_ps_txt(enum wifi_ps ps_name);
338214

339215
/** Wi-Fi power save modes. */
340216
enum wifi_ps_mode {
@@ -347,12 +223,8 @@ enum wifi_ps_mode {
347223
WIFI_PS_MODE_WMM,
348224
};
349225

350-
/** @cond INTERNAL_HIDDEN */
351-
static const char * const wifi_ps_mode2str[] = {
352-
[WIFI_PS_MODE_LEGACY] = "Legacy power save",
353-
[WIFI_PS_MODE_WMM] = "WMM power save",
354-
};
355-
/** @endcond */
226+
/** Helper function to get user-friendly ps mode name. */
227+
const char * const wifi_ps_mode_txt(enum wifi_ps_mode ps_mode);
356228

357229
/* Interface index Min and Max values */
358230
#define WIFI_INTERFACE_INDEX_MIN 1
@@ -394,12 +266,8 @@ enum wifi_twt_operation {
394266
WIFI_TWT_TEARDOWN,
395267
};
396268

397-
/** @cond INTERNAL_HIDDEN */
398-
static const char * const wifi_twt_operation2str[] = {
399-
[WIFI_TWT_SETUP] = "TWT setup",
400-
[WIFI_TWT_TEARDOWN] = "TWT teardown",
401-
};
402-
/** @endcond */
269+
/** Helper function to get user-friendly twt operation name. */
270+
const char * const wifi_twt_operation_txt(enum wifi_twt_operation twt_operation);
403271

404272
/** Wi-Fi Target Wake Time (TWT) negotiation types. */
405273
enum wifi_twt_negotiation_type {
@@ -411,13 +279,8 @@ enum wifi_twt_negotiation_type {
411279
WIFI_TWT_WAKE_TBTT
412280
};
413281

414-
/** @cond INTERNAL_HIDDEN */
415-
static const char * const wifi_twt_negotiation_type2str[] = {
416-
[WIFI_TWT_INDIVIDUAL] = "TWT individual negotiation",
417-
[WIFI_TWT_BROADCAST] = "TWT broadcast negotiation",
418-
[WIFI_TWT_WAKE_TBTT] = "TWT wake TBTT negotiation",
419-
};
420-
/** @endcond */
282+
/** Helper function to get user-friendly twt negotiation type name. */
283+
const char * const wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation);
421284

422285
/** Wi-Fi Target Wake Time (TWT) setup commands. */
423286
enum wifi_twt_setup_cmd {
@@ -439,18 +302,8 @@ enum wifi_twt_setup_cmd {
439302
WIFI_TWT_SETUP_CMD_REJECT,
440303
};
441304

442-
/** @cond INTERNAL_HIDDEN */
443-
static const char * const wifi_twt_setup_cmd2str[] = {
444-
[WIFI_TWT_SETUP_CMD_REQUEST] = "TWT request",
445-
[WIFI_TWT_SETUP_CMD_SUGGEST] = "TWT suggest",
446-
[WIFI_TWT_SETUP_CMD_DEMAND] = "TWT demand",
447-
[WIFI_TWT_SETUP_CMD_GROUPING] = "TWT grouping",
448-
[WIFI_TWT_SETUP_CMD_ACCEPT] = "TWT accept",
449-
[WIFI_TWT_SETUP_CMD_ALTERNATE] = "TWT alternate",
450-
[WIFI_TWT_SETUP_CMD_DICTATE] = "TWT dictate",
451-
[WIFI_TWT_SETUP_CMD_REJECT] = "TWT reject",
452-
};
453-
/** @endcond */
305+
/** Helper function to get user-friendly twt setup cmd name. */
306+
const char * const wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup);
454307

455308
/** Wi-Fi Target Wake Time (TWT) negotiation status. */
456309
enum wifi_twt_setup_resp_status {
@@ -541,12 +394,8 @@ enum wifi_ps_wakeup_mode {
541394
WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL,
542395
};
543396

544-
/** @cond INTERNAL_HIDDEN */
545-
static const char * const wifi_ps_wakeup_mode2str[] = {
546-
[WIFI_PS_WAKEUP_MODE_DTIM] = "PS wakeup mode DTIM",
547-
[WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL] = "PS wakeup mode listen interval",
548-
};
549-
/** @endcond */
397+
/** Helper function to get user-friendly ps wakeup mode name. */
398+
const char * const wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode);
550399

551400
/** Wi-Fi power save error codes. */
552401
enum wifi_config_ps_param_fail_reason {

0 commit comments

Comments
 (0)