#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <lasertag_utils.h>
#include <thread_mgmt.h>
#include <ble_mgmt.h>

LOG_MODULE_REGISTER(vest_app, CONFIG_LOG_DEFAULT_LEVEL);

int main(void)
{
    /* Initialize shared project logic and NVS */
    lasertag_utils_init();

    /* Initialize and start BLE management for provisioning */
    int rc = ble_mgmt_init(LT_TYPE_VEST);
    if (rc) {
        LOG_ERR("BLE initialization failed (err %d)", rc);
        return rc;
    } else {
        LOG_INF("BLE Management initialized successfully.");
    }

    /* Start BLE advertising */
    rc = ble_mgmt_adv_start();
    if (rc) {
        LOG_ERR("BLE advertising start failed (err %d)", rc);
    } else {
        LOG_INF("BLE advertising started.");
    }

    /* Initialize and start OpenThread stack */
    rc = thread_mgmt_init();
    if (rc) {
        LOG_ERR("Thread initialization failed (err %d)", rc);
    } else {
        LOG_INF("Vest Application successfully started with Thread Mesh.");
        return rc;
    }

    while (1) {
        /* Main loop - handle high-level game logic here */
        k_sleep(K_MSEC(1000));
    }

    return 0;
}