"""
IoT theta symbol constants — inlined for zero-dependency edge installs.

These are plain int constants (no IntEnum) so this file has no imports
and runs on any Python 3.10+ environment including constrained devices.

Source of truth: emergent-symbols package (private).
Prefix: 0xFC (Hardware+IoT), 0xFA (Geographic), 0xF2 (Metrics)
"""

# ---------------------------------------------------------------------------
# Hardware Sensor (0xFC60-0xFC6F)
# ---------------------------------------------------------------------------
SENSOR_TEMP       = 0xFC60  # S~t  Temperature reading
SENSOR_VOLTAGE    = 0xFC61  # S~v  Voltage reading
SENSOR_CURRENT    = 0xFC62  # S~a  Current (amps)
SENSOR_FAN        = 0xFC63  # S~f  Fan speed
SENSOR_PRESSURE   = 0xFC64  # S~p  Pressure
SENSOR_HUMIDITY   = 0xFC65  # S~h  Humidity
SENSOR_POWER_DRAW = 0xFC66  # S~w  Power draw (watts)
SENSOR_VIBRATION  = 0xFC67  # S~x  Vibration
SENSOR_NOISE      = 0xFC68  # S~n  Noise level (dB)
SENSOR_ALTITUDE   = 0xFC69  # S~z  Altitude
SENSOR_POLL       = 0xFC6A  # S?   Generic sensor read / poll
SENSOR_SUBSCRIBE  = 0xFC6B  # S*   Subscribe to sensor stream
SENSOR_THRESHOLD  = 0xFC6C  # S|   Threshold configuration
SENSOR_ALERT      = 0xFC6D  # S!   Threshold alert triggered
SENSOR_CALIBRATE  = 0xFC6E  # S=   Calibration event
SENSOR_HISTORY    = 0xFC6F  # S[]  Historical data query

# ---------------------------------------------------------------------------
# Hardware GPIO (0xFC80-0xFC8F)
# ---------------------------------------------------------------------------
GPIO_READ         = 0xFC80  # IO?  Read digital pin
GPIO_WRITE        = 0xFC81  # IO=  Write digital pin
GPIO_HIGH         = 0xFC82  # IO^  Set pin high
GPIO_LOW          = 0xFC83  # IOv  Set pin low
GPIO_TOGGLE       = 0xFC84  # IO~  Toggle pin
GPIO_PULL_UP      = 0xFC85  # IO+  Enable pull-up
GPIO_PULL_DOWN    = 0xFC86  # IO-  Enable pull-down
GPIO_FLOATING     = 0xFC87  # IO|  Set floating
GPIO_IRQ_RISE     = 0xFC88  # IO↑! Rising edge interrupt
GPIO_IRQ_FALL     = 0xFC89  # IO↓! Falling edge interrupt
GPIO_IRQ_BOTH     = 0xFC8A  # IO↕! Both-edge interrupt
GPIO_PWM_SET      = 0xFC8B  # IO%  Set PWM duty cycle
GPIO_PWM_FREQ     = 0xFC8C  # IO#  Set PWM frequency
GPIO_ANALOG_READ  = 0xFC8D  # IOA? Analog read (ADC)
GPIO_ANALOG_WRITE = 0xFC8E  # IOA= Analog write (DAC)
GPIO_RES          = 0xFC8F  # IO?? Reserved

# ---------------------------------------------------------------------------
# Hardware Actuator (0xFC90-0xFC9F)
# ---------------------------------------------------------------------------
ACTUATOR_MOTOR_START    = 0xFC90  # M▶  Start motor
ACTUATOR_MOTOR_STOP     = 0xFC91  # M⏹  Stop motor
ACTUATOR_MOTOR_SPEED    = 0xFC92  # M#   Set motor speed
ACTUATOR_MOTOR_DIR      = 0xFC93  # M↔  Set motor direction
ACTUATOR_SERVO_SET      = 0xFC94  # SV=  Set servo position
ACTUATOR_SERVO_HOME     = 0xFC95  # SV0  Servo home position
ACTUATOR_RELAY_ON       = 0xFC96  # RL^  Relay on
ACTUATOR_RELAY_OFF      = 0xFC97  # RLv  Relay off
ACTUATOR_RELAY_TOGGLE   = 0xFC98  # RL~  Relay toggle
ACTUATOR_SOLENOID_OPEN  = 0xFC99  # SL^  Solenoid open
ACTUATOR_SOLENOID_CLOSE = 0xFC9A  # SLv  Solenoid close
ACTUATOR_STEPPER_STEP   = 0xFC9B  # ST→  Stepper step
ACTUATOR_STEPPER_HOME   = 0xFC9C  # ST0  Stepper home
ACTUATOR_BUZZER_ON      = 0xFC9D  # BZ^  Buzzer on
ACTUATOR_LED_SET        = 0xFC9E  # LD=  LED set
ACTUATOR_RES            = 0xFC9F  # A??  Reserved

