#ifndef BLE_MGMT_H
#define BLE_MGMT_H

/**
 * @file ble_mgmt.h
 * @brief Bluetooth Low Energy management for provisioning and game communication.
 * This module handles Bluetooth initialization, advertising, and stopping advertising.
 */

/**
 * @brief Device types for LaserTag devices.
 */
#define LT_TYPE_LEADER  0x01
#define LT_TYPE_WEAPON  0x02
#define LT_TYPE_VEST    0x03
#define LT_TYPE_BEACON  0x04

/**
 * @brief Device configuration payload structure for BLE management.
 */
typedef struct __packed {
    uint8_t system_state;     /* Offset 0 */
    uint64_t game_id;         /* Offset 1 */
    uint16_t pan_id;          /* Offset 9 */
    uint8_t channel;          /* Offset 11 */
    uint8_t ext_pan_id[8];    /* Offset 12 */
    uint8_t network_key[16];  /* Offset 20 */
    char network_name[17];    /* Offset 36 */
    char node_name[33];       /* Offset 53 */
} device_config_payload_t;

/**
 * @brief Initialize Bluetooth and prepare services.
 * 
 * @param device_type The type of the device (e.g., leader, weapon, vest, beacon).
 * @return 0 on success.
 */
int ble_mgmt_init(uint8_t device_type);

/**
 * @brief Start Bluetooth advertising so the web app can find the device.
 * @return 0 on success.
 */
int ble_mgmt_adv_start(void);

/**
 * @brief Stop Bluetooth advertising.
 * @return 0 on success.
 */
int ble_mgmt_adv_stop(void);

#endif /* BLE_MGMT_H */