/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdio.h>
#include <zephyr/kernel.h>

#include "fcb.h"


static int fake_counter = 0;
struct FCB_sensor_data data;

void create_fake_data(void) {
	data.payload.sensor_ts = k_uptime_get();
	data.payload.message_counter = fake_counter++;
	data.payload.temp_deg_c = 2500; // 25.00 °C
	data.payload.humidity_percent = 5000; // 50.00 %
	data.payload.pressure_kpa = 1013; // 1013 hPa
	FCB_append_entry(&data, sizeof(data));
}

int main(void)
{
	printf("Hello World! %s\n", CONFIG_BOARD_TARGET);

	int err = FCB_init();
	if (err) {
		printf("FCB_init failed with error %d\n", err);
		return err;
	}

	printf("Starting to create fake data entries...\n");

	while(1){
		create_fake_data();
		FCB_read_all_sectors();
		k_sleep(K_MSEC(100));
		if (fake_counter >= 50) {
			break;
		}
	}

	return 0;
}
