• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2018 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17from acts.controllers.fuchsia_lib.base_lib import BaseLib
18
19COMMAND_SCAN = "wlan.scan"
20COMMAND_CONNECT = "wlan.connect"
21COMMAND_DISCONNECT = "wlan.disconnect"
22
23class FuchsiaWlanLib(BaseLib):
24    def __init__(self, addr, tc, client_id):
25        self.address = addr
26        self.test_counter = tc
27        self.client_id = client_id
28
29    def wlanStartScan(self):
30        """ Starts a wlan scan
31
32                Returns:
33                    scan results
34        """
35        test_cmd = COMMAND_SCAN
36        test_id = self.build_id(self.test_counter)
37        self.test_counter += 1
38
39        return self.send_command(test_id, test_cmd, {})
40
41    def wlanConnectToNetwork(self, target_ssid, target_pwd=None):
42        """ Triggers a network connection
43                Args:
44                    target_ssid: the network to attempt a connection to
45                    target_pwd: (optional) password for the target network
46
47                Returns:
48                    boolean indicating if the connection was successful
49        """
50        test_cmd = COMMAND_CONNECT
51        test_args = {
52            "target_ssid": target_ssid,
53            "target_pwd": target_pwd
54        }
55        test_id = self.build_id(self.test_counter)
56        self.test_counter += 1
57
58        return self.send_command(test_id, test_cmd, test_args)
59
60    def wlanDisconnect(self):
61        """ Disconnect any current wifi connections"""
62        test_cmd = COMMAND_DISCONNECT
63        test_id = self.build_id(self.test_counter)
64        self.test_counter += 1
65
66        return self.send_command(test_id, test_cmd, {})
67
68