BlueSync - BLE Time Sync for Zephyr
High-precision time synchronization for BLE Mesh networks
Loading...
Searching...
No Matches
local_time.h File Reference
#include <stdint.h>
Include dependency graph for local_time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint64_t get_logical_time_us (void)
 Get the logical time us value. This is the corrected us value after synchronisation. This represents the unix epoch timestamp in us of the overall mesh network. Basically, it converts logical ticks into us.
 
uint64_t get_logical_time_ticks (void)
 Get the logical time ticks value. This is the corrected ticks value after synchronisation. This represents the unix epoch timestamp in ticks of the overall mesh network.
 
uint64_t convert_uptime_ticks_to_est_master_ticks (uint64_t uptime_ticks)
 Convert a ticks value into an estimation in ticks of the overall unix epoch timestamp.
 
double get_current_slope_ticks ()
 Get the current slope ticks value.
 
double get_current_offset_ticks ()
 Get the current offset ticks value.
 
int64_t get_uptime_ticks_with_epoch ()
 Get the uptime ticks with epoch value. This method concerns only the authority Role. This method will return the unix epoch timestamp based on the elapsed time (uptime - ref) and add the overall reference.
 
void set_new_epoch_unix_ref (uint64_t epoch_ref_us)
 Set the new epoch unix ref value. Before the authority node starts a new network synchronisation, it should update the epoch reference.
 
void apply_timer_sync (double slope_timer, double offset_timer_us)
 Apply the synchronisation parameters. Once the LR is made, The result of it gives a drift value (slope) and the difference between itself and the reference (offset). This method permits to set these parameters in order to have the proper correction when getting timestamps values.
 
uint64_t uncompress_time (uint32_t compress_32bit_timestamp)
 Convert a uint32_t timestamps into a uint64_t values. This should be used in the sink node. In the Mesh network, pakcet payload is limited. Therefore only uint32_t timestamp can be used. When the sink received this kind of value, it can reconstruct the correct timestamps value.
 

Function Documentation

◆ apply_timer_sync()

void apply_timer_sync ( double  slope_timer,
double  offset_timer_us 
)

Apply the synchronisation parameters. Once the LR is made, The result of it gives a drift value (slope) and the difference between itself and the reference (offset). This method permits to set these parameters in order to have the proper correction when getting timestamps values.

Parameters
slope_timer
offset_timer_us

Definition at line 101 of file local_time.c.

◆ convert_uptime_ticks_to_est_master_ticks()

uint64_t convert_uptime_ticks_to_est_master_ticks ( uint64_t  uptime_ticks)

Convert a ticks value into an estimation in ticks of the overall unix epoch timestamp.

Parameters
uptime_ticks: value that should be concerted
Returns
uint64_t

◆ get_current_offset_ticks()

double get_current_offset_ticks ( )

Get the current offset ticks value.

Returns
double

Definition at line 159 of file local_time.c.

◆ get_current_slope_ticks()

double get_current_slope_ticks ( )

Get the current slope ticks value.

Returns
double

Definition at line 155 of file local_time.c.

◆ get_logical_time_ticks()

uint64_t get_logical_time_ticks ( void  )

Get the logical time ticks value. This is the corrected ticks value after synchronisation. This represents the unix epoch timestamp in ticks of the overall mesh network.

Returns
uint64_t

Definition at line 97 of file local_time.c.

◆ get_logical_time_us()

uint64_t get_logical_time_us ( void  )

Get the logical time us value. This is the corrected us value after synchronisation. This represents the unix epoch timestamp in us of the overall mesh network. Basically, it converts logical ticks into us.

Returns
uint64_t

Definition at line 92 of file local_time.c.

◆ get_uptime_ticks_with_epoch()

int64_t get_uptime_ticks_with_epoch ( )

Get the uptime ticks with epoch value. This method concerns only the authority Role. This method will return the unix epoch timestamp based on the elapsed time (uptime - ref) and add the overall reference.

Returns
int64_t

Definition at line 143 of file local_time.c.

◆ set_new_epoch_unix_ref()

void set_new_epoch_unix_ref ( uint64_t  epoch_ref_us)

Set the new epoch unix ref value. Before the authority node starts a new network synchronisation, it should update the epoch reference.

Parameters
epoch_ref_ms

Definition at line 112 of file local_time.c.

◆ uncompress_time()

uint64_t uncompress_time ( uint32_t  compress_32bit_timestamp)

Convert a uint32_t timestamps into a uint64_t values. This should be used in the sink node. In the Mesh network, pakcet payload is limited. Therefore only uint32_t timestamp can be used. When the sink received this kind of value, it can reconstruct the correct timestamps value.

Parameters
compress_32bit_timestamp
Returns
uint64_t

Definition at line 163 of file local_time.c.