blob: a4262625dd298c9cbce85fd56ab91b2904ec83bc [file] [log] [blame]
Jouni Malinencd4e3c32015-10-29 12:39:56 +02001/*
2 * Sigma Control API DUT (station/AP)
3 * Copyright (c) 2010, Atheros Communications, Inc.
Jouni Malinena3a88ad2019-02-19 12:17:31 +02004 * Copyright (c) 2019, The Linux Foundation
Jouni Malinencd4e3c32015-10-29 12:39:56 +02005 * All Rights Reserved.
6 * Licensed under the Clear BSD license. See README for more details.
7 */
8
9#include "sigma_dut.h"
10
11
Jouni Malinena3a88ad2019-02-19 12:17:31 +020012static enum sigma_cmd_result cmd_power_switch_ctrl(struct sigma_dut *dut,
13 struct sigma_conn *conn,
14 struct sigma_cmd *cmd)
Jouni Malinencd4e3c32015-10-29 12:39:56 +020015{
Jouni Malinena3a88ad2019-02-19 12:17:31 +020016 return SUCCESS_SEND_STATUS;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020017}
18
19
Jouni Malinena3a88ad2019-02-19 12:17:31 +020020static enum sigma_cmd_result cmd_power_switch_reset(struct sigma_dut *dut,
21 struct sigma_conn *conn,
22 struct sigma_cmd *cmd)
Jouni Malinencd4e3c32015-10-29 12:39:56 +020023{
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 }
Jouni Malinena3a88ad2019-02-19 12:17:31 +020035 return SUCCESS_SEND_STATUS;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020036}
37
38
Jouni Malinena3a88ad2019-02-19 12:17:31 +020039static enum sigma_cmd_result cmd_powerswitch(struct sigma_dut *dut,
40 struct sigma_conn *conn,
41 struct sigma_cmd *cmd)
Jouni Malinencd4e3c32015-10-29 12:39:56 +020042{
Jouni Malinena3a88ad2019-02-19 12:17:31 +020043 return SUCCESS_SEND_STATUS;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020044}
45
46
47void 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}