xref: /wlan-dirver/utils/sigma-dut/powerswitch.c (revision a3a88ad8fb742838d51a39737ac8099a151709fd)
1 /*
2  * Sigma Control API DUT (station/AP)
3  * Copyright (c) 2010, Atheros Communications, Inc.
4  * Copyright (c) 2019, The Linux Foundation
5  * All Rights Reserved.
6  * Licensed under the Clear BSD license. See README for more details.
7  */
8 
9 #include "sigma_dut.h"
10 
11 
cmd_power_switch_ctrl(struct sigma_dut * dut,struct sigma_conn * conn,struct sigma_cmd * cmd)12 static enum sigma_cmd_result cmd_power_switch_ctrl(struct sigma_dut *dut,
13 						   struct sigma_conn *conn,
14 						   struct sigma_cmd *cmd)
15 {
16 	return SUCCESS_SEND_STATUS;
17 }
18 
19 
cmd_power_switch_reset(struct sigma_dut * dut,struct sigma_conn * conn,struct sigma_cmd * cmd)20 static enum sigma_cmd_result cmd_power_switch_reset(struct sigma_dut *dut,
21 						    struct sigma_conn *conn,
22 						    struct sigma_cmd *cmd)
23 {
24 	if (system("killall hostapd") == 0) {
25 		int i;
26 
27 		/* Wait some time to allow hostapd to complete cleanup before
28 		 * starting a new process */
29 		for (i = 0; i < 10; i++) {
30 			usleep(500000);
31 			if (system("pidof hostapd") != 0)
32 				break;
33 		}
34 	}
35 	return SUCCESS_SEND_STATUS;
36 }
37 
38 
cmd_powerswitch(struct sigma_dut * dut,struct sigma_conn * conn,struct sigma_cmd * cmd)39 static enum sigma_cmd_result cmd_powerswitch(struct sigma_dut *dut,
40 					     struct sigma_conn *conn,
41 					     struct sigma_cmd *cmd)
42 {
43 	return SUCCESS_SEND_STATUS;
44 }
45 
46 
powerswitch_register_cmds(void)47 void powerswitch_register_cmds(void)
48 {
49 	sigma_dut_reg_cmd("power_switch_ctrl", NULL, cmd_power_switch_ctrl);
50 	sigma_dut_reg_cmd("power_switch_reset", NULL, cmd_power_switch_reset);
51 	sigma_dut_reg_cmd("PowerSwitch", NULL, cmd_powerswitch);
52 }
53