BlueSync - BLE Time Sync for Zephyr
High-precision time synchronization for BLE Mesh networks
Loading...
Searching...
No Matches
BlueSync Public API

Functions and definitions to use the BlueSync time synchronization system. More...

Enumerations

enum  bluesync_role_t { BLUESYNC_NONE_ROLE = 0 , BLUESYNC_AUTHORITY_ROLE = 1 , BLUESYNC_CLIENT_ROLE = 2 }
 Defines the operational roles for a BlueSync node. More...
 

Functions

void bluesync_init (void)
 Initializes the BlueSync time synchronization module.
 
void bluesync_set_role (bluesync_role_t role)
 Sets the operational role of the BlueSync node.
 
void bluesync_start_net_sync (void)
 Starts a BlueSync synchronization round as the time authority.
 
void bluesync_start_net_sync_with_unix_epoch_us (uint64_t unix_epoch_us)
 Starts a synchronization round using a known UNIX epoch time.
 
uint64_t get_current_unix_time_us (void)
 Gets the current synchronized UNIX time.
 

Detailed Description

Functions and definitions to use the BlueSync time synchronization system.

This group contains the public interface of the BlueSync module.

Enumeration Type Documentation

◆ bluesync_role_t

Defines the operational roles for a BlueSync node.

Enumerator
BLUESYNC_NONE_ROLE 

No role assigned.

BLUESYNC_AUTHORITY_ROLE 

Acts as the time authority (reference clock).

BLUESYNC_CLIENT_ROLE 

Acts as a time-synchronized client.

Definition at line 44 of file bluesync.h.

Function Documentation

◆ bluesync_init()

void bluesync_init ( void  )

Initializes the BlueSync time synchronization module.

This function sets up internal data structures, mutexes, and state variables required for BlueSync to operate. It should be called once at startup before any synchronization or logical time queries are made.

Definition at line 646 of file bluesync.c.

◆ bluesync_set_role()

void bluesync_set_role ( bluesync_role_t  role)

Sets the operational role of the BlueSync node.

This function configures the role of the device within the BlueSync synchronization system. Roles define whether the device acts as a time authority or as a client.

Parameters
roleRole to assign to the device. Must be one of bluesync_role_t:
  • BLUESYNC_AUTHORITY_ROLE
  • BLUESYNC_CLIENT_ROLE

Definition at line 656 of file bluesync.c.

◆ bluesync_start_net_sync()

void bluesync_start_net_sync ( void  )

Starts a BlueSync synchronization round as the time authority.

This should be called by the device with the BLUESYNC_AUTHORITY_ROLE to broadcast synchronization data to clients.

Definition at line 667 of file bluesync.c.

◆ bluesync_start_net_sync_with_unix_epoch_us()

void bluesync_start_net_sync_with_unix_epoch_us ( uint64_t  unix_epoch_us)

Starts a synchronization round using a known UNIX epoch time.

This function is used by the authority node to synchronize the network based on an external UNIX time reference.

Parameters
unix_epoch_usUNIX epoch timestamp in microseconds.

Definition at line 678 of file bluesync.c.

◆ get_current_unix_time_us()

uint64_t get_current_unix_time_us ( void  )

Gets the current synchronized UNIX time.

This returns the current time as synchronized with the authority node, expressed in microseconds since the UNIX epoch.

Returns
Current synchronized UNIX timestamp in microseconds.

Definition at line 138 of file local_time.c.