# Copyright (C) 2019 Majormode.  All rights reserved.
#
# This software is the confidential and proprietary information of
# Majormode or one of its subsidiaries.  You shall not disclose this
# confidential information and shall use it only in accordance with the
# terms of the license agreement or other applicable agreement you
# entered into with Majormode.
#
# MAJORMODE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
# OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE, OR NON-INFRINGEMENT.  MAJORMODE SHALL NOT BE LIABLE FOR ANY
# LOSSES OR DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
# OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

class WirelessAccessPointScanResult:
    def __init__(
            self,
            bssid,
            ssid,
            frequency,
            signal_level,
            sample_count):
        """
        Build an instance `WirelessAccessPointScanResult`.


        @param bssid: Basic Service Set Identifier (BSSID) that uniquely
            identifies the Wireless Access Point (WAP).  The BSSID is the MAC
            address of the WAP generated by combining the 24 bit Organization
            Unique Identifier (the manufacturer's identity) and the
            manufacturer's assigned 24-bit identifier for the radio chipset in
            the WAP.

        @param ssid: Service Set Identifier (SSID), a 1 to 32 byte string,
            which is normally a human-readable string and thus commonly called
            the "network name".  As a purported security enhancement, some
            access points allow a user to inhibit the broadcasting of their
            SSIDs, a tactic known as network cloaking; a station may then only
            join a BSS after the associated SSID has been specified
            explicitly.

        @param frequency: the frequency in MHz of the channel over which the
            client is communicating with the access point.

        @param signal_level: the median value of the detected signal levels in
            dBm of this Wireless Access Point.  The quality of a signal level
            can be interpreted as follows:

            * Excellent: -57 to -45 dBms (75 to 100%)

            * Good: -75 to -58 dBms (40 to 74%)

            * Fair: -85 to -76 dBms (20 to 39%)

            * Poor: -95 to -86 dBms (0 to 19%)

            * No Link

           Signal level is commonly correlated with the received signal
           strength indication (RSSI), which is a measurement of the power
           present in a received radio signal.

        @param sample_count: number of times this Wireless Access Point has
            been detected during the scan process.
        """
        self.bssid = bssid
        self.ssid = ssid
        self.frequency = frequency
        self.signal_level = signal_level
        self.sample_count = sample_count

    @staticmethod
    def from_json(payload):
        """
        Build an instance ``WirelessAccessPointScanResult`` from JSON data.


        @param payload: JSON containing the information about the result of
            the scan of a wirless access point.


        @return: an instance ``WirelessAccessPointScanResult``.
        """
        return payload and WirelessAccessPointScanResult(
                payload['bssid'],
                payload['ssid'],
                payload['frequency'],
                payload['signal_level'],
                payload['sample_count'])
