# Path: bluezero/adapter.py
# class AdapterError(Exception):
# class Adapter:
# def list_adapters():
#     def available():
#     def __new__(cls, adapter_addr=None, *args, **kwargs):
#     def __init__(self, adapter_addr=None):
#     def address(self):
#     def name(self):
#     def bt_class(self):
#     def alias(self):
#     def alias(self, new_alias):
#     def get_all(self):
#     def powered(self):
#     def powered(self, new_state):
#     def pairable(self):
#     def pairable(self, new_state):
#     def pairabletimeout(self):
#     def pairabletimeout(self, new_timeout):
#     def discoverable(self):
#     def discoverable(self, new_state):
#     def discoverabletimeout(self):
#     def discoverabletimeout(self, new_timeout):
#     def discovering(self):
#     def _discovering_timeout(self):
#     def uuids(self):
#     def nearby_discovery(self, timeout=10):
#     def show_duplicates(self):
#     def hide_duplicates(self):
#     def start_discovery(self):
#     def stop_discovery(self):
#     def remove_device(self, device_path):
#     def run(self):
#     def quit(self):
#     def _properties_changed(self, interface, changed, invalidated, path):
#     def _device_added(self, dbus_mngr, device_address):
#     def _interfaces_removed(self, path, device_info):
# 
# Path: bluezero/device.py
# class Device:
#     def available(adapter_address=None):
#     def __init__(self, adapter_addr, device_addr):
#     def address(self):
#     def name(self):
#     def icon(self):
#     def bt_class(self):
#     def appearance(self):
#     def uuids(self):
#     def paired(self):
#     def connected(self):
#     def trusted(self):
#     def trusted(self, new_state):
#     def blocked(self):
#     def blocked(self, new_state):
#     def alias(self):
#     def alias(self, new_alias):
#     def _adapter(self):
#     def adapter(self):
#     def legacy_pairing(self):
#     def legacy_pairing(self, new_status):
#     def modalias(self):
#     def RSSI(self):  # pylint: disable=invalid-name
#     def tx_power(self):
#     def manufacturer_data(self):
#     def service_data(self):
#     def services_resolved(self):
#     def services_available(self):
#     def pair(self):
#     def cancel_pairing(self):
#     def connect(self, profile=None, timeout=35):
#     def disconnect(self):
# 
# Path: bluezero/GATT.py
# class Service:
# class Characteristic:
# class Descriptor:
# class Profile:
# class GattManager:
#     def __init__(self, adapter_addr, device_addr, srv_uuid):
#     def resolve_gatt(self):
#     def UUID(self):  # pylint: disable=invalid-name
#     def device(self):
#     def primary(self):
#     def __init__(self, adapter_addr, device_addr, srv_uuid, chrc_uuid):
#     def resolve_gatt(self):
#     def UUID(self):  # pylint: disable=invalid-name
#     def service(self):
#     def value(self):
#     def value(self, new_value):
#     def notifying(self):
#     def flags(self):
#     def read_raw_value(self, flags=''):
#     def write_value(self, value, flags=''):
#     def start_notify(self):
#     def stop_notify(self):
#     def add_characteristic_cb(self, callback=None):
#     def props_changed_cb(self, iface, changed_props, invalidated_props):
#     def start_notify_cb(self):
#     def stop_notify_cb(self):
#     def __init__(self, adapter_addr, device_addr,
#                  srv_uuid, chrc_uuid, dscr_uuid):
#     def UUID(self):  # pylint: disable=invalid-name
#     def characteristic(self):
#     def value(self):
#     def flags(self):
#     def read_raw_value(self, flags=''):
#     def write_value(self, value, flags=''):
#     def __init__(self, adapter_addr, device_addr, profile_uuid):
#     def release(self):
#     def UUIDs(self):  # pylint: disable=invalid-name
# def generic_error_cb(error):
# def register_app_cb():
# def register_app_error_cb(error):
#     def __init__(self, adapter_addr):
#     def register_application(self, application, options):
#     def unregister_application(self, application):
# 
# Path: bluezero/tools.py
# def int_to_uint16(value_in):
# def sint16_to_int(byte_array):
# def bytes_to_xyz(byte_array):
# def int_to_uint32(value_in):
# def bitwise_or_2lists(list1, list2):
# def bitwise_and_2lists(list1, list2):
# def bitwise_xor_2lists(list1, list2):
# def url_to_advert(url, frame_type, tx_power):
# def get_fn_parameters(fn):
# def create_module_logger(module_name):


from time import sleep
from bluezero import adapter
from bluezero import device
from bluezero import GATT
from bluezero import tools
"""Classes that represent the GATT features of a remote device."""



logger = tools.create_module_logger(__name__)


class Central:
    """Create a BLE instance taking the Central role."""

    def __init__(self, device_addr, adapter_addr=None):
        if adapter_addr is None:
            self.dongle = adapter.Adapter()
            logger.debug('Adapter is: %s', self.dongle.address)
        else:
            self.dongle = adapter.Adapter(adapter_addr)
        if not self.dongle.powered:
            self.dongle.powered = True
            logger.debug('Adapter was off, now powered on')

