24#include <zephyr/kernel.h>
26#include "posix_native_task.h"
27#include "bsim_args_runner.h"
32#include <zephyr/logging/log.h>
39#define SEPARATION_TOKEN ";"
41#define TICKS_PER_SECOND 32768
73 uint64_t now_ticks = k_uptime_ticks();
78 uint64_t remainder = now_ticks % TICKS_PER_20SEC;
79 uint64_t ticks_until_next = (remainder == 0) ? 0 : (TICKS_PER_20SEC - remainder);
81 LOG_DBG(
"Now ticks: %llu", now_ticks);
82 LOG_DBG(
"First timer in %llu ticks (aligned to 1s)", ticks_until_next);
85 k_timer_start(&aligned_timer, K_TICKS(ticks_until_next), K_TICKS(
TICKS_PER_SECOND));
95static FILE *
open_stat(
char *filename, uint32_t device_number)
98 static char path[250];
99 memset(path, 0,
sizeof(path));
101 snprintf(path,
sizeof(path) - 1,
102 "%s%s_%i.csv",CONFIG_BLUESYNC_TEST_BABBLESIM_PATH,
103 filename, device_number);
104 LOG_DBG(
"path : %s\n", path);
105 fp = fopen(path,
"w");
106 __ASSERT(fp != NULL,
"Cannot open file");
113 uint32_t device_number = bsim_args_get_global_device_nbr();
uint64_t get_current_unix_time_us(void)
Gets the current synchronized UNIX time.
Public API for the BlueSync time synchronization module.
void my_work_handler(struct k_work *work)
void synced_time_logger_new_msg(struct msg_statistic *msg)
static FILE * open_stat(char *filename, uint32_t device_number)
static struct ble_node_stat node
void timer_handler(struct k_timer *timer_id)
LOG_MODULE_REGISTER(synced_time_logger, CONFIG_APP_LOG_LEVEL)
void synced_time_logger_deinit()
Deinitialize the timer that store regularly timestamp of the node.
void synced_time_logger_init()
Initialize the timer that store regularly timestamp of the node.
void init_sync_overall_timer(void)
K_TIMER_DEFINE(aligned_timer, timer_handler, NULL)