[wireless][wapi] add powersave cmd of wapi for Low-power modules
Signed-off-by: meijian <meijian@xiaomi.com>
This commit is contained in:
parent
c5541bfb56
commit
cf7491a1fe
@ -53,6 +53,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/ethernet.h>
|
||||
@ -973,6 +974,26 @@ int wapi_get_pta_prio(int sock, FAR const char *ifname,
|
||||
|
||||
int wapi_extend_params(int sock, int cmd, FAR struct iwreq *wrq);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_set_power_save
|
||||
*
|
||||
* Description:
|
||||
* Set power save status of wifi.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int wapi_set_power_save(int sock, FAR const char *ifname, bool on);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_get_power_save
|
||||
*
|
||||
* Description:
|
||||
* Get power save status of wifi.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int wapi_get_power_save(int sock, FAR const char *ifname, bool *on);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ static int wapi_reconnect_cmd (int sock, int argc, FAR char **argv);
|
||||
static int wapi_save_config_cmd (int sock, int argc, FAR char **argv);
|
||||
#endif
|
||||
static int wapi_pta_prio_cmd (int sock, int argc, FAR char **argv);
|
||||
static int wapi_power_save_cmd (int sock, int argc, FAR char **argv);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -134,6 +135,7 @@ static const struct wapi_command_s g_wapi_commands[] =
|
||||
{"save_config", 1, 1, wapi_save_config_cmd},
|
||||
#endif
|
||||
{"pta_prio", 2, 2, wapi_pta_prio_cmd},
|
||||
{"power_save", 2, 2, wapi_power_save_cmd},
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -1110,6 +1112,31 @@ static int wapi_pta_prio_cmd(int sock, int argc, FAR char **argv)
|
||||
return wapi_set_pta_prio(sock, argv[0], pta_prio);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_power_save_cmd
|
||||
*
|
||||
* Description:
|
||||
* Manually configure the power save status.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int wapi_power_save_cmd(int sock, int argc, FAR char **argv)
|
||||
{
|
||||
bool on = false;
|
||||
|
||||
if (strcmp(argv[1], "on") == 0)
|
||||
{
|
||||
on = true;
|
||||
}
|
||||
|
||||
/* Set power save status */
|
||||
|
||||
return wapi_set_power_save(sock, argv[0], on);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_showusage
|
||||
*
|
||||
@ -1154,7 +1181,7 @@ static void wapi_showusage(FAR const char *progname, int exitcode)
|
||||
fprintf(stderr, "\t%s save_config <ifname>\n", progname);
|
||||
#endif
|
||||
fprintf(stderr, "\t%s pta_prio <ifname> <index/flag>\n", progname);
|
||||
|
||||
fprintf(stderr, "\t%s power_save <ifname> <on|off>\n", progname);
|
||||
fprintf(stderr, "\t%s help\n", progname);
|
||||
|
||||
fprintf(stderr, "\nFrequency Flags:\n");
|
||||
|
@ -1659,3 +1659,54 @@ int wapi_extend_params(int sock, int cmd, FAR struct iwreq *wrq)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_set_power_save
|
||||
*
|
||||
* Description:
|
||||
* Set power save status of wifi.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int wapi_set_power_save(int sock, FAR const char *ifname, bool on)
|
||||
{
|
||||
struct iwreq wrq =
|
||||
{
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
wrq.u.power.flags = on;
|
||||
strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||
ret = wapi_extend_params(sock, SIOCSIWPWSAVE, &wrq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_get_power_save
|
||||
*
|
||||
* Description:
|
||||
* Get power save status of wifi.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int wapi_get_power_save(int sock, FAR const char *ifname, bool *on)
|
||||
{
|
||||
struct iwreq wrq =
|
||||
{
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
WAPI_VALIDATE_PTR(on);
|
||||
|
||||
strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||
ret = wapi_extend_params(sock, SIOCGIWPWSAVE, &wrq);
|
||||
if (ret >= 0)
|
||||
{
|
||||
*on = wrq.u.power.flags;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user