# T1 UAV Relay — main.cpp integration snippet

`uav_relay.h/.cpp` is a compile-out module. To enable, define
`PDL_ENABLE_UAV_RELAY` via `build_flags` in `platformio.ini`:

```
build_flags = -D PDL_ENABLE_UAV_RELAY
```

## setup() addition

```cpp
#include "uav_relay.h"
// ...
#ifdef PDL_ENABLE_UAV_RELAY
    uav_relay_init(/*hmac_key=*/nullptr, /*len=*/0);
#endif
```

## Main loop switch-statement addition

Extend the existing LoRa RX dispatcher (src/main.cpp around line 277)
with one new case:

```cpp
switch (msg_type) {
    case MSG_TYPE_CANDIDATE:
    case MSG_TYPE_CORROBORATE:
        ffps_handle_packet(rx_buf, rx_len, rx_rssi);
        break;

    case MSG_TYPE_OTA_CHUNK:
        ota_handle_chunk(rx_buf, rx_len);
        break;

    case MSG_TYPE_COMMAND:
        handleIncomingCommand(rx_buf, (size_t)rx_len);
        break;

    case MSG_TYPE_UAV_CMD:                          // 0x0A — NEW
        uav_relay_handle(rx_buf, (size_t)rx_len);
        break;

    case MSG_TYPE_CMD_ACK:
    case MSG_TYPE_UAV_ACK:                          // 0x0B — NEW
        break;

    default:
        break;
}
```

The `MSG_TYPE_UAV_CMD` (0x0A) and `MSG_TYPE_UAV_ACK` (0x0B) constants
are defined in `uav_relay.h`, not in `config.h`, so the sensor mesh
protocol is independent of the UAV opt-in.

## Compile-out behavior

When `PDL_ENABLE_UAV_RELAY` is undefined:
- `uav_relay_init()`, `uav_relay_handle()`, `uav_relay_send_ack()`,
  `uav_relay_parse()` compile to empty stubs.
- No UART subsystem is claimed.
- No memory footprint beyond the function symbols.

Safe to ship to fleets that do not operate UAV relays.