# ---------------------------------------------------------------------------
# IoT Protocol (0xFCA0-0xFCAF)
# ---------------------------------------------------------------------------
PROTO_MQTT_PUB    = 0xFCA0  # MQ↑  MQTT publish
PROTO_MQTT_SUB    = 0xFCA1  # MQ*  MQTT subscribe
PROTO_MQTT_CONN   = 0xFCA2  # MQ→  MQTT connect
PROTO_MQTT_DISC   = 0xFCA3  # MQ←  MQTT disconnect
PROTO_COAP_GET    = 0xFCA4  # CP?  CoAP GET
PROTO_COAP_PUT    = 0xFCA5  # CP=  CoAP PUT
PROTO_COAP_POST   = 0xFCA6  # CP+  CoAP POST
PROTO_COAP_OBS    = 0xFCA7  # CP*  CoAP observe
PROTO_ZIGBEE_JOIN = 0xFCA8  # ZB+  Zigbee join
PROTO_ZIGBEE_SEND = 0xFCA9  # ZB↑  Zigbee send
PROTO_LORA_TX     = 0xFCAA  # LR↑  LoRa transmit
PROTO_LORA_RX     = 0xFCAB  # LR↓  LoRa receive
PROTO_BLE_ADV     = 0xFCAC  # BT*  BLE advertise
PROTO_BLE_CONN    = 0xFCAD  # BT→  BLE connect
PROTO_MATTER_CMD  = 0xFCAE  # MT→  Matter command
PROTO_RES         = 0xFCAF  # P??  Reserved

# ---------------------------------------------------------------------------
# Edge lifecycle (0xFCB0-0xFCBF)
# ---------------------------------------------------------------------------
EDGE_OTA_START    = 0xFCB0  # OTA▶ OTA update start
EDGE_OTA_CHUNK    = 0xFCB1  # OTA+ OTA chunk transfer
EDGE_OTA_VERIFY   = 0xFCB2  # OTA= OTA verify
EDGE_OTA_APPLY    = 0xFCB3  # OTA✓ OTA apply
EDGE_WDT_KICK     = 0xFCB4  # WD♥  Watchdog kick
EDGE_WDT_EXPIRE   = 0xFCB5  # WD✗  Watchdog expired
EDGE_SLEEP        = 0xFCB6  # Zz   Enter sleep
EDGE_WAKE         = 0xFCB7  # Z!   Wake from sleep
EDGE_DEEP_SLEEP   = 0xFCB8  # ZZz  Deep sleep
EDGE_PROVISION    = 0xFCB9  # ID+  Provision device
EDGE_DEPROVISION  = 0xFCBA  # ID-  Deprovision device
EDGE_TWIN_SYNC    = 0xFCBB  # DT=  Digital twin sync
EDGE_TWIN_DELTA   = 0xFCBC  # DT∆  Digital twin delta
EDGE_INFER        = 0xFCBD  # EI▶  Edge inference
EDGE_RESET        = 0xFCBE  # HW0  Hardware reset
EDGE_RES          = 0xFCBF  # E??  Reserved

# ---------------------------------------------------------------------------
# Geographic / GPS (0xFA00-0xFA7F)
# ---------------------------------------------------------------------------
GEO_FIX           = 0xFA00  # GPS fix acquired
GEO_MOVE          = 0xFA10  # Movement event
GEO_FENCE_ENTER   = 0xFA20  # Geofence enter
GEO_FENCE_EXIT    = 0xFA21  # Geofence exit
GEO_PROXIMITY     = 0xFA70  # Proximity event

