#include <stdbool.h>

#include <dk_buttons_and_leds.h>

#include <zephyr/kernel.h>

#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/modem/nrf9160_slm.h>

#define RUN_STATUS_LED DK_LED1
#define RUN_LED_BLINK_INTERVAL 1000

#include <zephyr/devicetree.h>
#include <zephyr/device.h>
#define NRF9160_SLM_UART_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(test_nrf9160_slm)
static const struct device *const nrf9160_dev = DEVICE_DT_GET(NRF9160_SLM_UART_NODE);

void main(void)
{
    int err;
    int blink_status = 0;

    err = dk_leds_init();
    if (err) {
        printk("LEDs init failed (err %d)\n", err);
        return;
    }

    for (int i = 0;;) {
        dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
        k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
        if (i == 15) {
            nrf9160_slm_start(nrf9160_dev);
        }
        if (i < 16) {
            i++;
        }
    }
}
