#include <zephyr/kernel.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
|
| uint64_t | get_logical_time_ticks_ (int64_t uptime_ticks) |
| |
| uint64_t | convert_uptime_ticks_to_est_master_ticks (int64_t uptime_ticks) |
| |
| 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 () |
| | 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.
|
| |
| void | apply_timer_sync (double new_slope, double new_offset) |
| | 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.
|
| |
| 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.
|
| |
| uint64_t | ticks_to_us_unix_time (uint64_t logical_tick) |
| |
| uint64_t | get_current_unix_time_us (void) |
| | Gets the current synchronized UNIX time.
|
| |
| 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.
|
| |
| double | get_current_slope_ticks () |
| | Get the current slope ticks value.
|
| |
| double | get_current_offset_ticks () |
| | Get the current offset ticks value.
|
| |
| 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.
|
| |
◆ BLUESYNC_TICK_RATE_HZ
| #define BLUESYNC_TICK_RATE_HZ 32768 |
◆ LOCAL_FREQ_HZ
◆ ticks_to_us
| #define ticks_to_us |
( |
|
ticks | ) |
((uint64_t)(((double)(ticks)) * 1e6 / 32768.0)) |
◆ us_to_ticks
| #define us_to_ticks |
( |
|
us | ) |
((uint64_t)(((double)(us)) * 32768.0 / 1e6 + 0.5)) |
◆ 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 |
( |
int64_t |
uptime_ticks | ) |
|
◆ 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_ticks_()
| uint64_t get_logical_time_ticks_ |
( |
int64_t |
uptime_ticks | ) |
|
◆ 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
-
Definition at line 112 of file local_time.c.
◆ ticks_to_us_unix_time()
| uint64_t ticks_to_us_unix_time |
( |
uint64_t |
logical_tick | ) |
|
◆ 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
-
- Returns
- uint64_t
Definition at line 163 of file local_time.c.
◆ local
Initial value:= {
.uptime_ref_ticks = 0,
.epoch_ref_ticks = 0,
.epoch_ref_valid = false,
.curent_offset_ticks = 0.0,
.curent_slope_ticks = 1.0,
}
static struct local_time local
Definition at line 53 of file local_time.c.