Zephyr Project API  3.2.0
A Scalable Open Source RTOS
wifi_mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
13#define ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
14
15#include <zephyr/net/net_mgmt.h>
16#include <zephyr/net/wifi.h>
17#include <zephyr/net/ethernet.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* Management part definitions */
24
25#define _NET_WIFI_LAYER NET_MGMT_LAYER_L2
26#define _NET_WIFI_CODE 0x156
27#define _NET_WIFI_BASE (NET_MGMT_IFACE_BIT | \
28 NET_MGMT_LAYER(_NET_WIFI_LAYER) | \
29 NET_MGMT_LAYER_CODE(_NET_WIFI_CODE))
30#define _NET_WIFI_EVENT (_NET_WIFI_BASE | NET_MGMT_EVENT_BIT)
31
39};
40
41#define NET_REQUEST_WIFI_SCAN \
42 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_SCAN)
43
45
46#define NET_REQUEST_WIFI_CONNECT \
47 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONNECT)
48
50
51#define NET_REQUEST_WIFI_DISCONNECT \
52 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_DISCONNECT)
53
55
56#define NET_REQUEST_WIFI_AP_ENABLE \
57 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_ENABLE)
58
60
61#define NET_REQUEST_WIFI_AP_DISABLE \
62 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_DISABLE)
63
65
66#define NET_REQUEST_WIFI_IFACE_STATUS \
67 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_IFACE_STATUS)
68
70
77};
78
79#define NET_EVENT_WIFI_SCAN_RESULT \
80 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_RESULT)
81
82#define NET_EVENT_WIFI_SCAN_DONE \
83 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_DONE)
84
85#define NET_EVENT_WIFI_CONNECT_RESULT \
86 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_CONNECT_RESULT)
87
88#define NET_EVENT_WIFI_DISCONNECT_RESULT \
89 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_DISCONNECT_RESULT)
90
91#define NET_EVENT_WIFI_IFACE_STATUS \
92 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_IFACE_STATUS)
93
94
95/* Each result is provided to the net_mgmt_event_callback
96 * via its info attribute (see net_mgmt.h)
97 */
101
107
110};
111
113 const uint8_t *ssid;
114 uint8_t ssid_length; /* Max 32 */
115
117 uint8_t psk_length; /* Min 8 - Max 64 */
118
119 uint8_t *sae_password; /* Optional with fallback to psk */
120 uint8_t sae_password_length; /* No length restrictions */
121
126 int timeout; /* SYS_FOREVER_MS for no timeout */
127};
128
131};
132
134 int state; /* enum wifi_iface_state */
135 unsigned int ssid_len;
139 unsigned int channel;
144 int rssi;
145};
146
147#include <zephyr/net/net_if.h>
148
149typedef void (*scan_result_cb_t)(struct net_if *iface, int status,
150 struct wifi_scan_result *entry);
151
159#ifdef CONFIG_WIFI_USE_NATIVE_NETWORKING
161#else
162 struct net_if_api wifi_iface;
163#endif
164
165 /* cb parameter is the cb that should be called for each
166 * result by the driver. The wifi mgmt part will take care of
167 * raising the necessary event etc...
168 */
169 int (*scan)(const struct device *dev, scan_result_cb_t cb);
170 int (*connect)(const struct device *dev,
171 struct wifi_connect_req_params *params);
172 int (*disconnect)(const struct device *dev);
173 int (*ap_enable)(const struct device *dev,
174 struct wifi_connect_req_params *params);
175 int (*ap_disable)(const struct device *dev);
176 int (*iface_status)(const struct device *dev, struct wifi_iface_status *status);
177#ifdef CONFIG_NET_STATISTICS_WIFI
178 int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats);
179#endif /* CONFIG_NET_STATISTICS_WIFI */
180};
181
182/* Make sure that the network interface API is properly setup inside
183 * Wifi mgmt offload API struct (it is the first one).
184 */
185BUILD_ASSERT(offsetof(struct net_wifi_mgmt_offload, wifi_iface) == 0);
186
187void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status);
188void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status);
190 struct wifi_iface_status *iface_status);
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_ */
Ethernet.
#define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request)
Definition: net_mgmt.h:95
Public API for network interface.
Network Management API public header.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__INT8_TYPE__ int8_t
Definition: stdint.h:72
Runtime device structure (in ROM) per driver instance.
Definition: device.h:435
Definition: ethernet.h:404
Network Interface structure.
Definition: net_if.h:480
All Wi-Fi specific statistics.
Definition: net_stats.h:489
Definition: wifi_mgmt.h:152
struct net_if_api wifi_iface
Definition: wifi_mgmt.h:162
int(* scan)(const struct device *dev, scan_result_cb_t cb)
Definition: wifi_mgmt.h:169
int(* disconnect)(const struct device *dev)
Definition: wifi_mgmt.h:172
int(* ap_disable)(const struct device *dev)
Definition: wifi_mgmt.h:175
int(* ap_enable)(const struct device *dev, struct wifi_connect_req_params *params)
Definition: wifi_mgmt.h:173
int(* connect)(const struct device *dev, struct wifi_connect_req_params *params)
Definition: wifi_mgmt.h:170
int(* iface_status)(const struct device *dev, struct wifi_iface_status *status)
Definition: wifi_mgmt.h:176
Definition: wifi_mgmt.h:112
enum wifi_security_type security
Definition: wifi_mgmt.h:124
uint8_t * psk
Definition: wifi_mgmt.h:116
uint8_t channel
Definition: wifi_mgmt.h:123
uint8_t ssid_length
Definition: wifi_mgmt.h:114
int timeout
Definition: wifi_mgmt.h:126
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:125
uint8_t sae_password_length
Definition: wifi_mgmt.h:120
uint8_t band
Definition: wifi_mgmt.h:122
uint8_t * sae_password
Definition: wifi_mgmt.h:119
uint8_t psk_length
Definition: wifi_mgmt.h:117
const uint8_t * ssid
Definition: wifi_mgmt.h:113
Definition: wifi_mgmt.h:133
char ssid[WIFI_SSID_MAX_LEN]
Definition: wifi_mgmt.h:136
int rssi
Definition: wifi_mgmt.h:144
char bssid[WIFI_MAC_ADDR_LEN]
Definition: wifi_mgmt.h:137
enum wifi_security_type security
Definition: wifi_mgmt.h:142
unsigned int channel
Definition: wifi_mgmt.h:139
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:143
int state
Definition: wifi_mgmt.h:134
enum wifi_iface_mode iface_mode
Definition: wifi_mgmt.h:140
unsigned int ssid_len
Definition: wifi_mgmt.h:135
enum wifi_frequency_bands band
Definition: wifi_mgmt.h:138
enum wifi_link_mode link_mode
Definition: wifi_mgmt.h:141
Definition: wifi_mgmt.h:98
uint8_t ssid_length
Definition: wifi_mgmt.h:100
uint8_t band
Definition: wifi_mgmt.h:102
uint8_t mac[WIFI_MAC_ADDR_LEN]
Definition: wifi_mgmt.h:108
int8_t rssi
Definition: wifi_mgmt.h:106
uint8_t mac_length
Definition: wifi_mgmt.h:109
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:105
uint8_t channel
Definition: wifi_mgmt.h:103
uint8_t ssid[WIFI_SSID_MAX_LEN]
Definition: wifi_mgmt.h:99
enum wifi_security_type security
Definition: wifi_mgmt.h:104
Definition: wifi_mgmt.h:129
int status
Definition: wifi_mgmt.h:130
General WiFi Definitions.
wifi_frequency_bands
Definition: wifi.h:78
wifi_mfp_options
Definition: wifi.h:50
#define WIFI_MAC_ADDR_LEN
Definition: wifi.h:108
wifi_iface_mode
Definition: wifi.h:164
wifi_link_mode
Definition: wifi.h:202
#define WIFI_SSID_MAX_LEN
Definition: wifi.h:106
wifi_security_type
Definition: wifi.h:18
void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status)
#define NET_REQUEST_WIFI_SCAN
Definition: wifi_mgmt.h:41
void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status)
#define NET_REQUEST_WIFI_IFACE_STATUS
Definition: wifi_mgmt.h:66
#define NET_REQUEST_WIFI_AP_ENABLE
Definition: wifi_mgmt.h:56
void wifi_mgmt_raise_iface_status_event(struct net_if *iface, struct wifi_iface_status *iface_status)
#define NET_REQUEST_WIFI_DISCONNECT
Definition: wifi_mgmt.h:51
net_request_wifi_cmd
Definition: wifi_mgmt.h:32
@ NET_REQUEST_WIFI_CMD_AP_ENABLE
Definition: wifi_mgmt.h:36
@ NET_REQUEST_WIFI_CMD_SCAN
Definition: wifi_mgmt.h:33
@ NET_REQUEST_WIFI_CMD_IFACE_STATUS
Definition: wifi_mgmt.h:38
@ NET_REQUEST_WIFI_CMD_AP_DISABLE
Definition: wifi_mgmt.h:37
@ NET_REQUEST_WIFI_CMD_CONNECT
Definition: wifi_mgmt.h:34
@ NET_REQUEST_WIFI_CMD_DISCONNECT
Definition: wifi_mgmt.h:35
#define NET_REQUEST_WIFI_CONNECT
Definition: wifi_mgmt.h:46
net_event_wifi_cmd
Definition: wifi_mgmt.h:71
@ NET_EVENT_WIFI_CMD_SCAN_RESULT
Definition: wifi_mgmt.h:72
@ NET_EVENT_WIFI_CMD_DISCONNECT_RESULT
Definition: wifi_mgmt.h:75
@ NET_EVENT_WIFI_CMD_SCAN_DONE
Definition: wifi_mgmt.h:73
@ NET_EVENT_WIFI_CMD_IFACE_STATUS
Definition: wifi_mgmt.h:76
@ NET_EVENT_WIFI_CMD_CONNECT_RESULT
Definition: wifi_mgmt.h:74
void(* scan_result_cb_t)(struct net_if *iface, int status, struct wifi_scan_result *entry)
Definition: wifi_mgmt.h:149
#define NET_REQUEST_WIFI_AP_DISABLE
Definition: wifi_mgmt.h:61