# Path: beacontools/structs/ibeacon.py

# 
# Path: beacontools/structs/eddystone.py

# 
# Path: beacontools/structs/estimote.py

# 
# Path: beacontools/structs/controlj.py

# 
# Path: beacontools/structs/exposure_notification.py

# 
# Path: beacontools/const.py
# SERVICE_DATA_TYPE = 0x16
# 
# MANUFACTURER_SPECIFIC_DATA_TYPE = 0xFF
# 
# EDDYSTONE_UUID = b"\xaa\xfe"
# 
# ESTIMOTE_UUID = b"\x9a\xfe"
# 
# EDDYSTONE_UID_FRAME = 0x00
# 
# EDDYSTONE_URL_FRAME = 0x10
# 
# EDDYSTONE_TLM_FRAME = 0x20
# 
# EDDYSTONE_EID_FRAME = 0x30
# 
# ESTIMOTE_TELEMETRY_FRAME = 0x2
# 
# ESTIMOTE_MANUFACTURER_ID = b"\x5d\x01"
# 
# CJ_MANUFACTURER_ID = b"\x72\x04"
# 
# FLAGS_DATA_TYPE = 0x01
# 
# IBEACON_MANUFACTURER_ID = b"\x4c\x00"
# 
# EXPOSURE_NOTIFICATION_UUID = b"\x6f\xfd"


from construct import Struct, Byte, Switch, OneOf, Array, Bytes, GreedyRange, BitStruct, \
                      BitsInteger, Flag
from .ibeacon import IBeaconMSD
from .eddystone import EddystoneUIDFrame, EddystoneURLFrame, EddystoneTLMFrame, EddystoneEIDFrame
from .estimote import EstimoteTelemetryFrame, EstimoteNearableFrame
from .controlj import CJMonitorMSD
from .exposure_notification import ExposureNotificationFrame
from ..const import SERVICE_DATA_TYPE, MANUFACTURER_SPECIFIC_DATA_TYPE, EDDYSTONE_UUID, \
                    ESTIMOTE_UUID, EDDYSTONE_UID_FRAME, EDDYSTONE_URL_FRAME, EDDYSTONE_TLM_FRAME, \
                    EDDYSTONE_EID_FRAME, ESTIMOTE_TELEMETRY_FRAME, ESTIMOTE_MANUFACTURER_ID, \
                    CJ_MANUFACTURER_ID, FLAGS_DATA_TYPE, IBEACON_MANUFACTURER_ID, \
                    EXPOSURE_NOTIFICATION_UUID
"""Definiton of the length-type-value structure used by all beacon types."""


# pylint: disable=invalid-name

AdvertisingFlags = BitStruct(
    "reserved" / BitsInteger(3),
    "le_br_edr_support_host" / Flag,
    "le_br_edr_support_controller" / Flag,
    "br_edr_not_supported" / Flag,
    "le_general_discoverable_mode" / Flag,
    "le_limited_discoverable_mode" / Flag,
)

ServiceData = Struct(
    "service_identifier" / OneOf(Bytes(2), [
        EDDYSTONE_UUID,
        ESTIMOTE_UUID,
        EXPOSURE_NOTIFICATION_UUID
    ]),
    "service_data" / Switch(lambda ctx: ctx.service_identifier, {

# Path: beacontools/structs/ibeacon.py

# 
# Path: beacontools/structs/eddystone.py

# 
# Path: beacontools/structs/estimote.py

# 
# Path: beacontools/structs/controlj.py

# 
# Path: beacontools/structs/exposure_notification.py

# 
# Path: beacontools/const.py
# SERVICE_DATA_TYPE = 0x16
# 
# MANUFACTURER_SPECIFIC_DATA_TYPE = 0xFF
# 
# EDDYSTONE_UUID = b"\xaa\xfe"
# 
# ESTIMOTE_UUID = b"\x9a\xfe"
# 
# EDDYSTONE_UID_FRAME = 0x00
# 
# EDDYSTONE_URL_FRAME = 0x10
# 
# EDDYSTONE_TLM_FRAME = 0x20
# 
# EDDYSTONE_EID_FRAME = 0x30
# 
# ESTIMOTE_TELEMETRY_FRAME = 0x2
# 
# ESTIMOTE_MANUFACTURER_ID = b"\x5d\x01"
# 
# CJ_MANUFACTURER_ID = b"\x72\x04"
# 
# FLAGS_DATA_TYPE = 0x01
# 
# IBEACON_MANUFACTURER_ID = b"\x4c\x00"
# 
# EXPOSURE_NOTIFICATION_UUID = b"\x6f\xfd"


# Path: beacontools/structs/common.py
from construct import Struct, Byte, Switch, OneOf, Array, Bytes, GreedyRange, BitStruct, \
                      BitsInteger, Flag
from .ibeacon import IBeaconMSD
from .eddystone import EddystoneUIDFrame, EddystoneURLFrame, EddystoneTLMFrame, EddystoneEIDFrame
from .estimote import EstimoteTelemetryFrame, EstimoteNearableFrame
from .controlj import CJMonitorMSD
from .exposure_notification import ExposureNotificationFrame
from ..const import SERVICE_DATA_TYPE, MANUFACTURER_SPECIFIC_DATA_TYPE, EDDYSTONE_UUID, \
                    ESTIMOTE_UUID, EDDYSTONE_UID_FRAME, EDDYSTONE_URL_FRAME, EDDYSTONE_TLM_FRAME, \
                    EDDYSTONE_EID_FRAME, ESTIMOTE_TELEMETRY_FRAME, ESTIMOTE_MANUFACTURER_ID, \
                    CJ_MANUFACTURER_ID, FLAGS_DATA_TYPE, IBEACON_MANUFACTURER_ID, \
                    EXPOSURE_NOTIFICATION_UUID

"""Definiton of the length-type-value structure used by all beacon types."""


# pylint: disable=invalid-name

AdvertisingFlags = BitStruct(
    "reserved" / BitsInteger(3),
    "le_br_edr_support_host" / Flag,
    "le_br_edr_support_controller" / Flag,
    "br_edr_not_supported" / Flag,
    "le_general_discoverable_mode" / Flag,
    "le_limited_discoverable_mode" / Flag,
)

ServiceData = Struct(
    "service_identifier" / OneOf(Bytes(2), [
        EDDYSTONE_UUID,
        ESTIMOTE_UUID,
        EXPOSURE_NOTIFICATION_UUID
    ]),
    "service_data" / Switch(lambda ctx: ctx.service_identifier, {

        EXPOSURE_NOTIFICATION_UUID: ExposureNotificationFrame,