⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wps_dish.c

📁 WiFi Protected Setup (WPS) 又叫Simple config。 是无线局域网领域推出的新协议
💻 C
字号:

#include "../wps/wps_userapi.h"
#include "../wps/wps_common.h"
#include "../common/metatype.h"
#include "../common/strlib.h"
#include "../common/memlib.h"
#include "../common/malloc.h"
#include "../dish/dish.h"


static void callback_fn(USER_CALLBACK_EVENT event)
{
	USER_WLAN_PARAM param;
	
	switch (event) {
		case USER_CALLBACK_EVENT_ERROR:
			d_printf("###USER_CALLBACK_EVENT: Error");
			break;
		case USER_CALLBACK_EVENT_OVERLAP:
			d_printf("###USER_CALLBACK_EVENT: Overlap");
			break;
		case USER_CALLBACK_EVENT_SUCCESS:
			d_printf("###USER_CALLBACK_EVENT: Success");
			if (wps_enrol_get_wlan_param(&param) != WPS_ERROR_SUCCESS) {
				d_printf("Get WLAN parameters failed.");
			}
			else {
				d_printf("Get WLAN parameters successfully.");
			}
			break;
		case USER_CALLBACK_EVENT_STOPPED:
			d_printf("###USER_CALLBACK_EVENT: Stopped");
			break;
		default:
			d_printf("###USER_CALLBACK_EVENT: ???");
			break;
	}
}

static int wps_dish_start_pin(char *cmdp)
{
	wps_enrol_set_mode(USER_WPS_PIN_MODE);
	wps_enrol_set_pin("37030742");
	wps_enrol_set_callback(callback_fn);
	if (wps_enrol_start() != WPS_ERROR_SUCCESS) {
		d_printf("Start failed.");
	}
	return 0;
}

static int wps_dish_start_pbc(char *cmdp)
{
	wps_enrol_set_mode(USER_WPS_PBC_MODE);
	wps_enrol_set_callback(callback_fn);
	if (wps_enrol_start() != WPS_ERROR_SUCCESS) {
		d_printf("Start failed.");
	}
	return 0;
}

static int wps_dish_stop(char *cmdp)
{
	if (wps_enrol_stop() != WPS_ERROR_SUCCESS) {
		d_printf("Stop failed.");
	}
	return 0;
}


static dish_cmdlink   wps_dish_cmdlink;
static dish_hlplink   wps_dish_hlplink;
static const char wps_dish_module_name[] = "WPS";
const dish_cmdtbl wps_dish_cmdtbl[] = {
	{"s_pin",                           wps_dish_start_pin},
	{"s_pbc",                           wps_dish_start_pbc},
	{"stop",                            wps_dish_stop},
	{NULL,                              NULL}
};
const dish_hlptbl wps_dish_hlptbl[] = {
	{"s_pin",                           "Start WPS process with PIN mode"},
	{"s_pbc",                           "Start WPS process with PBC mode"},
	{"stop",                            "Stop the WPS process"},
	{NULL,                              NULL}
};

void wps_dish_init(void)
{
	dish_addcmd(wps_dish_cmdtbl, &wps_dish_cmdlink);
	dish_addhlp(wps_dish_hlptbl, &wps_dish_hlplink);
	dish_set_module_name(&wps_dish_cmdlink, &wps_dish_hlplink, wps_dish_module_name);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -