25#define EXAMPLE_SCAN_CHANNEL_START 1
26#define EXAMPLE_SCAN_CHANNEL_END 13
27#define EXAMPLE_SCAN_RESULT_SIZE 20
28#define EXAMPLE_SCAN_BLOCK_IS_ENABLE 1
30#if EXAMPLE_SCAN_BLOCK_IS_ENABLE
31# define EXAMPLE_SCAN_BLOCK true
33# define EXAMPLE_SCAN_BLOCK false
36#define EXAMPLE_WIFI_NTASK_PRIORITY 15
37#define EXAMPLE_WIFI_NTASK_PERIOD_MS 10
39#define TBL_IT(v) {v, XSTR(v)}
67static const char *
TAG =
"scan";
74#define ERROR_CHECK(expression) \
76 if (unlikely((expression) != XF_OK)) { \
77 XF_LOGE(TAG, "An error occurred: %s", XSTR(expression != XF_OK)); \
78 _error_check_failed(); \
116#if (!EXAMPLE_SCAN_BLOCK_IS_ENABLE)
123 XF_LOGI(
TAG,
"------------------------------");
126 XF_LOGI(
TAG,
"Channel %d scanning is complete. There are %d APs.",
144 XF_LOGI(
TAG,
"------------------------------");
193 for (i = 0; i < (
unsigned int)
ARRAY_SIZE(ex_auth_mode_msg_table); ++i) {
194 if (ex_auth_mode_msg_table[i].code == code) {
195 return ex_auth_mode_msg_table[i].
msg;
198 return ex_auth_mode_msg_table[
ARRAY_SIZE(ex_auth_mode_msg_table) - 1].
msg;
#define XF_NTASK_BEGIN(ntask)
#define xf_ntask_delay(delay_ms)
static xf_task_t xf_ttask_create_loop(xf_task_func_t func, void *func_arg, uint16_t priority, uint32_t delay_ms)
在默认的任务管理下,创建 ttask 循环任务。
#define ARRAY_SIZE(arr)
ARRAY_SIZE - 获取数组 arr 中的元素数量。
xf_err_t xf_wifi_scan_get_result(xf_wifi_ap_info_t result_array[], uint32_t result_array_size, uint32_t *p_result_num)
wifi 获取扫描结果。
xf_err_t xf_wifi_scan_start(const xf_wifi_scan_cfg_t *p_cfg, bool block)
wifi 启动 AP 扫描。
xf_err_t xf_wifi_scan_clear_result(void)
wifi 清除扫描结果。
xf_err_t xf_wifi_sta_set_cb(xf_wifi_cb_t cb_func, void *user_args)
wifi STA 设置回调函数.
xf_err_t xf_wifi_sta_init(const xf_wifi_sta_cfg_t *p_cfg)
启用 wifi STA 模式.
xf_err_t xf_wifi_enable(void)
启用 wifi 协议栈.
enum _xf_wifi_authenticate_mode_t xf_wifi_auth_mode_t
授权模式的强度。 OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA3_PSK = WPA2_WPA3_PSK
int32_t xf_wifi_event_id_t
wifi 事件 id。见 xf_wifi_event_code_t.
@ XF_WIFI_AUTH_WPA_WPA2_PSK
@ XF_WIFI_AUTH_ENTERPRISE
@ XF_WIFI_AUTH_WPA3_ENT_192
@ XF_WIFI_AUTH_WPA2_WPA3_PSK
@ XF_WIFI_EVENT_SCAN_DONE
uint8_t bssid[XF_MAC_LEN_MAX]
xf_wifi_auth_mode_t authmode
uint8_t ssid[XF_WIFI_SSID_LEN_MAX]
Parameters for an SSID scan.
xf_wifi_ap_info_t ap_info[EXAMPLE_SCAN_RESULT_SIZE]
uint8_t curr_scan_channel
static void task(xf_task_t task)
#define ERROR_CHECK(expression)
static void _error_check_failed(void)
#define EXAMPLE_WIFI_NTASK_PERIOD_MS
#define EXAMPLE_SCAN_CHANNEL_START
struct example_authenticate_mode_message_s ex_auth_mode_msg_t
static void _wifi_ntask(xf_task_t task)
#define EXAMPLE_WIFI_NTASK_PRIORITY
#define EXAMPLE_SCAN_CHANNEL_END
static void _wifi_sta_event_handler(xf_wifi_event_id_t event_id, void *event_data, void *user_args)
#define EXAMPLE_SCAN_BLOCK
static const char * ex_auth_mode_to_name(xf_wifi_auth_mode_t code)
struct example_scan_context_s ex_scan_ctx_t
static ex_scan_ctx_t * sp_ctx
#define EXAMPLE_SCAN_RESULT_SIZE
#define XF_LOGI(tag, format,...)