Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
csk_wifi.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5#pragma once
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define CSK_WIFI_SSID_LEN 32
12#define CSK_WIFI_BSSID_LEN 17
13#define CSK_WIFI_PWD_LEN 64
14
15#define CSK_WIFI_STATUS_STA_CONNECTED 0
16#define CSK_WIFI_STATUS_STA_DISCONNECTED 2
17#define CSK_WIFI_STATUS_STA_UNKNOWN 3
18
19/* TODO: Add WIFI state machine transition diagram */
20
24typedef enum {
25 CSK_WIFI_AUTH_OPEN = 0, /* Authenticate mode : open */
26 CSK_WIFI_AUTH_WEP, /* Authenticate mode : WEP */
27 CSK_WIFI_AUTH_WPA_PSK, /* Authenticate mode : WPA_PSK */
28 CSK_WIFI_AUTH_WPA2_PSK, /* Authenticate mode : WPA2_PSK */
29 CSK_WIFI_AUTH_WPA_WPA2_PSK, /* Authenticate mode : WPA_WPA2_PSK */
30 CSK_WIFI_AUTH_WPA2_ENTERPRISE, /* Authenticate mode : WPA2_ENTERPRISE */
31 CSK_WIFI_AUTH_WPA3_PSK, /* Authenticate mode : WPA3_PSK */
32 CSK_WIFI_AUTH_WPA2_WPA3_PSK, /* Authenticate mode : WPA2_WPA3_PSK */
33 CSK_WIFI_AUTH_MAX , /* Authenticate mode : WAPI_PSK */
35
39typedef enum {
40 CSK_WIFI_BW_HT20 = 0, /* Bandwidth is HT20(20M) */
41 CSK_WIFI_BW_HT40, /* Bandwidth is HT40(40M) */
43
47typedef struct {
48 char ssid[CSK_WIFI_SSID_LEN+1]; /* Target AP SSID */
49 char pwd[CSK_WIFI_PWD_LEN+1]; /* Target AP Password */
50 char bssid[CSK_WIFI_BSSID_LEN+1]; /* Target AP bssid (MAC address) */
51 uint8_t channel; /* Target AP channel */
52 int rssi; /* Target AP rssi */
53 csk_wifi_encryption_mode_t encryption_mode; /* Target AP encryption mode */
55
59typedef struct {
60 char ssid[CSK_WIFI_SSID_LEN+1]; /* WiFi SoftAP SSID */
61 char pwd[CSK_WIFI_PWD_LEN+1]; /* WiFi SoftAP Password */
62 csk_wifi_encryption_mode_t encryption_mode; /* WiFi SoftAP encryption mode */
63 csk_wifi_bandwidth_t bandwidth; /* WiFi SoftAP bandwidth */
64 uint8_t channel; /* WiFi SoftAP channel */
65 uint8_t max_connections; /* Maximum number of stations allowed to connect in */
66 bool ssid_hidden; /* SSID hidden */
68
72typedef struct {
73 char ssid[CSK_WIFI_SSID_LEN+1]; /* Neighboring AP SSID */
74 char bssid[CSK_WIFI_BSSID_LEN+1]; /* Neighboring AP BSSID */
75 int rssi; /* Neighboring AP rssi */
76 uint8_t channel; /* Neighboring AP channel */
77 csk_wifi_encryption_mode_t encryption_mode; /* Neighboring AP encryption mode */
79
83typedef enum {
84 CSK_WIFI_SUCCESS, /* WIFI operation successful */
85 CSK_WIFI_ERR_STA_FAILED, /* Unknown Station exception, will be raised in Station mode. TODO: remove it */
86 CSK_WIFI_ERR_AP_FAILED, /* Unknown SoftAP exception, will be raised in SoftAP mode. TODO: remove it */
87 CSK_WIFI_ERR_AP_NOT_FOUND, /* AP ssid not found, will be raised in Station mode */
88 CSK_WIFI_ERR_INVALID_PASSWORD, /* Invalid WIFI password, will be raised in Station mode */
89 CSK_WIFI_ERR_SCAN_FAILED, /* WiFi scan neighboring AP devices failed */
90} csk_wifi_result_t; /* WIFI API result type */
91
95typedef enum {
96 CSK_WIFI_EVT_STA_CONNECTED = BIT(0), /* WIFI-Station connected event bit */
97 CSK_WIFI_EVT_STA_DISCONNECTED = BIT(1), /* WIFI-Station disconnected event bit */
98 CSK_WIFI_EVT_AP_STARTED = BIT(2), /* WIFI-SoftAP stared event bit */
99 CSK_WIFI_EVT_AP_STOPPED = BIT(3), /* WIFI-SoftAP stopped event bit */
100 CSK_WIFI_EVT_AP_STACONNECTED = BIT(4), /* WIFI-SoftAP station connected event bit */
101 CSK_WIFI_EVT_AP_STADISCONNECTED = BIT(5), /* WIFI-SoftAP station disconnected event bit */
102 CSK_WIFI_EVT_SCAN_DONE = BIT(6), /* WIFI-SoftAP scan done event bit */
103 CSK_WIFI_EVT_STA_CONNECTING = BIT(7), /* WIFI-Station connecting event bit */
105
109typedef void(*wifi_event_cb_t) (csk_wifi_event_t event, void *event_data, uint32_t event_data_len, void *arg);
110
121typedef struct csk_wifi_event_cb {
127
132
137
142
147
151 void *arg;
153
159int csk_wifi_init(void);
160
166int csk_wifi_deinit(void);
167
176
186
202
203#ifdef CONFIG_CSK_WIFI_STATION
224int csk_wifi_sta_connect(csk_wifi_sta_config_t *sta_config, csk_wifi_result_t *result, k_timeout_t timeout);
225
245int csk_wifi_sta_disconnect(csk_wifi_result_t *result, k_timeout_t timeout);
246
252int csk_wifi_sta_get_status(void);
253
254#endif
255
256#ifdef CONFIG_CSK_WIFI_SOFTAP
273int csk_wifi_ap_start(const csk_wifi_softap_config_t *ap_config, csk_wifi_result_t *result, k_timeout_t timeout);
274
290int csk_wifi_ap_stop(csk_wifi_result_t *result, k_timeout_t timeout);
291#endif
292
293#ifdef __cplusplus
294}
295#endif
ZTEST_BMEM int timeout
Definition: main.c:31
int csk_wifi_remove_callback(csk_wifi_event_cb_t *wifi_event_cb)
Remove an wifi event callback.
Definition: csk_wifi_api_819s.c:55
struct csk_wifi_event_cb csk_wifi_event_cb_t
CSK WIFI callback structure.
int csk_wifi_scan_ap(csk_wifi_scan_info_t **ap_info, csk_wifi_result_t *result, k_timeout_t timeout)
Scan the neighboring AP device.
Definition: csk_wifi_api.c:53
int csk_wifi_deinit(void)
CSK WiFi driver deinitialize.
Definition: csk_wifi_api.c:48
int csk_wifi_add_callback(csk_wifi_event_cb_t *wifi_event_cb)
Add an wifi event callback.
Definition: csk_wifi_api.c:21
#define CSK_WIFI_BSSID_LEN
Definition: csk_wifi.h:12
#define CSK_WIFI_SSID_LEN
Definition: csk_wifi.h:11
void(* wifi_event_cb_t)(csk_wifi_event_t event, void *event_data, uint32_t event_data_len, void *arg)
Definition: csk_wifi.h:109
csk_wifi_event_t
CSK WiFi events structure.
Definition: csk_wifi.h:95
@ CSK_WIFI_EVT_AP_STOPPED
Definition: csk_wifi.h:99
@ CSK_WIFI_EVT_STA_DISCONNECTED
Definition: csk_wifi.h:97
@ CSK_WIFI_EVT_AP_STACONNECTED
Definition: csk_wifi.h:100
@ CSK_WIFI_EVT_AP_STARTED
Definition: csk_wifi.h:98
@ CSK_WIFI_EVT_STA_CONNECTED
Definition: csk_wifi.h:96
@ CSK_WIFI_EVT_AP_STADISCONNECTED
Definition: csk_wifi.h:101
@ CSK_WIFI_EVT_SCAN_DONE
Definition: csk_wifi.h:102
@ CSK_WIFI_EVT_STA_CONNECTING
Definition: csk_wifi.h:103
csk_wifi_bandwidth_t
CSK WiFi bandwidth mode.
Definition: csk_wifi.h:39
@ CSK_WIFI_BW_HT20
Definition: csk_wifi.h:40
@ CSK_WIFI_BW_HT40
Definition: csk_wifi.h:41
#define CSK_WIFI_PWD_LEN
Definition: csk_wifi.h:13
csk_wifi_encryption_mode_t
CSK WiFi encryption mode.
Definition: csk_wifi.h:24
@ CSK_WIFI_AUTH_WPA2_PSK
Definition: csk_wifi.h:28
@ CSK_WIFI_AUTH_WEP
Definition: csk_wifi.h:26
@ CSK_WIFI_AUTH_WPA_PSK
Definition: csk_wifi.h:27
@ CSK_WIFI_AUTH_WPA2_ENTERPRISE
Definition: csk_wifi.h:30
@ CSK_WIFI_AUTH_OPEN
Definition: csk_wifi.h:25
@ CSK_WIFI_AUTH_WPA_WPA2_PSK
Definition: csk_wifi.h:29
@ CSK_WIFI_AUTH_WPA3_PSK
Definition: csk_wifi.h:31
@ CSK_WIFI_AUTH_MAX
Definition: csk_wifi.h:33
@ CSK_WIFI_AUTH_WPA2_WPA3_PSK
Definition: csk_wifi.h:32
int csk_wifi_init(void)
CSK WiFi driver initialize.
Definition: csk_wifi_api.c:28
csk_wifi_result_t
CSK WiFi operation(API) results structure.
Definition: csk_wifi.h:83
@ CSK_WIFI_ERR_STA_FAILED
Definition: csk_wifi.h:85
@ CSK_WIFI_ERR_INVALID_PASSWORD
Definition: csk_wifi.h:88
@ CSK_WIFI_ERR_SCAN_FAILED
Definition: csk_wifi.h:89
@ CSK_WIFI_SUCCESS
Definition: csk_wifi.h:84
@ CSK_WIFI_ERR_AP_FAILED
Definition: csk_wifi.h:86
@ CSK_WIFI_ERR_AP_NOT_FOUND
Definition: csk_wifi.h:87
void
Definition: eswifi_shell.c:15
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
struct _snode sys_snode_t
Definition: slist.h:33
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
CSK WIFI callback structure.
Definition: csk_wifi.h:121
wifi_event_cb_t handler
Definition: csk_wifi.h:131
uint32_t event_data_len
Definition: csk_wifi.h:146
sys_snode_t node
Definition: csk_wifi.h:126
uint32_t events
Definition: csk_wifi.h:136
void * arg
Definition: csk_wifi.h:151
void * event_data
Definition: csk_wifi.h:141
CSK WiFi scan info type.
Definition: csk_wifi.h:72
csk_wifi_encryption_mode_t encryption_mode
Definition: csk_wifi.h:77
int rssi
Definition: csk_wifi.h:75
uint8_t channel
Definition: csk_wifi.h:76
CSK WiFi softap configuration struct.
Definition: csk_wifi.h:59
uint8_t channel
Definition: csk_wifi.h:64
csk_wifi_bandwidth_t bandwidth
Definition: csk_wifi.h:63
uint8_t max_connections
Definition: csk_wifi.h:65
bool ssid_hidden
Definition: csk_wifi.h:66
csk_wifi_encryption_mode_t encryption_mode
Definition: csk_wifi.h:62
CSK WiFi station configuration struct.
Definition: csk_wifi.h:47
csk_wifi_encryption_mode_t encryption_mode
Definition: csk_wifi.h:53
uint8_t channel
Definition: csk_wifi.h:51
int rssi
Definition: csk_wifi.h:52
Kernel timeout type.
Definition: sys_clock.h:65
Definition: errno.c:36