支持按键开关rf射频功能
This commit is contained in:
@@ -282,27 +282,38 @@ uint8_t wifi_init(init_device_t *port)
|
||||
void wifi_mode_switch(init_device_t *port)
|
||||
{
|
||||
static init_device_t* port_lat = NULL;
|
||||
static bool wifi_mode_flag = false;
|
||||
static uint8_t wifi_mode_flag = 0;
|
||||
|
||||
if(port_lat == NULL && port != NULL)
|
||||
{
|
||||
port_lat = port;
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
return;
|
||||
}
|
||||
|
||||
if (wifi_mode_flag)
|
||||
switch(wifi_mode_flag)
|
||||
{
|
||||
wifi_mode_flag = false;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_AP);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
SYS_LOG_INF("wifi mode switch to ap");
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_mode_flag = true;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_STA);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_STA;
|
||||
SYS_LOG_INF("wifi mode switch to sta");
|
||||
case 0:
|
||||
wifi_mode_flag = 1;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_STA);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_STA;
|
||||
SYS_LOG_INF("wifi mode switch to sta");
|
||||
break;
|
||||
case 1:
|
||||
wifi_mode_flag = 2;
|
||||
SYS_LOG_INF("wifi mode switch to off");
|
||||
port_lat->wifi_mode = RC_OFF_NONE;
|
||||
rf_stop(device_inside);
|
||||
break;
|
||||
case 2:
|
||||
rf_start(device_inside);
|
||||
wifi_mode_flag = 0;
|
||||
wifi_set_mode(WIFI_NETIF_MODE_AP);
|
||||
port_lat->wifi_mode = WIFI_NETIF_MODE_AP;
|
||||
SYS_LOG_INF("wifi mode switch to ap");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wifi_start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user