1#   Copyright 2017 - The Android Open Source Project
2#
3#   Licensed under the Apache License, Version 2.0 (the "License");
4#   you may not use this file except in compliance with the License.
5#   You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#   Unless required by applicable law or agreed to in writing, software
10#   distributed under the License is distributed on an "AS IS" BASIS,
11#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#   See the License for the specific language governing permissions and
13#   limitations under the License.
14
15import collections
16
17
18class BssSettings(object):
19    """Settings for a bss.
20
21    Settings for a bss to allow multiple network on a single device.
22
23    Attributes:
24        name: string, The name that this bss will go by.
25        ssid: string, The name of the ssid to brodcast.
26        hidden: bool, If true then the ssid will be hidden.
27        security: Security, The security settings to use.
28    """
29
30    def __init__(self, name, ssid, hidden=False, security=None, bssid=None):
31        self.name = name
32        self.ssid = ssid
33        self.hidden = hidden
34        self.security = security
35        self.bssid = bssid
36
37    def generate_dict(self):
38        """Returns: A dictionary of bss settings."""
39        settings = collections.OrderedDict()
40        settings['bss'] = self.name
41        if self.bssid:
42            settings['bssid'] = self.bssid
43        if self.ssid:
44            settings['ssid'] = self.ssid
45            settings['ignore_broadcast_ssid'] = 1 if self.hidden else 0
46
47        if self.security:
48            security_settings = self.security.generate_dict()
49            for k, v in security_settings.items():
50                settings[k] = v
51
52        return settings
53