# ---------------------------------------------------------------------------
# Metrics (0xF200-0xF2FF)
# ---------------------------------------------------------------------------
METRICS_COUNTER_INC   = 0xF200  # Counter increment
METRICS_GAUGE_SET     = 0xF210  # Gauge set
METRICS_GAUGE_CURRENT = 0xF216  # Gauge current value
METRICS_EVENT_EMIT    = 0xF230  # Event emit

# ---------------------------------------------------------------------------
# Default / fallback
# ---------------------------------------------------------------------------
GENERIC_POLL = SENSOR_POLL   # use as fallback when topic is unclassified

# ---------------------------------------------------------------------------
# Topic keyword → symbol (used by MQTTTopicClassifier)
# ---------------------------------------------------------------------------
TOPIC_KEYWORD_MAP = {
    "temp":        SENSOR_TEMP,
    "temperature": SENSOR_TEMP,
    "humidity":    SENSOR_HUMIDITY,
    "pressure":    SENSOR_PRESSURE,
    "voltage":     SENSOR_VOLTAGE,
    "current":     SENSOR_CURRENT,
    "power":       SENSOR_POWER_DRAW,
    "vibration":   SENSOR_VIBRATION,
    "noise":       SENSOR_NOISE,
    "altitude":    SENSOR_ALTITUDE,
    "sensor":      SENSOR_POLL,
    "threshold":   SENSOR_THRESHOLD,
    "alert":       SENSOR_ALERT,
    "motor":       ACTUATOR_MOTOR_START,
    "servo":       ACTUATOR_SERVO_SET,
    "relay":       ACTUATOR_RELAY_ON,
    "solenoid":    ACTUATOR_SOLENOID_OPEN,
    "stepper":     ACTUATOR_STEPPER_STEP,
    "led":         ACTUATOR_LED_SET,
    "buzzer":      ACTUATOR_BUZZER_ON,
    "actuator":    ACTUATOR_MOTOR_START,
    "gpio":        GPIO_READ,
    "pin":         GPIO_READ,
    "pwm":         GPIO_PWM_SET,
    "analog":      GPIO_ANALOG_READ,
    "adc":         GPIO_ANALOG_READ,
    "dac":         GPIO_ANALOG_WRITE,
    "ota":         EDGE_OTA_START,
    "update":      EDGE_OTA_START,
    "watchdog":    EDGE_WDT_KICK,
    "wdt":         EDGE_WDT_KICK,
    "sleep":       EDGE_SLEEP,
    "wake":        EDGE_WAKE,
    "twin":        EDGE_TWIN_SYNC,
    "shadow":      EDGE_TWIN_SYNC,
    "provision":   EDGE_PROVISION,
    "reset":       EDGE_RESET,
    "inference":   EDGE_INFER,
    "metrics":     METRICS_GAUGE_SET,
    "telemetry":   METRICS_GAUGE_SET,
    "counter":     METRICS_COUNTER_INC,
    "event":       METRICS_EVENT_EMIT,
    "log":         METRICS_EVENT_EMIT,
    "status":      METRICS_GAUGE_CURRENT,
    "cmd":         PROTO_MQTT_PUB,
    "command":     PROTO_MQTT_PUB,
}

PAYLOAD_KEY_MAP = {
    "temperature": SENSOR_TEMP,
    "temp":        SENSOR_TEMP,
    "humidity":    SENSOR_HUMIDITY,
    "pressure":    SENSOR_PRESSURE,
    "voltage":     SENSOR_VOLTAGE,
    "current":     SENSOR_CURRENT,
    "rpm":         ACTUATOR_MOTOR_START,
    "speed":       ACTUATOR_MOTOR_START,
    "angle":       ACTUATOR_SERVO_SET,
    "state":       METRICS_GAUGE_CURRENT,
    "value":       METRICS_GAUGE_SET,
    "count":       METRICS_COUNTER_INC,
    "level":       METRICS_GAUGE_SET,
}