# Path: bluezero/adapter.py
# class AdapterError(Exception):
# class Adapter:
# def list_adapters():
#     def available():
#     def __new__(cls, adapter_addr=None, *args, **kwargs):
#     def __init__(self, adapter_addr=None):
#     def address(self):
#     def name(self):
#     def bt_class(self):
#     def alias(self):
#     def alias(self, new_alias):
#     def get_all(self):
#     def powered(self):
#     def powered(self, new_state):
#     def pairable(self):
#     def pairable(self, new_state):
#     def pairabletimeout(self):
#     def pairabletimeout(self, new_timeout):
#     def discoverable(self):
#     def discoverable(self, new_state):
#     def discoverabletimeout(self):
#     def discoverabletimeout(self, new_timeout):
#     def discovering(self):
#     def _discovering_timeout(self):
#     def uuids(self):
#     def nearby_discovery(self, timeout=10):
#     def show_duplicates(self):
#     def hide_duplicates(self):
#     def start_discovery(self):
#     def stop_discovery(self):
#     def remove_device(self, device_path):
#     def run(self):
#     def quit(self):
#     def _properties_changed(self, interface, changed, invalidated, path):
#     def _device_added(self, dbus_mngr, device_address):
#     def _interfaces_removed(self, path, device_info):
# 
# Path: bluezero/device.py
# class Device:
#     def available(adapter_address=None):
#     def __init__(self, adapter_addr, device_addr):
#     def address(self):
#     def name(self):
#     def icon(self):
#     def bt_class(self):
#     def appearance(self):
#     def uuids(self):
#     def paired(self):
#     def connected(self):
#     def trusted(self):
#     def trusted(self, new_state):
#     def blocked(self):
#     def blocked(self, new_state):
#     def alias(self):
#     def alias(self, new_alias):
#     def _adapter(self):
#     def adapter(self):
#     def legacy_pairing(self):
#     def legacy_pairing(self, new_status):
#     def modalias(self):
#     def RSSI(self):  # pylint: disable=invalid-name
#     def tx_power(self):
#     def manufacturer_data(self):
#     def service_data(self):
#     def services_resolved(self):
#     def services_available(self):
#     def pair(self):
#     def cancel_pairing(self):
#     def connect(self, profile=None, timeout=35):
#     def disconnect(self):
# 
# Path: bluezero/GATT.py
# class Service:
# class Characteristic:
# class Descriptor:
# class Profile:
# class GattManager:
#     def __init__(self, adapter_addr, device_addr, srv_uuid):
#     def resolve_gatt(self):
#     def UUID(self):  # pylint: disable=invalid-name
#     def device(self):
#     def primary(self):
#     def __init__(self, adapter_addr, device_addr, srv_uuid, chrc_uuid):
#     def resolve_gatt(self):
#     def UUID(self):  # pylint: disable=invalid-name
#     def service(self):
#     def value(self):
#     def value(self, new_value):
#     def notifying(self):
#     def flags(self):
#     def read_raw_value(self, flags=''):
#     def write_value(self, value, flags=''):
#     def start_notify(self):
#     def stop_notify(self):
#     def add_characteristic_cb(self, callback=None):
#     def props_changed_cb(self, iface, changed_props, invalidated_props):
#     def start_notify_cb(self):
#     def stop_notify_cb(self):
#     def __init__(self, adapter_addr, device_addr,
#                  srv_uuid, chrc_uuid, dscr_uuid):
#     def UUID(self):  # pylint: disable=invalid-name
#     def characteristic(self):
#     def value(self):
#     def flags(self):
#     def read_raw_value(self, flags=''):
#     def write_value(self, value, flags=''):
#     def __init__(self, adapter_addr, device_addr, profile_uuid):
#     def release(self):
#     def UUIDs(self):  # pylint: disable=invalid-name
# def generic_error_cb(error):
# def register_app_cb():
# def register_app_error_cb(error):
#     def __init__(self, adapter_addr):
#     def register_application(self, application, options):
#     def unregister_application(self, application):
# 
# Path: bluezero/tools.py
# def int_to_uint16(value_in):
# def sint16_to_int(byte_array):
# def bytes_to_xyz(byte_array):
# def int_to_uint32(value_in):
# def bitwise_or_2lists(list1, list2):
# def bitwise_and_2lists(list1, list2):
# def bitwise_xor_2lists(list1, list2):
# def url_to_advert(url, frame_type, tx_power):
# def get_fn_parameters(fn):
# def create_module_logger(module_name):


# Path: bluezero/central.py
from time import sleep
from bluezero import adapter
from bluezero import device
from bluezero import GATT
from bluezero import tools

"""Classes that represent the GATT features of a remote device."""



logger = tools.create_module_logger(__name__)


class Central:
    """Create a BLE instance taking the Central role."""

    def __init__(self, device_addr, adapter_addr=None):
        if adapter_addr is None:
            self.dongle = adapter.Adapter()
            logger.debug('Adapter is: %s', self.dongle.address)
        else:
            self.dongle = adapter.Adapter(adapter_addr)
        if not self.dongle.powered:
            self.dongle.powered = True
            logger.debug('Adapter was off, now powered on')

        self.rmt_device = device.Device(self.dongle.address, device_addr)