"""GATT Characteristic UUIDs for Dangerous Pi BLE interface.

This module defines the UUIDs for all GATT services and characteristics
used by the Dangerous Pi BLE interface.

UUID Namespace: Dangerous Pi uses custom UUIDs in the format:
- Base UUID: 00000000-1234-5678-1234-56789abcdef0
- Service UUIDs end in 00-0f
- Characteristic UUIDs end in 10-ff
"""
from dataclasses import dataclass


# Base UUID template
BASE_UUID = "00000000-1234-5678-1234-56789abcdef{}"


@dataclass
class PM3CharacteristicUUIDs:
    """PM3 GATT Service and Characteristics.

    Service for Proxmark3 operations (command execution, status).
    """
    # Service UUID
    SERVICE = BASE_UUID.format("0")

    # Characteristics
    COMMAND_WRITE = BASE_UUID.format("1")      # Write: Execute PM3 command
    COMMAND_RESULT = BASE_UUID.format("2")     # Notify: Command result
    STATUS = BASE_UUID.format("3")             # Read: Get PM3 status
    SESSION_CREATE = BASE_UUID.format("4")     # Write: Create session
    SESSION_RELEASE = BASE_UUID.format("5")    # Write: Release session
    SESSION_INFO = BASE_UUID.format("6")       # Read: Get session info


@dataclass
class WiFiCharacteristicUUIDs:
    """WiFi GATT Service and Characteristics.

    Service for WiFi network management (scan, connect, status).
    """
    # Service UUID
    SERVICE = BASE_UUID.format("10")

    # Characteristics
    STATUS = BASE_UUID.format("11")            # Read: Get WiFi status
    SCAN = BASE_UUID.format("12")              # Write: Trigger scan, Notify: Results
    CONNECT = BASE_UUID.format("13")           # Write: Connect to network
    DISCONNECT = BASE_UUID.format("14")        # Write: Disconnect
    MODE = BASE_UUID.format("15")              # Read/Write: WiFi mode
    SAVED_NETWORKS = BASE_UUID.format("16")    # Read: Get saved networks
    FORGET_NETWORK = BASE_UUID.format("17")    # Write: Forget network


@dataclass
class SystemCharacteristicUUIDs:
    """System GATT Service and Characteristics.

    Service for system operations (info, shutdown, restart).
    """
    # Service UUID
    SERVICE = BASE_UUID.format("20")

    # Characteristics
    INFO = BASE_UUID.format("21")              # Read: Get system info
    SHUTDOWN = BASE_UUID.format("22")          # Write: Initiate shutdown
    RESTART = BASE_UUID.format("23")           # Write: Initiate restart
    LOGS = BASE_UUID.format("24")              # Read: Get service logs


@dataclass
class UpdateCharacteristicUUIDs:
    """Update GATT Service and Characteristics.

    Service for software update management.
    """
    # Service UUID
    SERVICE = BASE_UUID.format("30")

    # Characteristics
    CHECK = BASE_UUID.format("31")             # Write: Check for updates, Notify: Result
    DOWNLOAD = BASE_UUID.format("32")          # Write: Download update
    INSTALL = BASE_UUID.format("33")           # Write: Install update
    PROGRESS = BASE_UUID.format("34")          # Read/Notify: Update progress
    RELEASE_NOTES = BASE_UUID.format("35")     # Read: Get release notes


# Characteristic properties
class CharacteristicProperties:
    """Standard GATT characteristic properties."""
    READ = "read"
    WRITE = "write"
    WRITE_WITHOUT_RESPONSE = "write-without-response"
    NOTIFY = "notify"
    INDICATE = "indicate"


# Characteristic descriptors
CHARACTERISTIC_USER_DESCRIPTION_UUID = "00002901-0000-1000-8000-00805f9b34fb"
CLIENT_CHARACTERISTIC_CONFIG_UUID = "00002902-0000-1000-8000-00805f9b34fb"
