# Path: bluetooth_low_energy/api/util.py
# def format_advertisement(data):
#     """ format advertisement data and scan response data. """
#     resolve_dict = {
#         # FLAGS AD type
#         st_constant.AD_TYPE_FLAGS: 'FLAGS',
#         # Service UUID AD types
#         st_constant.AD_TYPE_16_BIT_SERV_UUID: '16_BIT_SERV_UUID',
#         st_constant.AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST: '16_BIT_SERV_UUID_CMPLT_LIST',
#         st_constant.AD_TYPE_32_BIT_SERV_UUID: '32_BIT_SERV_UUID',
#         st_constant.AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST: '32_BIT_SERV_UUID_CMPLT_LIST',
#         st_constant.AD_TYPE_128_BIT_SERV_UUID: '128_BIT_SERV_UUID',
#         st_constant.AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST: '128_BIT_SERV_UUID_CMPLT_LIST',
#         # Local name AD types
#         st_constant.AD_TYPE_SHORTENED_LOCAL_NAME: 'SHORTENED_LOCAL_NAME',
#         st_constant.AD_TYPE_COMPLETE_LOCAL_NAME: 'COMPLETE_LOCAL_NAME',
#         # TX power level AD type
#         st_constant.AD_TYPE_TX_POWER_LEVEL: 'TX_POWER_LEVEL',
#         # Class of device
#         st_constant.AD_TYPE_CLASS_OF_DEVICE: 'CLASS_OF_DEVICE',
#         # Security manager TK value AD type
#         st_constant.AD_TYPE_SEC_MGR_TK_VALUE: 'SEC_MGR_TK_VALUE',
#         # Security manager OOB flags
#         st_constant.AD_TYPE_SEC_MGR_OOB_FLAGS: 'SEC_MGR_OOB_FLAGS',
#         # Slave connection interval AD type
#         st_constant.AD_TYPE_SLAVE_CONN_INTERVAL: 'SLAVE_CONN_INTERVAL',
#         # Service solicitation UUID list AD types
#         st_constant.AD_TYPE_SERV_SOLICIT_16_BIT_UUID_LIST: 'SERV_SOLICIT_16_BIT_UUID_LIST',
#         st_constant.AD_TYPE_SERV_SOLICIT_32_BIT_UUID_LIST: 'SERV_SOLICIT_32_BIT_UUID_LIST',
#         st_constant.AD_TYPE_SERV_SOLICIT_128_BIT_UUID_LIST: 'SERV_SOLICIT_128_BIT_UUID_LIST',
#         # Service data AD type
#         st_constant.AD_TYPE_SERVICE_DATA: 'SERVICE_DATA',
#         # Manufaturer specific data AD type
#         st_constant.AD_TYPE_MANUFACTURER_SPECIFIC_DATA: 'MANUFACTURER_SPECIFIC_DATA'
#     }
#     offset = 0
#     size = len(data)
#     advertisement_dict = {}
#     while offset < size:
#         field_len = int.from_bytes(data[offset:offset + 1], 'little')
#         if field_len == 0 or offset + field_len > size:
#             return advertisement_dict
# 
#         field_type = int.from_bytes(data[offset + 1:offset + 2], 'little')
#         field_value = data[offset + 2:offset + 2 + field_len - 1]
# 
#         advertisement_dict.update({resolve_dict[field_type]: field_value})
# 
#         offset += field_len + 1
# 
#     return advertisement_dict


from bluetooth_low_energy.api.util import format_advertisement
# -*- coding: utf-8 -*-
# pylint: disable=C0111


class ScanEntry(object):
    """ ScanEntry """

    def __init__(self, address, address_type, rssi, data):
        self.address = address
        self.address_type = address_type
        self.rssi = rssi
        self.data = data

    def get_data(self):
        """ return formatted advertisement data"""

# Path: bluetooth_low_energy/api/util.py
# def format_advertisement(data):
#     """ format advertisement data and scan response data. """
#     resolve_dict = {
#         # FLAGS AD type
#         st_constant.AD_TYPE_FLAGS: 'FLAGS',
#         # Service UUID AD types
#         st_constant.AD_TYPE_16_BIT_SERV_UUID: '16_BIT_SERV_UUID',
#         st_constant.AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST: '16_BIT_SERV_UUID_CMPLT_LIST',
#         st_constant.AD_TYPE_32_BIT_SERV_UUID: '32_BIT_SERV_UUID',
#         st_constant.AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST: '32_BIT_SERV_UUID_CMPLT_LIST',
#         st_constant.AD_TYPE_128_BIT_SERV_UUID: '128_BIT_SERV_UUID',
#         st_constant.AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST: '128_BIT_SERV_UUID_CMPLT_LIST',
#         # Local name AD types
#         st_constant.AD_TYPE_SHORTENED_LOCAL_NAME: 'SHORTENED_LOCAL_NAME',
#         st_constant.AD_TYPE_COMPLETE_LOCAL_NAME: 'COMPLETE_LOCAL_NAME',
#         # TX power level AD type
#         st_constant.AD_TYPE_TX_POWER_LEVEL: 'TX_POWER_LEVEL',
#         # Class of device
#         st_constant.AD_TYPE_CLASS_OF_DEVICE: 'CLASS_OF_DEVICE',
#         # Security manager TK value AD type
#         st_constant.AD_TYPE_SEC_MGR_TK_VALUE: 'SEC_MGR_TK_VALUE',
#         # Security manager OOB flags
#         st_constant.AD_TYPE_SEC_MGR_OOB_FLAGS: 'SEC_MGR_OOB_FLAGS',
#         # Slave connection interval AD type
#         st_constant.AD_TYPE_SLAVE_CONN_INTERVAL: 'SLAVE_CONN_INTERVAL',
#         # Service solicitation UUID list AD types
#         st_constant.AD_TYPE_SERV_SOLICIT_16_BIT_UUID_LIST: 'SERV_SOLICIT_16_BIT_UUID_LIST',
#         st_constant.AD_TYPE_SERV_SOLICIT_32_BIT_UUID_LIST: 'SERV_SOLICIT_32_BIT_UUID_LIST',
#         st_constant.AD_TYPE_SERV_SOLICIT_128_BIT_UUID_LIST: 'SERV_SOLICIT_128_BIT_UUID_LIST',
#         # Service data AD type
#         st_constant.AD_TYPE_SERVICE_DATA: 'SERVICE_DATA',
#         # Manufaturer specific data AD type
#         st_constant.AD_TYPE_MANUFACTURER_SPECIFIC_DATA: 'MANUFACTURER_SPECIFIC_DATA'
#     }
#     offset = 0
#     size = len(data)
#     advertisement_dict = {}
#     while offset < size:
#         field_len = int.from_bytes(data[offset:offset + 1], 'little')
#         if field_len == 0 or offset + field_len > size:
#             return advertisement_dict
# 
#         field_type = int.from_bytes(data[offset + 1:offset + 2], 'little')
#         field_value = data[offset + 2:offset + 2 + field_len - 1]
# 
#         advertisement_dict.update({resolve_dict[field_type]: field_value})
# 
#         offset += field_len + 1
# 
#     return advertisement_dict


# Path: bluetooth_low_energy/api/scan_entry.py
from bluetooth_low_energy.api.util import format_advertisement

# -*- coding: utf-8 -*-
# pylint: disable=C0111


class ScanEntry(object):
    """ ScanEntry """

    def __init__(self, address, address_type, rssi, data):
        self.address = address
        self.address_type = address_type
        self.rssi = rssi
        self.data = data

    def get_data(self):
        """ return formatted advertisement data"""

        return format_advertisement(self.data)