# 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/peripheral.py
# class Peripheral:
#     def __init__(self, adapter_address, local_name=None, appearance=None):
#     def add_service(self, srv_id, uuid, primary):
#     def add_characteristic(self, srv_id, chr_id, uuid, value,
#                            notifying, flags,
#                            read_callback=None, write_callback=None,
#                            notify_callback=None):
#     def add_descriptor(self, srv_id, chr_id, dsc_id, uuid, value, flags):
#     def _create_advertisement(self):
#     def publish(self):
#     def on_connect(self):
#     def on_connect(self, callback):
#     def on_disconnect(self):
#     def on_disconnect(self, callback):
# 
# 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):


from gi.repository import GLib
from bluezero import adapter
from bluezero import peripheral
from bluezero import device
    def uart_write(cls, value, options):
        print('raw bytes:', value)
        print('With options:', options)
        print('Text value:', bytes(value).decode('utf-8'))
        cls.update_tx(value)


def main(adapter_address):
    ble_uart = peripheral.Peripheral(adapter_address, local_name='BLE UART')
    ble_uart.add_service(srv_id=1, uuid=UART_SERVICE, primary=True)
    ble_uart.add_characteristic(srv_id=1, chr_id=1, uuid=RX_CHARACTERISTIC,
                                value=[], notifying=False,
                                flags=['write', 'write-without-response'],
                                write_callback=UARTDevice.uart_write,
                                read_callback=None,
                                notify_callback=None)
    ble_uart.add_characteristic(srv_id=1, chr_id=2, uuid=TX_CHARACTERISTIC,
                                value=[], notifying=False,
                                flags=['notify'],
                                notify_callback=UARTDevice.uart_notify,
                                read_callback=None,
                                write_callback=None)

    ble_uart.on_connect = UARTDevice.on_connect
    ble_uart.on_disconnect = UARTDevice.on_disconnect

    ble_uart.publish()


if __name__ == '__main__':

# 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/peripheral.py
# class Peripheral:
#     def __init__(self, adapter_address, local_name=None, appearance=None):
#     def add_service(self, srv_id, uuid, primary):
#     def add_characteristic(self, srv_id, chr_id, uuid, value,
#                            notifying, flags,
#                            read_callback=None, write_callback=None,
#                            notify_callback=None):
#     def add_descriptor(self, srv_id, chr_id, dsc_id, uuid, value, flags):
#     def _create_advertisement(self):
#     def publish(self):
#     def on_connect(self):
#     def on_connect(self, callback):
#     def on_disconnect(self):
#     def on_disconnect(self, callback):
# 
# 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: examples/ble_uart.py
from gi.repository import GLib
from bluezero import adapter
from bluezero import peripheral
from bluezero import device

    def uart_write(cls, value, options):
        print('raw bytes:', value)
        print('With options:', options)
        print('Text value:', bytes(value).decode('utf-8'))
        cls.update_tx(value)


def main(adapter_address):
    ble_uart = peripheral.Peripheral(adapter_address, local_name='BLE UART')
    ble_uart.add_service(srv_id=1, uuid=UART_SERVICE, primary=True)
    ble_uart.add_characteristic(srv_id=1, chr_id=1, uuid=RX_CHARACTERISTIC,
                                value=[], notifying=False,
                                flags=['write', 'write-without-response'],
                                write_callback=UARTDevice.uart_write,
                                read_callback=None,
                                notify_callback=None)
    ble_uart.add_characteristic(srv_id=1, chr_id=2, uuid=TX_CHARACTERISTIC,
                                value=[], notifying=False,
                                flags=['notify'],
                                notify_callback=UARTDevice.uart_notify,
                                read_callback=None,
                                write_callback=None)

    ble_uart.on_connect = UARTDevice.on_connect
    ble_uart.on_disconnect = UARTDevice.on_disconnect

    ble_uart.publish()


if __name__ == '__main__':

    main(list(adapter.Adapter.available())[0].address)