# Path: bluezero/constants.py
# DBUS_OM_IFACE = 'org.freedesktop.DBus.ObjectManager'
# DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
# BLUEZ_SERVICE_NAME = 'org.bluez'
# ADAPTER_INTERFACE = 'org.bluez.Adapter1'
# DEVICE_INTERFACE = 'org.bluez.Device1'
# GATT_MANAGER_IFACE = 'org.bluez.GattManager1'
# GATT_PROFILE_IFACE = 'org.bluez.GattProfile1'
# GATT_SERVICE_IFACE = 'org.bluez.GattService1'
# GATT_CHRC_IFACE = 'org.bluez.GattCharacteristic1'
# GATT_DESC_IFACE = 'org.bluez.GattDescriptor1'
# LE_ADVERTISING_MANAGER_IFACE = 'org.bluez.LEAdvertisingManager1'
# LE_ADVERTISEMENT_IFACE = 'org.bluez.LEAdvertisement1'
# MEDIA_PLAYER_IFACE = 'org.bluez.MediaPlayer1'
# BLUEZERO_DBUS_NAME = 'ukBaz.bluezero'
# BLUEZERO_DBUS_OBJECT = '/ukBaz/bluezero'
# 
# 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):


import re
import subprocess
import dbus
from bluezero import constants
from bluezero import tools
    """
    get the version of the BlueZ daemon being used on the system

    :return: String of BlueZ version
    """
    cmd = ['bluetoothctl', '-v']
    cmd_output = subprocess.run(cmd, capture_output=True, check=True)
    version = cmd_output.stdout.decode('utf-8').split()
    return version[1]


def bluez_experimental_mode():
    """
    Return True if the BlueZ daemon service is in experimental mode
    :return: True if experimental enabled
    """
    status = subprocess.check_output('service bluetooth status', shell=True)
    if re.search('--experimental', status.decode('utf-8')) is None:
        return False
    else:
        return True


def interfaces_added(path, interfaces):
    """
    Callback for when an interface is added
    :param path:
    :param interfaces:
    :return:
    """

# Path: bluezero/constants.py
# DBUS_OM_IFACE = 'org.freedesktop.DBus.ObjectManager'
# DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
# BLUEZ_SERVICE_NAME = 'org.bluez'
# ADAPTER_INTERFACE = 'org.bluez.Adapter1'
# DEVICE_INTERFACE = 'org.bluez.Device1'
# GATT_MANAGER_IFACE = 'org.bluez.GattManager1'
# GATT_PROFILE_IFACE = 'org.bluez.GattProfile1'
# GATT_SERVICE_IFACE = 'org.bluez.GattService1'
# GATT_CHRC_IFACE = 'org.bluez.GattCharacteristic1'
# GATT_DESC_IFACE = 'org.bluez.GattDescriptor1'
# LE_ADVERTISING_MANAGER_IFACE = 'org.bluez.LEAdvertisingManager1'
# LE_ADVERTISEMENT_IFACE = 'org.bluez.LEAdvertisement1'
# MEDIA_PLAYER_IFACE = 'org.bluez.MediaPlayer1'
# BLUEZERO_DBUS_NAME = 'ukBaz.bluezero'
# BLUEZERO_DBUS_OBJECT = '/ukBaz/bluezero'
# 
# 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/dbus_tools.py
import re
import subprocess
import dbus
from bluezero import constants
from bluezero import tools

    """
    get the version of the BlueZ daemon being used on the system

    :return: String of BlueZ version
    """
    cmd = ['bluetoothctl', '-v']
    cmd_output = subprocess.run(cmd, capture_output=True, check=True)
    version = cmd_output.stdout.decode('utf-8').split()
    return version[1]


def bluez_experimental_mode():
    """
    Return True if the BlueZ daemon service is in experimental mode
    :return: True if experimental enabled
    """
    status = subprocess.check_output('service bluetooth status', shell=True)
    if re.search('--experimental', status.decode('utf-8')) is None:
        return False
    else:
        return True


def interfaces_added(path, interfaces):
    """
    Callback for when an interface is added
    :param path:
    :param interfaces:
    :return:
    """

    if constants.DEVICE_INTERFACE in interfaces: