BlueSync - BLE Time Sync for Zephyr
High-precision time synchronization for BLE Mesh networks
Loading...
Searching...
No Matches
bs_state_machine.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Tobias Moullet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * File: bs_state_machine.h
17 * Description: Implementation of the state machine for Bluesync
18 *
19 * Project: BlueSync - BLE Time Sync for Zephyr
20 * Repository: https://github.com/Tobi15/zephyr-bluesync-ble
21 */
22
23
24#ifndef ZEPHYR_BLUESYNC_SRC_BS_STATE_MACHINE_H_
25#define ZEPHYR_BLUESYNC_SRC_BS_STATE_MACHINE_H_
26
27#include "bluesync.h"
28
42
58
69
74 void (*bs_sync_cb)();
75
80 void (*bs_update_cb)(void);
81
86 void (*bs_adv_cb)(void);
87
92 void (*bs_stop_cb)(void);
93};
94
99extern struct bs_sm_handlers *bs_sm_handlers;
100
107
114
121
128
135
136#endif /* ZEPHYR_BLUESYNC_SRC_BS_STATE_MACHINE_H_ */
struct bs_sm_handlers handlers
Definition bluesync.c:586
bs_sm_state_t bs_state_machine_get_state()
Get the current state.
void bs_state_machine_init(struct bs_sm_handlers *handlers)
Init the state machine by passing the list of callbacks.
void bs_state_machine_set_role(bluesync_role_t role)
Indicate the role to the state machine.
bluesync_role_t bs_state_machine_get_role()
Get the node role.
bs_sm_state_t
Type definition representing the states.
@ BS_COUNT
@ BS_SCAN_WAIT_FOR_SYNC
@ BS_ADV
@ BS_UPDATE
@ BS_STOP
@ BS_NONE_STATE
@ BS_SYNC
bs_sm_event_t
Type definition representing the events.
@ EVENT_ADV_EXPIRED
@ EVENT_SYNC_EXPIRED
@ EVENT_UPDATE_FAILED
@ EVENT_NEW_SYNC_RCV
@ EVENT_NONE
@ EVENT_NEW_NET_SYNC
@ EVENT_COUNT
@ EVENT_INIT
@ EVENT_UPDATE_SUCCESS
void bs_state_machine_run(bs_sm_event_t event)
Annonce an event to the state machine.
bluesync_role_t
Defines the operational roles for a BlueSync node.
Definition bluesync.h:44
Struct defining the callbacks of the state machine.
void(* bs_adv_cb)(void)
This callback is called when entering in adv state.
void(* bs_stop_cb)(void)
This callback is called when entering in stop state.
void(* bs_sync_cb)()
This callback is called when entering in sync state.
void(* bs_scan_wait_for_sync_cb)(void)
This callback is called when entering in wait_for_sync state.
void(* bs_update_cb)(void)
This callback is called when entering in update state.